BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – PULSOUT
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 347
PULSOUT
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
PULSOUT Pin, Duration
Function
Generate a pulse on Pin with a width of Duration.
• Pin is a variable/constant/expression (0 – 15) that specifies the I/O
pin to use. This pin will be set to output mode.
• Duration is a variable/constant/expression (0 – 65535) that specifies
the duration of the pulse. The unit of time for Duration is described
in Table 5.84.
Quick Facts
Table 5.84: PULSOUT Quick
Facts.
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
Duration units
10 µs 2 µs 2 µs 0.8 µs 0.8 µs 2 µs 0.8 µs
Maximum
Pulse Width
655.35 ms 131.07 ms 131.07 ms 52.428 ms 52.428 ms 131.07 ms 52.428 ms
Related
Command
PULSIN
Explanation
PULSOUT sets Pin to output mode, inverts the state of that pin; waits for
the specified Duration; then inverts the state of the pin again; returning the
bit to its original state. The unit of Duration is described in Table 5.84. The
following example will generate a 100 µs pulse on I/O pin 7 (of the BS2):
PULSOUT 7, 50 ' generate 100 us pulse on P7
The polarity of the pulse depends on the state of the pin before the
command executes. In the example above, if pin 7 was low, PULSOUT
would produce a positive (high) pulse. If the pin was high, PULSOUT
would produce a negative (low) pulse.
If the pin is an input, the output state bit, OUT7 (PIN7 on the BS1) won’t
necessarily match the state of the pin. What happens then? For example:
pin 7 is an input (DIR7 = 0) and pulled high by a resistor as shown in
Figure 5.29a. Suppose that pin 7 is low when we execute the instruction:
PULSOUT 7, 5 ' generate pulse on P7
NOTE: Expressions are not allowed as
arguments on the BS1. The range of
the Pin argument on the BS1 is 0 – 7.
C
ONTROLLING THE POLARITY OF THE
PULSE
.
W
ATCH OUT FOR UNDESIRABLE PULSE
GLITCHES
.
1
A
ll
2
1