MPXA4115A picbasic code


Closed Thread
Results 1 to 40 of 104

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default

    Darrel,
    it is a very usefull calculator: thanks again.
    I will use a 5Vdc Vref+ and a divide by resistor divider for Vref-. Could it be OK ?
    Is there any possibility to compensate for the accuracy error ?
    ( I am not familiar with those sensors .. ).
    Thanks,
    regards,
    Ambrogio
    IW2FVO
    North Italy

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


    Did you find this post helpful? Yes | No

    Default

    Resistors will work fine.
    It's difficult to get exactly 3.0V using standard values, but with a 4.7K and 6.8K divider, you'll get about 2.96V. Use 1% or better resistors.

    These pressure sensors are "Ratiometric" which means that their output voltage changes proportionally to the power supply voltage. So using resistors allows the Vref to change with the power supply voltage too, which is a good thing. A voltage reference that does not change with PS differences can cause incorrect readings if VDD is not exactly 5.00V. Many 7805 type regulators will be anywhere from 4.85 to 5.15V

    For the accuracy, each sensor will be off by a different amount up to 1.8% of full scale.
    You would need to take readings from the sensor being used at both the high and low ends of the range, and compare them against values read by some other device that is known to be calibrated.

    The slope and intercept can then be recalculated for the measured values to create a new formula for that specific sensor. The calculations can be done with the PIC, but I wouldn't recommend it. Or you can do the calculation manually and just enter the slope and intercept into the PIC for that specific sensor.
    DT

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    And if you need more resolution - you can use an 18F8723. They have 12 bit A/D's.
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default

    I've updated the Calculator again to include a Calibration section at the bottom.

    Once you have test data for a sensor, it will calculate the new slope and intercept.
    Be sure to set the number of decimals at the top, it affects the calibration numbers.

    Cheers,
    DT

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Darrel

    This tool is becoming from good to better and better !

    Just one point :

    Don't you think, for a 10 bits ADC i.e., the LSB is Vref / 1024 and not Vref /1023 ???

    as 0 is 0v and 1023 is NOT Vref ( see µChip apps ...), but Vref x 1023/1024 ...


    Not so big an error ... but for those looking for the 224th bit error !!!

    and it is neater tho get exact 4 mv/bit for a 4.096 v ref. ...


    BTW ... I think ! ( yes ... I can ! ) ...

    What about a " Mouseover " on the graph to show the Pressure and AD Count values pointed at ???

    Regards

    Alain
    Last edited by Acetronics2; - 17th May 2009 at 09:52.
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Actually, it's 1024 bits, but you include ZERO, so the range is 0-1023.

    But your math is always divided by the MAXIMUM (Full Scale) value (which is 1023).

    That is because there are 1023 equal portions of whatever you are dividing up to make your whole. Zero is not a portion! I'd get the hump (big-time) if I went into Maison Alain (French Restaurant) and got the Zero portion of the Cream Cake!

  7. #7
    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 10: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 " !!!
    *****************************************

Similar Threads

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