Code
jgonzo
Posts: 5
PUB timer
· dira[noparse][[/noparse]1..5]~~
· outa[noparse][[/noparse]1..5]~
· repeat
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *5 + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq*5 + cnt)
··
··· I wrote this code to turn on and off 2 groups of outputs.· On for 3 seconds and off for 5 seconds, etc.
Then due to hardware logic changes I just want to invert the outputs.· So I made the following modification.
PUB timer
· dira[noparse][[/noparse]1..5]~~
· outa[noparse][[/noparse]1..5]:=1
· repeat
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *5 + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq*5 + cnt)
Only the outputs 3..5 were reversed.··Output 1..2 were not.··Can you tell me what I am doing wrong?
··
· dira[noparse][[/noparse]1..5]~~
· outa[noparse][[/noparse]1..5]~
· repeat
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *5 + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq*5 + cnt)
··
··· I wrote this code to turn on and off 2 groups of outputs.· On for 3 seconds and off for 5 seconds, etc.
Then due to hardware logic changes I just want to invert the outputs.· So I made the following modification.
PUB timer
· dira[noparse][[/noparse]1..5]~~
· outa[noparse][[/noparse]1..5]:=1
· repeat
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]1..2]
··· waitcnt(clkfreq *5 + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq *3· + cnt)
··· !outa[noparse][[/noparse]3..5]
··· waitcnt(clkfreq*5 + cnt)
Only the outputs 3..5 were reversed.··Output 1..2 were not.··Can you tell me what I am doing wrong?
··
Comments
I hope I've interpreted your requirements correctly, here is my version of your code...
I've added some comments to the code to explain what is happening,
Your first routine converted thus:-
All pins start low (~) Pins 1..2 High (~~) for 3 Seconds, all pins low for 5 seconds, Pins 3..5 High for 3 Seconds, all pins low for 5 seconds, repeat ad infinitum.
Your second routine:-
Pins 1..2 start low (~) and Pins 3..5 start high (~~), Pins 1..2 High for 3 Seconds, Pins 1..2 low and Pins 3..5 remain high for 5 seconds , Pins 3..5 Low for 3 Seconds, Pins 1..2 remain low and Pins 3..5 high for 5 seconds, repeat ad infinitum.
I hope that helps a bit.
Regards,
Coley
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite