Chipres contributed a Bus Pirate demo of a MaxSonar-EZ1 ultrasonic range finder with serial output.

Demo: is a weekly series that demonstrates devices with the Bus Pirate. Come back next Monday for another new demo.

Continue reading the demo below.

Device: MaxSonar-EZ1 ($29.95)
Bus: UART (asynchronous serial)
Power requirements: 5 volts
References: datasheet

Connection

Bus Pirate MaxSonar-EZ1
MOSI TX
`+5V +5V
GND GND

The ranger is powered with the Bus Pirate’s on-board 5volt power supply. The serial output levels will be 5volts, but that’s OK because the Bus Pirate pins are 5.5volt tolerant.

Bus Pirate setup

HiZ>m
1. HiZ
2. 1-WIRE
3. UART

10. LCD
(1) >3 <<< UART mode
Mode selected
Set serial port speed: (bps)
1. 300
2. 1200
3. 2400

9. 115200
10. 31250 (MIDI)
(1) >5<<< 9600bps
<<< 8N1, idle high (default settings)
Select output type:
1. Open drain (H=Hi-Z, L=GND)
2. Normal (H=3.3V, L=GND)
(1) >2 <<<normal output (doesn’t matter)
READY
UART>

Put the Bus Pirate in serial UART mode (m). Setup the UART for the MaxSonar-EZ1 serial output speed (9600bps, 8N1). It doesn’t matter if you choose normal or Hi-Z style outputs because we’re only using the input pin.

Interfacing

UART>W <<< power supplies on
POWER SUPPLIES ON

The range finder is powered by the Bus Pirate’s 5volt power supply. Enable the power supply with the W command.

UART>(2) <<< live UART monitor
Raw UART input. Space to exit.

chipres used the live UART monitor to bridge raw data from the ranger to a computer over USB. Turn off the terminal, then start an decoding application that reads from the Bus Pirate virtual serial port.

Remember that the Bus Pirate virtual serial port operates at 115200/8N1, even though the bridge to the ranger runs at 9600bps. If your application opens the virtual serial port at 9600bps, the data will appear to be garbage. If you can’t force the application to open the port at 115200bps, you can reconfigure the Bus Pirate terminal interface for 9600bps with the baud rate configuration menu (b).

Taking it further

Check the Bus Pirate manual for a complete list of chip demonstrations. Requests or demo contributions are always appreciated.

Advertisements