start
set ram1 ip1 # read current input
xor ram1 ram2 ram2 # ram2 is set only if state change
and ram1 ram2 ram2 # ram2 is set only if state change AND rising edge
tstgt ram2 0 # is ram2 set?
add cts 20 ram3 # re-trigger timer to expire 20 seconds from now
set ram2 ram1 # save current input state for next scan
# Here is the test you use to see when the timer expires
tstgt ram3 cts op1 # set output 1 while the timer is running
set op2 ip3 # or do any other command you like here that will only run while the timer is running.
end
What I want is to be able to do something for 1 scan or cycle. Then when the state changes do it again.
set ram1 ip1 # read current input
xor ram1 ram2 ram2 # ram2 is set only if state change
and ram1 ram2 ram2 # ram2 is set only if state change AND rising edge
set ram2 ram1 # save current input state for next scan
.... rest of your code continues
end
set ram2 ip1 # get input 1
mul ip2 2 ram1 # align bits for input 2
add ram1 ram2 ram2 # add to flag
mul ip3 4 ram1 # align bits for input 3
add ram1 ram2 ram2
mul ip4 8 ram1 # align bits for input 4
add ram1 ram2 ram2
mul ip5 16 ram1
add ram1 ram2 ram2
mul ip6 32 ram1
add ram1 ram2 ram2
mul ip7 64 ram1
add ram1 ram2 ram2
mul ip8 128 ram1
add ram1 ram2 ram2 # ram2 now has 8 bits mirroring the 8 inputs
xorb ram2 ram3 ram1 # ram1 now has 1 bits for every changed input
andb ram1 ram2 ram1 # ram1 now has 1 bits for every rising edge only
set ram3 ram2 # save all 8 input states for next scan
# your code goes here. Test each bit of ram1 to see if it just changed to "on"
orb ram1 1 # test input 1
(do whatever)
orb ram1 128 # test input 8
(do whatever)
etc etc.
ANDB CTS 64 RamX
To take this even further and more useful as well. This also has the makings of a BSL or a BSR. Just not sure how to do this, yet. I don't need it, just see another idea someone else might need.Code:set ram2 ip1 # get input 1 mul ip2 2 ram1 # align bits for input 2 add ram1 ram2 ram2 # add to flag mul ip3 4 ram1 # align bits for input 3 add ram1 ram2 ram2 mul ip4 8 ram1 # align bits for input 4 add ram1 ram2 ram2 mul ip5 16 ram1 add ram1 ram2 ram2 mul ip6 32 ram1 add ram1 ram2 ram2 mul ip7 64 ram1 add ram1 ram2 ram2 mul ip8 128 ram1 add ram1 ram2 ram2 # ram2 now has 8 bits mirroring the 8 inputs xorb ram2 ram3 ram1 # ram1 now has 1 bits for every changed input andb ram1 ram2 ram1 # ram1 now has 1 bits for every rising edge only set ram3 ram2 # save all 8 input states for next scan # your code goes here. Test each bit of ram1 to see if it just changed to "on" orb ram1 1 # test input 1 (do whatever) orb ram1 128 # test input 8 (do whatever) etc etc.
START
begin:
SET RAM2 IP1
MUL IP2 2 RAM1
ADD RAM1 RAM2 RAM2
MUL IP3 4 RAM1
ADD RAM1 RAM2 RAM2
MUL IP4 8 RAM1
ADD RAM1 RAM2 RAM2
MUL IP5 16 RAM1
ADD RAM1 RAM2 RAM2
MUL IP6 32 RAM1
ADD RAM1 RAM2 RAM2
MUL IP7 64 RAM1
ADD RAM1 RAM2 RAM2
MUL IP8 128 RAM1
ADD RAM1 RAM2 RAM2
XORB RAM2 RAM3 RAM1
ANDB RAM1 RAM2 RAM1
SET RAM3 RAM2
ANDB RAM1 2 VAR2
ANDB RAM1 8 VAR4
ANDB RAM1 4 VAR3
ANDB RAM1 16 VAR5
SET VAR6 RAM1
SET VAR7 RAM2
SET VAR8 RAM3
ANDB RAM1 1 var1 # I changed the test to andb. ( banging my head here until the duh hit me :blush: , orb will place either or both in)
bnz send
set var7 111111 # to see where flow was going
goto begin
send:
webset url1 1
set var8 121212 # to see where flow was going
goto begin
END
This works. Thanks for the idea Ross. The webset sends 1x (3-5 times actually cuz you can see the switch bounce)
I'm thinking of leaving a several degrees spread to help with the flutter as well as the Tx[xxx].