PDA

View Full Version : transmitter receiver help



Deorge M
- 6th June 2009, 16:40
Hello
I am a new user in picbasic and would want help
I found this code for 16F84 but communication transmitter receiver is not good

Thanks

Transmitter

DEFINE OSC 4
DEFINE BUTTON_PAUSE 50

TRISA=%11110
TRISB=%11110000
PORTA=0
PORTB=0


VERICI VAR Byte
VERICI=0
Index VAR Byte
X VAR Byte
b1 var Byte
b2 var Byte
b3 var Byte
b4 var Byte
PAUSE 500


START:
Button PORTA.1,0,255,0,b1,1,ch1
Button PORTA.2,0,255,0,b2,1,ch2
Button PORTA.3,0,255,0,b3,1,ch3
Button PORTA.4,0,255,0,b4,1,ch4
GoTo START


ch1:
VERICI=10
GoTo GONDER

ch2:
VERICI=20
GoTo GONDER

ch3:
VERICI=30
GoTo GONDER

ch4:
VERICI=40
GoTo GONDER


GONDER:
SerOut PORTA.0,396,[REP$AA\5,REP$00\5,REP$FF\5]
SEROUT2 PORTA.0,396,["I","S","K","O",VERICI]
GoTo START


receiver


DEFINE OSC 4
TRISA=0011
TRISB=%11110000
PORTA=0
PORTB=0

dekths VAR BYTE
Index VAR BYTE
aa1 var word
x VAR BYTE
aa2 var word
aa3 var word
dekths=0
aa1=300
aa2=300
aa3=500

PAUSE 500

START:
SERIN2 PORTA.0,396,[WAIT("ISKO"),dekths]


if PORTA.1=1 then poa1
if PORTA.1=0 then poao

poao:
IF dekths=10 THEN
high PORTB.0
PAUSE aa2
low PORTB.0
PAUSE aa3
ENDIF

IF dekths=20 THEN
high PORTB.1
PAUSE aa2
low PORTB.1
PAUSE aa3
ENDIF

IF dekths=30 THEN
high PORTB.2
PAUSE aa2
low PORTB.2
PAUSE aa3
ENDIF

IF dekths=40 THEN
high PORTB.3
PAUSE aa2
low PORTB.3
PAUSE aa3
ENDIF

GOTO START


poa1:
IF dekths=10 THEN
TOGGLE PORTB.0
PAUSE aa1
ENDIF

IF dekths=20 THEN
TOGGLE PORTB.1
PAUSE aa1
ENDIF

IF dekths=30 THEN
TOGGLE PORTB.2
PAUSE aa1
ENDIF

IF dekths=40 THEN
TOGGLE PORTB.3
PAUSE aa1
ENDIF

GOTO START
END

sakis st
- 8th June 2009, 12:20
Try it

SerOut PORTA.0,396,[REP$AA\5,REP$00\5,REP$FF\5]
pause 200 <----------------------------------------
SEROUT2 PORTA.0,396,["I","S","K","O",VERICI]
pause 200 <----------------------------------------

Deorge M
- 8th June 2009, 12:30
It is better but Lost a bytes

thanks

dhouston
- 8th June 2009, 14:13
See http://davehouston.org/RFTipsTricks.htm for an explanation of why using $55 or $AA for synchronization is not the best way to do this.

Deorge M
- 9th June 2009, 07:31
Hi dhouston
Please give me an example in picbasic

Pedro Pinto
- 9th June 2009, 21:00
Hi dhouston
Please give me an example in picbasic


Me too.
Thank You

Regards
Pedro

dhouston
- 9th June 2009, 22:10
Please give me an example in picbasic
Follow the links on the referenced webpage.

Me too.You,too.

Note: The SerOut2/SerIn2 example has not been tested - I'm too busy with a project of my own right now.

Deorge M
- 11th June 2009, 07:17
Note: The SerOut2/SerIn2 example has not been tested - I'm too busy with a project of my own right now

any help ;