PDA

View Full Version : RF Transmitter



et_Fong
- 26th October 2005, 15:27
My project is using RS-232 Pin 3 to send data to PIC16F84A, after that the PIC will send the data to Holtek 12E encoder then transmit the data the RF transmitter module. Then the RF signal will receive by a receiver circuit. the decoder on the receiver circuit, the 8 address pin i connect it to ground.
then i been told that the encoder 8 address pin need to connect to ground too.
Now, here is my question, how to modify my programming if i connect the encoder address pin to ground.
p/s: RS232 :9600 baud, no parity, 8 data, and 1 stop bit

;************************************************* *****************
;
; The Serial Interface Between PC and PIC
;
;************************************************* *****************
list p=pic16f84a
include p16f84a.inc
__CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
errorlevel -302 ;Eliminate bank warning

;************Label Definition*************************************

ra4 equ 04 ;RA4 bit
cnt01 equ 0c ;counter address
address equ 0e ;address word
addtemp equ 0f ;address tempory
datbyte equ 10 ;data word
dattemp equ 11 ;data temport

;************* Program Start *************************************
org 0 ;Reset vector
goto Start
org 4 ;Interrupt vector
goto Start

;*********** Initial Process *************************************

Start bsf STATUS,RP0 ;change to Bank1
movlw b'00010000'
movwf TRISA ;Set PORTA,4 to input mode
clrf TRISB ;Set PORTB to Output mode
bcf STATUS,RP0 ;Change to Bank0
clrf PORTB ;Clear PORTB
clrf PORTA ;Clear PORTA

;************ Synchronize Check Process **************************

keyscan btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
bit_1 call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay
btfsc PORTA,ra4 ;ra4 Low?
goto keyscan
call delay
btfss PORTA,ra4 ;ra4 High?
goto bit_1
call delay

call delay
call delay

;********************** Match ************************************

movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000001'
movwf address
call delay ;1st address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,f
rrf addtemp,w
andlw b'00000010'
iorwf address,f
call delay ;2nd address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,f
rrf addtemp,w
andlw b'00000100'
iorwf address,f
call delay ;3rd address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rrf addtemp,w
andlw b'00001000'
iorwf address,f
call delay ;4th address bit finish

movf PORTA,w
andlw b'00010000'
iorwf address,f
call delay ;5th address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,w
andlw b'00100000'
iorwf address,f
call delay ;6th address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,w
andlw b'01000000'
iorwf address,f
call delay ;7th address bit finish

movf PORTA,w
andlw b'00010000'
movwf addtemp
rlf addtemp,f
rlf addtemp,f
rlf addtemp,w
andlw b'10000000'
iorwf address,f
movf address,w
movwf PORTB

call delay ;8th address bit finish

call delay
call delay

;*************** START TO READ DATA WORD *************************

movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000001'
movwf datbyte
call delay ;1st address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,f
rrf dattemp,w
andlw b'00000010'
iorwf datbyte,f
call delay ;2nd address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,f
rrf dattemp,w
andlw b'00000100'
iorwf datbyte,f
call delay ;3rd address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rrf dattemp,w
andlw b'00001000'
iorwf datbyte,f
call delay ;4th address bit finish

movf PORTA,w
andlw b'00010000'
iorwf datbyte,f
call delay ;5th address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,w
andlw b'00100000'
iorwf datbyte,f
call delay ;6th address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,w
andlw b'01000000'
iorwf datbyte,f
call delay ;7th address bit finish

movf PORTA,w
andlw b'00010000'
movwf dattemp
rlf dattemp,f
rlf dattemp,f
rlf dattemp,w
andlw b'10000000'
iorwf datbyte,f
movf datbyte,w
movwf PORTA
call delay ;8th address bit finish
call delay

goto keyscan

;******************** Delay **************************************

delay movlw d'35' ;(1) Set loop cnt1
movwf cnt01 ;(1) Save loop cnt1
delay1 decfsz cnt01,f ;(1)*35 cnt1-1=0?
goto delay1 ;(2)*34 No, continue
return ;(2) yes. cnt end
;Total 107*1usec=105.6usec
;which > 104.166usec(1/9600)

;************************* Finish ********************************

end

milestag
- 26th October 2005, 15:51
EDIT: Okay, now I have looked at your code and see your problem. The problem is that you are not using "PicBasicPro". So you are in the wrong FORUM.... good luck.



Just curious...If you are already using a PIC, then why add a Holtek chip to your data path? Why not use SerOut and SerIn, and eliminate the Holtek chip altogether. Or write your own serial routines if you need manchester encoding or whatever.

If I remember right, the Holtek chips have to send the data repeatedly (maybe 5 times?), and has to receive it 3 times. That's alot of overhead for data transmission. Unless you are only sending single byte commands?

As far as the address pins, they just have to be set the same on both chips. Usually with dip switches. Get a copy of the Holtek datasheets. They are pretty detailed with example circuits.

Ron Marcus
- 26th October 2005, 21:26
What are you trying to accomplish? A contact closure, data transmission, or just a signaling device? I'm in agreement that you can drop the Holtek encoder/ decoders, or get rid of the PIC. The Holteks can be used with buttons, just as the PICs can very easily emulate the Holtek chips. When the 12E is activated, it sends a 12 bit PWM AM word. It repeats this after a small delay until deactivated. The receiver looks for three correct words in a row. The first 8 bits are address, the last 4 are control bits. It is easier to write the code in assembly, due to tight timing, but it can be done in PBP.

Ioannis
- 27th October 2005, 08:10
Look at an earlier post of mine: http://www.picbasic.co.uk/forum/showpost.php?p=679&postcount=6

Ioannis

et_Fong
- 27th October 2005, 16:34
since i am using Microsoft VB to make my interface, so i am using "170" as synchronize signal, "0" as address bit, "0~9" data bit which run certain function. that's why i need to perform the "match" , to read the "0" address bit, which is similar as connect PORT B to ground.
after i send the RF signal, the receiver size will receive and decode the signal to 4 parallel data to PIC16F84A RA0~3, then it will control the movement according to the data receive........