Follow MaxBotix:
Ask A Question
|     Written By: Tom Bonar     |     Date Posted: 04-09-2012     |
MaxSonar Pulse Width

Connecting The MaxSonar to a Computer

The MaxSonar® can be directly interfaced to be used with your PC, if you have a PC with a DB9 Serial connection or a USB to DB9 convertor. The DB9 connection is capable of being connected to the TX pin output on the MaxSonar® sensor. Connecting the sensor to a computer allows the user to see range readings that have already been processed to distance using RS232.

Although the voltage of 0-Vcc is outside the RS232 standard, most RS232 devices have sufficient margin to read 0-Vcc serial data. If standard voltage level RS232 is desired, invert, and connect an RS232 converter such as a MAX232.

When interfacing MaxSonar sensors with a computer, a power input is still required for the sensor to operate. A computer's DB9 input typically has enough margin to read the serial data output even when the sensor is powered at its minimum required voltage.

We recommend powering that the sensor is powered at 5VDC when connecting the sensor to a computer's DB9 connection. It is also recommended that the power supplied to the sensor is from a voltage regulator or any source able to provide clean stable power to the sensor.

To interface the sensor with the computer, pin 5 on the DB9 connection must be connected to the GND pin on the MaxSonar® and pin 2 on the DB9 connection must be connected to Pin 5 (TX) on the MaxSonar®. Please refer to figure 1.1 below for the pin layout of DB9 serial connections.

Connection image
Figure 1.1

The serial (TX) output delivers asynchronous serial with an RS232 format, except voltages are 0-Vcc. The output is an ASCII capital “R”, followed by ASCII character digits representing the range.  This is then followed by a return carriage. For the maximum range reported for your sensor please refer to your sensor’s data sheet.

TTL Serial

The HR-MaxSonar sensors have added TTL serial to the Pin 5 output. This allows micro-controllers that accept TTL to use our sensors. If you wish to use an LV-MaxSonar or XL-MaxSonar with a TTL compatible micro-controller, it is required to use a hardware inverter when interfacing with the micro-controller. To read more on this skip down to Troubleshooting the Serial Output here

Serial Port Configuration Settings

Com Port: Determined by Hardware*
Baud 9600 Bits per Second
Data Bits: 8
Parity: 0 / none
Stop Bit: 1
Flow Control: 0 / none

For computers with a DB9 port attached to the motherboard, this port is typically assigned "ComPort 1". If an adapter such as a USB to DB9 adapter is being used, the computer operating system will assign this port a unique Com Port.


Setting up Serial Port Software

First you will want to select the proper COM port on your computer. After the COM port is selected configure the port. Set the bits per second (BAUD) to 9600. Set your data bits to 8 and your parity to none. If there is a way to set the stop bits, set the stop bit to 1. Final setting if the software has it is Flow Control. If Flow Control is available set this setting to none.

In the past, HyperTerminal came standard on computers with Windows XP or older. For Windows Vista and Windows 7 users, software has to be downloaded in order to read the serial port.

To download HyperTerminal click here.

An alternative to HyperTerminal is HyperSerialPort which can be downloaded here. We have completed basic testing to verify this software operates with our sensor.

Troubleshooting the Serial Output

One common issue when connecting a MaxSonar sensor to a computer is the baud rate, bit, or parity not set correctly. The computer configuration is: a baud rate of 9600, 8 bits, no parity, and one stop bit.

Another common issue when using the serial output of the MaxSonar is inverting. The TX output needs to be inverted from RS232 to TTL to be compatible with TTL devices. To invert the signal you will need an inverter such as a MAX232.

Some users may not have DB9 connection on their computer and need a USB to serial adapter. USB to serial adapters may have an auto switch that switches between TTL and RS232 which may not work properly with our sensors. To allow proper operation of our sensor with an adapter you may have to invert the serial output (with an inverter like the Max232) prior to connecting the sensor to the USB to serial adapter.

Although the voltage of 0-Vcc is outside the RS232 standard, most RS232 devices have sufficient margin to read 0-Vcc serial data. If standard voltage level RS232 is desired, invert, and connect an RS232 converter such as a MAX232.

Author: Kathy Kostal  Date: 08-31-2016
Inc 5000 Maxbotix Logo Inc. Magazine Unveils 35th Annual List of America's Fastest Growing Private Companies–the Inc. 5000. MaxBotix Inc., Ranks No. 1752 on the 2016 Inc. 5000 with Three–Year Sales Growth of 213%.
Click here for full article.
Author: Cody Carlson  Date: 08-02-2016
Raspberry Pi 2 board MaxSonar sensors offer a variety of outputs including TTL serial data. This tutorial guides you through the process of setting up your Raspberry Pi 3 with a MaxBotix sensor. Click here for full article.
Author: Scott Wielenberg  Date: 07-26-2016
Full Horn Housing MaxBotix offers an expanded range of packaging options for many of our sensors. Each option provides unique benefits to certain mounting integrations. This article provides a brief overview of each option.
Click here for full article.
Author: Scott Wielenberg  Date: 07-18-2016
Sensor is Tested When providing support, our technical support team may determine that further testing at our facility is the best way to help resolve the issue that you are facing. At this point, they will start the Return Merchandise Authorization (RMA) process. This article will explain what you can expect as your ultrasonic sensor travels through our RMA process.
Click here for full article.
Author: Scott Wielenberg  Date: 07-11-2016
Typical Wall Pipe Many customers have requested the option to mount an ultrasonic sensor in a pipe. During the testing and development cycle, we discovered a number of considerations and requirements that must be met for the application to be successful. When all of these are met, a user may be able to achieve the desired level of success for measuring the liquid level inside of a pipe.
Click here for full article.
Author: Jenney Grover  Date: 06-28-2016
one of the options for outputs On April 19th, we welcomed our supporters to join us for the Grand Opening of the Build Out. Bob and Nita Gross gave a tour of the build out and their vision for the space. We continue to be in awe of the support from our community, our employees, our distributors, and our customers. Thank you for the many years of support, and we look forward to serving you in the years to come.
Click here for full article.
Signup for notification of our exciting new products and periodic new letters. We are excited to provide the latest information from MaxBotix Inc.