MaxBotix has been a proud sponsor of FIRST teams since 2012 and once again we are supporting your team by giving a voucher for a free MB1043 MaxSonar Sensor from our HRLV-MaxSonar-EZ line. This small and lightweight sensor is designed for easy integration into your robot and is a great option for autonomous robot navigation as well as teleop assist routines.
This page should contain everything you need to get your sensor up and running with your robot. Should you have any questions, you can email us at techsupport@maxbotix.com or call us at 218.454.7363
Take a look at our data sheet for more information on your sensor!

Datasheet
How Ultrasonic Sensors Work

All of our ultrasonic rangefinders will measure distance by tracking the time-of-flight of a sound wave. The diagram below shows how the sensor sends and receives the sound waves. Once the sensor emits a sound wave, it tracks how long it takes for the sound to reflect off of a surface and travel back to the sensor. The sensor then uses the known speed-of-sound to turn the time-of-flight into a range reading.


Sensor Wiring

Our sensors can easily be connected and powered by the analog inputs on your NI roboRIO. If you use multiple sensors, you will have to connect the freerun/stop pin of the sensor to a digital output on the NI roboRIO. It is recommended to only have one sensor ranging at a time to avoid acoustic interfence, and the freerun/stop pin will allow you to control this. In our examples, the Analog Output (Pin 3) is the pin where you read the range value reported from the sensor.
The sensor pinout is shown below. The square pad with a hole is Pin 1.


Connect these pins to an Analog Input port on your RoboRIO. Our example uses Analog Port 0. That's all we need to do to connect our Sensor to the RoboRIO.

> Sensor Pin 3 connected to S
> Sensor Pin 6 connected to 5V
> Sensor Pin 7 connected to ⏚

Single or Multiple Sensor Analog Voltage Example
Programming for use with a RoboRIO

Our sensors communicate with your RoboRIO using one of three methods:

  • Analog Voltage Output (Pin 3) (example shown above)
  • Pulse Width Output (Pin 2)
  • 5 Volt RS-232 Serial Output (Pin 5)

In this example, we will use the Analog Voltage output for simplicity.
When power is applied to Pins 6 and 7 of our sensor, the voltage on pin 3 will change according to the distance between the sensor and the object in front of it. We can then use the RoboRIO to measure the voltage on Pin 3. This can be done using the WPILib Analog Input Library.

First, let's import the library: Next, let's create an instance of the Analog Input class and specify that it should use Analog Pin 0: Finally, we can use this instance to collect a range reading from the sensor, and convert it to the appropriate units. A full code example showing how to operate two sensors (one active during autonomous and one active during teleop) is show below:
First, let's import the library: Next, let's create an instance of the Analog Input class and specify that it should use Analog Pin 0: Finally, we can use this instance to collect a range reading from the sensor, and convert it to the appropriate units. A full code example showing how to operate two sensors (one active during autonomous and one active during teleop) is show below:

Good luck teams! We can't wait to see what you build this season. If you have any questions, don't hesitate to contact us.
Email: techsupport@maxbotix.com
Call: 218-454-7363