You can use spc_request_dev or spc_request_sys function when setting or using a smart expansion board.
spc_request_dev($sid, $cmd)
spc_request_sys($sid, $cmd)
Common commands can be used with spc_request_sys function and a list of the commands is as follows:
Command | Option | Description |
---|---|---|
get | did | get a device ID |
get | uid | get a unique ID |
Dedicated commands for each smart expansion board can be used with spc_request_dev. A list of dedicated commands for PES-2404 is as follows:
cmd | arg1 | arg2 | arg3 |
---|---|---|---|
pwm | set | pol | (+ or -) |
dir | (+ or -) | ||
period | (1 ~ 1000000) | ||
width | (1 ~ 1000000) | ||
decay | (fast or slow) | ||
enc | set | pol | (+, - or 0) |
pos | (-1000000000 ~ +1000000000) | ||
psr | (1 ~ 64) | ||
get | pos | - | |
period | - | ||
lpf | set | freq | n |
pnc | n | ||
get | pnc | - |
When creating a command string using the above commands, you must specify the port number of the DC motor at the beginning of the string. Port 1 uses dc1 and port 2 uses dc2. The following is an example of a command string.
"dc1 pwm set pol +"
"dc2 enc set pos 500"