This function sets the current limiting for keeping lock state of a stepper motor.
step.setVrefLock(vref)
vref - a integer value which represents the current limiting (0 ~ 15)
none
#include <PhpocExpansion.h>
#include <Phpoc.h>
byte spcId = 1;
ExpansionStepper step(spcId);
int state;
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);
// sets the current limiting for run state
step.setVrefLock(8);
step.setSpeed(400);
step.setAccel(4000);
step.setEioMode(0, 1);
step.setEioMode(1, 1);
step.setEioMode(2, 1);
step.setEioMode(3, 1);
step.stepGoto(4000);
while(step.getState() > 1) {
delay(1);
}
// state: 0 - stop, 1 - locked
Serial.print("step_state ");
Serial.println(step.getState());
step.unlock();
// state: 0 - stop, 1 - locked
Serial.print("step_state ");
Serial.println(step.getState());
}
void loop() {
}