07-09-2021 11:37 AM
I am new to the NI DAQ. Using NI USB 6501 to turn on various sections of my system
Please look at the below python code.
I am making all digital outputs of Port 0 to low. And then I am trying to make Port 0 line 7 to logical high. But the code is not working.
Please help me figure out the mistake.'
import nidaqmx
task= nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0:7")
value =True
task.start()
task.write([False,False,False,False,False,False,False,False])
task.write([False,False,False,False,False,False,False,True])
task.stop()
Tried below code also and not working.
import nidaqmx
task= nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0:7")
value =True
task.start()
task.write([False,False,False,False,False,False,False,False])
task.stop()
task= nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0:7")
task.start()
task.write([False,False,False,False,False,False,False,True])
task.stop()
But below code is working.
import nidaqmx
task= nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line0:7")
value =True
task.start()
task.write([False,False,False,False,False,False,False,False])
task.stop()
task= nidaqmx.Task()
task.do_channels.add_do_chan("Dev1/port0/line7")
task.start()
task.write([True])
task.stop()
07-12-2021 09:46 AM - edited 07-12-2021 09:47 AM
Trying using the following line when you create your DO task:
task.do_channels.add_do_chan("Dev1/port0/line0:7",line_grouping=nidaqmx.constants.LineGrouping.CHAN_PER_LINE)
I think your problem might be the line grouping. I ran into something similar last week.
Edit: because I cannot do grammar.
07-13-2021 10:32 AM
Thanks...it helped.
One more related question, please.
I want to send high on port0 line0,2 and 4. How to implement this. Tried below and is not working.
task.do_channels.add_do_chan("Dev1/port0/line0, Dev1/port0/line2, Dev1/port0/line4")
task.write([True,True,True],True)