While Loop Problems
Hey all! Working on a project to control a stepper motor on a power drawbar for a milling machine. The program should run the motor in one direction if the UnclampSwitch is triggered until the UnclampedSwitch is triggered, with the same being true for the ClampSwitch and ClampedSwitch. In addition, lights should turn on if either the UnclampedSwitch or ClampedSwitch are triggered (UnclampedLight and ClampedLight, respectively). Here's the code I have so far:
I'm suspecting that its some small syntax problem somewhere, but I've got no clue what it might be. Anyone got any ideas?
CON
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
_xinfreq = 5_000_000
UnclampSwitch=0
UnclampedSwitch=1
UnclampedLight=18
ClampSwitch=2
ClampedSwitch=3
ClampedLight=19
PulseFrequency=1000 {In Hz}
PulseWidth=50 {In uSeconds}
StepPin=16 {Step pin of driver}
DirPin=17 {Direction pin of driver}
VAR
long Period
long PauseTime
PUB Monitor
dira[UnclampSwitch]~
dira[UnclampedSwitch]~
dira[UnclampedLight]~~
dira[ClampSwitch]~
dira[ClampedSwitch]~
dira[ClampedLight]~~
dira[StepPin]~~
dira[DirPin]~~
Period:=clkfreq/PulseFrequency
PauseTime:=Period-PulseWidth
Repeat
If ina[ClampSwitch]~~ & ina[ClampedSwitch]~
Clamp
Elseif ina[UnclampSwitch]~~ & ina[UnclampedSwitch]~
Unclamp
If ina[ClampedSwitch]~~
outa[ClampedLight]~~
Elseif ina[UnclampedSwitch]~~
outa[UnclampedLight]~~
waitcnt(clkfreq/1000)
PUB Clamp
outa[DirPin]~
Repeat While (ina[ClampedSwitch]~)
outa[StepPin]~~
waitcnt(PulseWidth+cnt)
outa[StepPin]~
waitcnt(PauseTime+cnt)
RETURN
PUB Unclamp
outa[DirPin]~~
Repeat While (ina[UnclampedSwitch]~)
outa[StepPin]~~
waitcnt(PulseWidth+cnt)
outa[StepPin]~
waitcnt(PauseTime+cnt)
RETURN
I'm suspecting that its some small syntax problem somewhere, but I've got no clue what it might be. Anyone got any ideas?

Comments
I believe you need to relate what the problem is. That part seems to be missing.
Your code below:
looks like it's attempting to set the ina values. I don't recall ever seeing comparisons done this way and my guess is they wouldn't work as expected.
I'd suggest changing this and other comparisons to something like this.