10F222 ADC Problem


Closed Thread
Results 1 to 8 of 8
  1. #1

    Default 10F222 ADC Problem

    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

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    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.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

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

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Tobias View Post
    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.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    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).

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    missed that ADCON line rusty you said
    Last edited by mister_e; - 30th October 2008 at 03:32.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Thanks, that fixed the problem.

    Quote Originally Posted by skimask View Post
    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.

Similar Threads

  1. ADC or ADCIN "bias" problem?
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2010, 19:39
  2. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  3. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. ADC problem
    By NacNud in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th December 2004, 02:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts