16F RF Module Example
RF modules make communicating with projects in isolated areas/long
distances much easier, and its so simple to do. There are many
different RF modules to choose from, most important of the features
is the
baud
rate. Frequency is important aswell, however, in your
program, when you use a RSOUT or RSIN command, you must specify a
baud
rate in the settings (declarations). If the RF module cant
handle the desired baud, then the data will become scrambled and
undecipherable.
I used the TLP434A and RLP434A modules, they are by no means the
best, I just chose them as they were the cheapest. They can handle
up to 3K baud efficiently, and in my serial programming, I always
use computer equivalent bauds such as 2400/4800/9600.


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

Note the PIC's power supply/oscillator are not shown
Wiring
Diagram for the transmitter (PSU/Osc not shown):

Note the PIC's power supply/oscillator are not shown
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.
An
example of a transmitter program;
Device 16F876A
XTAL = 4
Dim Number As Word
DECLARE RSOUT_PIN PORTA.0
DECLARE RSOUT_MODE INVERTED
DECLARE RSOUT_PACE 5
DECLARE SERIAL_BAUD 2400
ALL_DIGITAL = True
Low PORTA.0
Main:
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
DECLARE RSIN_PIN PORTA.0
DECLARE RSIN_MODE INVERTED
DECLARE SERIAL_BAUD 2400
DECLARE RSIN_TIMEOUT 1000
ALL_DIGITAL = True
INPUT PORTA.0
Main:
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
Time_Out:
' This is where to go if nothing is received
' in 1000ms
Goto Main ' Loop For ever

 | Site Tutorial Index |
|  | 16F PIC Examples |
| |  | Motors |
| |  | Thermometers |
| |  | Code Snippets |
|  | 18F PIC Examples |
|  | Handy Tips |