vtt-info
- 21st December 2007, 17:05
Hi all,
this ist me first post. I have here the old code of a stairwell light in BS1 and would like to convert it in PicBasic 2.50a. What do I have to do?
************************************************** *****************
' {$STAMP BS1}
'Typ: PBASIC-Source for stairwell light
'Name: stairwell_light.bas
'Stand: 29/11/1999
' Constants
SYMBOL tast_msk= %00010000 'Mask for button
SYMBOL lampen = 6 'Pin for lamps
' Variables
SYMBOL inp = B0 'read IO byte
SYMBOL count1 = W1 'Cycle counter
SYMBOL init = W2 '2559 Cycles to 20 ms
SYMBOL count2 = B6 'Number of keystrokes
SYMBOL count3 = B7 'Minutes
SYMBOL outflag = B8 'Flag whether pushed for a long time
' Initialization
count1 = 0 'counter for time interval = 0
count2 = 0 'Number of keystrokes = 0
count3 = 0 'Minutes = 0
outflag = 0 'Flag = 0
DIRS = %01000000 'Pin 6 is output (relay)
EEPROM 0, ($0f,$09) '$09FF in EEPROM
READ 0,init 'Read Initialwert (Lo byte)
READ 1,inp 'Read Initialwert (hi byte)
init = 256 * inp + init 'Initialwert cycle counter
' Main program
main:
inp = PINS & tast_msk 'masking of bit 3
IF inp = tast_msk THEN decr_count 'If not pressed button, then decr-count
PAUSE 300 'Pause for 300 ms
inp = PINS & tast_msk 'masking of bit 3
IF outflag = 1 THEN on 'Questions whether turned off already
IF inp <> tast_msk THEN off1 'questions on long pushing -> Lamp off
on: HIGH lampen 'Switching on light
outflag = 0 'Putting back flag for out switching cycle
IF count2 = 4 THEN main 'more as 4 times push prevent
count2 = count2 + 1 'Number of keystrokes inkr.
LOOKUP count2, (0,3,10,30,600),count3 'Minutes determine
count1 = init 'lamps on for 1 minute
decr_count:
PAUSE 20 'Pause 20 ms
IF count1 = 0 THEN off0 'if count1 = 0, then light off
count1 = count1 - 1 'Cycle counter decrementieren
IF outflag = 1 THEN L1 'In the end switching cycle
IF count3 > 1 THEN L1 'last minute reaches?
IF count1 <> 853 THEN L1 '20 second before end reaches?
count2 = 0 'Number of keystrokes = 0
LOW lampen
PAUSE 500 'Light for 0.5 Seconds off
HIGH lampen
L1: IF count1 <> 0 THEN main 'if cycle not gone off, then loop
count3 = count3 - 1 'Number of cycles decrementieren
IF count3 <> 0 THEN count1_init 'if count3 > 0, then cont1 newly initialize
off0: 'switching off normally after expiry of the time
LOW lampen
count2 = 0 'Number of keystrokes = 0 '
count3 = 0
GOTO main 'Number of keystrokes = 0
off1: 'Switching off by pushing for a long time
LOW lampen
PAUSE 500 'Light for 0.5 Seconds off
HIGH lampen
count1 = init ' counter for a minute initialize
count2 = 0 'putting count2 to 0
count3 = 1 'a minute
outflag= 1 'Putting flag for out switching cycle
GOTO main 'back to the main program
count1_init:
count1 = init 'count1 initialsieren
GOTO main 'back to the main program
************************************************** *****************
I am grateful for help
Konrad
this ist me first post. I have here the old code of a stairwell light in BS1 and would like to convert it in PicBasic 2.50a. What do I have to do?
************************************************** *****************
' {$STAMP BS1}
'Typ: PBASIC-Source for stairwell light
'Name: stairwell_light.bas
'Stand: 29/11/1999
' Constants
SYMBOL tast_msk= %00010000 'Mask for button
SYMBOL lampen = 6 'Pin for lamps
' Variables
SYMBOL inp = B0 'read IO byte
SYMBOL count1 = W1 'Cycle counter
SYMBOL init = W2 '2559 Cycles to 20 ms
SYMBOL count2 = B6 'Number of keystrokes
SYMBOL count3 = B7 'Minutes
SYMBOL outflag = B8 'Flag whether pushed for a long time
' Initialization
count1 = 0 'counter for time interval = 0
count2 = 0 'Number of keystrokes = 0
count3 = 0 'Minutes = 0
outflag = 0 'Flag = 0
DIRS = %01000000 'Pin 6 is output (relay)
EEPROM 0, ($0f,$09) '$09FF in EEPROM
READ 0,init 'Read Initialwert (Lo byte)
READ 1,inp 'Read Initialwert (hi byte)
init = 256 * inp + init 'Initialwert cycle counter
' Main program
main:
inp = PINS & tast_msk 'masking of bit 3
IF inp = tast_msk THEN decr_count 'If not pressed button, then decr-count
PAUSE 300 'Pause for 300 ms
inp = PINS & tast_msk 'masking of bit 3
IF outflag = 1 THEN on 'Questions whether turned off already
IF inp <> tast_msk THEN off1 'questions on long pushing -> Lamp off
on: HIGH lampen 'Switching on light
outflag = 0 'Putting back flag for out switching cycle
IF count2 = 4 THEN main 'more as 4 times push prevent
count2 = count2 + 1 'Number of keystrokes inkr.
LOOKUP count2, (0,3,10,30,600),count3 'Minutes determine
count1 = init 'lamps on for 1 minute
decr_count:
PAUSE 20 'Pause 20 ms
IF count1 = 0 THEN off0 'if count1 = 0, then light off
count1 = count1 - 1 'Cycle counter decrementieren
IF outflag = 1 THEN L1 'In the end switching cycle
IF count3 > 1 THEN L1 'last minute reaches?
IF count1 <> 853 THEN L1 '20 second before end reaches?
count2 = 0 'Number of keystrokes = 0
LOW lampen
PAUSE 500 'Light for 0.5 Seconds off
HIGH lampen
L1: IF count1 <> 0 THEN main 'if cycle not gone off, then loop
count3 = count3 - 1 'Number of cycles decrementieren
IF count3 <> 0 THEN count1_init 'if count3 > 0, then cont1 newly initialize
off0: 'switching off normally after expiry of the time
LOW lampen
count2 = 0 'Number of keystrokes = 0 '
count3 = 0
GOTO main 'Number of keystrokes = 0
off1: 'Switching off by pushing for a long time
LOW lampen
PAUSE 500 'Light for 0.5 Seconds off
HIGH lampen
count1 = init ' counter for a minute initialize
count2 = 0 'putting count2 to 0
count3 = 1 'a minute
outflag= 1 'Putting flag for out switching cycle
GOTO main 'back to the main program
count1_init:
count1 = init 'count1 initialsieren
GOTO main 'back to the main program
************************************************** *****************
I am grateful for help
Konrad