for Microchip PICs

Home - About- Consulting* - Articles - FAQs - Contact
Tour - Application Example - Sub circuits - Projects - Download
Projects: RF communications - addressable data receiver
This QuickBuilder project can be downloaded here.

RF communications - addressable data receiver

This project demonstrates the 'AM RF Receiver' sub-circuit and is intended to be used with project RFTX.QPR. Receiving data over the RF link effects a simple remote control.

The target device is a PIC16F84.

The receiver is polled until new data arrives indicated by RFRX_NOTIFY. The data is inspected and the appropriate action is taken. In this case a relay is either energised or de-energised. The device could, of course, be something other than a relay, such as a digital to analogue converter or a display device.

The ID of the receiver can be in the range 0-255 and is set by using the inputs of ID_HI_ and ID_LO_ ('4-bit port' sub-circuit').

Application code
Below is the application code for this project. To use it, select and copy (ctr-insert) the code below, paste it into a text editor and save as a 'C' file in your working directory. You may also need to change the build output path using 'Project | Options'.

////                         ARFRX.C                               ////
////                                                               ////
////  Demonstrates the 'AM RF Receiver' (RFRX) sub-circuit         ////
////  based on the RF Solutions AM-HRRN receiver module.           ////
////  The receiver can have any ID in the range 0-255.             ////
////  See also project RFTX.QPR.                                   ////
////                                                               ////
////  This program is an example of how your application code is   ////
////  is organised. Note the #include "rfrx.c", this include       ////
////  file was generated by QuickBuilder and contains all          ////
////  driver code.                                                 ////
////                                                               ////
////  Compile using CCS 'C'  visit www.quickbuilder.co.uk/qb/ccs   ////
#include <16f84.H>



#define PORTA 5 
#define PORTB 6
#define TRISA 0x85 
#define TRISB 0x86

#include "rfrx.c"

main() {
    signed long l;

    // initialise
    RFRX_LOCAL = ID_LO_READ();          // set local ID lo nibble
    RFRX_LOCAL |= ID_HI_READ() << 4;    // set local ID hi hibble
    RFRX_ON();                          // receiver on

    // main loop
    while(1) {

        if ( RFRX_INCOMING() )
            RFRX_DO();             // poll receiver
        if (RFRX_NOTIFY) {                       
            if ( RFRX_DATA[0] == 1 )
                RL_SET(1);          // energise relay
                RL_SET(0);          // de-energise relay                            
            RFRX_NOTIFY = 0;            
Copyright 2002-2009 Summit Electronics Ltd