确认状态


为了确认步进电机当前状态的命令是get

确认步进电机动作状态

确认步进电机的动作状态的命令是state

"get state"

返还的动作状态的种类如下。

返还值 状态
0 stopped
1 control locked
otherwise running
<?php
include_once "/lib/sd_spc.php";

spc_reset();
spc_sync_baud(115200);

$sid = 1;
spc_request_dev($sid, "set mode full");
spc_request_dev($sid, "set vref stop 2");
spc_request_dev($sid, "set vref drive 8");
spc_request_dev($sid, "set speed 400");
spc_request_dev($sid, "set accel 800");
spc_request_dev($sid, "set rsnc 120 250");

$state = 0;
spc_request_dev($sid, "move 400");
while($state = (int)spc_request_dev($sid, "get state"))
{
  echo "state: $state\r\n";
  usleep(200000);
}
echo "state: $state\r\n";
?>
state: 3
state: 2
state: 2
state: 2
state: 2
state: 2
state: 2
state: 0

确认计数位置

当前确认计数位置的命令是pos

"get pos"

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

spc_reset();
spc_sync_baud(115200);

$pos = -400;
$sid = 1;
spc_request_dev($sid, "set mode full");
spc_request_dev($sid, "set vref stop 2");
spc_request_dev($sid, "set vref drive 8");
spc_request_dev($sid, "set speed 400");
spc_request_dev($sid, "set accel 800");
spc_request_dev($sid, "set rsnc 120 250");
spc_request_dev($sid, "set pos $pos");

spc_request_dev($sid, "goto 400");
while((int)spc_request_dev($sid, "get state"))
{
    $pos = (int)spc_request_dev($sid, "get pos");
  echo "position: $pos\r\n";
  usleep(200000);
}
?>
position: -315
position: -233
position: -151
position: -68
position: 14
position: 96
position: 178
position: 260
position: 338
position: 392

确认数字输入端口的状态

为了确认数字输入端口的当前状态的命令是eio get

"eio get (p) input"

p指输入端口的ID(0 ~ 3)。 返还的输入端口状态种类如下。

value state
0 LOW
1 HIGH (default)
<?php
include_once "/lib/sd_spc.php";

spc_reset();
spc_sync_baud(115200);

$sid = 1;
while(1)
{
    echo spc_request_dev($sid, "eio get 0 input");
    echo spc_request_dev($sid, "eio get 1 input");
    echo spc_request_dev($sid, "eio get 2 input");
    echo spc_request_dev($sid, "eio get 3 input");

    echo "\r\n";
    sleep(1);
}
?>
1111  
0110  
...omitted...