Joe, here is the code I am sending from pic to pic:
INCLUDE "MODEDEFS.BAS"
@ DEVICE PIC16F628a,XT_OSC
@ DEVICE pic16F628a, WDT_OFF
' Watchdog Timer
@ DEVICE pic16F628a, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628a, MCLR_ON
' Master Clear Options (Internal)
@ DEVICE pic16F628a, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628a, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628a, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628a, PROTECT_OFF
define osc 4
CMCON=%00000111
trisb = %11111111
trisa = %00010111
chk_sum var byte
dgood var porta.2
serpin var porta.3
nokey con %11111111
synch con 254
address con %00000001
keyin var portb
keydata var byte
E VAR PORTB.0
D VAR PORTB.1
G VAR PORTB.2
A VAR PORTB.3
B VAR PORTB.4
C VAR PORTB.5
F VAR PORTB.6
na VAR PORTB.7
PreAmble CON $A5 ' 10100101
findkey:
if A = 0 then sw0
if B = 0 then sw1
if C = 0 then sw2
if D = 0 then sw3
if E = 0 then sw4
if F = 0 then sw5
if G = 0 then sw6
goto findkey
sw0:
keydata = %01010110
goto dout
sw1:
keydata = %01011001
goto dout
sw2:
keydata = %01011010
goto dout
sw3:
keydata = %01100101
goto dout
sw4:
keydata = %01100110
goto dout
sw5:
keydata = %01101001
goto dout
sw6:
keydata = %01101010
goto dout
dout:
low dgood
pause 100
chk_sum = (address + address)
chk_sum = chk_sum + (keydata + keydata)
goto transmit
transmit:
serout serpin,N9600[$55,$55,$55,$55,$55,$AA,$AA,$AA,$AA,$AA,synch,addr ess,address,keydata,keydata,chk_sum]
if keyin = nokey then x2
goto findkey
x2:
high dgood
keydata = %00000000
serout serpin,N9600,[$55,$55,$55,$55,$55,$AA,$AA,$AA,$AA,$AA,synch,addr ess,address,keydata,keydata,chk_sum]
goto findkey
end
Anyhow, it works, tx side seems to be fine, my big problem is on the rx side each output that is a if/then statement will come on but when I release the button it stays on. The only way to make it turn off is to press another momentary button. The toggle function works fine, although if I hold onto the button to long it will toggle on/off. if/then example I have tried after Skimask post:
if mydata1=%01011001 then pause 50
if mydata1=%01011001 then
high 1
else
low 1
endif
I am using a direct cable link, and will try again later with the Linx modules.
"logic dictates, cmcon goes before anything portA, then tris registers dictate input or output, then port dictates hi or low status."
And I have modified the suggestion to this tx program yet, but I will later this evening.
Many thanks for the help.
Bookmarks