Problem Time
I have a small problem.· I need to move my stepper 25.75 steps.· Obviously, the BS2E can't do that.· If I move the stepper 26 steps, every four iterations the stepper gains one step, so every fifth iteration I need to move the stepper only 25 steps to compensate for the error.· Is this the correct way to do it?
goleft:
HIGH dir
z = 0·········· 'counter
w = 26········· 'number of steps
FOR x = 1 TO w·
PULSOUT stp, 10
z = z + 1
IF z = 5 then
w = 25
z = 0
ELSE w = 26
ENDIF
NEXT
PAUSE 1000
RETURN
Sid
goleft:
HIGH dir
z = 0·········· 'counter
w = 26········· 'number of steps
FOR x = 1 TO w·
PULSOUT stp, 10
z = z + 1
IF z = 5 then
w = 25
z = 0
ELSE w = 26
ENDIF
NEXT
PAUSE 1000
RETURN
Sid
Comments
This should execute the PULSOUT 26 times each of the first 4 loops, but 25 times for the·fifth loop.· You may need to put this inside even another loop if you want to run even further (or you can call the subroutine multiple times).· Since this didn't seem to be a concern in your original code, I think you can handle it here [noparse]:)[/noparse]· good luck.
Thanks for the effort anyway -· it is sincerely appreciated.
Sid
·
The variable z is being treated like a static member variable in C++ (if you're not familar with C++, don't worry about it).· I hope this is the correct solution.
Another thought: I'm guessing you're attempting to build a CNC machine.· If you want to make this even more accurate (and simplify the code), have whatever is sending the movement info (I assume a computer) crunch the numbers to figure out how many steps there should be in whatever motion it has planned.· This will essentially cause it to "round" to the nearest step.
for y = 1 to 1000
if y/111 'is an integer then gosub correct'·· Need help with this
w = 26········· 'number of steps
FOR x = 1 TO w·
PULSOUT stp, 10
next
pause 500
next
Something like (Ithink):
x = 111
z =y//x
if z = 0 then gosub correct
Am I close?
Post edited.
Sid
Post Edited (Newzed) : 8/5/2005 9:54:26 PM GMT
Sid