getPosition()


Description

This function gets the current counter position of a stepper motor.

Syntax

position = step.getPosition()

Parameters

none

Returns

a integer value represents the current counter position of a stepper motor

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());

    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(1600);

    while(step.getState()) {
        // gets the current counter position
        Serial.println(step.getPosition());
        delay(1000);
    }
}

void loop() {

}