This mode is used to precisely generate rectangular wave, which can be a single pulse or a chain of pulses with various durations. In this mode, HT pin is toggled after each predefined time durations.
Waveform of HT pin will depend on:
Command | Sub Command | Description | |||
---|---|---|---|---|---|
set | mode | output | toggle | set mode: toggle | |
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] ... [T8] | 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 toggle mode, this command is used to set the number of times of toggling.
Command | Syntax | Valid 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)
In output toggle mode, this command is used to specify list of time duration that right after the time duration is elapsed, output signal at HT pin is toggled. The unit of time is specified in "set div" command. The number of the time duration ranges from one to eight. Valid value for each time duration is from 1 to 32764.
Command | Syntax | Valid range of each T |
---|---|---|
set count | pid_ioctl($pid, "set count T1 T2 … T8"); | 1 to 32764 |
This command must be used before timer starts. If not, an error is generated. The list of duration time is used in circular order if the number of times of toggling exceeds the number of the specified time duration. The figure below shows waveform in the case of:
Note that: Waveform is depended on the states of HT pin at the time timer starts. The following example depicts the different signal when states of HT pin at the time timer start are different. The number of toggling times is three. Time durations between two consecutive toggles are T1, T2 and T3, respectively.
State of HT pin can be:
Time durations between two consecutive toggles can be set by using "set count" command.
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.
Invert mode is disabled by default.
The following example depicts the different signal when invert mode is disabled and enabled. The number of toggling time is three. Duration time between two consecutive toggles are T1, T2 and T3, respectively. "set output high" command is used before timer starts.
As shown in above figure, when invert mode is enabled, "set output high" command forces HT pin signal to LOW.
<?php
$pid = pid_open("/mmap/ht0"); // open HT 0
pid_ioctl($pid, "set div us"); // set unit: microsecond
pid_ioctl($pid, "set mode output toggle"); // set mode: toggle
pid_ioctl($pid, "set repc 1"); // set repeat count: 1
pid_ioctl($pid, "set count 1"); // set count T1: 1
pid_ioctl($pid, "start"); // start HT
while(pid_ioctl($pid, "get state"));
pid_close($pid);
?>
The meaning of "set count" is amount of time between starting HT and output toggle signal. The figure below shows waveform of the above example.
<?php
$pid = pid_open("/mmap/ht0"); // open HT 0
pid_ioctl($pid, "set div us"); // set unit: microsecond
pid_ioctl($pid, "set mode output toggle"); // set mode: toggle
pid_ioctl($pid, "set repc 3"); // set repeat count: 3
pid_ioctl($pid, "set count 1 2 1"); // set count values: 1, 2 and 1
pid_ioctl($pid, "start"); // start HT
while(pid_ioctl($pid, "get state"));
pid_close($pid);
?>
In the example above, three count values (T1, T2 and T3) are set and those are 1, 2 and 1 microsecond. The waveform of HT output is as follows: