Retrieves the value of a resistor or a capacitor.


var = GETRC( pin )


var The variable that receives the value.
pin The port pin the R/C is connect to.
This function uses TIMER0.

See also

' retrieve resistor value
' Connect 10KOhm variable resistor from +5V to P1.7 for this example
' Connect 10nF capacitor from P1.7 to ground
' The GETRC(pin) function measures the time needed to charge the capacitor

Config Timer0 = Timer , Gate = Internal , Mode = 1 'the GETRC() functions needs timer 0
$baud = 9600 'just my settings
$crystal = 11059200
Dim W As Word 'alloc space vor variable

Do 'forever
W = Getrc(p1.7) 'get RC value
Print W 'print it
Wait 1 'wait a moment

'return values for cap=10nF .The resistor values where measured with a DVM

' 250 for 10K9
' 198 for 9K02
' 182 for 8K04
' 166 for 7K
' 154 for 6K02
' 138 for 5K04
' 122 for 4K04
' 106 for 3K06
' 86 for 2K16
' 54 for 1K00
' 22 for 198 ohm
' 18 for 150 ohm
' 10 for 104 ohm
' 6 for 1 ohm (minimum)

'As you can see there is a reasonable linearity

'So you can do some math to get the resistor/capacitor value
'But the function is intended to serve as a rough indication for resistor values
'You can also change the capacitor to get larger values.
'With 10nF, the return value fits into a byte
'Of course, the R or the C value must be known in order to calculate the other value.