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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compilerstops. With the circuit in figure A, the voltage will start at 0V and riseto 1.5V (spanning only 1.5V) before RCIN stops.For the same combination of R and C, the circuit shown in figure Awill produce a higher result, and therefore more resolution than figureB.Before RCIN executes, the capacitor must be put into the state specifiedin the RCIN command. For example, with figure B, the capacitormust be discharged until both plates (sides of the capacitor) are at 5V.It may seem strange that discharging the capacitor makes the inputhigh, but you must remember that a capacitor is charged when thereis a voltage difference between its plates. When both sides are at +5Volts, the capacitor is considered discharged.Below is a typical sequence of instructions for the circuit in figure A.DIM Result as WORDHIGH PORTB.0DELAYMS 1Result = RCIN PORTB.0 , HighPRINT @Result , “ “' Word variable to hold result.' Discharge the cap' Wait for 1 ms.' Measure RC charge time.' Display the value on an LCD.Using RCIN is very straightforward, except for one detail: For a givenR and C, what value will RCIN return? It’s actually rather easy to calculate,based on a value called the RC time constant, or tau (τ) forshort. Tau represents the time required for a given RC combination tocharge or discharge by 63 percent of the total change in voltage thatthey will undergo. More importantly, the value τ is used in the generalizedRC timing calculation. Tau’s formula is just R multiplied by C: -τ = R x CThe general RC timing formula uses τ to tell us the time required foran RC circuit to change from one voltage to another: -time = -τ * ( ln (Vfinal / Vinitial ) )In this formula ln is the natural logarithm. Assume we’re interested ina 10k resistor and 0.1µF cap. Calculate τ: -τ = (10 x 10 3 ) x (0.1 x 10 -6 ) = 1 x 10 -3The RC time constant is 1 x 10 -3 or 1 millisecond. Now calculate thetime required for this RC circuit to go from 5V to 1.5V (as in figure B):Time = -1 x 10 -3 * ( ln(5.0v / 1.5v) ) = 1.204 x 10 -3106Copyright Crownhill 2001

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

Saved successfully!

Ooh no, something went wrong!