Shop OBEX P1 Docs P2 Docs Learn Events
Waitpeq Woes! — Parallax Forums

Waitpeq Woes!

JacobotsJacobots Posts: 1
edited 2008-11-20 22:13 in Propeller 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

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-11-20 21:47
    I don’t know if you considered this or not, but you did not mention what is connected to the pin you’re monitoring. If the pin is floating your results will be affected…in any event it would be a good idea to provide that information as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • T ChapT Chap Posts: 4,223
    edited 2008-11-20 22:13
    I would meter the pin P3 to be sure it is low, if you have a scope see what noise could be there as well.

    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.
Sign In or Register to comment.