Full Version : Vasilis 2 Channel RF Remote @ 418MHz (ASM)
avr >>COMMUNICATIONS & WEB PROJECTS >>Vasilis 2 Channel RF Remote @ 418MHz (ASM)


<< Prev | Next >>

Admin3- 04-20-2006
2 channel RF remote control at 418 MHz

With this 2 channel RF remote control you can control 2 relays for garage door, security alarm, turn lights ON-OFF and more applications.

New version of firmwares support roll-code feature.

Designed by: Serasidis Vasilis

Link: http://www.serasidis.gr/circuits/RF_remote...ote_control.htm

Introduction



How many times you needed some remote control to handle some electric device ? many times. There are lot of remote controls like infrared, RF, SMS (like my other circuit) and more. The basic small-range remote controls are 2, Infrared and RF (Radio Frequency). One of the weaks of Infrared is that the signal can not pass the walls. So, if you want to control your garage door, the only way is to use some RF remote control. The circuit (transmitter and receiver) use few components and ordinary (I love few component circuits) . Its easy to build it because you don't have to tune-up any coil or variable capacitor. The RF modules are fix to work in 418MHz area.



I have designe this remote control considering :



a.) the check of the received data because many other devices are working in this frequency (418MHz)

b.) and the power-saving of the transmitter. One transmitter must have battery long-life, there is not good to change the battery after 3 days ;) . I don't care about the receiver`s power supply, because receiver must be working all the time.

Transmitter

Standby: <1uA (less than 1 microampere)
only 3v power supply
10...15m distance range
2400bps communication
2 initial bytes for device recognition (ID bytes)
calculate the checksum of the sended data (to avoid fake commands)
few components
small size
Receiver

Hardware UART at 2400bps
4 bytes (32bit) length communication
checksum of the received bytes (to avoid fake commands)
few components
smal size

Transmitter description

Schematic of the transmitter

The transmitter is constituted by AT90S2323 microcontroller and TLP434 RF transmitter module at 418MHz. I have designe the transmitter for more battery economy and safe transmition of the data.

The battery economy is made it by the use of powerdown mode of AVR. In this case the AVR goes to sleep with less than 1uA (microampere) current and wait for external interrupt on pin PB1 to awake from sleep and continue operating.

If you press the S2 key, the logic of this pin goes to '0' (0V) and AVR awake frome the sleep mode (because PB1 is INT0) and check if pressed the S1 key. If not, the AVR take as pressed key the S2. If yes the AVR take as pressed key the S1.

If you press the S1 key the logic of this pin and PB1 (through 1N4148) goes to '0' (0V). In this case the AVR take as pressed key the S1.

After, calculate the checksum and transmit 4 times the same 4 byte sequence to make sure that receiver takes the data and goes to sleep mode until next interrupt on PB1.

When the INT0 pin (PB1) of AVR goes to 0V, the transmitter TLP434A is working. If you stop press the switch S1 or S2, the TLP is stop working.

The safe transmition of the data based to transmition of 4 bytes with serial form at 2400 bps (bits per seconds). 1st and 2nd byte are for recognition of valid remote control from receiver (like ID bytes), 3rd byte is command byte. The relays status dependet by the value of this byte. Finaly, the 4th byte is the checksum of the earlier 3 bytes.

example: if byte1=30h, byte2=35h and byte3=02h the 4th byte (chechsum) will be (byte1) XOR (byte2) XOR (byte3) = 30h XOR 35h XOR 03h = 06h.

This method use 4 bytes x 8 bit each = 32 bit length (without start and stop bits). That is mean 1 possibility at 4.294.967.295 to receive the receiver, the same 4 bytes from some other RF device.

This transmitter will work with all 2323 chips but better is AT90LS2323 with working voltage 2.7 - 6 volts.The microcontroller that I use is AT90S2323 with working voltage 4 - 6 volts. Its worked fine with 3v lithium battery.

