Boe Bot remote controlled with XBee
The Boe Bot remotely controlled using XBee radios
The whole idea of this project was to build a Boe Bot which could be remote controlled using a PC. The bot can also send back data to the PC (ie.: sensor data) and it has been mindbreadking sometimes, so I spare you the research and wrote it down.
Hardware I've used for this project:
- Boe Bot with Basic Stamp 2 module
- Ping sensor with servo
- Two XBee Pro series 2 radios
- Sparkfun XBee Explorer USB
- Sparkfun XBee Explorer Regulated
- Mini USB cable
Software:
- Basic Stamp Editor 2.5
- X-CTU
- Eclipse (to build a Java GUI)
Code: xbee_demo.bs2
Insert one of the XBee radios into the XBee Explorer USB and connect a USB cable to it from your PC. Fire up X-CTU and select the right USB COM port and click 'Test/Query'.
This should display a message something like this:
Click on the 'Modem Configuration' tab and select the correct modem for your XBee radio (this depends on the type of Xbee radio you bought). My modem type is the XBP24-ZB. From the 'Function set' list, select the 'ZIGBEE COORDINATOR AT'.
Now we need to set the parameters of this firmware. Under 'Networking', set the PAN ID to a value of your choice. This is the channel number where the radios communicate on.
Under 'Adressing' you for 'Serial Number High' and 'Serial Number Low'. Write down both values on a piece of paper.
Under 'Serial Interfacing' look for 'Baud Rate' and set it to '38400'.
Select the 'Always update firmware' checkbox and click on the 'Write' button. The firmware with your parameters is now written to the XBee radio.
Sometimes X-CTU is unable to communicate with the XBee and a message is show that you need to reset the XBee. This is very easy but a crucial step to remember. I've used it quite a lot to fix communication bewteen my laptop and my XBee. By connecting the 'RST' pin with the 'GND' pin for just a second using a wire, a reset signal is triggered in the XBee. Whenever you experience communication issues, try this first.
After the firmware is saved to the XBee, unplug the USB cable and remove the XBee from it's USB adapter board. Now insert the second Xbee into the adapter board and plug the USB cable back in.
In X-CTU, click on the corresponding USB COM port and click 'Test/Query' again and comminucation should be ok. In the 'Modem Configuration' tab select the correct modem type again and set the 'Function set' to ZIGBEE ROUTER AT. First a used END DEVICE but this gave issues when sending back data and ZIGBEE ROUTER AT works just fine.
Now we need to set the parameters of this firmware. Under 'Networking', set the PAN ID to a the same value as you entered on the COORDINATOR.
Under 'Adressing' search for 'Serial Number High' and 'Serial Number Low'. Write down both values on a piece of paper.
Under 'Adressing' search for 'Destination Address High' and 'Destination Address Low'. Change the value of DH to the 'Serial Number High' value you wrote down. Do the same for the DL value and change it to the 'Serial Number Low' value you wrote down.
Under 'Serial Interfacing' look for 'Baud Rate' and set it to '38400'.
Select the 'Always update firmware' checkbox and click on the 'Write' button. The firmware with your parameters is now written to the XBee radio.
Disconnect the USB cable and gently take out the XBee out of the adapter board and insert it into the other adapter board without the USB connector. Now insert the adapter board with the XBee radio on it into the breadboard on the Boe Bot. Now we can start wiring the Xbee.
Connect the Vdd to the 5V pin (pin number 11).
COnnect the Vss to the GND pin (pin number 10).
Connect the DOUT to the DIN pin (pin number 3 and 4).
The hardest part is to get the XBee radios to communicate properly with each other. So I recommend everybody to start with a range test.
Insert the COORDINATOR XBee into the USB adapterboard and connect it to your PC.
On the Boe Bot, set the the power switch to '1', we don't need to set it to '2' because we don't need to use any servo's yet. The 'PWR' led on the XBee should glow red now.
Go back to X-CTU and click 'test/query' to make sure your connection is correct. You might need to change the Baud Rate here to 38400.
Click on the 'Modem configuration tab' and click on the 'Read' button.
Under 'Adressing' search for 'Destination Address High' and 'Destination Address Low'. Change the value of DH to the 'Serial Number High' value you wrote down last time. Do the same for the DL value and change it to the 'Serial Number Low' value you wrote down.
Now click on the 'Write' button and the changes should be saved.
Click on the 'Terminal' tab. In the box below enter a random alphanumeric character. This character is displayed in blue. Blue characters are characters which are sent. If your setup is correct, it displays the character you entered twice, one in blue and one in red. The red character is the data which is received from the Boe Bot XBee radio.
The hardware and software is now properly configured to perform a range test.
Click on the 'Range test' tab and click on the 'Advanced' button. Change 'Data receive timeout' value to 5000 ms.
Now click on the 'Start' button to start the range test. When the radios are in close range, a 100% value should always be the case. If not, check your setup again.
If this all went well, you've managed to send and receive data between the XBee radios!
Whenever you experience transmission issues fall back to this setup for testing.
Now we can re-wire the Boe Bot to actually do something
Disconnect the loopback wire from DIN and DOUT.
Connect one wire from DOUT to a free pin on your Boe (I used pin 3).
Connect one wire from DIN to a free pin on your Boe (I used pin 4).
Now the Boe is capable of receiving and transmitting data to your Basic Stamp from your XBee.
Now load the BS2 code into the editor and change the pin settings to match your setup (servo and XBee pins).
Load the program into the Basic Stamp and set the power switch to '2'.
Open X-CTU and go to the 'Terminal' tab. Enter the character 'f' and your Boe Bot should move forward. Check the code for the other navigation keys.
The code also includes the usage of a Ping sensor. By pressing the 'm' key, it measures the distance and sends the data back to the COORDINATOR. The result should appear in the X-CTU terminal window.
That's it, you've now got a fully remote controlled Boe Bot!
Current issues:
- The Basic Stamp cannot read incoming data and power the servo's at the same time because it is not capable of performing multiple tasks concurrently. I am planning on converting my setup to use the Propeller module.
Have phunn!!
Greetz HackWar
The whole idea of this project was to build a Boe Bot which could be remote controlled using a PC. The bot can also send back data to the PC (ie.: sensor data) and it has been mindbreadking sometimes, so I spare you the research and wrote it down.
Hardware I've used for this project:
- Boe Bot with Basic Stamp 2 module
- Ping sensor with servo
- Two XBee Pro series 2 radios
- Sparkfun XBee Explorer USB
- Sparkfun XBee Explorer Regulated
- Mini USB cable
Software:
- Basic Stamp Editor 2.5
- X-CTU
- Eclipse (to build a Java GUI)
Code: xbee_demo.bs2
Insert one of the XBee radios into the XBee Explorer USB and connect a USB cable to it from your PC. Fire up X-CTU and select the right USB COM port and click 'Test/Query'.
This should display a message something like this:
Click on the 'Modem Configuration' tab and select the correct modem for your XBee radio (this depends on the type of Xbee radio you bought). My modem type is the XBP24-ZB. From the 'Function set' list, select the 'ZIGBEE COORDINATOR AT'.
Now we need to set the parameters of this firmware. Under 'Networking', set the PAN ID to a value of your choice. This is the channel number where the radios communicate on.
Under 'Adressing' you for 'Serial Number High' and 'Serial Number Low'. Write down both values on a piece of paper.
Under 'Serial Interfacing' look for 'Baud Rate' and set it to '38400'.
Select the 'Always update firmware' checkbox and click on the 'Write' button. The firmware with your parameters is now written to the XBee radio.
Sometimes X-CTU is unable to communicate with the XBee and a message is show that you need to reset the XBee. This is very easy but a crucial step to remember. I've used it quite a lot to fix communication bewteen my laptop and my XBee. By connecting the 'RST' pin with the 'GND' pin for just a second using a wire, a reset signal is triggered in the XBee. Whenever you experience communication issues, try this first.
After the firmware is saved to the XBee, unplug the USB cable and remove the XBee from it's USB adapter board. Now insert the second Xbee into the adapter board and plug the USB cable back in.
In X-CTU, click on the corresponding USB COM port and click 'Test/Query' again and comminucation should be ok. In the 'Modem Configuration' tab select the correct modem type again and set the 'Function set' to ZIGBEE ROUTER AT. First a used END DEVICE but this gave issues when sending back data and ZIGBEE ROUTER AT works just fine.
Now we need to set the parameters of this firmware. Under 'Networking', set the PAN ID to a the same value as you entered on the COORDINATOR.
Under 'Adressing' search for 'Serial Number High' and 'Serial Number Low'. Write down both values on a piece of paper.
Under 'Adressing' search for 'Destination Address High' and 'Destination Address Low'. Change the value of DH to the 'Serial Number High' value you wrote down. Do the same for the DL value and change it to the 'Serial Number Low' value you wrote down.
Under 'Serial Interfacing' look for 'Baud Rate' and set it to '38400'.
Select the 'Always update firmware' checkbox and click on the 'Write' button. The firmware with your parameters is now written to the XBee radio.
Disconnect the USB cable and gently take out the XBee out of the adapter board and insert it into the other adapter board without the USB connector. Now insert the adapter board with the XBee radio on it into the breadboard on the Boe Bot. Now we can start wiring the Xbee.
Connect the Vdd to the 5V pin (pin number 11).
COnnect the Vss to the GND pin (pin number 10).
Connect the DOUT to the DIN pin (pin number 3 and 4).
The hardest part is to get the XBee radios to communicate properly with each other. So I recommend everybody to start with a range test.
Insert the COORDINATOR XBee into the USB adapterboard and connect it to your PC.
On the Boe Bot, set the the power switch to '1', we don't need to set it to '2' because we don't need to use any servo's yet. The 'PWR' led on the XBee should glow red now.
Go back to X-CTU and click 'test/query' to make sure your connection is correct. You might need to change the Baud Rate here to 38400.
Click on the 'Modem configuration tab' and click on the 'Read' button.
Under 'Adressing' search for 'Destination Address High' and 'Destination Address Low'. Change the value of DH to the 'Serial Number High' value you wrote down last time. Do the same for the DL value and change it to the 'Serial Number Low' value you wrote down.
Now click on the 'Write' button and the changes should be saved.
Click on the 'Terminal' tab. In the box below enter a random alphanumeric character. This character is displayed in blue. Blue characters are characters which are sent. If your setup is correct, it displays the character you entered twice, one in blue and one in red. The red character is the data which is received from the Boe Bot XBee radio.
The hardware and software is now properly configured to perform a range test.
Click on the 'Range test' tab and click on the 'Advanced' button. Change 'Data receive timeout' value to 5000 ms.
Now click on the 'Start' button to start the range test. When the radios are in close range, a 100% value should always be the case. If not, check your setup again.
If this all went well, you've managed to send and receive data between the XBee radios!
Whenever you experience transmission issues fall back to this setup for testing.
Now we can re-wire the Boe Bot to actually do something
Disconnect the loopback wire from DIN and DOUT.
Connect one wire from DOUT to a free pin on your Boe (I used pin 3).
Connect one wire from DIN to a free pin on your Boe (I used pin 4).
Now the Boe is capable of receiving and transmitting data to your Basic Stamp from your XBee.
Now load the BS2 code into the editor and change the pin settings to match your setup (servo and XBee pins).
Load the program into the Basic Stamp and set the power switch to '2'.
Open X-CTU and go to the 'Terminal' tab. Enter the character 'f' and your Boe Bot should move forward. Check the code for the other navigation keys.
The code also includes the usage of a Ping sensor. By pressing the 'm' key, it measures the distance and sends the data back to the COORDINATOR. The result should appear in the X-CTU terminal window.
That's it, you've now got a fully remote controlled Boe Bot!
Current issues:
- The Basic Stamp cannot read incoming data and power the servo's at the same time because it is not capable of performing multiple tasks concurrently. I am planning on converting my setup to use the Propeller module.
Have phunn!!
Greetz HackWar
Comments
You need a ServoPAL!
The ServoPAL is a tiny module that plugs in between your BASIC Stamp and two servo motors to pulse the motors so your PBASIC program doesn't have to.
Thanks for your answer!
So if I understand it correctly I only need to send 1 command to the ServoPAL and it will power my servo's for let's say 5 seconds and continue processing code while the ServoPAL powers the servo's?