LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly read digital input on USB-6501?

Solved!
Go to solution

How to properly do digital reading on bi-directional DIO of USB-6501?

 

I have 5V connected to P1.0 in series with mechanical switch. I would like to read input to know position of switch.

Logic on the first picture is working, but only once :-), when 5V is off it measures Low, switching 5V on gives High reading. But switching 5V off again does not return Low reading back, it still reads High. I have measured voltage with meter, there is still 1.6V on the P1.0, seems like due to pull up resistor. So, to reinitialize the USB-6501 back to original state I have to reconfigure DIO as output and write there Low before do read, see second picture, it works although looks strange. Are there any proper way how to do it on USB-6501?

SergeS_0-1630682444178.png

 

 

SergeS_1-1630682900999.png

 

0 Kudos
Message 1 of 6
(4,087 Views)

What is your 5V source? Cutting the power off of a voltage source doesn't necessarily mean the output pin goes to 0 V. Cranking the voltage down to 0 V (and leaving it on) will get the output pin to 0 V though...

 

What happens if you leave your voltage source on and flip your switch a few times? Do you see the expected behavior, i.e. your "data" is False on the open condition and "True" on the closed condition, without any sort of re-initialization?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 2 of 6
(4,080 Views)

The USB-6501 does have a built-in 4.7kOhm pull up to 5V.  So if you have nothing hooked up to the line, it would read high.  On top of that, you will be fighting capacitance and whatever else is in your circuit.  I'd hate to say this, but you really need a DIO module that uses a pull down.  You could accomplish this with a simple buffer circuit where the input of the buffer has a pull down.  Another thought would be use a FET to pull the input to ground when the 5V is active (have a pull down on the input to the FET), but this will invert your logic.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(4,070 Views)

Alternative, instead of connecting to 5V through the switch, connect the switch to the ground and enable the pull-up resistors (not sure if it is always enabled).

 

Now, whenever the switch is pressed, DIO will read LOW, and otherwise HIGH, just add an invert logic when you read the DIO state using DAQmx read.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
0 Kudos
Message 4 of 6
(4,047 Views)

@santo_13 wrote:

Alternative, instead of connecting to 5V through the switch, connect the switch to the ground and enable the pull-up resistors (not sure if it is always enabled).


Another stupid thought: Use a SPDT switch.  On one side, you have the 5V.  On the other, you have GND.  The common goes to the digital input.  This would definitely be the cleanest option.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(4,035 Views)
Solution
Accepted by topic author SergeS

Have added voltage divider (two resistors 1K), which is like pull down resistor when voltage is off. It works now with logic as on first picture.

Thanks to everybody.

0 Kudos
Message 6 of 6
(4,016 Views)