This function sets a acceleration speed and a deceleration speed of a stepper motor.
step.setAccel(accel)
step.setAccel(accel, decel)
accel - a integer value which represents the acceleration speed in pps/s unit (~ 2400000)
decel - a integer value which represents the deceleration speed in pps/s unit (~ 2400000)
※ pps: pulse per second
none
#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);
// sets a acceleration speed and a deceleration spped
step.setAccel(800, 800);
step.setPosition(-400);
step.stepGoto(400);
delay(1000);
step.stepGoto(-400);
delay(1000);
step.stepGoto(400);
while(step.getState()) {
delay(1);
}
}
void loop() {
}