1st Prop project: Trouble with joystick/XBee to XBee comm
Falcon
Posts: 191
I've been a BS2 user for quite a while, and am just now starting to use the Propeller. I've completed the PE Kit but have no other propeller experience.
My ultimate goal is to make a remote control for a robot using two Propellers and two XBee modules.
I've started with some code from a Tymkrs.com post found here http://forums.parallax.com/showthread.php?141739-Making-Parallax-Modules-Wireless-with-XBee-modules&highlight=joystick to display joystick position on the PC.
I have this code to read the joystick (P/N 27800) and transmit the position via XBee mounted to a Propeller Demo Board.
I verified the joystick works with the Propeller on a Demo Board using the Kickstart code. I verified the XBee's work using the XBee "Getting Started" Tutorial but used a USB Adapter board.
XBee DOUT to pin5
XBee DIN to pin6
Joystick to pin0 and pin1
I'm using the following code to receive the data with another XBee and Propeller (on a Demo Board) and display it on the PC.
XBee DOUT to pin0
XBee DIN to pin1
I use a single USB cable to first program the sending Propeller, then the receiving Propeller. I then open the Parallax Serial Terminal (PST) with F12. After that I get no display on the PST.
I did see something about a Pass-Thru method. Is that something that is significant to using the Demo Board vs. the USB XBee Adapter?
I appreciate anyone that can get me pointed in the right direction,
falcon
My ultimate goal is to make a remote control for a robot using two Propellers and two XBee modules.
I've started with some code from a Tymkrs.com post found here http://forums.parallax.com/showthread.php?141739-Making-Parallax-Modules-Wireless-with-XBee-modules&highlight=joystick to display joystick position on the PC.
I have this code to read the joystick (P/N 27800) and transmit the position via XBee mounted to a Propeller Demo Board.
I verified the joystick works with the Propeller on a Demo Board using the Kickstart code. I verified the XBee's work using the XBee "Getting Started" Tutorial but used a USB Adapter board.
XBee DOUT to pin5
XBee DIN to pin6
Joystick to pin0 and pin1
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 XB_Rx = 5 ' XBee DOUT XB_Tx = 6 ' XBee DIN XB_Baud = 9600 CR = 13 ' Carriage Return value OBJ XB : "FullDuplexSerial" rc : "RCTime" Pub Start | UD, LR XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee waitcnt(clkfreq + cnt) repeat rc.rctime(0, 1, @LR) rc.rctime(1, 1, @UD) XB.Str(String("UD = ")) XB.dec(UD) XB.Str(String(", LR = ")) XB.dec(LR) XB.tx(13) waitcnt(clkfreq / 2 + cnt) ' 1/2 second delay
I'm using the following code to receive the data with another XBee and Propeller (on a Demo Board) and display it on the PC.
XBee DOUT to pin0
XBee DIN to pin1
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ' Set pins and Baud rate for XBee comms XB_Rx = 0 ' XBee DOUT XB_Tx = 1 ' XBee DIN XB_Baud = 9600 ' Set pins and baud rate for PC comms PC_Rx = 31 PC_Tx = 30 PC_Baud = 9600 Var long stack[50] ' stack space for second cog OBJ PC : "FullDuplexSerial" XB : "FullDuplexSerial" Pub Start PC.start(PC_Rx, PC_Tx, 0, PC_Baud) ' Initialize comms for PC XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee cognew(XB_to_PC,@stack) ' Start cog for XBee--> PC comms PC.rxFlush ' Empty buffer for data from PC repeat XB.tx(PC.rx) ' Accept data from PC and send to XBee Pub XB_to_PC XB.rxFlush ' Empty buffer for data from XB repeat PC.tx(XB.rx) ' Accept data from XBee and send to PC
I use a single USB cable to first program the sending Propeller, then the receiving Propeller. I then open the Parallax Serial Terminal (PST) with F12. After that I get no display on the PST.
I did see something about a Pass-Thru method. Is that something that is significant to using the Demo Board vs. the USB XBee Adapter?
I appreciate anyone that can get me pointed in the right direction,
falcon
Comments
To:
You should at least see:
In the terminal window.
If you don't then there's a problem with the serial connection/terminal window. If you see the above message then we know to look elsewhere.
I received a "expected an expression term" error pop-up with the "XB_to_PC" highlighted.
falcon
I changed the USB cable and switched to a different USB port on my PC, I unplugged all unnecessary USB cables. Still no "Press any key to start." text in the PST.
Here is my step by step process:
1. Unplug Rx (Prop Demo board with XBee) USB cable
2. Plug USB cable to Tx (Prop Demo board/XBee/joystick)
3. Load TX code as seen above.
4. Move USB cable to Rx (Prop Demo board/XBee)
5. Load RX code above with snippet from Duane Degn
6. Click Enable on PST (previously opened)
7. Press Reset on Rx (Prop Demo board/XBee)
Still no "Press any key to start." text in the PST.
I even switched the Prop Demo Boards thinking one was damaged, but that didn't help.
What could be wrong with the serial connection/terminal window function?
falcon
You want to make sure the serial terminal is set to this same com port. You also want to make sure the serial terminal is set to the correct baud.
I appreciate your and Mike Green's help. It looks like I have a long way to go to become competent with the propeller. I am pretty comfortable with the BS2 but like the idea of multiple processors so I will forge ahead.
Next step: Convert Joystick values to Pulse Out commands to operate servos.
Thank you both.
falcon
The Prop is a great microcontroller for robotics. IMO, it's worth the effort to learn to use it.
You'll find lots of people willing to help you out.
Post #15 of my QuickStart servo tester thread has a very simple servo demo program. You might find it useful. There's also a demo program in the Prop Tool's library but I think my version is even easier to understand "official" demo (which is also good demo).