RF communications - slave transponder

Introduction
This project demonstrates the 'AM RF Transponder'
sub-circuit when used as a slave. The slave
transponder operates by receiving data sent
over a radio frequency link from a remote 'AM
RF Transponder' operating as a master. When
data is received the appropriate request is
carried out and the slave transponder replies
to the originating master. See also project
RFXM.QPR.
Operation
When RFX_NOTIFY indicates the arrival of new data,
the request contained in the data is carried out.
In this case when RFX_RDATA[0] is a '1' the temperature
on the 'DS1820 Temperature sensor' is read and sent
back to the requesting transponder.
Note: The ID of the remote transponder
is automatically saved to RFX_REMOTE when the master
transponder sends the request.
The ID of this (slave) transponder is
set by 'PORT4BIT', which has four external connections.
The ID may be anywhere within the range 0-15.
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 it as a 'C' file
in your working directory.
You may also need to change the build
output path using 'Project | Options'.
///////////////////////////////////////////////////////////////////////
//// ARFXS.C ////
//// ////
//// This project demonstrates the 'AM RF Transponder' ////
//// sub-circuit used as a slave. When RF data is sent to the ////
//// transponder it responds by measuring the temperature ////
//// using the 'DS1820 Temperature sensor' and transmits the ////
//// result to the transponder that originated the request. ////
//// Connect PORT4BIT-0,1,2,3 to GND to give the transponder ////
//// an identification of 0. More transponders can be used if ////
//// required. ////
//// See also project RFXM.QPR. ////
//// ////
//// This program is an example of how your application code is ////
//// is organised. Note the #include "rfxs.c", this include ////
//// file was generated by QuickBuilder and contains all ////
//// dirver code. ////
//// ////
//// Compile using CCS 'C' visit www.quickbuilder.co.uk/qb/ccs ////
///////////////////////////////////////////////////////////////////////
#include <16f84.H>
#fuses XT,NOPROTECT,NOWDT
#case
#define PORTA 5
#define PORTB 6
#define TRISA 0x85
#define TRISB 0x86
#include "rfxs.c"
main() {
signed long l;
// initialise
//------------
INIT_SUB_CIRCUITS();
RFX_LOCAL = PORT4BIT_READ(); // set local ID
RFX_RON(); // receiver on
// main loop
//----------
while(1) {
if ( RFX_RINCOMING() )
RFX_RDO(); // poll transponder
if (RFX_RNOTIFY) {
if ( RFX_RDATA[0] == 1 ) { // if reading requested then
BUSYLED_SET(1); // led on
l = DS1820_1READ_TEMPERATURE(); // read temperature
RFX_TSTART(0x0); // data address
RFX_TSENDDATA(l); // data lo byte
RFX_TSENDDATA(l>>8); // data hi byte
RFX_TSTOP(); // end transmission
BUSYLED_SET(0); // led off
}
RFX_RNOTIFY = 0;
}
}
}