脉冲输出模式


此模式是输出脉冲波的模式。在脉冲输出模式可使用的命令如下。

命令 下级命令 说明
set mode output pulse set mode: pulse
div ms set unit: millisecond
us set unit: microsecond
output od open-drain
pp push-pull
low output: LOW
high output: HIGH
invert 0 not invert output
1 invert output
count [T1] [T2] set output timing parameters
repc [N] set repeat count
trigger from ht0 set trigger target: ht0
php set trigger target: none
reset - reset
get state get current state
div get division rate
repc get remaining repeat count
start - start
stop - stop

输出设定

HT的输出设定有如下项目。

下级命令 语法
open-drain pid_ioctl($pid, "set output od");
push-pull pid_ioctl($pid, "set output pp");
output HIGH pid_ioctl($pid, "set output high");
output LOW pid_ioctl($pid, "set output low");
invert output pid_ioctl($pid, "set output invert 1"); // inverted output
pid_ioctl($pid, "set output invert 0"); // normal output

所有输出模式的命令在实行行的同时反映在输出针。

设定反复次数

反复次数决定输出信号的输出次数。可设定的N的范围是0至64。 基本值为0,0指最大可反复次数64。

命令 语法
set repc pid_ioctl($pid, "set repc N");

计数值设定

为了调整输出时间使用计数设定。在脉冲输出模式下计数值设定范围如下。

命令 语法
set count pid_ioctl($pid, "set count T1 T2");

在脉冲输出模式下可设定的计数值如下。

区分 可设定值
T1 1 ~ 32763
T2 1 ~ 32763
T1 + T2 2 ~ 32764

在脉冲输出模式需要两个计数值(T1和 T2T)的设定。在脉冲输出模式下反复次数为2时T1和T2的时间如下。

ht_set_pulse_01

脉冲输出模式使用例

脉冲输出模式的使用 (HIGH pulse)

$pid = pid_open("/mmap/ht0");               // open HT 0
pid_ioctl($pid, "set div us");              // set unit: microsecond
pid_ioctl($pid, "set mode output pulse");   // set mode: pulse
pid_ioctl($pid, "set count 1 2");           // set count values: 1, 2
pid_ioctl($pid, "set repc 1");              // set repeat count: 1
pid_ioctl($pid, "start");                   // start HT
while(pid_ioctl($pid, "get state"));
pid_close($pid);

脉冲输出模式的基本模式是high。维持high状态的时间依据设定时间的单位与通过"set count"设定的(T1和T2)来被决定。 实行上面的例子时HT输出结果如下。

ht_set_pulse_02

脉冲输出模式的使用 (LOW pulse)

$pid = pid_open("/mmap/ht0");               // open HT 0
pid_ioctl($pid, "set div us");              // set unit: microsecond
pid_ioctl($pid, "set mode output pulse");   // set mode: pulse
pid_ioctl($pid, "set count 1 2");           // set count values: 1, 2
pid_ioctl($pid, "set repc 1");              // set repeat count: 1
pid_ioctl($pid, "set output invert 1");     // invert output
pid_ioctl($pid, "start");                   // start HT
while(pid_ioctl($pid, "get state"));
pid_close($pid);

实行"set output invert 1"命令以后的输出将被逆转。脉冲输出也被逆转,实行上面的例子时,HT的输出结果如下。

ht_set_pulse_03