MPXA4115A picbasic code


Closed Thread
Results 1 to 40 of 104

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Mel

    I found that in the MAX 1241 datasheet:


    Output Coding and Transfer Function

    The data output from the MAX1240/MAX1241 is binary,
    and Figure 10 depicts the nominal transfer function.
    Code transitions occur halfway between successiveinteger
    LSB values. If VREF = +2.500V, then 1 LSB =
    610μV or 2.500V/4096
    This is not the first ADC datasheet where i've found that ...

    from MAX 187


    Output Coding and Transfer Function

    The data output from the MAX187/MAX189 is binary,
    and Figure 10 depicts the nominal transfer function.
    Code transitions occur halfway between successive
    integer LSB values. If VREF = +4.096V, then
    1 LSB = 1.00mV or 4.096V/4096.
    From MCP 3202


    4.2 Digital Output Code

    The digital output code produced by an A/D Converter
    is a function of the input signal and the reference voltage.
    For the MCP3202, VDD is used as the reference
    voltage. As the VDD level is reduced, the LSB size is
    reduced accordingly. The theoretical digital output code
    produced by the A/D Converter is shown below.
    where:
    VIN = analog input voltage
    VDD = supply voltage
    Digital Output Code = 4096 * VIN / VDD
    From MIC 640 ( a pre-programmed 12F675 )


    · Résultat = 256 x VIN/VCC où VIN est la tension d’entrée et où résultat est arrondi à
    l’entier le plus proche.
    Ainsi par exemple, si VCC = 5 volts et VIN = 3,5 volts, le résultat de la conversion sera :

    Résultat = 256 x 3,5 / 5 = 179,2 arrondi donc à 179 soit encore B3 en hexadécimal.
    so, I'm a bit confused, here ...

    Regards
    Alain
    Last edited by Acetronics2; - 17th May 2009 at 11:49.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I'm sorry, bit I'm going to 'DISAGREE' with them ALL...

    Common sense...

    Let's go to the extreeme... a ONE BIT ADC... (the kind every PIC has on every I/O Channel)...

    Are you going to consider your I/O pin as having TWO states ZERO and ONE?

    Well, I suppose it has got two states... so the 'ADC' range is 0-1.

    So therefore whenever I use TWO in my calculations I can never get any more than 50% of the true answer? So with 5v as my VREF, I'll never get more than 2.5v in the calculations with an input state of 1. I must get an input state of 2 before I get 5v... Kinda tough getting 2 out of 1 bit!!!!!!!!

    Are you dividing your 'cake' into 1023 or 1024 portions?

    Is your range 1024 portions ie 1/1024 all the way to 1024/1024??? No it's not because 1024 is an INVALID number, you NEVER get 1024 out of your ADC... your range is 1/1023 all the way to 1023/1023 because 0/1023 although being the 1024th value is not counted when dealing with mathematical equations.

    Taking what you read as Gospel without question is what crashes Mars Landers...

    Yes... this is a 'simplistic' view, because many chips have peculiarities which have to be additionally accounted for (like for example not being true rail-to-rail)... what I am arguing is pure mathematics here.

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Melanie,

    I usually illustrate this with a short staircase of 4 equal steps. The bottom level is 0 and the top is 4. While there are 5 levels (0-4), there are only 4 steps (or intervals) each of which is 1/4 of the total height. It you let people draw and number it themselves, it sticks with them longer.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Gosh ...

    One more manufacturer ( Linear ) in error ?? ...



    But here ... he shows output number vs input voltage


    look at this joined piece of datasheet ...

    Code "1023" is NOT corresponding to Vref ... but Vref MINUS one LSB ...

    so ... Vref corresponds to code "1024" !!! and there are 1024 steps, the "1024" value never being displayed ...

    May be the explanation is here ...

    Alain
    Attached Images Attached Images
    Last edited by Acetronics2; - 17th May 2009 at 13:30.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Well, in this instance ADCMAX is correct because VREF is never attainable.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Mel

    ...

    and I do think it's the same for all the manufacturers ...

    just have a look to µChip AN 544d ... or the Midrange Manual ... they all show code $3FF for 1023 LSB ... not Vref , which is 1024 x LSB ! ( see § 23.12 )

    Would be interesting to verify which input voltage give code 255 for a 2.56v ref ( quite simple !) , ... give code 4095 for a 4.096 v Vref ( less simple ), etc, etc.

    don't you think ???

    Regards
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I agree with Melanie.

    Let's forget about what the overpaid engineers and datasheets have said, and look at it from purely a results perspective.

    With 10-bit A/D the resulting values go from 0 - 1023.
    If Vref=5.00V and you apply 5.00 volts to the A/D you get a reading of 1023.

    If you then use 1024 as the Vref divisor, the formula to calc the Voltage from the A/D reading would be ...

    5.00/1024 * 1023 = 4.99 ; Not the 5V we were looking for.

    But if you use 1023 ...

    5.00/1023 * 1023 = 5.00 ; this is what I want it to read.
      Notice how the (/1023 * 1023) cancels out.

    In the context of this thread, the results are similar.
    If the manufacturer states a pressure of 115kPa at 4.7V ... using 1024 with a 4.7V input, you will only read 114.xxkPa, again not the reading we wanted.

    So for this (and any other analog projects), I'll continue using the maximum ADC value for the divisor (255, 1023, 4095).
    <br>
    DT

Similar Threads

  1. sample code for AT45DB642D in Picbasic Pro
    By itsssyam in forum General
    Replies: 0
    Last Post: - 10th March 2010, 07:01
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 15:17
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 19:31
  4. PicBasic code problems with a 16F84A
    By Lauren Barta in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 23:50
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 11:04

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