Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Tasks python

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()

 

0 Kudos
Message 1 of 3
(1,573 Views)

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.

0 Kudos
Message 2 of 3
(1,501 Views)

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)

 

0 Kudos
Message 3 of 3
(1,482 Views)