Hi all, my first post on this great site, so be gentle with me...
I need to embed a program in the Olimex PIC I/O board. It has 4 Inputs and 4 relay Outputs. I am using a 16F628A. Using PBP. I use several of these boards in my little welding shop and always seem to have the same problem with Basic language programming. The relay response time when the input changes state is affected by the Pause command. I want to turn on a vacuum, pause, turn on a light, pause, turn on a power feed, pause, turn on a saw. I flip the switch on -vac comes on followed by the other relays OK. But there is that darned delay of up to 3 seconds at the beginning of each cycle. When the switch is turned off the saw MUST shut down immediately. But there is that darned delay again. The more Pause I include in the program the more delay I get at the beginning of each cycle. I can program the same hardware in Ladder Logic and not get the delay but I want to use PBP. Please tell me what the fix is. It's usually simple, I know, but 6 Saturdays have been invested with little result.
My latest (cleaned up) incantation:

pause 50
define OSC 20
CMCON = 7 ' digital I/O
TRISA = %00010000
TRISB = %00111001

counter var word

loop:
toggle portb.5 'Cycle on/off Power-On LED
if portb.0 = 1 then 'Switch is Off
gosub sub1
else
portb.0 = 0 'Switch is On
gosub sub2
endif
goto loop
sub1:
low 11 'Turn Off SAW immediately
gosub delay
low 10 'Turn Off power feed
gosub delay
low 9 'Turn Off Light
gosub delay
low 8 'Turn Off Vacuum
goto loop
sub2:
high 8 'Turn On Vacuum
gosub delay
high 9 'Turn On Light
gosub delay
high 10 'Turn On Power Feed
gosub delay
high 11 'Turn On SAW
goto loop

delay:
counter=32
repeat
pause 50
counter=counter-1
until counter=0
return

end

As I said, this works, but when I flip the switch off I really need the saw to stop immediately. Thanks to all of you. lloyd778