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, ST pin is toggled after each predefined time durations.
Waveform of ST pin will depend on:
A block diagram of ST in toggle mode is as follows:
Command | Sub Command | Description | |||
---|---|---|---|---|---|
set | mode | output | toggle | set mode: toggle | |
div | sec | set unit: second | |||
ms | set unit: millisecond | ||||
us | set unit: microsecond | ||||
output | od | open-drain | |||
pp | push-pull | ||||
low | output LOW | ||||
high | output HIGH | ||||
dev | uio0 | #pin | set output device and pin | ||
invert | 0 | not invert output | |||
1 | invert output | ||||
count | [T1] ... [T8] | set output timing parameters | |||
delay | [D] | set delay before output signal | |||
repc | [N] | set repeat count | |||
trigger | from | st# | set trigger target: st0 ~ st7 | ||
php | set trigger target: none | ||||
reset | - | reset | |||
get | state | get current state | |||
repc | get remaining repeat count | ||||
start | - | start | |||
stop | - | stop |
This command is for giving delay before PHPoC outputs signal. The unit of delay depends on the unit which is set by "set div" command.
Command | Syntax |
---|---|
set delay | pid_ioctl($pid, "set delay D"); |
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 1 billion |
If the command is not used, the default value is zero.
Setting this value to zero means the maximum repeat count (1 billion).
(see example of waveform in "Set Count Values" section)
This command is for defining point of time to output signal. In toggle mode, the valid number of count value ranges from one to eight. How to use this command is as follows:
Command | Syntax |
---|---|
set count | pid_ioctl($pid, "set count T1 T2 … T8"); |
Available values for counts in toggle mode are as follows:
Unit | Available Count Values (10㎲ ~ half an hour) |
---|---|
microsecond | 10 ~ 1,800,000,000 |
millisecond | 1 ~ 1,800,000 |
second | 1 ~ 1,800 |
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 ST pin at the time timer starts. The following example depicts the different signal when states of ST 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 ST pin can be:
LOW or HIGH, depending on the previous operation of timer (toggle, pulse, or PWM).
Time durations between two consecutive toggles can be set by using "set count" command.
Command | Syntax |
---|---|
set output dev D N | pid_ioctl($pid, "set output dev uio0 0"); |
Before using output mode of ST, you must use this command to specify the output pin. Set a device name (e.g. uio0) and a pin number to D and N.
This command immediately forces ST pin to LOW or HIGH.
Command | Syntax | Description |
---|---|---|
set output low | pid_ioctl($pid, "set output low"); | Set ST pin to LOW |
set output high | pid_ioctl($pid, "set output high"); | Set ST pin to HIGH |
Note that if invert mode is enabled, this command will force ST pin to the state that is invert of normal operation.
This command set output type of ST 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 ST 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), ST 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 ST pin signal to LOW.
This command is used when you want to synchronize an ST start time with another ST. Target of trigger should be one of ST devices.
Target | Syntax |
---|---|
ST(st0/1…) | pid_ioctl($pid, "set trigger from st0"); |
php | pid_ioctl($pid, "set trigger from php"); |
Default value of trigger target is "php"(no target).
Command "get repc" is for reading the remaining repeat count which will be executed.
Command | Syntax |
---|---|
get repc | pid_ioctl($pid, "get repc"); |
Toggle mode toggles output signals.
<?php
$pid = pid_open("/mmap/st0"); // open ST 0
pid_ioctl($pid, "set div sec"); // set unit: second
pid_ioctl($pid, "set mode output toggle"); // set mode: toggle
pid_ioctl($pid, "set output dev uio0 0"); // set output device / pin: uio0 / 0
pid_ioctl($pid, "set repc 1"); // set repeat count: 1
pid_ioctl($pid, "set count 1"); // set count: T1 only
pid_ioctl($pid, "start"); // start ST
while(pid_ioctl($pid, "get state"));
pid_close($pid);
?>
The meaning of "set count" is amount of time between starting ST and output toggle signal. The figure below shows waveform of the above example.
<?php
$pid = pid_open("/mmap/st0"); // open ST 0
pid_ioctl($pid, "set div sec"); // set unit: second
pid_ioctl($pid, "set mode output toggle"); // set mode: toggle
pid_ioctl($pid, "set output dev uio0 0"); // set output device / pin: uio0 / 0
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 ST
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 second. The waveform is as follows: