pic 2 (incomplete)
TRISB = %00000000DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
DEFINE CCP1_BIT 2 'Hpwm 1 pin bit
DEFINE CCP2_REG PORTC 'Hpwm 2 pin port
DEFINE CCP2_BIT 1 'Hpwm 2 pin bitindata Var Byte(80)
ndeg Var Word
nmin Var word
wim1 Var Wordnoon Var Word
shift Var Word
modify Var Wordj Var Byte
w Var BYTE(3)
tx var portc.6
rx var portc.7
inv9600 con 16468 ' baudmode for seri.2 and serout2: 9600 8-N-1 inverted
non9600 con 84 ' baudmode for serin2 and serout2: 9600 8-N-1 non-invertedled1 VAR portC.4
led2 VAR portC.3High led2
Hpwm 1, 127, 1000Pause 1000 ' Wait a second at startup
main:
serin2 tx, inv9600, 4000, main, [wait("yes"), STR indata\6]
pause 5'for j = 0 to 2
'w[j] = indata[j + 3]
'next j
'wim1 = (w[0]-48)*100 + (w[1]-48)*10 + (w[2]-48)
high led2
Hpwm 1, 127, 1000
'Hpwm 2, wim1/2, 1000
Pause 1000
low led2
goto main
pic1
TRISB = %00000000Posted by William Blaze at April 24, 2005 11:42 PM | TrackBack
High portb.7
Low portb.6
dataByte var byte
dataByte2 var byte
DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
DEFINE CCP1_BIT 2 'Hpwm 1 pin bit
'DEFINE CCP2_REG PORTC 'Hpwm 2 pin port
'DEFINE CCP2_BIT 1 'Hpwm 2 pin bit
'output portb.3
init Var Byte
init = 0
loginTime Var Byte(80)
sendTime Var Byte(17)
h2 VAR BYTE
m2 Var BYTE
s2 Var BYTE
h VAR BYTE(2)
m Var BYTE(2)
s Var BYTE(2)
ndeg Var Word
nmin Var word
wim1 Var Wordnoon Var Word
shift Var Word
modify Var Word
tx var portc.6
rx var portc.7
xportRx var portC.0
xportTx var portA.1
xportDTR var portA.0
pic2tx Var portA.3
inv9600 con 16468 ' baudmode for seri.2 and serout2: 9600 8-N-1 inverted
non9600 con 84 ' baudmode for serin2 and serout2: 9600 8-N-1 non-invertedi var byte ' counter
j Var Byteled1 VAR portC.4
led2 VAR portC.3High led2
'High portb.3
Pause 1000 ' Wait a second at startupserout2 tx, inv9600, ["starts", 13, 10]
main:
'High portb.3
serout2 tx, inv9600, ["time loop starts", 13, 10]
SEROUT2 xporttx, non9600, ["C129.6.15.28/13", 10]
serin2 xportrx, non9600, 4000, main, [wait("5"), str loginTime\35]
pause 100
serout2 tx, inv9600, ["passed serin", 13, 10]
for i = 0 to 17
sendTime[i] = loginTime[i + 14]
next i
for j = 0 to 1
h[j] = loginTime[j + 14]
next j
for j = 0 to 1
m[j] = loginTime[j + 17]
next j
for j = 0 to 1
s[j] = loginTime[j + 20]
next j
h2 = (h[0]-48)*10 + (h[1]-48)
m2 = (m[0]-48)*10 + (m[1]-48)
s2 = (s[0]-48)*10 + (s[1]-48)
ndeg = (h2 * 60 / 4) + (m2 / 4)
nmin = ((m2 // 4) * 60 / 4) + (s2 / 4)
'serout2 xporttx, non9600, ["send all ", DEC ndeg ," degrees ", DEC nmin, " minutes ", 13, 10]
'serout2 xporttx, non9600, ["send ", STR nameArray, " " , str sendTime\17, "---", DEC ndeg ,"deg ", DEC nmin, "min", 13, 10]
'wim1 = nmin*60/255
wim1 = 255*nmin/60
if nmin <20 Then
High portb.7
High portb.6
low portb.5
High portb.4
High portb.3
low portb.2
endif
if nmin >19 Then
High portb.7
Low portb.6
High portb.5
High portb.4
low portb.3
high portb.2
ENdif
if nmin > 39 Then
LOW portb.7
High portb.6
High portb.5
low portb.4
High portb.3
High portb.2
ENdif
Noon = ndeg/36
shift = ndeg//36
modify = 50*shift/36serout2 pic2tx, inv9600, ["yes", DEC wim1]
serout2 tx, inv9600, [str sendTime\8, 13, 10, DEC ndeg ," degrees ", DEC nmin, " minutes ", 13, 10, Dec noon, " " ,Dec shift, " " ,Dec modify, 13, 10]
Hpwm 1, wim1, 1000
Hpwm 2, wim1/2, 1000
Pause 1000
goto main