PDA

View Full Version : 10F222 ADC Problem



Tobias
- 30th October 2008, 01:38
HI
I am using a 10f222 to monitor the value of a throttle position sensor (TPS).
0%-100%
When the 10F222 is not connected to the TPS, the TPS output is 4.00-2.18v
When the 10F222 is not connected to the TPS, the GPIO.0 has 3.9V
When the 10F222 is connected to the TPS, the TPS output is 3.99-3.89v.

So I don't know why GPIO.0 has 3.9v on it. When I do a debug, I can see the voltage, around 200 counts. Thats around 4v. What flag am I missing?


@ Device PIC10F222, IOFSCS_4MHZ, MCPU_OFF, WDT_OFF, PROTECT_OFF, MCLR_OFF
OPTION_REG.5=0
ADCON0 = 0
TRISIO =0
GPIO = 0

DEFINE DEBUG_REG GPIO 'SET DEBUG PIN PORT
DEFINE DEBUG_BIT 2 'SET DEBUG PIN BIT
DEFINE DEBUG_BAUD 9600 'SET DEBUG BAUD RATE
DEFINE DEBUG_MODE 1 'SET DEBUG MODE 0=TRUE / 1=INVERTED

Define ADC_BITS 8 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS

CR CON 13 'constant for carriage return
Throttle var word 'Stores ADC value
IRQ var GPIO.1 'Output for throttle state

Start:
ADCIN 0, Throttle
debug "Throttle = ", # Throttle ,13
If Throttle < 200 then
low IRQ
else
high IRQ
Endif
goto start

mister_e
- 30th October 2008, 01:53
If you leave AN0 floating, you'll pick up noise... if you place a pull-down on... TADA, no longer noise, your count should be=0

Tobias
- 30th October 2008, 03:06
I guess I need to rephrase the problem. The TPS values are incorrect when the 10F222 is attached to the output of the TPS. The TPS values really don't change much at all when attached, look at the TPS values when not attached. It varies appr 1.8 volts without the PIC attached to calculate the analogue level.

mister_e
- 30th October 2008, 03:17
I don't have a clue how TPS are made, but i have this feeling that you may need a buffer between the PIC and the sensor...

skimask
- 30th October 2008, 03:24
I guess I need to rephrase the problem. The TPS values are incorrect when the 10F222 is attached to the output of the TPS. The TPS values really don't change much at all when attached, look at the TPS values when not attached. It varies appr 1.8 volts without the PIC attached to calculate the analogue level.

You've got GPIO.0 set as a digital pin, and an output, and set logic low, so it's dragging down the TPS line.
Try configuring the pin correctly for what you are trying to do...
And since the ADC on the 10F222 is an 8bit result, there's no need for throttle to be a word.
BUT...since you're also DEFINE'ing ADC_xxxxx, this might be overriding everything you've just set up wrong.

skimask
- 30th October 2008, 03:25
I don't have a clue how TPS are made, but i have this feeling that you may need a buffer between the PIC and the sensor...
Usually, a TPS is just a pickup from a pot referenced to +5v/Gnd...usually...unless he's picking off the wrong wire (the 'top' of the pot if the phrase fits).

mister_e
- 30th October 2008, 03:28
missed that ADCON line :eek: rusty you said :eek:

Tobias
- 30th October 2008, 03:46
Thanks, that fixed the problem.


You've got GPIO.0 set as a digital pin, and an output, and set logic low, so it's dragging down the TPS line.
Try configuring the pin correctly for what you are trying to do...
And since the ADC on the 10F222 is an 8bit result, there's no need for throttle to be a word.
BUT...since you're also DEFINE'ing ADC_xxxxx, this might be overriding everything you've just set up wrong.