Tuesday, April 5, 2011

Wireless communication - Part Deux

Hooray!!  After several hours of troubleshooting, I have finally figured out (I think) the last issue for communication!  In my previous post, I mentioned that when I sent more than one byte across the connection, that the later bytes were garbling.  Well, I decided to ignore it and move on to work with my PS2 controller and how it communicates.  I was sending one value just fine, but when I attempted to send a second one, I was perpetually getting bogus values for every byte after the first.  When I should have been getting (128, 128), I was getting (128, 192), and for kicks I tried (128, 128, 128, 128) and got (128, 192, 192, 192).  Interestingly, 192 is 64 bigger than 128, so I thought for some reason that subsequent bytes were getting bit-shifted somehow, but I couldn't figure it out.

I finally stumbled upon a post about other people using the NewSoftSerial library for Arduino (http://arduiniana.org/libraries/NewSoftSerial/), and what I found was that the 57600 baud rate that some of the XBee tutorials told me to use is on the absolute edge of capability of this NewSoftSerial library.  So I used X-CTU to reconfigure the XBees to communicate at 19200, and changed all serial calls in my sketches to use 19200, and...

VOILA!!!

Appropriate value passing is now occuring.  Likely, if I really wanted to, I could probably upload sketches wirelessly now... but I'm fine with my current way... I've gotten used to it.

What is that?  I didn't describe to you my current way of uploading sketches?  Ok, since you asked so nicely... I'll tell you in my next post.  Just need to snap some photos.  ;-)

No comments:

Post a Comment