Controlling by move


A command move is for controlling a stepper motor based on the current position of the motor.
This method is only available when the motor is stopped.

"move [sign](step) [speed] [accel] [decel]"

※ Caution: there is no space between [sign] and (step)

Descriptions of the arguments are as follows:

argument description mandatory/optional
sign direction, "+"(forward) or "-"(reverse) optional(default: "+")
step the number of steps to move mandatory
speed speed(unit: pps) optional
accel acceleration(unit: pps/s) optional
decel deceleration(unit: pps/s) optional

The argument step is based on the current position of the motor.

If the decel(deceleration) is omitted, it is automatically set to the same value of the acceleration.

<?php
include_once "/lib/sd_spc.php";

spc_reset();
spc_sync_baud(115200);

$sid = 1;
spc_request_dev($sid, "set mode 4");
spc_request_dev($sid, "set vref stop 2");
spc_request_dev($sid, "set vref drive 8");
spc_request_dev($sid, "set rsnc 120 250");

spc_request_dev($sid, "move 800 400 800 0");
while((int)spc_request_dev($sid, "get state"))
  usleep(1);

sleep(1);

spc_request_dev($sid, "move -800 400 0 800");
while((int)spc_request_dev($sid, "get state"))
  usleep(1);
?>

※ This command can be used only when the stepper motor is stopped. So, as in the example above, always program the move command to run after the motor is stopped.