Waitpeq Woes!
Jacobots
Posts: 1
VAR
word state
word desrev
word miss
word turn
word done
long outpt
CON
LED = 0
Motor = 1
SwitchOutput = 5
PUB Toggle
desrev := 0
done := 0
turn := 0
dira := %00000000_00000000_00000000_01010111 'P0=LED, P1=Motor, P2=Hall Effect Input, P3=Hall Effect Output, P4=Switch Input, P5=Switch Output
outa := %00000000_00000000_00000000_01010100
repeat
waitcnt (2_000_000 + cnt)
state := ina[noparse][[/noparse]SwitchOutput] 'set state = to 1 if switch is pressed
If state == 1 'if pin5 = 1
desrev++ 'add one to desrev
outa[noparse][[/noparse]LED]~~ 'turn LED on to show it is counted
waitcnt (2_000_000+ cnt)
outa[noparse][[/noparse]LED]~
Elseif state == 0 'if pin5 = 0
miss++ 'add one to miss
If miss == 4 'if miss = 4
quit 'quit loop
repeat while done < 100
!outa[noparse][[/noparse]0]
waitcnt (250_000 + cnt)
done++
outa[noparse][[/noparse]0]~
waitcnt (12_000_000 + cnt)
outa := %00000000_00000000_00000000_00010010
waitpeq (%00000000_00000000_00000000_00001000,%00000000_00000000_00000000_00001000, 0)
waitcnt (120_000_000 + cnt)
outa~
HELP ME!!!
for a few months now, I have utterly not been able to figure out how to use the waitpeq command- it always seems to ignore me... it almost skips the command, specifically the command on the second last line. please, if someone could explain to me either what is going wrong, how I am messing this up, or anything else you could help me with.... thank you for anything you can do!!!
Jacobots
word state
word desrev
word miss
word turn
word done
long outpt
CON
LED = 0
Motor = 1
SwitchOutput = 5
PUB Toggle
desrev := 0
done := 0
turn := 0
dira := %00000000_00000000_00000000_01010111 'P0=LED, P1=Motor, P2=Hall Effect Input, P3=Hall Effect Output, P4=Switch Input, P5=Switch Output
outa := %00000000_00000000_00000000_01010100
repeat
waitcnt (2_000_000 + cnt)
state := ina[noparse][[/noparse]SwitchOutput] 'set state = to 1 if switch is pressed
If state == 1 'if pin5 = 1
desrev++ 'add one to desrev
outa[noparse][[/noparse]LED]~~ 'turn LED on to show it is counted
waitcnt (2_000_000+ cnt)
outa[noparse][[/noparse]LED]~
Elseif state == 0 'if pin5 = 0
miss++ 'add one to miss
If miss == 4 'if miss = 4
quit 'quit loop
repeat while done < 100
!outa[noparse][[/noparse]0]
waitcnt (250_000 + cnt)
done++
outa[noparse][[/noparse]0]~
waitcnt (12_000_000 + cnt)
outa := %00000000_00000000_00000000_00010010
waitpeq (%00000000_00000000_00000000_00001000,%00000000_00000000_00000000_00001000, 0)
waitcnt (120_000_000 + cnt)
outa~
HELP ME!!!
for a few months now, I have utterly not been able to figure out how to use the waitpeq command- it always seems to ignore me... it almost skips the command, specifically the command on the second last line. please, if someone could explain to me either what is going wrong, how I am messing this up, or anything else you could help me with.... thank you for anything you can do!!!
Jacobots
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
Put a pull down on it if it is floating as Chris suggested. You state that it is a switch input, make sure it is pulled to GND with a 10k and not floating.