09-03-2021 10:29 AM
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?
Solved! Go to Solution.
09-03-2021 10:46 AM
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?
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.
09-03-2021 11:01 AM
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.
09-03-2021 11:24 AM
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.
09-03-2021 12:16 PM
@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.
09-03-2021 02:31 PM
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.