Shop OBEX P1 Docs P2 Docs Learn Events
How to implement Vref and Vin(-) on an ADC0831 ??? — Parallax Forums

How to implement Vref and Vin(-) on an ADC0831 ???

floodhoundfloodhound Posts: 45
edited 2007-05-25 21:11 in General Discussion
I needed some input on how the ADC0831 works when using V- and Vref.
·
For example: I was under the impression that if Vref = 3Volts and Vin(-) = 1Volt then I could read a span of 2 volts giving a 0-255 byte value. This is not the case though.
·
I found it a bit confusing that on page 197 of “Process and Control guide” that stated if Vin(-) is set to .7V and Vref is set to .5 volts the ADC will convert the range on .7 to 1.2V to a byte value of 0-255.
·
Could some one please explain to me in more detail how this is the case. I want to be able to read from 2V to 3V and still get a byte value from 0-255. I am also using the setup like this picture is showing.

picture11.JPG

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2007-05-24 00:23
    Vin(-) is the zero value (bottom end). Vref sets the span above Vin(-) that the ADC reads and divides into 256 parts. So Vin(-) + Vref = top end.

    So in the example, Vin(-) is 0.7 and Vref is 0.5 the the ADC reads from .7 to 1.2 (.7 + .5 = 1.2).

    Your Vin(+) needs to fall within that span.

    So for your 2 volts to 3 volts, you need to set Vin(-) to 2 volts and Vref to 1 volt. then your range is 2 to 3 volts (2 +1=3).

    The voltage you want to measure must then be between 2 and 3 volts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • KatyBriKatyBri Posts: 171
    edited 2007-05-24 00:41
    Floodhound-

    What temp sensor are you using and when you get your ADC working, could you post your code? Thanks.
  • floodhoundfloodhound Posts: 45
    edited 2007-05-24 15:31
    Thanks again, I kind of figure this to be the case I just wanted it to be clear to me, again thanks a million. Now since I could not sleep last night I have to ask - What is the closest I can set Vref and Vin(-)? At the current I am stated I needed 2 – 3 volts and it is working great, but what if I need to get a better resolution? I have set up the ADC0831 so that I can change the Voltages for “ Vref and Vin(-) “ on the fly so I just need to know my limits. Can I set Vref say to 2.001 and Vin(-) to 2.10 for example?

    I am using an LM235 and my code for this bit of hardware is:

    [noparse][[/noparse]code]

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}


    '######################################################################################
    '######################################################################################

    ADC_CS PIN 15
    ADC_CL PIN 14
    ADC_DO PIN 13
    ADC_PW1 PIN 11
    ADC_PW2 PIN 12

    ADC_RESULT VAR Word

    '######################################################################################
    '######################################################################################

    MAIN:
    HIGH 0 'Power LED on this pin
    GOSUB SET_AD
    GOSUB READ_AD
    GOSUB DISPLAY_IT
    PAUSE 10

    GOTO main

    '######################################################################################
    '######################################################################################

    SET_AD:
    'soon add offset allowing for the ability to zoom in on a temp for better resoluition
    PWM ADC_PWM, 104, 255 '2v Vin(-)works good for now
    PWM ADC_PW2, 75, 255 '1V Vref settings
    RETURN


    '######################################################################################
    '######################################################################################

    READ_AD:
    LOW ADC_CS
    SHIFTIN ADC_DO, ADC_CL, MSBPOST, [noparse][[/noparse]ADC_RESULT\9]
    HIGH ADC_CS
    RETURN

    '######################################################################################
    '######################################################################################

    DISPLAY_IT:
    DEBUG CLS, HOME, "TEMP IS-- " , DEC ADC_RESULT
    RETURN

    [noparse][[/noparse]\code]
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-05-24 16:54
    I'm not sure because it's been a while since I read the data sheet, but I think Vin and Vref have to be at least 1 volt apart, so you could get down to 4 millivolt resolution. That's pretty small. If you need more you may need to go to a 10 or 12 bit ADC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
  • floodhoundfloodhound Posts: 45
    edited 2007-05-24 17:13
    I am sorry but i am reading the data sheet and i can not locate the information. I agree though that 1 volt is a great value. Thanks again i just hope you remembered correctly. [noparse]:)[/noparse]
  • RDL2004RDL2004 Posts: 2,554
    edited 2007-05-25 21:11
    I couldn't find it either. I must have been thinking of how it goes non-linear with a Vref below 1 volt.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Rick
Sign In or Register to comment.