Proton Tutorial - RF Modules

RF modules make communication in isolated areas/long distances easy, and contrary to popular belief, the whole process is quite simple. There are many different 'passive' RF modules that simply interface with a micro-controller via USART. I call them passive RF modules as much of the process is 'taken care of' .. modulating data (converting 1s and 0s into an RF signal), reception and then demodulating into digital form. You generally need not worry how these RF modules operate under the hood.

That said, there are some very important considerations, particularly buad and operating voltage.

Most data protocols have a buad specification and USART is particularly dependant upon buad. With Proton and the RSOUT or RSIN commands, you must specify a  baud rate in the settings (declarations). If the RF module can not operate at the desired buad, then the data will become scrambled and undecipherable.

In this example I have used the TLP434A and RLP434A modules. They are by no means the best, I just chose them as they were cheap (and available). They can handle up to 3K baud efficiently, and in my serial programming, I always use computer equivalent (standard) bauds such as 2400/4800/9600.


Wiring Diagram for the receiver (PSU/Osc not shown):


 Wiring Diagram for the transmitter (PSU/Osc not shown):


Code Example

Now for the easy part, programming them. Just a quick 101 on serial transfer, the header "Z" is sent before the value as a marker. This is so that the receiver knows that the data its receiving is legit, well as good as it can be. The post marker "A" allows the RSIN command to recognized that the whole number has been sent. It must be an alphabetical value, and if there was no post marker, it wouldn't know if the last number it received is actually the last number, and will wait until it times out for the next value (see the Proton User Guide for more information about how RSIN and RSOUT work under the hood).

An example of a transmitter program;

Device 16F876A
XTAL = 4
Dim Number As Word
    Inc Number ' Increment the variable  
    RSOUT "Z"DEC Number, "A"13
     ' Send the value 34761 via the serial o/p   
     ' with the header Z, and the footer "A"  
    Goto Main ' Loop for ever


Receiver Example:

Device 16F876A
XTAL = 4
Dim Number As Word
    RSIN {Time_Out}, WAIT("Z")DEC Number
     ' Wait for the value "Z" to be received and  
     ' When it has, retrieve the number.   
     ' Should the RSIN function not receive anything in 1000ms, it will   
     ' jump to Time_Out, but if it does receive a number, then you could   
     ' print it to an LCD/do what ever you wanted with it  
    Print At 1,1, DEC5 Number ' Display the number on an LCD  
     ' This is where to go if nothing is received   
     ' in 1000ms  
    Goto Main ' Loop For ever


Forum Activity

Member Access