Remote Mobile Robot with XBee-WiFi

Remote Mobile Robot with XBee-WiFi

*During writing this tutorial, XBee WiFi doesn’t have SoftAP mode yet. But now, Xbee WiFi offers SoftAP mode which is much more suitable for this application. So it is recommended to read this tutorial: Remote Mobile Robot with XBee-WiFi (Android)

Since Digi International (the company of XBee) has launched its WiFi module (XBee-WiFi), I am thinking to create a simple but interesting application using this module. What should be on your mind? Then I start to check my store, what should be the interested item. After a while, I found this, mobile robot base with motor and wheel, MC40A board (I get this during the “spot 1 sen item” by Cytron), 7.4V LiPo Battery with connector, Xbee WiFi with SKXBee Rev2.0 and 4 sets of PCB stand.

You can find all these items on Cytron's Website:

1. Educational Mobile Robot 2.0 (EDUBOT2)

2. XBee WiFi Wire Antenna (XBEE-WIFI) *this item is not available in our store, you may find a replacement.

3. XBee Starter Kit Without Module (SKXBEE BOARD), I am using SKXBee Rev2.0, if you are using Rev1.0, please refer here for a minor modifications.

4. 1 unit of 7.4V 900mAH LiPo Battery (LI-7.4-900)

This is my base robot using a donut board. I made it last 2 years, complete with SPG10 DC motors, extended bracket, and Tamiya castor. At that time EDUBOT2 is not launched yet, so I choose the donut board as a base. Why? I can easily drill using Pro’sKIT mini hand drill.

2 wires represent 2 points at each DC motor. It will be connected to MC40A ‘Left M’ and ‘Right M’ connectors respectively. So I can control the DC motor's direction.

Time to start assembling the mobile robot. Put the PCB stands at every edge (hole) of the base. Ok, done!

Wait, this PCB stand is too long, need to find a medium-long PCB stand. Yes, I have it. Ok, done! Look better, right? 

Next is the battery, you utilize 2 units of 3.7V 1100mAH LiIon Battery, or the easiest way to stick the battery at the base is by using the double-sided tape.

The wire converter for my battery is quite long. Need to manage the wire properly; at least it is not touching the wheel and the floor.

OK, mount the MC40A on the top, then put the nuts and screw it medium tight.

Connect all the wires respectively. The left motor connects to the ‘Left M’ connector, the right motor connects to the ‘Right M’ connector and the battery to the Vin adapter. Set the mini jumper (Vmo/Vin) to Vin.

Finally, put the XBee WiFi with SXBee (Rev2.0) on MC40A, there is a socket for it.

Ok, done with the hardware. Very handsome right? Now time to set the XBee-WiFi.

I assume you know how to connect and open the XCTU software or you can refer to this tutorial “Getting Started with XBee-WiFi“.

Once your module has been recognized by the XCTU software, try to connect to your WiFi network. First click on ‘Active Scan > Scan’.

I’m using YES and this is my WiFi name “IdrisWiFi”. Click yours and enter the WiFi password.


 

Yes! My module connected to IdrisWiFi in 9614 ms.

Once connected, ASSO LED (DS5) on your SKXbee will blink, which means your module has successfully joined the WiFi network and it will be given a specific IP address. Click on ‘Read’ and you will see the updated ‘MY – Module IP Address’, ‘MK – IP Address Mask’, and ‘GW – IP Address of Gateway’. Look at ‘DL – Destination IP Address’, it shows 255.255.255.255 which means the broadcast address. It is better to set it corresponding to your PC/laptop IP address.

Make sure your PC/laptop is connected to WiFi too. Then check your IP address. You can use the command prompt, then type “ipconfig” followed by “enter”. It will display your current IP address. Mine is 192.168.1.10.

Now I will set the ‘DL – Destination IP Address’ to 192.168.1.10 in XCTU. Then change the ‘IP – IP Protocol’ to ‘1-TCP’. Why TCP? Because I just want to use the HyperTerminal software, and this software is a client TCP/IP. After done all the settings, click ‘Write’.

Make sure the ASSO LED (DS5) is blinking; otherwise you can press the reset button on the SKXBee and wait until the ASSO LED blinks. Then click ‘Read’ again to double-check all the parameters following what you set before. If it is different, you can repeat the configuration again.

Now, I want to test the connection. Open HyperTerminal software, and give a name e.g. “XbeeWiFi”.

Choose connect using “TCP/IP (Winsock)”. Then type your module IP address in the “Host address” box followed by “Port number”. Confuse?

“Host address” refers to ‘MY – Module IP Address (192.168.1.11)

“Port number” refers to ‘CO – Source Port’ (0x2616).

* REMEMBER! ‘CO – Source Port’ (XCTU) in HEX but “Port number” (HyperTerminal) in DEC.

Click OK. Make sure it is Connected: 0.00.00 (look at bottom left).

Don’t forget the basic setting on ASCII Setup. Check box for “Send line ends with line feed” and “Echo typed characters locally”.

Try to send any data. “Assalamualaikum” is a data from HyperTerminal to XCTU, and “Waalaikumussalam” is a data from XCTU to HyperTerminal. The communication between my laptop and the module via the WiFi network is successful.

Now, time to program the PIC16F887. I’m using MPLAB X IDE V1.51 and XC8 V1.12. Let’s focus on the main part.

After you download the program, make sure the XBee-WiFi is connected to your laptop Wifi (check the ASSO LED on SKXBee Rev2.0, it should blink), and press SW1. The robot will send some string to the HyperTerminal, then it will move a little left and right to test the motor. Once you get the “Ready!” string, you can start pressing a key on the keyboard.

w/W – Forward

a/A – Rotate Left

d/D – Rotate Right

s/S – Stop

That’s all from me, hope you can play with it. Of course, you will face some problems and troubleshooting, that’s called experience, and experience gives you valuable knowledge. 

P/S: If you have questions for Author, please discuss them in Cytron’s technical forum.

 

 

 

Sample Code:

Remote Mobile Robot with Xbee-WiFi

BUY