iRoboBumper: SONAR-Obstacle Detection System for Robotics Platforms
Licensed under CC BY-SA 4.0
System Build Up
This section will detail the steps taken to mount all of components of the system to the housing created in the
previous section.
- First, the servo horn is mounted onto the non-rotating base. This is done using four #4-40 x 1/2" pan head
screws, washers, and nuts. The servo horn points up through the bottom of the base and the screws insert
into the top of the base. Figure 35 shows the top of the base with the servo horn installed.
Figure 35: Mounting Servo Horn to Base
- Next, we start mounting everything to the base of the rotating part of the system. We start by mounting the
Proximity/ Optical Sensor Board:
- Two #4-40 x 1/2" screw and nuts are used to screw the board to the rotating base.
- The TCRT1010 Proximity sensor faces down so that it can be used to detect the three 3/8" alignment holes
that were drilled in the non-rotating base of the system.
Figure 36 shows the Proximity Sensor Board mounted to the rotating base.
Figure 36: Mounting Proximity Sensor PCB
- After mounting the Proximity Sensor Board, we mount the Parallax servo. Four #4-40 x 1/2" screws, washers,
and nuts were used to secure the servo to the base of the rotating part of the system. The images in the
figure below show both the top and bottom of the housing with the servo mounted.
Figure 37: Mounting Servo
- The next components to be mounted are the two PING))) sensors.
- The jumper wires for the PING))) sensors were installed on each sensor prior to mounting as connecting
them later will be a little more challenging.
- For each sensor, two #4-40 x 1" screws and nuts were used secure it to the side of the rotating housing.
- In addition, a 1/4" nylon spacer was used as a standoff between the PING))) sensor and the side of the
housing and a nylon flat washer was used between the nut and the backside of the PING))) sensors. The
use of these can be seen in the left image of Figure 38.
Figure 38: Mounting PING))) Sensors
- After mounting the PING))) sensors, we mount the two battery holders and toggle switch.
- The battery holders are mounted on the open sides of the rotating base, facing out, so that they are
easily accessible to replace the batteries when needed.
- Two #4-40 x 1/2" pan head screws and nuts were used to secure each battery holder to the base of the
rotating housing.
- The toggle switch mounts to the small area on the top of the rotating part of the housing where we
drilled the 1/4" hole for it.
Figure 39 shows the rotating housing with the battery holders and toggle switch installed.
Figure 39: Battery Holders and Toggle Switch Mounted
- Next, the four standoffs are mounted to the base of the rotating housing.
- Four 1-1/4" tall standoffs were used as the servo extended about 1" to 1-1/8" above the top of the base
of the rotating housing. This will allow the Main System PCB to be mounted to the standoffs and sit just
above the servo.
- A #4-40 x 1/2" pan head screw was used to secure each standoff to the base.
Figure 40 shows the rotating housing with the standoffs in place.
Figure 40: Main System PCB Standoffs Mounted
- Mounting the Main System PCB:
- Finally, the Main System PCB is mounted to the standoffs using four #4-40 x 1/4" machine screws.
- After the PCB has been mounted, the five jumper connectors are connected, and this completes the
build-up of the rotating part of the system.
Figure 41 shows the housing with everything installed and the connection of the jumper wires to the Main
System PCB.
Figure 41: Main System PCB Mounted and Connected
Loading Software and XBee Configuration
This section will describe how to load the software created to run on the Arduino Pro Mini, and discuss how to
configure the XBee wireless modules. As a note, version 1.0.6 of the Arduino IDE was used during development of
the project as it was the latest version at the time, but likely any version will work. This Arduino IDE can be
downloaded from Arduino's website at http://arduino.cc/en/main/software.
The Arduino sketch that was created for this project is contained in a single file, iRoboBumper.ino, located with
the Source Files.
A decent amount of time was devoted to commenting the
software so that you can understand how it works and why the software was architected the way it was. Some of
the software uses Arduino functions, etc. however, other places configure microcontroller registers directly to
work around performance issues that were found with Arduino. One example is the reading of analog voltages. In
this application, the proximity sensor needs to be read at a fairly high rate to ensure accurate timing
measurement of the alignment holes. In addition, the temperature sensor and battery voltage need to be read
periodically. The Arduino function, AnalogRead, blocks until the requested voltage has been read which is
typically in the range of 100 microseconds. Unfortunately, when you want to make readings at a decent pace,
these 100 microsecond blocks add up quickly. Instead, the registers of the ATmega microcontroller were
configured to allow an interrupt to be generated when the analog to digital conversion has finished and the
Interrupt Service Routine (ISR) processes the data and starts the next conversion. This is just one example, but
all of this is well documented in the code.
Once you have the IDE installed, you will need to start the Arduino IDE. Once the application starts up you will
be presented with the window shown in Figure 42.
Figure 42: Arduino IDE Interface at Start Up
Select File->Open and navigate to the iRoboBumper folder where the iRoboBumper.ino file resides. Select the file
and click open. Figure 43 shows the Open File dialog window prior to clicking open.
Figure 43: Selecting the iRoboBumper.ino File
Once the Arduino IDE opens the iRoboBumper sketch, you will see a window with the contents of the iRoboBumper
file. Select Sketch->Verify / Compile from the menu bar and the sketch should build, as shown in Figure 44.
Note: It shows this sketch is using 7,888 out of 30,720 bytes available.
Figure 44: Build Successful of iRoboBumper.ino
Next, you need to connect your Arduino programmer to the Arduino Pro Mini, and using a USB cable connect the
Arduino programmer to your PC. This setup is shown in Figure 45.
Figure 45: Arduino Pro Mini and Programmer Connected
The final step is to program your Arduino Pro Mini. Simply, select File->Upload to have the Arduino IDE and
embedded bootloader transfer your program to the Pro Mini. The first time you use your programmer you will have
to tell the Arduino IDE which COM port it is connected to, but you should be able to identify it from the list
of available COM ports on your computer. Once complete you should see a "Done Uploading" message in the blue
status bar near the bottom of the IDE's window. Now you can disconnect the USB cable from the programmer and
then separate the programmer and the Arduino Pro Mini. Finally, plug your Arduino Pro Mini into the socket on
the Main System PCB and we are almost ready to power up!
Before we power up the system, we need to configure the XBee wireless modules to act as wireless serial port
bridges. During development both WiFi and ZigBee-based XBee modules were successfully tested. However, the
intention is that this will be short range wireless communication to a module located on the host robotics
platform (i.e. likely less than a foot or two away). In this case, the lower power ZigBee-based modules make the
most sense and will be used to demonstrate the system. To configure the XBee modules you need to connect to
their serial interface using some type of adapter. In the Bill of Materials, there are USB to XBee modules that
are used for this exact purpose. Figure 46 shows the two ZigBee-based wireless modules plugged into the USB to
XBee adapters and USB cables connecting them to the PC.
Figure 46: XBee Modules on USB to XBee Adapters
DIGI, the manufacturer of the XBee modules has an XBee configuration tool available called XCTU.
You can download it from DIGI's website at http:\\digi.com\xctu. Once installed, we will use
this application to
configure the two XBee modules to act as a wireless serial adapter so that our system and the host platform can
communicate while our system continuously rotates. To start, run the XCTU application. Once it has started, you
will be presented with the screen shown in Figure 47.
Figure 47: XCTU Startup
Next, you will want to click on the "Discover devices" button. It is the icon on the left side of the menu bar
that looks like an XBee module with a magnifying glass over it. Once you click it, XCTU will present you with
the window below and ask what COM port you want it to discover XBee modules on. In Figure 48, both of the ZigBee
modules were plugged in and they enumerated as COM10 and COM11. Thus, we have selected to have XCTU discover
modules on each of these ports.
Figure 48: XCTU COM Port Discovery Selection
Next, XCTU will allow you to select what serial port settings it should use to discover the XBee modules. Figure
49 shows the default selections which should allow XCTU to discover your modules. Note: if you change the baud
rate setting of the module, as we will do shortly, and want to use XCTU in the future you will need to modify
these settings.
Figure 49: XCTU COM Port Settings for Discovery
Once you have selected the settings for XCTU to use, click 'Finish'. Next, XCTU will attempt to communicate with
the modules on the COM ports you have selected. This will take some time depending on the number of ports and
settings you selected. Once complete, XCTU will present you with the dialog window shown in Figure 50 and ask
you which of the discovered modules you would like to add to the 'Radio Modules' list. Select both of your
modules and click on the 'Add selected devices' button.
Figure 50: XCTU Discovered Modules
Now, you will be back to the main XCTU window and your wireless modules will be listed on the left. In Figure 51,
you can see the two modules which are connected to COM10 and COM11.
Figure 51: XCTU Application with Discovered Modules – click
image to enlarge
You will also notice that both of the discovered modules are currently configured to be ZigBee Router AT devices,
as this is how they were configured from the factory. So the first thing we must do is to change the firmware in
one of the devices to be a ZigBee Coordinator AT device. To update the firmware in a module, click on the module
under the 'Radio Modules' list on the left side of the application. Next, click on the 'Update firmware' button
which is on the right side of the application and looks like an electronic component with an arrow pointing
down. Clicking on it will cause the 'Update firmware' dialog box to appear as seen in Figure 52.
Figure 52: XCTU Update Firmware Dialog
Next, select the XB24-ZB option under the Product family, then the select 'ZigBee Coordinator AT' under the
Function set, and finally select 20A7 (Newest) under Firmware version. These are the options selected in Figure
52, for reference. Now click 'Finish' to have XCTU update the firmware on the selected module. After the module
has been updated, XCTU will return to the main window and the module is now configured as a ZigBee Coordinator
AT as can be seen in Figure 53.
Figure 53: XCTU Application after Firmware Update
Next, we need to update the settings of both devices to allow them to act as a point-to-point wireless serial
port adapter. The Coordinator AT needs to have its PAN ID set to a unique value; 2121 was the value chosen here,
but yours can be different. Just remember the value as the Router's PAN ID must be the same! Next the
Destination High and Low Address (DH and DL) must be set to the Serial Number High and Low values (SH and SL) of
the Router. In addition, you can set the Node Identifier to a value, but this is not required. All of these
values can be seen in Figure 54.
Figure 54: ZigBee Coordinator AT Settings – click image to
enlarge
Next, we need to change some of the parameters on the ZigBee Router AT module, as shown in Figure 55. For this
module, set the PAN ID (ID) to the same value that you used for the Coordinator (i.e. 2121 in this case). Next,
change the Destination High and Low Address (DH and DL) to be the Serial Number High and Low (SH and SL) value
of the ZigBee Coordinator AT. As with the Coordinator you can change the Node Identifier (NI) to be a unique
value, but this is not required.
Figure 55: XCTU ZigBee Router AT Settings – click image to
enlarge
Finally, our Arduino sketch is using a baud rate of 115.2 kbaud, so we need to change the Baud Rate (BD) setting
of both modules to be 115200. This setting is a little over half way down in the list of settings for each
device. Figure 56 shows the correct setting. Once you have made all of the changes and written the values to
flash, your modules should be setup to communicate with each other and act as the wireless serial adapter we
require.
Figure 56: XCTU Baud Rate setting for Both Modules
Next, you can use the terminal utility with XCTU or any serial port terminal application to verify that your
modules have been configured correctly. Figure 57 shows Tera Term was used to connect both modules and send a
message from each module to the other... Success!
Figure 57: Testing the XBee Modules After Configuring
Next, unplug and remove one of the modules from the USB to XBee adapters and place it in the socket on the Main
System PCB. We will leave the other modules on the USB to XBee adapter for now to allow the Microsoft Windows'
demonstration application to receive the information from the system. We are now ready to test so... put the
batteries in and throw the lid on!
System Demonstration
The Arduino Sketch outputs all of the data from the iRoboBumper system as ASCII text. This was intended so that a
PC with a second XBee module connected to it can be used to see the output of the system. Figure 58 below shows
a screen shot of the system's data captured from a serial terminal application on a PC. Remember that the system
is taking a reading from each PING))) sensor 50 times a second and outputting it via the serial port, so data
scrolls down at a decent pace. The capture in the figure shows 37 sets of data which represents approximately
0.75 seconds in time.
Figure 58: Serial Terminal Data Capture – click image to
enlarge
The Arduino code outputs two different types of data and all data is tab delimited.
The first type of data is a status line that starts with capital 'S'. This type of line is only output once every
time the "home" alignment hole is detected. The 'S' is followed by four values that represent the time it took
the system to rotate the previous 360 degrees (i.e. the pan time) in micoseconds, the current commanded servo
PWM time in microseconds, the current battery voltage in millivolts, and finally the current temperature in
degrees C. Thus, in the figure above we see the following line at the top
S 1554928 1347 5722 24
This tells us that it took a little over 1.5 seconds to pan 360 degrees, the servo's PWM signal is high for 1347
microseconds, the battery voltage is 5.722 V, and the temperature is approximately 24 degrees C.
The second type of line contains the sensor data and is output roughly 50 times a second. These lines start with
the approximate angle that the system has rotated since the last time the "home" alignment hole was detected in
degrees; next is the reading from the first PING))) sensor in millimeters, followed by the reading from the
second PING))) sensor in millimeters, and finally the reading of the proximity sensor in millivolts. In the
figure above we see the following line immediately after the status line.
3.74 3169 3169 605
This indicates that the system has rotated approximately 3.74 degrees from "home", both PING))) sensors reported
a range of 3.1 meters (i.e. this is typical when no return was received and thus indicates there is nothing
closer than 3 meters), and finally the voltage from the proximity sensor was 0.605 V. Notice that the proximity
sensor voltage is relatively low here, but rises to approximately 2.1 V where it stays until it starts falling
at the bottom of the capture. The drop in the proximity sensor voltage is due to the proximity sensor detecting
the second alignment hole that is 180 degrees from the "home" alignment hole. In this run, at approximately 170
degrees we have fallen to 0.6 V and appear to still be dropping. This is expected as the data represents
approximately 0.75 seconds and our pan rate was 1.55 seconds on the previous pan. Thus, we should be nearing the
half way point of this pan (i.e. 180 degrees).
Obviously, this is not the optimal way for us to view the data, especially when it is streaming out at 50 times a
second. To help us visualize the data, a Microsoft Windows application was created to receive, parse, and
display this data. Figure 59 below is a screen shot from the demonstration video and shows the iRoboBumper
system with obstacles on the left and the demonstration application on the right.
Figure 59: Demonstration Application Example
The application visual shows the most recent distance data for the full 360 degree area around the system. In
addition, it show the angle that each PING))) sensor is pointing at the current time. The outer ring of the
circle represents 2 meters and the inner ring represent 1 meter. Thus, each of these targets are around the 1
meter range, but the bottom right target is slightly closer. It is hard to read in the image above, but the
current pan rate, battery voltage, temperature, and proximity sensor data are all displayed in the area
surrounding the distance data. The demonstration video for this project shows the system in operation while the
demonstration application is running, with different sets of obstacles including obstacles that are moving
towards the system as well as obstacles being removed.
The demonstration video can be viewed at http://
The demonstration application can be downloaded at http://
We would love to hear what you think about this project; please tell us in the
comments section below.