Log in

View Full Version : MaxBotix Sonar Sensor Analog not working


Cataclysmatic
16-03-2014, 11:08
Hello,

I have recently been trying to test a few things sensor wise in advance of our next regional, but I cannot seem to get the MaxBotix Sonar sensor to work, everything seems to be fine by multimeter, but I am not actually able to read a voltage in C++ using GetVoltage() or GetAverageVoltage(), I assume either one of these would probably work for my desired function.

How the sonar is wired/plugged into the analog card in slot 1:
http://imgur.com/idGN4Tr
http://imgur.com/Ajw5fmr

As for the actual code:
Declaration:
AnalogChannel *Sonar;
double voltageSonar;

Construction I have tried two different ways, neither have worked.
Sonar = new AnalogChannel(1, 8);
Sonar = new AnalogChannel(8);

Inside TeleopPeriodic I have tried:
voltageSonar = Sonar->GetVoltage();
voltageSonar = Sonar->GetAverageVoltage();//Only used one of these, but are both methods I used for testing.
//---------------------
SmartDashboard::PutNumber9"Voltage: ", voltageSonar);

I know that I still have to scale the voltage, but I actually need to read a voltage in order to do so... Does anyone have any ideas as to what I am doing incorrectly?
Thanks!

Joe Ross
16-03-2014, 13:36
You can't use Analog Channel 8 on Module 1, it is used for battery voltage monitoring. Choose another channel.

Cataclysmatic
16-03-2014, 15:02
Should have probably checked at each channel, I know there are other spots throughout that do not function properly because of things like that.

Thanks for the help, it now is functioning properly.