App controlled Robot using XBee Wifi and Propeller Chip
Kevin_Pace
Posts: 22
I have been running a robotics competition in Virginia Beach, Va for a few years. I have used a wired PS2 as a controller and XBpro to XBpro communication to achieve wireless robot control with the PROP as the microcontroller. It has worked well and has allowed us to run over 200 plus robots in a day long competition in a convention center.
My goal is to replace the PS2 with an APP and run my robots using WIFI through the new XB wifi module.
I have purchased a set of XB wifi and I have basic communication between the latest version of XCTU and the android Cell phone app "WIFLY REMOTE". (Ill consider making my own app once I get this working)
I setup the xbee in soft AP mode and created an SSID so that the Xbee becomes its own network (essentially) Once I connect my phone to the Xbee network I can view the data I send in the XCTU console by pushing the buttons on the app.
My xbee has been connected to the Parallax XB adaptor for the process above.
Now I want to connect the xbee to the PROP and send the same signal and receive it on the PROP side as output.
My XBee pin 2 (DOUT or Rx) is connected to Prop Pin 4 and my XBee pin 3 (Din or TX) is connected to Prop pin 3.
If I can see the data from the app in XCTU..... is there a way for me to view the same data in the Parallax Serial terminal while its connected to the PROP?
Also, has anyone tackled this issue and willing to share what you have discovered?
This is an area I have not experimented with yet and I have been doing some research to see if there is anyone who has done this or is in the process of doing this but i haven't found much info.
There is a lot more info with people running arduino with XBee wifi and apps than there is propeller.
Thanks for your consideration to help me find a solution!
KP
My goal is to replace the PS2 with an APP and run my robots using WIFI through the new XB wifi module.
I have purchased a set of XB wifi and I have basic communication between the latest version of XCTU and the android Cell phone app "WIFLY REMOTE". (Ill consider making my own app once I get this working)
I setup the xbee in soft AP mode and created an SSID so that the Xbee becomes its own network (essentially) Once I connect my phone to the Xbee network I can view the data I send in the XCTU console by pushing the buttons on the app.
My xbee has been connected to the Parallax XB adaptor for the process above.
Now I want to connect the xbee to the PROP and send the same signal and receive it on the PROP side as output.
My XBee pin 2 (DOUT or Rx) is connected to Prop Pin 4 and my XBee pin 3 (Din or TX) is connected to Prop pin 3.
If I can see the data from the app in XCTU..... is there a way for me to view the same data in the Parallax Serial terminal while its connected to the PROP?
Also, has anyone tackled this issue and willing to share what you have discovered?
This is an area I have not experimented with yet and I have been doing some research to see if there is anyone who has done this or is in the process of doing this but i haven't found much info.
There is a lot more info with people running arduino with XBee wifi and apps than there is propeller.
Thanks for your consideration to help me find a solution!
KP
Comments
Do you just want a simple bridge program? If so the bridge I wrote for the SayIt module should work. Just adjust the I/O pins and baud to match your settings.
Thanks
I'm not really sure what you're trying to do. The bridge program should show on a PC terminal whatever is sent to the Propeller in plain text (assuming a wifi XBee behaves like a normal XBee which, as you suggest, may not be the case). If you were to type a message in the XCTU terminal, it should show up in the Parallax Serial Terminal.exe window. It won't let you see an attempt to program the Propeller (at least I don't think it would be meaningful). The programming interface needs a way to reset the Propeller to begin the programming sequence. There are devices available which allow one to program the Prop wirelessly. A pair of Pololu's Wixels can be used to program the Propeller.
It is possible to program a Propeller over an XBee connection but you need special loader code included in your program. Parallax has an appnote on this topic (appnote #7). I have links to all the appnotes in post #3 of my index (see my signature for a link).
What I am trying to accomplish with the code that I have attached is to be able to see the data that the WIFLY REMOTE app is sending to the xbee wifi in the Parallax Serial Terminal. I have broken down the information that I have been working with and it might make a bit more sense!
I believe I am making progress. I have created some code that I believe in theory should allow me to see the data in the PST. Im certainly not a master at SPIN and I could use any help that could be provided!
On the WiFly Remote app, code is generated in the XCTU console when each of the four arrows are pressed. Below I am listing what each button sends out;
The UP arrow sends the following data;
On the LEFT side of the XCTU console log you will see: F80;S0;
On the right side of the console log you will see: 46 38 30 3B 53 30 3B
The DOWN arrow sends the following data;
On the LEFT side of the XCTU console you will see: B80;S0;
On the right side of the console log you will see: 42 38 30 3B 53 30 3B
The LEFT arrow sends the following data;
On the LEFT side of the XCTU console you will see: L40;S0;
On the right side of the console you will see: 4C 34 30 3B 53 30 3B
The RIGHT arrow sends the following data;
On the LEFT side of the XCTU console you will see: R40;S0;
On the right side of the console you will see: 52 34 30 3B 53 30 3B
I am also attaching my PROP code: Keep in mind that my WIFi xbee is connected to pins 4 and 3 on the PROP. Prop Pin 4 is connected to xbee OUTPUT(pin 2) and Prop Pin 3 is connected to xbee INPUT (pin 3)
Any help to be able to see the app data in the Parallax serial terminal will be a great help!
Thanks KP
I'm curious if this program will show anything in the terminal window when used.
If you get data coming to the terminal window, try commenting out lines 31 and 32 to let the rest of the program run.
The XCTU log appears to contain ASCII characters which are used to indicate which buttons on the pad are pressed. Are bits being set and sent?
My ultimate goal with all of this is to replace the PS2 controller with the APP and create an app that has a buttons and analog sticks to run the robots. We have been running about 300 robots in a convention center over an 8 hour span to complete our event. They are spaced in 50' pods and we have been running all the xbees on Low power setting to reduce the RF footprint. We have been able to run about 12 channels in a single POD.
With this new xbee setup there will likely be many more questions after I get this part working such as...
1. How many robots will I be able to run at one time in a 50 foot radius
2. Will I be able to assign each robot a special port?
Setting up an APP with an IP address and PORT is not a huge deal, but as I have used the Wifly app, it only allows logging in using port 9750. That has me stumped! When setting up the configuration of the xbee in XCTU it has a port modification slot where you can change the port value. However, the ports on my xbee wifi in XCTU are not set to 9750 and it still communicates. I'm assuming..maybe wrongfully, that port 9750 is some kind of standard value.
btw...in case you didn't know
XCTU allows you to create an SSID for the xbee, so basically it becomes its own network and the phone connects to the network of the xbee through wifi.
I like the way you laid this out. I truly appreciate your time on this. I will share my results tomorrow.
Thanks Again!
I remember being confused about same port 9750 when connecting from an iPad, have you checked if the ports in XCTU are in hex-format and corresponds to decimal 9750? I might find the documentation later on, but don't count on it.
Many thanks for getting me over the hurdle on this initial phase!
Ill be getting back with some code once I get a basic robot moving around!
I am thrilled to move this project forward! Thanks Again!
I will check this out tonight! I believe that the number was 2616. That is GOOD NEWS! Thanks so much for following up.
I will post some update info on the project tomorrow!
but data does not show up in the PST unless I change the xbee.start command RX pin to 5,6,7,8,or 9 This truly has stumped me.
I made absolutely sure I duplicated my steps from the prior day.
I have disconnected the xbee module and reconnected it to xctu to be sure the app and the xbee are still communicating and that is still working like it always has.
Pin 5 through 9 on my PROP are not connected to anything! Below you will see what streams in the PST window when the RX pin is changed to any pin 5 through 9.
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00><$00>
<$00><$00><$00><$00><$00><$00><$00><$00><$00
If I comment out the lines below, I will see the text "error input character" pulsing at the top corner of the PST terminal!
So...I believe its getting data but I can't make heads or tails of it!
repeat 'If data is displayed, try commenting out these two lines
SafeTx(Xbee.rx) 'to see if the rest of the program works.
Tracy Allen's four port serial driver rejects these sorts of framing errors but most of the other serial drivers don't (including PST apparently).
Often adding a pull-up resistor on the RX line will eliminate these framing errors but then there's still the problem of not receiving real data.
1. The RX indicator in the PST doesn't blink when buttons are pushed on the app (generally when data is moving into the PST the RX light blinks.)
I have to assume that I'm not getting data which leads me to number 2.
2. From what I am reading, the xbee requires a start indicator (character) such as an "!" I believe that Duane used the "delimiter' command for this.
Please correct me if I am wrong Duane.
3. However, When I used two xbee pros,(with my old project) the start indicator was critical to data flow. Data would not move unless the transmitter and
receiver had the same start indicator.
4. The data that comes from the app and goes into XCTU (the XB) is stuff like " R40;S0;" or "F80;S0;" Is there a way in PROP programming to identify these special patterns of 7 bits and call them something simple, but something that always begins with the same character?
I have tried all kinds of variable ideas and I keep running into syntax errors.
It seems to me that if we had the same start character for each button, the rx would pass through since the start character would be the same.
Just a thought....
So right now I am stuck because I can't seem to find a way to display the app button data in the PST.
If anyone has experience a similar problem or has a solution, it would be very welcomed!
Thanks to all!
I interpreted the command "R40;S0:" to mean go right 40 units and then stop. I don't know if the units are in speed or distance. I'm not familiar with the app being used but perhaps there is a way to proportionally control a robot by changing the values after the letter commands.
I'm not sure if it's clear to you or not but the data displayed on the left side of the console are the ASCII values (in hex) of the characters displayed on the right side of the console.
I figure these are the character you have to work with if you want to develop a Spin program using the app as input. From what I understand, you're not free to assign your own start characters. Personally, I don't think this is a problem. I think the problem is for some reason the XBees aren't communicating.
Thanks for any light you can shed on the problem. I apologize if I didn't post this link in a better way. I'm not overly familiar with the FORUM as of yet!
https://play.google.com/store/apps/details?id=com.inex.wiflyremote&hl=en
I wonder if there's a more cost effective solution than the XBee modules.
I just purchased one of these $4.50 WiFi modules and hope to get it working with the Propeller.
I've used $2 nRF24L01+ modules to control robots in the past by I haven't ever used a WiFi connection to control a robot.
I personally really like the PS2 controller. My one and only submission to the OBEX is a PS2 driver which will allow access to the analog buttons on the controller. Here's a link to my overly complex robot controller I've been working on. It uses a PlayStation 2 controller as well as a touchscreen.
300 robots running around a convention center sure sounds like a lot of fun.
I totally respect your thinking and under different circumstances, I would probably look for another option. Thanks for your input and thoughts on this project Duane.
I have talked with Chris Savage and he has told me that he may try to duplicate my setup to see where he thinks the code hangup may be. Chris believes it might even be a timing issue. I am hopeful that he can be a game changer. I just have to believe that if so many other platforms are doing it, we need to be on the playing field too. In my opinion, the Propeller is the best micro-controller on the market because of its vast ability and support. We have invested over $100,000 dollars in the past 5 years buying materials from Parallax and their team has never let me down. Andy Lindsay coached me along in the beginning and helped me get it going initially and we have seen a BOOM in growth. We have 60 schools in our own school division involved in this program. over 50% of the schools are elementary. The kids build the circuit boards and then test them, learn to program with some basic spin activities and then get moving on building a robot for the annual challenge. We have over 175 mentors and teachers involved as well.
I hope this paints a little bigger picture for everyone concerning the importance of it.
I'm excited because I feel confident once we jump this hurdle, it will be moving forward pretty fast!
Thanks again for all your input. I will certainly share anything once I get it working!
It sure sounds like a lot of fun getting that many robots together.
Just so I know, are these the XBee WiFi modules you're using?
You just need one module right? The other side of the com link is the tablet's WiFi radio, right?
I'm staying positive that communication can be established in the PST window!
Its chaotic right now in most places with Christmas etc...but maybe Chris will be able to shed some light on this very soon!
Have a Merry Christmas!
Thanks for all you feedback and help!
This and one other issue I promised to look into are on my priority list today. The holidays didn't go as I planned. I expected to relax mostly and work on some projects. I only just got my bench back together yesterday. So today I have the parts I need sitting on the bench ready to go. I am just currently playing catch-up on forums, support e-mail and support calls. But we'll get it done. Thank for your patience.
I am having some difficulty with this app connecting to my module. Part of my confusion is whether the port value on the app is specified in decimal or hex. In X-CTU it is in hex, which is different from typical Windows apps which usually specify the port in decimal. Also, I didn't think to have you post your settings for the S6B so I could ensure I am using the same settings as you. Could you post your settings in X-CTU for the S6B?