This mode is used to precisely generate rectangular wave, which can be a single pulse or a chain of pulses. The pulses are identical to each other.
Waveform of HT pin will:
Command | Sub Command | Description | |||
---|---|---|---|---|---|
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 |
In output pulse mode, this command is used to set the number of pulses.
Command | Syntax | Vaild range of N |
---|---|---|
set repc | pid_ioctl($pid, "set repc N"); | 0 to 64 |
If the command is not used, the default value is zero.
Setting this value to zero means the maximum repeat count (64).
(see example of waveform in "Set Count Values" section)
A rectangular pulse is composed of high-level signal and low-level signal. In output pulse mode, this command is used to specify the durations signal stays in low-level and high-level during a pulse. The unit of time is specified in "set div" command.
Command | Syntax |
---|---|
set count | pid_ioctl($pid, "set count T1 T2"); |
Valid values for T1 and T2 in pulse mode are as follows:
Division | Available Count Values |
---|---|
T1 | 1 ~ 32763 |
T2 | 1 ~ 32763 |
T1 + T2 | 2 ~ 32764 |
This command must be used before timer starts.
If not, an error is generated.
The figure below shows waveform in the case of:
This command immediately forces HT pin to LOW or HIGH.
Command | Syntax | Description |
---|---|---|
set output low | pid_ioctl($pid, "set output low"); | Set HT pin to LOW |
set output high | pid_ioctl($pid, "set output high"); | Set HT pin to HIGH |
Note that if invert mode is enabled, this command will force HT pin to the state that is invert of normal operation.
This command set output type of HT pin
Command | Syntax | Description |
---|---|---|
set output pp | pid_ioctl($pid, "set output pp"); | Set output type to push-pull |
set output od | pid_ioctl($pid, "set output od"); | Set output type to open-drain |
If the command is not used, the output type of HT pin is push-pull by default.
This command is used to enable/disable invert mode.
Command | Syntax | Description |
---|---|---|
set output invert 0 | pid_ioctl($pid, "set output invert 0"); | disbale invert mode |
set output invert 1 | pid_ioctl($pid, "set output invert 1"); | enable invert mode |
When invert mode is enabled:
When the invert mode is changed (from enabled to disabled or vice versa), HT pin is toggled immediately.
In other words, this command specifies the form of pulse.
There are two forms of pulse:
invert mode is disabled
Invert mode is disabled by default.
<?php
$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);
?>
Pulse mode basically changes level from low to high. The timing of change depends on both division rate and count values (T1 and T2). The figure below shows waveform of the example above.
<?php
$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);
?>
After executing the command line "set output invert 1", all output levels are inverted including a pulse output. The figure below shows waveform of the example above.