Here is my Transmitter code:
#chip 16F684, 8 'mhz
#config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off
Ser_Init
dir portc.5 out ' 5
main:
repeat 4
Xmit_Print ("s$s$")
Xmit_Print ("s$")
end repeat
wait 1 s
repeat 4
Xmit_Print ("t$t$")
Xmit_Print ("t$")
end repeat
goto main
Sub Ser_Init
#define baud 832 ;the us delay for 1200 baud rate '104-9600
#define SerTxHigh Set portc.5 on
#define SerTxLow Set portc.5 off
SerTxhigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
And here is one of the reciever codes:
#chip 12F683, 20 'mhz
#config XT, MCLRE=off, WDT=off',OSC=INTOSC
dim temp as byte
dir gpio.0 in
dir gpio.1 out
#define RecAHigh GPIO.0 off
#define RecALow GPIO.0 on
InitSer 1,r1200,1,8,1,none,invert
dim temp1 as byte
dim loc as byte
loc = 0
set gpio.1 on
wait 2 s
set gpio.1 off
main:
if loc = 0 then
SerReceive 1, Temp
if temp <> 36 then loc = 1
end if
if loc = 1 then
SerReceive 1, Temp1
if temp1 = 36 then
if temp = 115 then
set gpio.1 on
wait 250 ms
set gpio.1 off
end if
if temp = 123 then set gpio.1 on
if temp = 125 then set gpio.1 off
loc = 2
end if
end if
if loc = 2 then loc = 0
goto main
the problem is i send the command to turn on the output of the rx unit but it does not get it reliably? any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is my Transmitter code:
#chip 16F684, 8 'mhz
#config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off
Ser_Init
dir portc.5 out ' 5
main:
repeat 4
Xmit_Print ("s$s$")
Xmit_Print ("s$")
end repeat
wait 1 s
repeat 4
Xmit_Print ("t$t$")
Xmit_Print ("t$")
end repeat
goto main
Sub Ser_Init
#define baud 832 ;the us delay for 1200 baud rate '104-9600
#define SerTxHigh Set portc.5 on
#define SerTxLow Set portc.5 off
SerTxhigh ;Initial RS232 idle state
end sub
sub XMIT_PRINT (PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then exit sub
'Write Data
for SysPrintTemp = 1 to PrintLen
XMIT_RS232(PrintData(SysPrintTemp))
next
end sub
Sub XMIT_RS232(Xmit_Byte)#NR
SerTxLow ;Start bit
wait baud us
For cntr = 1 to 8
Rotate Xmit_Byte Right
If Status.C ON Then SerTxHigh
If Status.C Off Then SerTxLow
wait baud us
Next
SerTxHigh ;Stop bit
wait baud us
end sub
And here is one of the reciever codes:
#chip 12F683, 20 'mhz
#config XT, MCLRE=off, WDT=off',OSC=INTOSC
dim temp as byte
dir gpio.0 in
dir gpio.1 out
#define RecAHigh GPIO.0 off
#define RecALow GPIO.0 on
InitSer 1,r1200,1,8,1,none,invert
dim temp1 as byte
dim loc as byte
loc = 0
set gpio.1 on
wait 2 s
set gpio.1 off
main:
if loc = 0 then
SerReceive 1, Temp
if temp <> 36 then loc = 1
end if
if loc = 1 then
SerReceive 1, Temp1
if temp1 = 36 then
if temp = 115 then
set gpio.1 on
wait 250 ms
set gpio.1 off
end if
if temp = 123 then set gpio.1 on
if temp = 125 then set gpio.1 off
loc = 2
end if
end if
if loc = 2 then loc = 0
goto main
the problem is i send the command to turn on the output of the rx unit but it does not get it reliably? any ideas?