Hello,
you ask:
> What command can I send to the stepper to move it a specified number of
> steps in a specified direction rather than sending it to a specified
> position?
the move() function moves a relative number of steps.
Suggest you carefully read the AccelStepper documentation at:
http://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html
Cheers.
On Thursday, February 27, 2014 06:00:19 AM
t...@thegauvins.com wrote:
> Mike,
>
> Thanks for the code example. It is much cleaner than what I was doing.
> I've edited my code to use "WetCmps.moveTo((Heading % 360) * 10);"
>
> Unfortunately, it doesn't address my primary issue. It works great for
> heading changes that don't cross North, but when crossing North it does not
> act correctly.
>
> As an example I'll use a 2 degree change that crosses North:
>
> *What I need the code to do:*
>
> When the current heading is 359 and the next heading string received is 001
> I need the stepper to move Clockwise 20 steps and consider its new position
> to be 10 and not 3610
> Or conversely
> When the current heading is 001 and the next heading string received is 359
> I need the stepper to move Counter Clockwise 20 steps and consider its new
> position to be 3590 and not -20
>
> *What it is doing:*
>
> At present with either my original code or the newly edited code a change
> from 359 to 001 causes the stepper to move counter clockwise 3580 steps
> or if 001 to 359 it moves clockwise 3580 steps.
>
> What command can I send to the stepper to move it a specified number of
> steps in a specified direction rather than sending it to a specified
> position?
>
> What I think I need is something like this (again using my 2 degree change
> crossing North example) but I don't yet understand Accelstepper well enough
> to know how to make it happen:
>
> if (Heading == 001 && HeadingLast == 359){
>
> <send command to stepper to move clockwise 20 steps>
>
> CrntPstn = WetCmps.currentPosition(10);
>
> }
>
>
> OR
>
> if (Heading == 359 && HeadingLast == 001){
>
> <send command to stepper to move counter clockwise 20 steps>
>
> CrntPstn = WetCmps.currentPosition(3590);
>
> }
>
> *// Keeping in mind that the biggest single heading change I might receive
> is 5 to 10 degrees*
>
> *// I would, of course, modify the above to look at a range of 355 to 010,
> maybe a bit wider,*
>
> *// and calculate the needed steps to cross North properly *
>
>
> It's the <send command to stepper to move x direction, x steps> line that I
> don't know how to do. And, I need to be sure that my use of
> currentPosition "CrntPstn = WetCmps.currentPosition(3590);" will do what I
> think it does.
>
> If you have any advice on how I can do that, or a simpler way to do it,
> that would be greatly appreciated!
>
> Thanks!!!
> Tom G.