Log in

View Full Version : Wiring Maxbotix ultrasonic sensor to serial on cRIO?


CRITICALThinker
20-02-2014, 19:24
My team is planning to add a ultrasonic sensor at the pits (MB 1013 http://www.maxbotix.com/Ultrasonic_Sensors/MB1013.htm ) to our bot using the serial port on the cRIO to aim our launcher.

What is the best way to wire it (even through another port), and how would we go about coding it? Thanks all for the help to a very inexperienced team

BitTwiddler
20-02-2014, 19:34
Are you programming in LabView?
If so go to the opening splash screen, select Support, Find FRC Examples, go down to sensors folder and open it, find EZ-1 MB1010 Sonar - Analog.lvproj. and start it. The example shows how its done.
Whoops, I just re-read your post where you say you plan to use the serial port. Sorry, that's gonna be trickier.

CRITICALThinker
20-02-2014, 19:48
we are also programming in C++

RoboMo786
20-02-2014, 19:55
Look at the attached pics. One will show you what to wire to the rangefinder. The other pic is from team 358 (http://www.team358.org/) website. It shows you the Analog Input Module (NI 9201) and the Analog Breakout. You should plug the pwm cable from the ultrasonic rangefinder to any of ports 1-7 on the analog breakout.

My team is programming in LabVIEW, so I can't help you with code, sorry.

Hope this helps. :)

wireties
20-02-2014, 19:57
We are doing the same thing. The serial port on the Maxbotix sensor (at least our model) is not real RS-232. It is an inverted TTL serial port. We had to make a circuit to invert the signals then pass it through a TTL-RS232 converter to get it to work.

Good luck!

BitTwiddler
20-02-2014, 20:01
you could run the TTL signals to and from the DIO ports but then you'd need a driver to extract out the serial data. Not sure if there's a library API that does that.

mega900997
20-02-2014, 20:11
We are using the same sensor on our robot. I wired it so it would give an Analog voltage(white wire on a PWM to pin 3) and plugged it into the analog module on the cRIO. In the code, I did:

AnalogChannel *UltrasonicSensor;
UltrasonicSensor = new AnalogChannel(1);

float Distance = UltrasonicSensor->GetVoltage();

I don't remember the conversion from voltage to feet offhand but that can be figured out with a bit of testing.

Heres the datasheet for the sensor. Read the pin out section of the sensor and wire accordingly. http://www.maxbotix.com/documents/HRLV-MaxSonar-EZ_Datasheet.pdf