setMode()


Description

This function sets the division rate of microstepping.

Syntax

step.setMode(mode)

Parameters

mode - one of following values which represents the division rate

mode description
1 full-step
2 half-step
4 1/4-step
8 1/8-step
16 1/16-step
32 1/32-step

Returns

none

Example

#include <PhpocExpansion.h>
#include <Phpoc.h>

byte spcId = 1;

ExpansionStepper step(spcId);

void setup() {
    Serial.begin(9600);
    while(!Serial)
        ;

    Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
    Expansion.begin();

    Serial.println(step.getPID());
    Serial.println(step.getName());

    // sets the division rate
    step.setMode(4);
    step.setVrefStop(2);
    step.setVrefDrive(8);
    step.setResonance(120, 250);
    step.setSpeed(400);
    step.setAccel(0, 0);
    step.setPosition(-400);

    step.stepGoto(400);
    delay(1000);
    step.stepGoto(-400);
    delay(1000);
    step.stepGoto(400);

    while(step.getState()) {
        delay(1);
    }
}

void loop() {

}