Welcome back to the Part II of RF Communication tutorial. Here I will show you the basic working of RF modules and how to send and receive data. Please see the Part I of this tutorial for basic introduction. You should also be familiar with RS232 communication. If you are new to it please see RS232 Serial Communication Tutorial. I also recommend using wireless link only after you have successfully tried wired RS232 communication. Here I will not go deep in how RS232 works because it is already discussed in RS232 Serial Communication Tutorial. I will use my interrupt driven fully buffered USART library for communication.
How RF Module Works
Working of RF Modules is simple but with a little trick. The working is shown in figure below.
Fig- Working of RF Modules.
Here what ever digital data you input on "Data In" of TX is available on "Data Out" of RX. Say, if you set "data in" high, the "data out" will become high as well. But here lies the trick! The fact is that you cannot Keep Logic HIGH or LOW for a Long period of time, say for a few millisecond second. If you apply a logic low on "data in" the "data out" will become low but only for few millisecond and it will start oscillating(become high/low repeatedly) after that. Same thing will happen if you set "data in" to high state.
Let us assume we have connected the RF modules with MCUs as shown below.
Fig- RF Modules connected to USART of Microcontrollers.
When the TX unit is switched off or not transmitting data, then as I said the "data out" of RX will be oscillating high and low and as this is connected to RX of MCU’s USART, the MCU#2 will be receiving garbage data. And when TX unit will send some data, MCU#2 will also be receiving them. So MCU #2 is always receiving data,even when MCU#1 is not sending anything. So their must be a mechanism to differentiate real data with garbage data.
Sending and receiving data.
For this I created a simple mechanism. The steps are shown below.
- We begin transmission by sending character ‘A’
- We again send one more ‘A’
- Then we send the actual data.
- Now we send the inverse of data. That is all 0′s are converted to 1 and vice-versa.
- We end the packet by sending ‘Z’
In this way we create a simple packet based transmission with error detection. Now in the RX side MCU our program follows the algorithm given below.
Fig- Data Reception Algorithm.
If we went to the end of algorithm successfully it means that we have got a valid data and we can use it.
So in this way we saw how a byte of data is transmitted from MCU#1 to MCU#2 via air. This simple algorithm filters real data from garbage data. In the next tutorial we will see the practical example of data transmission and reception. We will use the received data to control the IO ports of MCU, in this way we will create a simple multi channel wireless remote control.
eXtreme Electronics highly recommends EasyEDA circuit design & order PCB.
Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.