11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerUsing a 20MHz crystal, the unit of time is 2µs, that time (1.204 x 10 -3 )works out to 602 units. With a 10k resistor and 0.1µF capacitor, RCINwould return a value of approximately 600. Since Vinitial and Vfinal don'tchange, we can use a simplified rule of thumb to estimate RCIN resultsfor circuits similar to figure A: -RCIN units = 600 x R (in kΩ) x C (in µF)Another useful rule of thumb can help calculate how long tocharge/discharge the capacitor before RCIN. In the example shown,that’s the purpose of the HIGH and DELAYMS commands. A givenRC charges or discharges 98 percent of the way in 4 time constants(4 x R x C).In both circuits, the charge/discharge current passes through a 220Ωseries resistor and the capacitor. So if the capacitor were 0.1µF, theminimum charge/discharge time should be: -Charge time = 4 x 220 x (0.1 x 10 -6 ) = 88 x 10 -6So it takes only 88µs for the cap to charge/discharge, which meansthat the 1ms charge/discharge time of the example is more than adequate.You may be wondering why the 220Ω resistor is necessary at all.Consider what would happen if resistor R in figure A were a pot, andwas adjusted to 0Ω. When the I/O pin went high to discharge the cap,it would see a short direct to ground. The 220Ω series resistor wouldlimit the short circuit current to 5V/220Ω = 23mA and protect the PICfrom any possible damage.See also :ADIN, POT107Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!