03-22-2019 05:23 PM
This question probably has a simple answer, but it is eluding me for some reason. I've wired my NI-9209 to report voltage in several VIs using the DAQ assistant and DAQms. When I measure the voltage with a battery attached to the ports, the voltage reading is as expected. When I measure the voltage reading without anything attached to the ports, my voltage reads around 10.3 volts consistently. I understand that the difference between the ground and the port of interest will never be true zero, but I need it to measure something close to 0 for my program to work.
03-22-2019 06:05 PM
That's because the analog input port has an infinite impedance relative to analog ground and it is going to float to whatever level it wants.
What do you mean by you want it to be close to zero for your program to work? How do you expect your program to "work" when it isn't reading anything?
If you want to read 0V, then connect a wire between the analog input and ground.
03-22-2019 06:11 PM
https://en.wikipedia.org/wiki/Pull-up_resistor
If you want it to read battery voltage with the battery attached, and zero voltage with nothing attached, connect a large resistor from the input terminal to ground in parallel with where you're connecting the battery voltage. Make sure it's big enough to draw negligible current from your battery. When the battery is disconnected, the resistor will pull the floating input to ground. When the battery is connected, its voltage won't sag much under the resistor.
For a 10.3V battery, you could use a ~10 kOhm resistor in parallel, and you'd only draw 1 mA from the battery when it's connected. If that's too high, use 100 kOhms for 100 microamps.