RCTIME - Urgent Help Needed
frage
Posts: 2
Hey, I' ve constructed a colour sensor which uses a differential op-amp to amplify the output·signal·and want to convert the analogue voltage to a digital valve using RCTIME. The output from the debug terminal was fixed at 18, and would not change with varying voltage.
Any help would be greatly appreciated
This is the code that i have been using:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'Prog 4G: Monitoring RCTime
Pot VAR Word· 'Variable to hold results
rc PIN 0
Main:
··· LOW rc··· 'Discharge network
··· PAUSE 1··· 'Time to fully discharge
··· RCTIME rc,0,Pot· 'Read charge time and store in Pot
··· DEBUG ? Pot··· 'Display value of Pot
··· PAUSE 500··· 'Short pause
GOTO Main··· 'Jump back to beginning
And this is the circuit setup:
[size=-1] 681 kohm 470 ohm
Vx ----/\/\/\---o
/\/\/\----P0 to stamp
unknown |+
voltage ===== 0.01 uF Cap
|
Vss[/size]
Post Edited (frage) : 2/17/2006 4:19:33 PM GMT
Any help would be greatly appreciated
This is the code that i have been using:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
'Prog 4G: Monitoring RCTime
Pot VAR Word· 'Variable to hold results
rc PIN 0
Main:
··· LOW rc··· 'Discharge network
··· PAUSE 1··· 'Time to fully discharge
··· RCTIME rc,0,Pot· 'Read charge time and store in Pot
··· DEBUG ? Pot··· 'Display value of Pot
··· PAUSE 500··· 'Short pause
GOTO Main··· 'Jump back to beginning
And this is the circuit setup:
[size=-1] 681 kohm 470 ohm
Vx ----/\/\/\---o
/\/\/\----P0 to stamp
unknown |+
voltage ===== 0.01 uF Cap
|
Vss[/size]
Post Edited (frage) : 2/17/2006 4:19:33 PM GMT
Comments
What RCTime does is wait until the capacitor is DIScharged below the voltage where the microcontroller
senses a Zero instead of One - (about 1.4 volts) . So the MOST you could do is sense something about the
voltage you are sourcing between 0 volts (Time = R*C) and 1.3999 volts (Where you would take a VERY long time to
dischage the capacitor.
What is the range of voltage your device puts out??
You probably need to add an Analog-to-digital converter...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards, Terry King ...On The Mediterranean in Carthage, Tunisia, North Africa
American Cooperative School of Tunis
terry@terryking.us
My sensor output is approximately 2 - 3 volts but can be amplifed to whatever is required.
I understand that rctime measures the time for the I/O pin to change state, as you said to go from 5v to 1.4 volts or from 0v to 1.3 as the capacitor is charged or discharged.
my question is if RC stays constant should n't rctime be affected by a changing voltage as this will also effect the charge time
Regards,
James
One possibility, IF your output values can be kept in the region of 2 to 3 (or preferably 3 to 4 or 3 to 5) then you
may be able to use the "Circuit B" version. The Help file says:
"With Circuit B, the voltage will start at 0V and rise to 1.4V (spanning only 1.4V) before RCTIME stops. For the same combination of R and C, Circuits A will yield a higher count, and therefore more resolution than Circuit B. "
If you connect your Voltage to be measured thru a suitable resistance to the I/O Pin, (Your source takes the place of "Vdd" in the diagram for option "B" in the Help), and use RCTIME in that mode where it measures CHARGE (up toward +) time, you may get useable data. You will have to calibrate the system for the values that mean something to you.
Give it a try??
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Regards, Terry King ...On The Mediterranean in Carthage, Tunisia, North Africa
American Cooperative School of Tunis
terry@terryking.us
emesystems.com/BS2rct.htm#B_voltage
It should work. It would be better if you can amplify the signal more, to a higher voltage range above the 1.4 volt threshold, simply because the RCTIME formula then will be simpler and the result will be more stable. I don't see anything wrong with your code. Recheck the wiring. What happens if you connect the top of the 681kohm resistor to +5 volts Vdd? On a BS2 the RCTIME reading should be around 1200 (2400 microseconds).
Is this sensor a photodiode? If so, you can dispense with the op amp transconductance (I->V) amplifier and use the photodiode in reverse bias mode directly in the RCTIME circuit. The charging of the capacitor is a then a linear function of current, not exponential, so it becomes easier to calculate exact results. And the circuit is simpler.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
· This is basically·the·state=1 circuit.· Test program incl. (no extra charge.)
· Go ahead and experiment with different values of C and the Emitter resistor.
Post Edited (PJ Allen) : 2/19/2006 4:14:08 PM GMT