Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading digital ports with python Library NIDAQMX with NI USB 6008

Hello guys.

 

I am facing an issue and i have not found the workaround. I got a NI USB 6008 and i am playing with it, since this is my first time using a Data adquisition card.  I downloaded the python library to write/read into its Analog and Digital port.

 

My problem is with the digital port. Basically, I can write values into them, and the board holds the values. The problem arises when i try to read the digital port. When i read a digital port, the port is set to TRUE (Logical1). ALL THE TIME. I even measured it with a tester and i confirmed that everytime i run the instruction:

data = task4.read(); The port assigned to the task4 is set as 1(5volts), instead of reading what is set in the port already (FALSE IN MY CASE). 
 
This happens with all the digital ports. 
 
this the part of the code:
 
with nidaqmx.Task() as task4:
                 task4.di_channels.add_di_chan("Dev1/port0/line0"line_grouping=LineGrouping.CHAN_PER_LINE)
                data = task4.read()
                print(data)
 
how can i solve it?
Melvin,

 

 

 

 

 

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

Do you have anything actually connected to the digital input ports? I believe the default reading for USB-6008's digital port is HIGH so you would have 1 as output if you don't have anything physically connected to it.

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9GESA0&l=ja-JP

Message 2 of 3
(3,032 Views)

Thank you for your answer!!!.

No, actually there was nothing connected to the port. I was only reading the port as it is.

 

I will check that out by connecting something into it.

 

0 Kudos
Message 3 of 3
(3,013 Views)