Wireless communication with DIY RC Car - Page 1
Forum section: electronics / beginners

author: FenderBender
author_rank: Super Contributor
timestamp: July 17, 2012, 08:54:49 pm
content: Hello,Something that's been in the back of my mind for a while has been the idea of making an RC car. In theory, it's really quite simple. The problem I'm having is doing RF transmission to the car effectively. I plan on using an Arduino in the remote controller and an Arduino in the car itself. (Not Arduino boards, just MCUs with the Arduino bootloaders.)So one thing I ran across were these neat little 315MHz transmitter and receiver modules avaialable all over the place. I can get a receiver and transmitter for $9 total, which is pretty good, considering Xbee or other devices would be atleast 5x more.http://www.sparkfun.com/products/10533http://www.sparkfun.com/products/10535I've seen mixed reviews, but I would guess that the bad reviews were just not implemented correctly. I am good at programming, but I still don't know microcontrollers too much.Do you think this is a viable solution?Thanks.

author: Psi
author_rank: Super Contributor
timestamp: July 18, 2012, 03:47:34 am
content: With those you will need to do good amount of analog filtering on the output to get a clear signal without noise.Perhaps use manchester code and a band pass filter.Also the data stream will need software checksums, so it can detect and discard bad data segments.But to answer your question yes, it's perfectly doable.If it was me though, i'd probably spend a bit more and get some pre-made transceiver modules that do their own error detection/correction and provide a digital serial connection.It's nice to have two way comms, so you can warn the user when the error rate starts to climb.

author: electrode
author_rank: Regular Contributor
timestamp: July 18, 2012, 03:56:30 am
content: I think it's a good project, and you could learn a lot if you do it this way, instead of the XBee route.Seeing as you have the Arduino, you can easily do any sort of fail-safe you want. You could, for example, send messages in packets of X bytes with checksums, and use that as verification. You can make it kill the motor. You can do encryption.DO look into dealing with noise before you start though. I'm sure someone has come up with something workable.

author: FenderBender
author_rank: Super Contributor
timestamp: July 18, 2012, 04:11:39 am
content: Thanks.I'm going to need to read up quite a bit on all of the packet transmission technicalities. Never did much of that in the type of programming I did. I read one guy's comment on Sparkfun and he advised some sort of bandpass or low pass filter I believe. Probably easy enough, but hell I don't know.The whole packet loss thing: Yeah, seriously, I'm very new to that stuff, hence why I'm writing in Beginners. Anywhere I could learn about that? What would manchester code achieve? Any example code on how to make sure data is transmitted accurately?Between my lack of MCU experience and lack of RF/wireless experience, it's going to be a wild ride.Thank you.

author: Psi
author_rank: Super Contributor
timestamp: July 18, 2012, 05:11:56 am
content: Quote from: FenderBender on July 18, 2012, 04:11:39 amIt solves a problem with filtering a digital signal. If you look at stream of digital data it occasionally has blocks of all ones or all zeros and these blocks could be very long. This creates a problem as it means the frequency of your data is quite variable.It makes it hard to try and filter your signal vs the noise.eg, a 4kHz data signal of 1111000011110000 looks the same as a 2khz data signal of 11001100.So you can't just band pass filter around your data clock rate or you will kill any blocks of ones or zeros in your dataManchester code results in a signal which changes state very often. You never get prolonged high/low states even when you're sending prolonged low or high data.Google/youtube it if you need to know in detail but basically it works by using the falling/rising edges to represent data rather than the high/low state.Quote from: FenderBender on July 18, 2012, 04:11:39 amThe quick/easy way is to decide on a packet structure and length.Lets say all packets are 8 bytes long.Lets say all packets start with SSLet say all packets have a checksum byte on the end which we call CAnd some random data we want to send = 12345Then a packet would look likeSS12345CThe checksum byte C is calculated by doing an XOR to all bytes in sequence.so S xor S xor 1 xor 2 xor 3 xor 4 xor 5 = CThe xor operation is a single ^ mark in the C language so real easy to do in code. You can just loop through and calculate what C should be. Or you can calculate the checksum as the bytes come in.If you get a packet and calculate C should be 55 but 23 was sent in the packet then you know this packet is corrupt.Note: A checksum will detect most errors but you can get corrupt packets that pass the check sometimes. For better error detection you can use a two byte checksum, one checksum for odd numbers in your packet and one for even.If you want more reassurance look at a CRC code, however this is more complicated.For detecting when packets arrive just look for two "S" chars then start buffering the data in an 8byte array until you get the entire frame. Then you can either pass the array to a function to do stuff. or ignore it and clear the buffer if the checksum is bad.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 18, 2012, 06:56:54 am
content: have done this with similar "cheapo" type transmitter/receiver (433MHz) module with pic16f690. the module is fun and easy! i resorted to cheapo module due to failure to make the CC1100 module to work. my only problem was the effective reliable transmission distance, this one still pending to be solved. instead of manchaster, i used my "own proprietary encoding scheme". its highly classified and other word... secret!only piece of 2cnts advice, since you are using "generic" transmitter, you need to handle yourself things like unique ID, preambling and whatnot to avoid clashing with other 315MHz system, and multiple transmission and sort of "integrity checking" to increase distance reliability beyond simpler method.

author: FenderBender
author_rank: Super Contributor
timestamp: July 18, 2012, 05:25:07 pm
content: Right. Manchester code makes plenty of sense. I'm not sure how to implement it though. Again, I really need to do some experiments just to get started. I know there's a serial library for Arduino that makes communication easy. I guess you'd just have to write something in code with ORs and XORs and stuff. Just not sure how to write the code for it since I don't fully understand it. Is manchester code typical for wireless transmission? I'll have to google it.

author: electrode
author_rank: Regular Contributor
timestamp: July 18, 2012, 09:11:14 pm
content: This thread may help:http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1199058664/0

author: FenderBender
author_rank: Super Contributor
timestamp: July 19, 2012, 01:46:51 am
content: Hmm too bad the library doesn't even seem to be available. Shucks. I guess I'm going to have to figure out how to do it myself.Better order these Tx and Rx modules...