As antenna you can use ~7cm cable in to transmitter`s box.

Receiver description

The receiver constituted by RF receiver module RLP434A at 418MHz, the microcontroller AT90S2313 and the 2 relays with can handle any electric (or electronic) device up to 10 Amps (the contacts of my relays are 10Amp at 250Volts).

The RLP434A is an RF receiver module with receipt frequency at 418MHz with ASK modulation. There are 2 outputs from this module, the digital, with levels from 0v to VCC (5 volts in our case) and the analog output. Analog output is not used. The transmitter send 4 bytes with 2400bps 4 times and the receiver RLP-434A, collect them and move them to AT90S2313 to RxD pin, PD0.

Two reasons to select AT90S2313 (20pins) instead of AT90S2343 (8pins) is because

a.) AT90S2313 use a hardware UART adjusted at 2400bps and the hardware UART is more stable, with smaller code, than software UART that I use in the transmitter. If some serial data arrive at the middle-time of some other routine other than receive routine, for sure we will loose this bits of data. The hardware UART does not have this problem because have buffer for this (UDR register). This is what I mean that the hardware UART is "stable".

b.) with AT90S2313 we can drive up to 14 relays with future upgrade of the firmware, one relay to each pin.

As antenna you can use a cable 30 - 35cm long

The power supply of receiver

The power supply of RF receiver constituted by 2 voltage regulator, LM7812 and LM7805. The first (12V) its only to power the 2 relays and the 2nd (5V) to power the AVR microcontroller and the RF receiver module. The LED, is voltage indicator and the 4 capacitors are to flattening the voltage.

Usage of transmitter

Power on the receiver and press S1 key to transmitter. You will see that relay on PB0 of receiver will arm. If you press one more time the same key, the relay will dissarm. If you press S2 key from transmitter you will see that relay on PB1 of receiver will arm. If you press one more time the same key, the relay will dissarm. Each key is for 1 relay only.

I choose to drive 2 relays and not only 1 because for some application like garage door 1 relay can handle the door (open-close) and the other to turn-on or off the light of the garage.

UPDATED!!!

New feature added! roll-code. Roll-code function is increase the safety of remote control, because it is change the transmitting code everytime you press any key on the remote control (AT90S2323 circuit) and the RF thief scanners will be useless!

CODE


;***************************************************************************************
;
;
;    Title: RF remote control at 418MHz with roll-code
;              
;     (RF 418MHz transmitter code)
;
;    Device:  AT90s2323 at 4MHz crystal
;       and TLP-434 RF transmitter (418 MHz)
;    Author:  Serasidis Vasilis
;    Date:  04.06.2004
;    Updated:  15.04.2005 Added roll-code feaure.
;    Home:  http://www.serasidis.gr
;    email:  info@serasidis.gr
;
;    Based in software UART at 2400bps, 8n1
;
;***************************************************************************************


.include "2323def.inc"  ;Define chip

.equ TxD   =0  ;Transmition pin is PB0
.equ key1  =2  ;Key No1 is connected to pin PB2
.equ key2  =1  ;Key No2 is connected to pin PB1
.equ Key_1  =01
.equ Key_2  =02


.def temp  =R16 ;temporary storage register.
.def temp2  =R17 ;temporary storage register.
.def Txbyte  =R18 ;Data to be transmitted.

.def init_byte =R19 ;This byte is sended first and its to recognize the receiver the correct remote control.
.def second_byte =R20 ;This byte is sended second and its to recognize the receiver the correct remote control.
.def command  =R21 ;The command byte mean which key is pressed from the remote.
.def bitcnt  =R23 ;bit counter
.def count  =R24
.def dcount  =R25
.def dcount2  =R26
.def rollcode =R27

.cseg

.org 0
rjmp  reset ;Reset handler
ret    ;Return from sleep and go to "keys" address.



reset:

ldi  temp,RAMEND
out  SPL,temp ;Init Stack Pointer

ldi  temp,0b00000001;PB0 output, PB1, PB2 inputs
out  DDRB,temp

ldi  temp,0b00000111
out  portB,temp     ;enable internal pullup resistor on PB1 and disable on PB2...
     ;...and enable Data-pin TxD (PB0).
start:
clr  second_byte
Release_keys:
rcall delay
sbis PINB,key1 ;
rjmp Release_keys

rcall delay
sbis PINB,key2 ;
rjmp Release_keys

;subi second_byte,$20

ldi  temp,0x30 ;turn on sleep mode (Power-down mode)
out  MCUCR,temp ;interrupt on low level.
ldi  temp,0x40 ;enable external interrupts (INT0)
out  GIMSK,temp
sei     ;enable global interrupts ready
sleep    ;go to sleep mode



;===================================================================================

keys:
sbic PINB,key1 ;
rjmp next_key

ldi  command,Key_1 ;load the code for key No1
rjmp Enable_RF

next_key:
ldi  command,Key_2 ;load the code for key No2

Enable_RF:

ldi  count,4  

load:

ldi  init_byte,$30 ;Load init_byte register with initial byte (recognition byte).

mov  txbyte,init_byte;1) send initial byte
rcall b_transmit  
mov  txbyte,second_byte;2) send second byte
rcall b_transmit  
mov  txbyte,command ;3) send the command byte
rcall b_transmit

eor  init_byte,second_byte;4) create the checksum of bytes "init_byte" and "second_byte"...
eor  init_byte,command
mov  txbyte,init_byte;...move the resault to transmit byte (txbyte)...
rcall b_transmit  ;and send it out.

dec  count   ;send 4 times the data
brne load

inc  second_byte
rjmp  Release_keys;


;***************************************************************************
;*   Transmition routine TxD
;***************************************************************************


b_transmit:

ldi  bitcnt,10;1+8+sb (sb is # of stop bits)
com  Txbyte ;Invert everything

sec    ;Start bit

putchar0:
brcc putchar1;If carry set
cbi  PORTB,TxD;    send a '0'
rjmp putchar2;else

putchar1:
sbi  PORTB,TxD;    send a '1'
nop

putchar2:
rcall UART_delay;One bit delay
rcall UART_delay

lsr  Txbyte ;Get next bit
dec  bitcnt ;If not all bit sent
brne putchar0;send next

ret    ;return
;***************************************************************************
;*
;* "UART_delay"
;*
;* This delay subroutine generates the required delay between the bits when
;* transmitting and receiving bytes. The total execution time is set by the
;* constant "b":
;*
;* 3xb + 7 cycles (including rcall and ret)
;***************************************************************************

.equ b=135;2400 bps @ 4 MHz crystal, +5V
.equ c=2

UART_delay:
ldi  temp2,c
UART_delay2:
ldi  temp,b
UART_delay1:
dec  temp
brne UART_delay1
dec  temp2
brne UART_delay2
ret


;***************************************************************************
;*   Delay routine
;***************************************************************************


delay:
ldi  dcount2,10
delay_:
ldi  dcount,250
delay1:
dec  dcount
brne delay1
dec  dcount2
brne delay_
ret

.db "(c) 09.06.2004 by Serasidis Vasilis. www.serasidis.gr"





Free Forum Hosting by Forumer.comTM!