Hearing aids

ALMA! Check your battery!

In which we make a MaxBotix sonar speak properly over a serial connection.

Recently I hooked up a MaxBotix MB1220 XL sonar to an FTDI breakout board to do some experimenting, and I ran in to an issue I had discovered before but thought was an artifact of the processor I was using.  You see, previously (a couple years ago) I had connected a MB1220 to a Fez Panda II and discovered a wonderful stream of gibberish flowing from my brand new sonar.  At first I assumed I had connected it improperly.  There are only three wires that need to be connected to make the sonar transmit over the serial port - power, ground, and TX - but just maybe I had accidentally hooked up to the analog voltage instead of TX.

No dice.

All connections secure? Check.
Are we using 5 volts? Check.
Is the processor 5 volt tolerant? Check.
Is the TX from the sonar connected to the RX of the processor? Check.
9600 baud 8N1? Check.

Still no luck.

Still just gibberish.

At some point while reading about TTL versus RS232 serial connections it occurred to me that perhaps

... the Pin 5 output delivers asynchronous serial with an RS232 format, except voltages are 0-Vcc.

could mean the levels were inverted rather than being out of range.  In other words, what my processor thought was high the sonar thought was low and vice versa.

Not having a hex inverter (or even a single inverter) handy, I flipped through some old notes about logic gates and found a simple inverter made from a couple of resistors and a transistor, parts I had on hand.

Below is what I threw together on a breadboard.

R1 = 1K
R2 = 10K
Q1 is a generic NPN transistor out of a pack from Radio Shack.

With this in place, R121 flashed across my LCD display.


Flash forward two years, and we are back to me hooking up the MB1220 to an FTDI breakout board.  The breakout board was set to 5v.  The sonar was being powered by 5v from the breakout board.  Putty was up and set for a serial connection with 9600 baud 8N1.

The result?


I then wired up the above circuit on a breadboard, connected the sonar and the breakout board, and presto, the range information I expected to see.

If like me, you connect a MaxBotix sonar to a processor, FTDI chip, or anything else over serial and find gibberish, you probably should invert the signal with something like the circuit above… or stick to their I2C line.

Comments (1) -

  • MaxBotix Inc

    7/14/2014 11:28:26 AM |


    This is Tom Bonar from MaxBotix Inc.

    For people requiring TTL serial support, the HRLV-MaxSonar-EZ sensor line will output either RS232 or TTL.  The TTL serial output is as simple as soldering a jumper on the back of the PCB.  This sensor line was introduced in April of 2012.  This sensor also features a 1mm resolution on the Pulse Width and Serial data outputs, and a 5 mm resolution on the Analog Voltage output.  For users that require a rugged sensor, all of our MB738X sensors output TTL serial natively.

    You are correct when you state that an inverter is needed for the XL-MaxSonar and LV-MaxSonar sensor lines.

    I hope this bit of information is able to assist your computer create smaller projects with a couple less components.

    If you need any further support, please don't hesitate to email me directly at thomas@maxbotix.com

    Tom Bonar
    Level 2 Technical Support
    of MaxBotix Inc.
    Phone: (218) 454-0766 ext 2#
    Fax: (218) 454-0768
    Email: thomas@maxbotix.com

Comments are closed