Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

read the state of the output pins of the USB 6501

Hi,
I am testing the USB 6501. I need one Digital output line to switch ON and OFF some hardware.
I am using LV7.1 with NIDAQmx Base 1.5.
I want to be able to check what is the current state of the output line, without changing it.
I have studied the USB-6501 Interactive Control.vi example provided, but this programs starts by configuring all pins (or lines) to INPUT.
Which function should I use?
Thanks in advance.
0 Kudos
Message 1 of 8
(5,221 Views)
Hi Baptiste,
 
first i would recommend to use DAQmx instead of DAQmx Base. It will be easier to program that way.
2nd I would like to ask, what to you meanwith checking the current state? Do you want to use one line as a output and measure this signal parallel on a second line as a input?
 
Regards,
Stefan Henke
NIG
0 Kudos
Message 2 of 8
(5,212 Views)
Hi Stefan,

-I first chose DAQmx Base because it is way smaller, and I plan to distribute the apllication, so I will have to install "only" the ~150MB of DAQmx Base. I have also installed DAQmx 7.5, and I hope the simple task that I want to execute is available in Base as well.

-with "checking the current state", I actually mean be able to set one line output value, and later programmatically find out what is the status of this line (High or low). I would expect that it is possible without using an extra input line. I have seen a Labview driver for another DIO device: the 2 vi were "get TTL outputs value" and "set TTL outputs value". I want go create a function that does just that: "get TTL outputs value".

Does anybody know how I could do this (with DAQmx Base or DAQmx)?

Thanks,
Baptiste
0 Kudos
Message 3 of 8
(5,208 Views)
Hi,
 
I think, I know what you want to do, but not really why.
If you write a High to a digital Line, than you have this Information in your Program. You can use this Information again later if you save it in a Flag.
If it is important to know, what state the Line physically has, I would read this information back by another Inputline.
 
I dont know of a Property which gives back the current state. But you could attach the 2 VIs, which are realizing this functions and I could take a look on how they do it.
 
Regards,
Stefan Henke
NIG
0 Kudos
Message 4 of 8
(5,206 Views)
Thanks Stefan:
sorry for the confusion.
-first, the VIs I have talked about are for different hardware, not from NI, that have static digital outputs (cannot be configured as input). So it would not be helpfull to look at the code. My point is that the function (Get TTL outputs value) is available for similar hardware, and I am looking if it is available for the USB-6501.

-second, in my application it should be possible that an executable program writes values to digital output - for example switching ON and OFF a couple of machines in a defined sequence. Then the user could close the executable, even log out of his Windows session. I suppose the USB-6501 stays in the state defined before the excutable program was stopped.
Then another user could log-in and start ANOTHER executable program that displays the status of the the machines.
You see that relying on the information in the program is not possible anymore. I would need some sort of temporary buffer then like a file in C:\, or an entry in the Registry, I'd rather avoid that.
Your suggestion of connecting my output lines to input lines would certainly work, but this still looks like a workaround - and it relies on external connections.

I would prefer to get the info directly from the USB-6501, I mean from the firmware. The device should be aware of the state of its lines. I there no direct way to get this info from the device?

regards,
Baptiste

0 Kudos
Message 5 of 8
(5,201 Views)
Hi Baptist,
 
the best way to read the status back is to perform a DAQmx Read or a DAQmx Base Digital read (U32) on the DAQ Task for your Device, without starting the Task with DAQmx Start Task.VI before. The Read VI gives the current status of the DO of the device back.
 
 
Hope this is what you wanted to do?
 
Regards,
Stefan Henke
NIG
0 Kudos
Message 6 of 8
(5,192 Views)
Stefan:
well this is exactly what I want to do.
From what you wrote I understand the following:
using the "DAQmxBase Create Channel (DI-Digital Input).vi" followed by the "DAQmxBase Start Task.vi" actually configures as INPUTS the lines described by the string "line" of the Create Channel VI. Is that correct?
And if one does not use the Start Task VI, then the lines are not reconfigured. Still correct?

I have tried your suggestion (see screen shot of my code). The Read VI always generate an error -1073807346: VISA:  (Hex 0xBFFF000E) The given session or object reference is invalid.
The input value for Lines 2 is:"Dev1/Port2" I tried also with "Dev1/Port2/line1".
Want should I modify to avoid this error?

Regards,
Baptiste.
0 Kudos
Message 7 of 8
(5,190 Views)
Hi all,
in case someone had the same troubles, here is the solution I found...

first I recommend to use NIDAQmx and NOT NIDAQmx Base! I noticed Base (v1.5) makes your Vis very slow to load, and make them use a lot of memory.
in DAQmx (v7.5) you can actually use the DAQmx Read Vi on a channel created as a Digital Output - Base returns an error if you try this.
You don´t have to start or stop the task as Stefan mentionned. - Thanks again Stefan.
I included a snapshot of the working code.
Good Luck,
Baptiste
0 Kudos
Message 8 of 8
(5,149 Views)