Controlling by goto


A command goto is for controlling a stepper motor based on the initial position, not the current position of the motor.
This method can be used even when the motor is running.

"goto [sign](pos) [speed] [accel] [decel]"

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

Descriptions of the arguments are as follows:

argument description mandatory/optional
sign direction, "+"(forward) or "-"(reverse) optional(default: "+")
pos target counter position mandatory
speed speed(unit: pps) optional
accel acceleration(unit: pps/s) optional
decel deceleration(unit: pps/s) optional

The argument pos is based on the initial position, not the current position of the counter.

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, "set pos -400");

spc_request_dev($sid, "goto +400 200 0");
sleep(1);
spc_request_dev($sid, "goto -400 200 0");
sleep(1);
spc_request_dev($sid, "goto +400 200 0");
while((int)spc_request_dev($sid, "get state"))
    usleep(1);
?>

※ This command can be used even when stepper motor is in operation. Therefore, if a new goto command is executed while the motor is running, it is executed immediately.