[Rafael] built a system that uses radio frequency for communications. The code he was using with the inexpensive receiver/transmitter pairs already had some error correction but from time to time an entire message would be missed by the receiver. He set out to make these RF communications more robust.
A little more than a year ago we looked at using these same transmitters with an Arduino. [Rafael] has a similar setup but since they are unidirectional he chose to use two pairs for bidirectional communication (each operating at a different frequency to avoid interference). On one end, a computer transmits data to the Arduino which is in a remote location. His confirmation protocol relies on a randomly generated message identifier. The computer will continually transmit the same message. The Arduino continually receives these messages, comparing them with the last successfully received message. If they match, it is considered a successful data transfer and the Arduino transmits a confirmation back to the computer which then starts transmitting the next message.
This isn’t an application-specific protocol. For demonstration purposes [Rafael] built a quick home automation setup that uses it to operate a house lamp.
35 thoughts on “Data Confirmation With RF Communications”
I had thought about doing something with units like this when I was in college to try and make a wireless usb interface.
Pretty cool setup though. This would be great for robotics to control the bot and get data back from sensors.
here is great example why Arduino is evil, ever hear of Manchester code ? the one used almost in every digital device that communicate with outside for error correction
Um… I don’t really see the hack here… He simply used an offset frequency… I hate to dog, but seriously, a hack would have been if he created his own RF transmitter. (I haven’t yet, but I’ve thought about it, so don’t tell me to show mine)
therian is right, you are supposed to use Manchester Encoding when using these transmitters to eliminate any potential DC bias.
I don’t think DC bias will adversely affect these as they are designed for direct computer communication. If it’s required (which I doubt, seeing as the data is modulated onto a carrier anyway), presumably the modules take care of any Manchester encoding themselves.
Simply repeating the transmitted data packet to check for discrepancy is wasteful though: minimum 100% redundancy and no chance of error correction if a bit is flipped. Far more efficient would be to hash or checksum the data and transmit that sequentially.
Or better still would be to add some forward error correction (Viterbi would be a good choice) to the packet so the listener has a chance to correct any errors locally before requesting retransmission.
avr-libc has CRC-16 already implemented…
As to Viterbi, especially the decoding, this
is one of the most ressource-consuming algorithms
for forward error correction…
therian needs to STFU. He’s nothing but a troll and a wannabe engineer with no experience and no creativity.
What this guy did is in the true spirit of hacking. He didn’t know how to do something, and came up with an idea to experiment with, and achieved his goal using resources around him. Now he can continue to experiment and learn some more.
Wow, what an incredibly inefficient error correction method. Not to mention the fact that these are off-the-shelf RF transmitters that have not been modified. Where is the hack, again?
I move that this ‘hack’ be deleted. It’s embarrassing to read.
It looks like somebody “reinvented” FEC or SITOR-B. What’s the baud rate of these devices?
@Jake: Can you reveal your measure of efficiency?
Getting things done with the least amount of effort _is_ efficient.
I don’t know what you’re smoking, but manchester coding is not used in “almost every digital device that communicates with outside” — Manchester coding is a(n ancient) means of coding a signal so that the clock can be recovered and it is terribly wasteful of bandwidth. Throwing a simple ECC code on top of your packet would go a long way in increasing the reliability without adding lengthy turnaround delays for acknowledgement.
Any microcontroller could implement it and it’d be fairly straightforward with an Arduino. -1 for the article though. No clear explanations, no conclusions, hell no schematics showing what he did with the diode or other hardware to increase reliability. 30 more minutes would have given him a great article and reference for others.
I don’t know what you’re smoking andrew but i wish you would share.
You right that it ancient and original Manchester code might not be used so widely today but its variations are base for any communication.
And terribly wasteful of bandwidth is sending repeated data all the time
Im trying to create super-cheap transmitter/receiver link from scratch too, transmitters are not the problem but receivers are, so far simple circuits like regenerative or super regenerative are bad solutions today in crowded spectrum other methods require much complicated circuits but I found one old and forgotten method to decode frequency modulation by creating weak Q frequency generator so when it sense outside frequency that is close to its own it locks on it, by changing frequency transistor change current consumption just a little but it enough to detect signal. here circuit I play with so far results are great but whole circuit need good shielding to work : https://sites.google.com/site/lionmax/PhaseAutoFrequencyTracking.gif
Never again will I touch those damn transmitters. Recycle some bottles if you have to but save up a few more bucks and get a unit that does the error checking for you. I know, I shouldn’t be saying such crazy things on HaD but damn, those things are annoying.
While the method described might not be the most efficient, I think that the creator has done a great job of quickly solving a problem he was having with the hardware he already had. The purpose of the Arduino is to let people without a Master’s degree in Computer Engineering play with microcontrollers, so when a quick solution pops up instead of an “efficient” one, that shouldn’t be surprising and it shouldn’t be put down. I think it is great to make suggestions for improvement, but to call someones project “embarrassing” when they have put their hard work into it is truly embarrassing.
“the creator has done a great job of quickly solving a problem he was having”
dont you think about others? he solve the problem for himself but create one for others by completely taking whole channel to himself and blocking it for others
Why are the “Professional” engineers bagging on the author? Because it’s not up to their “Professional” standards? How about some of you *fine* people show me how well you code 3D graphics in assembler? or how well your holographic display is coming? or how well your DIY .0001″ accuracy gantry mill is cutting stainless steel?
Not everyone here has the resources or training to do everything to “Professional” standards. If that’s what you’re expecting, why the h*ll are you even reading a site called “HACK-a-day”?
@rallen the *fine* people want others to know that there is better and more efficient way to do stuff.
If your a newbie and see something here, you probably say, “oh that is the way to go, I will use the same techniques in my next project.” With the comments, you can give feedback and explain that cyclic redundancy check (CRC) or polynomial code checksum is the way to go in wireless communication.
I used these same devices in http://hackaday.com/tag/marauders-map/
For DC restoration (Manchester code) I looked at
doing it in the limited Picaxe code, but I realized I could just code up my constants in a balanced format (0x55, for example).
I think i have something to say here.
@Jake, it’s not an error correction method, it’s an error detection method, and it may not be the best one but it worked for the kind of application i was working on.
@asheets, up to 2400bps, i used 1200bps.
@sneakypoo, i thought about using XBee, but, as you said, they’re a little bit more expensive.
@@rallen, i’m already working on using CRC16 instead.
I think these sparkfun RF units can be done with less passive components, and this protocol can be done more efficiently..I have spoken.
but seriously why is there no open source UART RF transmitters? They are cheap to make and really useful..
@xorpunk: I think it might be simpler to start with a microcontroller with the radio already built in. The TI CC1110 immediately springs to mind, and an im-me will give you two of them plus a USB interface. Perhaps it would be nice if the Arduino framework could be ported to it one day, but I guess it’s a non starter as they are 8051 based and not supported with a c++ compiler.
“The purpose of the Arduino is to let people without a Master’s degree in Computer Engineering play with microcontrollers”
I never read such crazy talk in my life…
VirtualWire has a server-client implementation which i could not be able to put it working :|.
However, i’m receiver/transmitter (one way method). I send the same message for 8 times with the same id, which increases the accept success rate.
@rallen is right.
“no open source UART RF transmitters?”
I guess it’s because a lot of people see it as trivial, and a lot of people see it as voodoo, and the vast majority are content to use “established off the shelf standard units” from various places. For the newbies, here’s the 411:
The UART is easy – whether built into the system or implemented in software – especially if you’re just sending data in packets, or fixed length bursts. Robustness is something else altogether – you need error detection, at least, and maybe correction [pain in the ass, generally] and maybe bidirectional communications. All a uart does is take a digital word or byte and pass the status of the 1s or 0s sequentially to the output pin, or take the input and stick it into a word or byte for later use. We generally do this at a fixed rate using a timer, but there are other methods using clock signals and so forth.
Bidirectional full-duplex communications is a pain to implement without hardware help, but it makes an excellent introduction to the joy of realtime programming. Bidirectional half-duplex communications is less of a pain, but when radio or other uncertain transmission media are added to the mix, well, you tend to get a little crazy.
Anyway, to get back on topic, RF transmission of data boils down to picking a modulation and demodulation method, piping it to and from the radio and getting on with the job. Therian actually raises a good point, even if his grasp of the subject appears hampered… It can be worth trying to minimize your usage of an RF channel for a lot of reasons.
If you just want to bang data around, I suggest buying a couple of the cheap prebuilt modules. On the other hand, if you feel that hacking is the way to go, just find any circuit for an FM or AM transmitter and receiver pair. These can be built with one or two transistors if you don’t mind the awful side effects of drift. Given a wide enough bandwidth, it can work at low data rates (300 baud, anyone? 110? 75? ) and at a single digit baud rate, you can get pretty lax with your circuits.
Most people go for crystal or resonator controlled transmitters to avoid the pain. So you can build a bad ass low frequency FM or AM transmitter with a crystal, some logic gates and a few components – especially if you like really fat channels and lots of harmonics. The schematic is pretty simple – one quad NAND gate chip in the cmos family will get you all the way to the FM broadcast range and beyond. The 555 is usable, but isn’t a good design choice outside of audio ranges.
So if you want to modulate it, you can just gate it on and off. This isn’t very sophisticated. We really want FSK or quadrature to get anything done, so now you have to be able to shift the frequency rather than turn it on or off. To do this, we need a little more gating and maybe another oscillator.
I can’t be bothered to do this*, so it’s easier to just program the mcu to pump out the modulation frequency directly by using a timer in the MCU. Then you can connect this to the aforementioned oscillator circuit, and now you have all kinds of options for modulation.
(*actually, this is all historical.)
But to give a wink at therian, you now have to worry about reducing the bandwidth and removing all those harmonics that cause interference. This means putting filters on the circuit so that what gets to the antenna isn’t all over the place. Think of it as focusing a light to a narrow beam.
The receive side is simply the reverse process.
You don’t need radio to play with this code, it can be quite instructive to try and test your ideas using a microphone and speaker connected to input and output pins.
Figuring out how to get usable audio from a microphone into a single input pin on a microprocessor constitutes an excellent and complete introductory course on signal processing, as you learn that PWM is magic!
PCB size was too small to made? I also want to do a small size one.
I finally jumped on buying a pair of these in each freq. I’ve had a bunch of wireless uC projets in mind but a wifi subsystem is too expensive to deploy about 10 small sensors around my house. This looks perfect and if I can get clean code examples I can probably replicate his design in about 2 hours and have 10 sensors transmitting to 1 receiver that delivers the sensor data via /dev/ttyUSB0.
Maybe it’s not the textbook example of efficiency in RF code design but it’s cheap and possibly quite reusable for a variety of projects.
For those interested, here’s a second post on the protocol.
If you want easy RF, bundled with a good ARM7 microcontroller, then consider the mc13224v:
If you need reliable transmission, run Contiki and use with TCP with 6lowpan or runicast with RIME. 802.15.4 is nice too since it has a lot of redundancy at the radio layer and so can handle a few bad bits per symbol.
Chips are $5. My dev boards are $55.
And making your own digital receiver is hard — but fun. I’ll post my 27MHz tran and recv soon. The baseband processor is an AT90USB so all the AVR guys can go nuts. Setting everything to be exactly the same frequency, with zero drift, and dealing with the phasing is a lot to do… and that’s just scratching the surface.
Notice that LC tank run on 1/2 of receiving frequency so harmonics are not the problem, this is why I love that little circuit
in other words, he invented the RS232 protocol.
Congrats! Computer scientists from the 1950’s would be proud of you!
Early radio telemetry often used LC swamping for modulation. I haven’t heard that phrase in a very long time… nobody uses it any more. I guess we could rig up a coherer circuit with a pager vibrator and get single digit baud rates. That’d be a hack.
Y’all want a great and easy low speed FSK circuit? look up kansas city standard. Couple of parts on either end, provides level balance and handles all manner of channel degradation. Downside – 300 baud. But 300 baud is pretty good. Works like gangbusters if you want a low speed optical connection as well. It even works with really crappy inductive systems.
On a related dregs-of-computing note, I once saw a data isolator in a cooling chamber that worked using a tiny heating coil and a thermistor through a heat pipe. I cannot guess what the point was, but it was some kind of fail safe. Most asinine thing I ever saw, but it was surprising that anyone would even think of this.
Good idea using a microphone and speaker. It also quickly teaches the virtue of not hogging the channel bandwidth: “What? WHAT? I CAN’T HEAR YOU, BLOODY SENSORS HAVE BEEN CHIRPING ALL DAY!”
i wonder would i be able 2 use this 4 my 3rd year project,im doing goal line technology a chip in a football & a reciver in the goals so when the ball crosses the line it will send a message to let it know it crossed the line any suggestions?
Please be kind and respectful to help make the comments section excellent. (Comment Policy)