Connecting The MaxSonar to a ComputerThe 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.
TTL SerialThe 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
Serial Port Configuration Settings
|Com Port:||Determined by Hardware*|
|Baud||9600 Bits per Second|
|Parity:||0 / none|
|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 SoftwareFirst 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. We have completed basic testing to verify this software operates with our sensor.
Troubleshooting the Serial OutputOne 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.
Products Related to the Article
The HRLV‑MaxSonar‑EZ0 has the widest and most sensitive beam pattern of any unit from...Buy Now
The XL‑MaxSonar‑EZ0 offers the widest and most sensitive beam pattern of any indoor sensor ...Buy Now
The weather resistant HRXL-MaxSonar-WR is a rugged, ultrasonic sensor component module...Buy Now