Analog Sensors Returning Incorrect Voltages

Hey all,

Today we were adding our sensors to the robot and started testing out code and we discovered the they were returning near zero voltages from the getAverageVoltage() method.

[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.23009997599999998
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.24552717599999999
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.240384776
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.214672776
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.101539976
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.142679176
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.122109576
[cRIO] Ultrasonic: -0.0014189800000000002
[cRIO] Potentiometer: 0.106682376

Does anyone have an idea as to why this is happening? We wired them right as far as we know and the Analog Breakout has power. We were also adjusting the sensors correctly.

Thanks for any help

Are you sure you didn’t plug them in backwards?

I had a similar problem with an ultrasonic, but that was a few weeks ago and I forget exactly how I fixed it. I think I had some code in the wrong place… It might help if you posted your code so we could take a look at it.


Our Analog Breakout seemed to be labeled wrong :confused: and the Potentiometer now works fine. However; the ultrasonic returns either a constant voltage of 3 with one orientation or a voltage ranging from 0-1. We are using the basic MaxSonar analog ultrasonic sensor.

Any information would be incredibly beneficial.


Team 4338

I’m not sure about an analog ultrasonic sensor, but the digital ones require you to tell it when to ping. With the Ultrasonic object, you can turn on an “automatic mode” that will continuously ping.

us = new Ultrasonic(2,3);

If I remember correctly ping isn’t a factor in an analog object (correct me if I’m wrong). The analog channel class has no method for setting ping. We tested with a multimeter and the sensor was receiving 5 volts when ground and +5 were tested. The AN return a near 0 voltage as before. We are getting correct readings from the pot so I can only assume something is wrong with either the sensor itself or the signal wiring.


Remember that the analog voltage is just proportional to the distance. Does it change with distance to the sensor?

I am assuming you are using the LV series sensor and have read the datasheet and the application notes for the sensor :slight_smile: (I know because we screwed up at first too).


Thanks, we figured it out! The sensor is now working perfectly fine with further testing it should be great!