The control lock is a kind of physical protection function. This function is to connect a limit switch to the digital input port and disable further control if the switch is closed. Therefore, the operating range of the stepper motor can be limited.
If the operation of the motor is stopped by the limit switch, the motor status is locked and no further control is possible until the lock is released.
Set the input mode of the digital input port referring to Settings chapter.
A command unlock is for releasing the state of control lock.
When you execute the unlock command, the motor status changes from the locked state to the stopped state and the input mode of the digital input port is reset to the normal input mode from the control lock mode.
That means you can control the motor normally after executing unlock.
<?php
include_once "/lib/sd_spc.php";
spc_reset();
spc_sync_baud(115200);
$sid = 1;
spc_request_dev($sid, "set vref stop 2");
spc_request_dev($sid, "set vref drive 8");
spc_request_dev($sid, "set vref lock 8");
spc_request_dev($sid, "set mode 4");
spc_request_dev($sid, "eio set 0 mode lock");
spc_request_dev($sid, "eio set 1 mode lock");
spc_request_dev($sid, "eio set 2 mode lock");
spc_request_dev($sid, "eio set 3 mode lock");
spc_request_dev($sid, "move 4000 400 4000");
while((int)spc_request_dev($sid, "get state") > 1)
usleep(1);
// state: 0 - stop, 1 - locked
echo "step_state ", spc_request_dev($sid, "get state"), "\r\n";
spc_request_dev($sid, "unlock");
// state: 0 - stop, 1 - locked
echo "step_state ", spc_request_dev($sid, "get state"), "\r\n";
?>
step_state 1
step_state 0