Need Help Coding/Configuring Wireless Device In Basic Stamp 2
Im New To Micro
Posts: 42
Hi all,
Over at electro-tech-online.com I was asking others what I needed to buy to control things on my Board of education wirelessly, such as, control my Boe Bot wirelessly, or turn LEDs on and off wirelessly with a controller (one I create or a professional one already made).
Anyway, they referred me to the following two devices/chips, but the problem is, I have no idea what code I should use or if a tutorial is even out there to help me set these up to link to each other and send bytes back and forth.
http://www.sparkfun.com/commerce/product_info.php?products_id=8945
http://www.sparkfun.com/commerce/product_info.php?products_id=8947
I saw that Basic Stamp 2 uses the serin and serout, but it just didn't give me enough information on how to set these two particular components up.
Any help is appreciated!
Over at electro-tech-online.com I was asking others what I needed to buy to control things on my Board of education wirelessly, such as, control my Boe Bot wirelessly, or turn LEDs on and off wirelessly with a controller (one I create or a professional one already made).
Anyway, they referred me to the following two devices/chips, but the problem is, I have no idea what code I should use or if a tutorial is even out there to help me set these up to link to each other and send bytes back and forth.
http://www.sparkfun.com/commerce/product_info.php?products_id=8945
http://www.sparkfun.com/commerce/product_info.php?products_id=8947
I saw that Basic Stamp 2 uses the serin and serout, but it just didn't give me enough information on how to set these two particular components up.
Any help is appreciated!
Comments
I took a look at the datasheet for those wireless modules you linked to. They look pretty snazzy, and for a total cost of less than 10 bucks for the pair, thats pretty hard to beat .
The BS2 should be able to talk to these things nicely - there doesn't look to be any real configuration necessary. Now, Im not sure about this because I have never used these modules and their datasheets are a little sparse about how to communicate between them, but it looks like you can send data to the transmitter and have the receiver echo that data on the other side - this is very similar to the Linx Transceiver modules that Parallax sells (_this one_).
The following is a short code sequence for the transmitter:
This code is for the receiver:
What this does is have the transmitter send a start byte (the "!") followed by 4 bytes. On the receiver side, the BS2 waits until it sees an "!" from the receiver and then copies the next 4 bytes to their respective variables. Once the receiving BS2 has this data, it can do whatever you want to do with it - I.E. control motors, turn on LEDs, play a tune...
In the code above, I set the baud mode to 396. For a BS2, this sets up the serial transmission/receiving to 2400 Baud, 8 data bits, no parity, and one stop bit (2400 bps @ 8n1). Those serial modules you posted have some limitations on the transmission speed, which is why I chose 2400 baud.
Something to consider with these wireless modules: there is no wireless network protocol that these modules adhere to. That is, you have to define to the transmitting BS2 the order in which you send bytes and program the receiving BS2 to receive bytes in that order and somehow validate the received data. This is the point behind sending and receiving a preamble of "!". Also, Sparkfun's page states that "Only one 315MHz transmitter will work within the same location.". This might not be good for your application because you cannot get bi-directional communication between your two devices.
If you want a little more information about the theory of how those code segments work, check out the following PDFs - they are for the Linx transmitter and receiver modules. Parallax's Linx Transceiver module that I linked above is essentially both of the following devices rolled into one device (does that make sense?).
Transmitter: TX Product Sheet
Receiver: RX Product Sheet
Did you pick up a pair of those transmitters/receivers? I am curious to see how they work for you .
Yeah I did because of how cheap they were, but I'll definitely give that code above a shot to see how things goes. It's a lot to take in, but if all goes wrong, I'll just buy the parallax module.
I'm sure I'll have other questions, so I'll keep you posted
If you want, you can even post some of your code here - I would be happy to give you some pointers. Same with any questions as thats what Im here for :cool:
Will do. I'm just so busy with school this week and have an exam next Mon I need to study for, so I haven't been able to try out that code as quickly as I wanted. I should have some free time Saturday I hope.
Hey Daniel, have you determined whether or not these RF modules handle the error checking for you? Remember, you can grab all the XBee stuff you want from inventory. Ahh - hassle-free RF is only 50 feet away from your desk. 2mW to 60 mW with the adapters and microcontrollers of your choice! You can have the best for free sometimes!
Ken Gracey
I have one of those transmitter/receiver pairs sitting around here somewhere - I haven't touched them since I got my first XBees a few years ago.
My perspective is the same. If one's time is of any value then it's really worth spending the money to get the XBee units. My only problem with the personal commitment to using XBee is that I'm now wearing RF "blinders". It would take a real convincing case and super easy technical transition to make me use something else at this point.
The Lynx devices mentioned above work well and they're really simple, but you have to do the error checking/checksums in your code. This becomes a focus of its own sometimes.