How to read analog 0-1v signal
jbalat
Posts: 96
Is it possible, if so..
Is this on along a similar line to the RC time stuff ?
Is this on along a similar line to the RC time stuff ?
Comments
A little more information is needed to give you the proper solution.
Jim
Post Edited (hover1) : 2/1/2010 12:31:06 AM GMT
I just thought instead of using a pot I just use the 1v source with a lower resistor if any at all as per the standard rctime circuit with the capacitor ?
PUB Pot | potTime, M
' Configure counter module.
ctra[noparse][[/noparse]30..26] := %01000 ' Set mode to "POS detector"
ctra[noparse][[/noparse]5..0] := POT_PIN ' Set APIN to P0
frqa := 1 ' Increment phsa by 1 for each clock tick
repeat
' Charge RC circuit.
dira[noparse][[/noparse]POT_PIN] := outa[noparse][[/noparse]POT_PIN] := 1 ' Set pin0 to output-high
waitcnt(clkfreq/100_000 + cnt) ' Wait for circuit to charge
' Start RC decay measurement. It's automatic after this...
phsa~ ' Clear the phsa register
dira[noparse][[/noparse]POT_PIN]~ ' Pin to input stops charging circuit
waitcnt(clkfreq / 5 + cnt) ' Wait for Decay 1/5 second
' Get Time difference
potTime := (phsa - 624) #> 0
M := (potTime / 360) ' use a factor to get right voltage
waitcnt(clkfreq / 20 + cnt) ' Wait 1/20 second -> 10 Hz