PULSOUT

BS1 icon BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

PULSOUT Example

 

 

 

Syntax: PULSOUT Pin, Duration

Function

Generate a pulse on Pin with a width of Duration.

* Note: expressions are not allowed as arguments on the BS1. The range of the Pin argument on the BS1 is 0–7.

Quick Facts

  BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
Units in Variable 10 µs 2 µs 2 µs 0.8 µs 0.8 µs 2 µs 0.81 µs
Maximum pulse width 655.35 ms 131.07 ms 131.07 ms 52.428 ms 52.428 ms 123.6 ms 53.08 ms
Related Commands

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 above. The following example will generate a 100 µs pulse on I/O pin 5:

  PULSOUT 5, 50                         ' generate a pulse on pin 5

The polarity of the pulse depends on the state of the pin before the command executes. In the example above, if pin 5 was low, PULSOUT would produce a positive pulse. If the pin was high, PULSOUT would produce a negative pulse.

If the pin is an input, the output state bit, OUT5 (PIN5 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 below. Suppose that pin 7 is low when we execute the instruction:

  PULSOUT 7, 5                          ' generate a pulse on pin 7

The figure below shows the sequence of events on that pin. Initially, pin 7 is high. Its output driver is turned off (because it is in input mode), so the 10 kΩ resistor sets the state on the pin. When PULSOUT executes, it turns on the output driver, allowing OUT7 (PIN7 on the BS1) to control the pin.

 

Since OUT7 (PIN7 on the BS1) is 0, the pin goes low when made an output. After a few microseconds of preparation, PULSOUT inverts the state of the pin; from low to high. It leaves the pin in that state for the specified time (10µs if using a BS2) and then inverts it again, leaving the pin in its original (output) state.

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012