Troubles with If statement logic
I was wondering if anybody could give a suggestion of how to go about putting a conditional statement in my program.
Basically the stamp reads in 2 nibbles, puts them into a byte and steps a motor. All i'm trying to do at the moment is to stop the stepper sequence when a high signal is read off an input pin, and store the stepper counter as a variable.
The problem is wherever I seem to put the if statement, the stepper does something different and unexpected. I'm guessing its because I'm trying to exit a counted loop.
...
So within this code, I'm just looking to put something like
So just to clarify, the motor will step for the number of times specified in reconstructed data, and i'm trying to get the program to read the value of an input pin each itteration which would exit the loop and return to the beginning if low
Thanks for looking and If I can do anything else to help, like posting the entire code please let me know
Cheers
Martyn
Basically the stamp reads in 2 nibbles, puts them into a byte and steps a motor. All i'm trying to do at the moment is to stop the stepper sequence when a high signal is read off an input pin, and store the stepper counter as a variable.
The problem is wherever I seem to put the if statement, the stepper does something different and unexpected. I'm guessing its because I'm trying to exit a counted loop.
...
IF(Reconstructed_data = $07) THEN Demo 'step_fwd
'if (data < 30) && data = 0x3f), revsteps = ox3f 'step_back
OUTA = $02
GOTO CHECK_ENABLE_ONE
Demo:
FOR idx = 1 TO Reconstructed_data 'idx = 1; idx < portd reading (200); idx++
GOSUB Step_Fwd 'goto step_ (sub routine...so has a return)
NEXT 'exit loop
PAUSE 200
FOR idx = 1 TO Reconstructed_data 'for(idx = 1; i < revsteps (200); i++)
GOSUB Step_Rev
NEXT
PAUSE 200
GOTO CHECK_ENABLE_ONE 'return after one revolution
Step_Fwd:
stpIdx = stpIdx +1 //NumSteps 'increments step value
GOTO Do_Step 'ELSE
Step_Rev:
stpIdx = stpIdx + LastStep //NumSteps 'point to previous step
GOTO Do_Step
Do_Step:
'STATEMENT HERE FOR SWITCH FEEDBACK...............................
READ (Step1 + StpIdx), Coils 'output new coil data - read variable () and store in coils (outb)
PAUSE stpDelay 'delay between steps
RETURN
So within this code, I'm just looking to put something like
IF IN11 = 0 THEN Stalled 'switch is active low Stalled: Stalled_Motor = idx GOTO the_start
So just to clarify, the motor will step for the number of times specified in reconstructed data, and i'm trying to get the program to read the value of an input pin each itteration which would exit the loop and return to the beginning if low
Thanks for looking and If I can do anything else to help, like posting the entire code please let me know
Cheers
Martyn

Comments