Functions | |
int | Stepper_SetActive (int index, int state) |
Sets whether the specified Stepper is active. | |
int | Stepper_GetActive (int index) |
Check whether the stepper is active or not. | |
int | Stepper_SetPosition (int index, int position) |
Set the position of the specified stepper motor. | |
int | Stepper_SetPositionRequested (int index, int positionRequested) |
Set the destination position for a stepper motor. | |
int | Stepper_SetSpeed (int index, int speed) |
Set the speed at which a stepper will move. | |
int | Stepper_GetSpeed (int index) |
Get the speed at which a stepper will move. | |
int | Stepper_GetPosition (int index) |
Read the current position of a stepper motor. | |
int | Stepper_GetPositionRequested (int index) |
Read the destination position of a stepper motor. | |
int | Stepper_Step (int index, int steps) |
Simply take a number of steps from wherever the motor is currently positioned. | |
int | Stepper_SetDuty (int index, int duty) |
Set the duty - from 0 to 1023. | |
int | Stepper_GetDuty (int index) |
Get the duty Read the value previously set for the duty. | |
int | Stepper_SetBipolar (int index, int bipolar) |
Declare whether the stepper is bipolar or not. | |
int | Stepper_GetBipolar (int index) |
Get the bipolar setting Read the value previously set for bipolar. | |
int | Stepper_SetHalfStep (int index, int halfStep) |
Declare whether the stepper is in half stepping mode or not. | |
int | Stepper_GetHalfStep (int index) |
Read whether the stepper is in half stepping mode or not. |
Up to 2 stepper motors can be controlled with the Make Application Board. Specify settings for your stepper motor by setting whether it's:
For absolute positioning, call Stepper_SetPositionRequested() with the desired position, and the motor will move there. You can read back the stepper's position at any point along the way to determine where it is at a given moment. The board keeps an internal count of how many steps the motor has taken in order to keep track of where it is.
For relative positioning, use Stepper_Step( ) to simply move a number of steps from the current position.
See the Stepper Motor how-to for more detailed info on hooking up a stepper motor to the Make Controller.
int Stepper_GetActive | ( | int | index | ) |
Check whether the stepper is active or not.
index | An integer specifying which stepper (0-1). |
if( Stepper_GetActive(1) ) { // Stepper 1 is active } else { // Stepper 1 is inactive }
int Stepper_GetBipolar | ( | int | index | ) |
Get the bipolar setting Read the value previously set for bipolar.
index | An integer specifying which stepper (0 or 1). |
if( Stepper_GetBipolar(1) ) { // stepper 1 is bipolar } else { // stepper 1 is unipolar }
int Stepper_GetDuty | ( | int | index | ) |
Get the duty Read the value previously set for the duty.
index | An integer specifying which stepper (0 or 1). |
int step1_duty = Stepper_GetDuty(1); // step1_duty has the current duty for stepper 1
int Stepper_GetHalfStep | ( | int | index | ) |
Read whether the stepper is in half stepping mode or not.
index | An integer specifying which stepper (0 or 1). |
if( Stepper_GetHalfStep(1) ) { // stepper 1 is in half step mode } else { // stepper 1 is in full step mode }
int Stepper_GetPosition | ( | int | index | ) |
Read the current position of a stepper motor.
index | An integer specifying which stepper (0 or 1). |
int step0_pos = Stepper_GetPosition(0); // now step0_pos has the current position of stepper 0
int Stepper_GetPositionRequested | ( | int | index | ) |
Read the destination position of a stepper motor.
This indicates where the stepper is ultimately headed. To see where it actually is, see Stepper_GetPosition().
index | An integer specifying which stepper (0 or 1). |
int step1_destination = Stepper_GetPositionRequested(1); // step1_destination has the requested position for stepper 1
int Stepper_GetSpeed | ( | int | index | ) |
Get the speed at which a stepper will move.
Read the value previously set for the speed parameter.
index | An integer specifying which stepper (0 or 1). |
int step0_speed = Stepper_GetSpeed(0); // now step0_speed has the speed of stepper 0
int Stepper_SetActive | ( | int | index, | |
int | state | |||
) |
Sets whether the specified Stepper is active.
index | An integer specifying which stepper (0 or 1). | |
state | An integer specifying the active state - 1 (active) or 0 (inactive). |
// enable stepper 1 Stepper_SetActive(1, 1);
int Stepper_SetBipolar | ( | int | index, | |
int | bipolar | |||
) |
Declare whether the stepper is bipolar or not.
Default is bipolar.
index | An integer specifying which stepper (0 or 1). | |
bipolar | An integer 1 for bipolar, 0 for unipolar |
// set stepper 1 to unipolar Stepper_SetBipolar(1, 0);
int Stepper_SetDuty | ( | int | index, | |
int | duty | |||
) |
Set the duty - from 0 to 1023.
The default is for 100% power (1023).
index | An integer specifying which stepper (0 or 1). | |
duty | An integer specifying the stepper duty (0 - 1023). |
// set stepper 0 to half power Stepper_SetDuty(0, 512);
int Stepper_SetHalfStep | ( | int | index, | |
int | halfStep | |||
) |
Declare whether the stepper is in half stepping mode or not.
Default is not - i.e. in full step mode.
index | An integer specifying which stepper (0 or 1). | |
halfStep | An integer specifying 1 for half step, 0 for full step |
// set stepper 1 to half step mode Stepper_SetHalfStep(1, 1);
int Stepper_SetPosition | ( | int | index, | |
int | position | |||
) |
Set the position of the specified stepper motor.
Note that this will not ask the stepper to move. It will simply update the position that the stepper thinks its at. To move the stepper, see Stepper_SetPositionRequested() or Stepper_Step().
index | An integer specifying which stepper (0 or 1). | |
position | An integer specifying the stepper position. |
// reset stepper 1 to call its current position 0 Stepper_SetPosition(1, 0);
int Stepper_SetPositionRequested | ( | int | index, | |
int | positionRequested | |||
) |
Set the destination position for a stepper motor.
This will start the stepper moving the given number of steps at the current speed, as set by Stepper_SetSpeed().
While it's moving, you can call Stepper_GetPosition() to read its current position.
index | An integer specifying which stepper (0 or 1). | |
positionRequested | An integer specifying the desired stepper position. |
// start moving stepper 0 1500 steps Stepper_SetPositionRequested(0, 1500);
int Stepper_SetSpeed | ( | int | index, | |
int | speed | |||
) |
Set the speed at which a stepper will move.
This is a number of ms per step, rather than the more common steps per second. Arranging it this way makes it easier to express as an integer. Fastest speed is 1ms / step (1000 steps per second) and slowest is many seconds.
index | An integer specifying which stepper (0 or 1). | |
speed | An integer specifying the stepper speed in ms per step |
// set the speed to 1ms / step (1000 steps per second) Stepper_SetSpeed(0, 1);
int Stepper_Step | ( | int | index, | |
int | steps | |||
) |
Simply take a number of steps from wherever the motor is currently positioned.
This function will move the motor a given number of steps from the current position.
index | An integer specifying which stepper (0 or 1). | |
steps | An integer specifying the number of steps. Can be negative to go in reverse. |
// take 1200 steps forward from our current position Stepper_Step(0, 1200);