This commit is contained in:
tillraab 2019-09-10 13:55:38 +02:00
parent deaa7cceb7
commit 2d9991c295

View File

@ -17,20 +17,23 @@ from IPython import embed
from uldaq import (get_daq_device_inventory, DaqDevice, AInScanFlag, ScanStatus,
ScanOption, create_float_buffer, InterfaceType, AiInputMode)
def GPIO_setup():
def GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin):
# LED output pins
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT) # 1
GPIO.output(11, GPIO.LOW)
GPIO.setup(13, GPIO.OUT) # 2
GPIO.output(13, GPIO.LOW)
GPIO.setup(LED1_pin, GPIO.OUT) # 1
GPIO.output(LED1_pin, GPIO.LOW)
GPIO.setup(LED2_pin, GPIO.OUT) # 2
GPIO.output(LED2_pin, GPIO.LOW)
LED_status = [False, False]
# switch controlled input
GPIO.setup(16, GPIO.IN)
GPIO.setup(18, GPIO.IN)
GPIO.setup(Button1_pin, GPIO.IN)
GPIO.setup(Button2_pin, GPIO.IN)
# GPIO.setup(Button1_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
# GPIO.setup(Button2_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
return LED_status
@ -170,16 +173,21 @@ def main():
file = os.path.join(path, 'traces-grid1.raw')
f = open(file, 'wb')
f.close()
# f.close()
embed()
quit()
LED_status = GPIO_setup()
LED1_pin = 11
LED2_pin = 13
Button1_pin = 16
Button2_pin = 18
LED_status = GPIO_setup(LED1_pin, LED2_pin, Button1_pin, Button2_pin)
# DAQ setup
if True:
channels = 16
# channels = 16
status = ScanStatus.IDLE
@ -191,7 +199,7 @@ def main():
high_channel = channels
samples_per_channel = 20000 # ToDo: ???? Buffer size ?!
rate = 20000
# rate = 20000
scan_options = ScanOption.CONTINUOUS
flags = AInScanFlag.DEFAULT
@ -250,7 +258,7 @@ def main():
rate = ai_device.a_in_scan(low_channel, high_channel, input_mode, ranges[range_index], samples_per_channel,
rate, scan_options, flags, data)
last_idx = 0
f = open('/media/pi/data1/test_file.raw', 'wb')
# f = open('/media/pi/data1/test_file.raw', 'wb')
# LED on when here ... wait for switch to start data aquisition