确认状态


为了确认步进电机当前状态的命令是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 4");
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: 2
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 4");
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: -400
position: -376
position: -317
position: -235
position: -153
position: -70
position: 12
position: 94
position: 175
position: 258
position: 336
position: 391

确认数字输入端口的状态

为了确认数字输入端口的当前状态的命令是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...