Author Topic: Wireless communication with DIY RC Car  (Read 5548 times)

0 Members and 1 Guest are viewing this topic.

Offline FenderBenderTopic starter

  • Super Contributor
  • ***
  • Posts: 1115
  • Country: us
    • The Solid State Workshop
Wireless communication with DIY RC Car
« on: July 17, 2012, 08:54:49 pm »
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/10533
http://www.sparkfun.com/products/10535

I'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.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9953
  • Country: nz
Re: Wireless communication with DIY RC Car
« Reply #1 on: July 18, 2012, 03:47:34 am »
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.
« Last Edit: July 18, 2012, 03:52:52 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Wireless communication with DIY RC Car
« Reply #2 on: July 18, 2012, 03:56:30 am »
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.
 

Offline FenderBenderTopic starter

  • Super Contributor
  • ***
  • Posts: 1115
  • Country: us
    • The Solid State Workshop
Re: Wireless communication with DIY RC Car
« Reply #3 on: July 18, 2012, 04:11:39 am »
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.
« Last Edit: July 18, 2012, 04:35:47 am by FenderBender »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9953
  • Country: nz
Re: Wireless communication with DIY RC Car
« Reply #4 on: July 18, 2012, 05:11:56 am »
What would manchester code achieve?

It 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 data

Manchester 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.

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?

The 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 SS
Let say all packets have a checksum byte on the end which we call C
And some random data we want to send = 12345

Then a packet would look like
SS12345C

The 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 = C
The 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.
« Last Edit: July 18, 2012, 05:45:12 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11653
  • Country: my
  • reassessing directives...
Re: Wireless communication with DIY RC Car
« Reply #5 on: July 18, 2012, 06:56:54 am »
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" 8). its highly classified and other word... secret! :P :D

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.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline FenderBenderTopic starter

  • Super Contributor
  • ***
  • Posts: 1115
  • Country: us
    • The Solid State Workshop
Re: Wireless communication with DIY RC Car
« Reply #6 on: July 18, 2012, 05:25:07 pm »
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.
« Last Edit: July 18, 2012, 09:32:47 pm by FenderBender »
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Wireless communication with DIY RC Car
« Reply #7 on: July 18, 2012, 09:11:14 pm »
 

Offline FenderBenderTopic starter

  • Super Contributor
  • ***
  • Posts: 1115
  • Country: us
    • The Solid State Workshop
Re: Wireless communication with DIY RC Car
« Reply #8 on: July 19, 2012, 01:46:51 am »
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...
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf