5: BASIC Stamp Command Reference – PWM
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 249
voltage setting established by PWM. Keep in mind that leakage currents
of up to 1 µA can flow into or out of this “disconnected” pin. Over time,
these small currents will cause the voltage on the capacitor to drift. The
same applies for leakage current from an op-amp’s input, as well as the
capacitor’s own internal leakage. Executing PWM occasionally will reset
the capacitor voltage to the intended value.
PWM charges the capacitor; the load presented by your circuit discharges
it. How long the charge lasts (and therefore how often your program
should repeat the PWM command to refresh the charge) depends on how
much current the circuit draws, and how stable the voltage must be. You
may need to buffer PWM output with a simple op-amp follower if your
load or stability requirements are more than the passive circuit of Figure
5.27 can handle.
The term “PWM” applies only loosely to the action of the BASIC Stamp's
PWM command. Most systems that output PWM do so by splitting a
fixed period of time into an on time (1) and an off time (0). Suppose the
interval is 1 ms and the duty cycle is 100 / 255. Conventional PWM would
turn the output on for 0.39 ms and off for 0.61 ms, repeating this process
each millisecond. The main advantage of this kind of PWM is its
predictability; you know the exact frequency of the pulses (in this case,
1 kHz), and their widths are controlled by the duty cycle.
BASIC Stamp's PWM does not work this way. It outputs a rapid sequence
of on/off pulses, as short as 1.6 µs in duration, whose overall proportion
over the course of a full PWM cycle of approximately a millisecond is
equal to the duty cycle. This has the advantage of very quickly zeroing in
on the desired output voltage, but it does not produce the neat, orderly
pulses that you might expect. The BS2, BS2e, BS2sx and BS2p also uses
this high-speed PWM to generate pseudo-sine wave tones with the
DTMFOUT and FREQOUT instructions.
H
OW
P
ULSE
-W
IDTH
-M
ODULATION IS
GENERATED
.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...