MPXA4115A picbasic code


Closed Thread
Results 1 to 40 of 104

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    The MPX4115A is a "Ratiometric" type of device. Which means that the output voltage is proportional to the power supply voltage.
    This is a great feature when using a PIC, because the PIC's A/D converter is also "Ratiometric".
    This way you will always get the same results from the sensor, even if your power supply isn't exactly 5.00V or if it drifts a little, like will happen with a battery operated device.

    If you try to measure a ratiometric device using a fixed voltage reference ... as the VDD voltage changes, your pressure reading will change too. So you've lost that nice stable signal that a ratiometric sensor gives you.

    I don't think you should use a VREF+ at all.<hr>

    Quote Originally Posted by bitmaniac
    Using Darrel code for 14bit convertion I have problems with servo in / out routine. Using pulsin/pulsout to re-generate servo signals although normal servo response ok (a little bit jerky motion) when it comes to use Speed controller to ontrol brushless motor it does not seem to respond at all. If I disable Darrel convertion routine SC workink ok.
    Trying to do all that in software ... no doubt there are problems.

    For 14-bit resolution it takes a minimum of 7.4ms to grab the 256 samples needed.
    If you left PBP's default AD defines intact, it could take up to 25ms.
    Obviously not fast enough to do software timed servos too.

    I agree, an external A/D with higher resolution will probably be best. (without fixed Vref+)

    Added:

    But if you're just going to a 12-bit external A/D.
    You might try the same routines again at the 12-bit resolution. Or even 13-bit.

    At 12-bit resolution it only needs 16 samples, which takes <strike>387us</strike> 465us minimum.
    Plenty of time left for eveything else.
    <br>
    Last edited by Darrel Taylor; - 8th September 2009 at 00:05. Reason: 12/13-bit
    DT

  2. #2
    Join Date
    Jan 2004
    Location
    Thessaloniki , GREECE
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Well,
    I put together some stuff on a prototype pcb and servo routines worked ok! ( a little bit of improvement needed!)
    I notice that without an op-amp and using just a max187 12bit ADC with EXTERNAL Vref tied to Vdd I get readings from ADC that plays between 2-3 value (NOT good). If we think that we use 12bit we have a resolution of about -+2meters and if the value plays between 2-3 values the error increase between -+6 meters (not good at all).
    May be the only and better solution is go to 12bit ADC AND an op-amp too!
    Also as a final thought is that maybe I have interference somewhere with the sensor although I used decoupling and filter capacitors according to MPX datasheet.
    The main thing is that servo routines / speed controller arming e.t.c work fine!

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Alexandros

    1) do not forget a LoPass R/C at the sensor output ( Freescale AN's ... )

    2) take care to the ground plane (@ 12 bits it becomes useful !!! )

    2) you can take 8 or 16 samples and calculate the mean value ( this is pompously called ... "Oversampling" , if you take into account the UNMEANINGFUL LSBits of the result . LOL ! )

    or better use a " rolling mean value " ( mean value = 7/8 oldvalue + 1/8 Newvalue i.e. , for 8 samples ) advantage is you access meanvalue after each sampling ...

    I am testing an auto zeroing and resolution enhancement design on my side ... but shhhht !!!

    Alain
    Last edited by Acetronics2; - 8th September 2009 at 20:59.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  4. #4
    Join Date
    Jan 2004
    Location
    Thessaloniki , GREECE
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Alain about your suggestions:
    1> I think you are right I have not implement an rc filter. AN note is VERY usefull here I think. (although I have read it before I did not use rc filter just decoupling caps). I have some 750ohm and 330nf around here so I can give it a try.
    2> for the moment no ground plane just a proto-raster board (this of course causes problem by itself)
    3>samples is already there but I get only 4samples maybe get 8 or 16 and see what happens.

    ALL the suggestions you make is not difficult to imlemented so I will give them all a try and let you know

    (...and shhhhht ,yah waiting for your enhancements!!)

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Since the sites.picbasic.net had some issues a while back (and erased everyone's attached files) Darrel's DT_Analog.pbp file got gobbled up! So, none of my links to his code work anymore. Attached is his file that takes multiple samples from the A/D converter, and can "oversample" from 10 to 16 bits resolution. It is pretty slick, (no matter what Alain says ) as it can make a 16 bit A/D converter out of a $1.50 PIC12F683.

    Some more info on DT-Analog.pbp's sampling rates:


    Hardware for my altimeter using his above code:
    http://sites.picbasic.net/index.php?...d=91&pageid=81

    Also attached is my AltimeterBlink.pbp code that calculates altitude, and sends it out the serial port, as well as blinks it out on an LED.
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Default

    Sorry about the broken links Walter.
    I've re-posted it where I can be sure it stays intact.

    http://www.darreltaylor.com/DT_Analog/

    And yeah, it is pretty cool isn't it.
    (No matter what Alain says).
    DT

  7. #7
    Join Date
    Jan 2004
    Location
    Thessaloniki , GREECE
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Oh my friends you made me come back with my previous project (that didn't manage to finish yet!)
    Well I have tried all methods available with previous mentioned hw and a few not-listed here one.

    The problem I came accross was with picbasic pwm routines to pass-through servos signal .

    Just to remind: In addition to ALT measurement I also use a servo in and a setvo out pin to pass-through the throttle signal and actually cut the throtle when 200m ALT reached!

    All experiments with oversampling or no , with opamp etc worked ok when I connect servo (for throttle) -although a little bit of jerky movement servo works! , but everytime it comes to use SpeedControl it does not arm and this has to do with delays on servo routines.

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    949


    Did you find this post helpful? Yes | No

    Default "define adc_bits 16" ???

    Hi All,

    Just a question about DEFINEs.

    In Darrel's code, I can see
    Code:
    DEFINE ADC_BITS 16 '10 BIT A/D CONVERSION RESULT
    What does it mean?

    I'm using a 12F683 that can only do a 10 bits resolution son what do I not understand? Why 16?
    Roger

  9. #9
    Join Date
    Jan 2004
    Location
    Thessaloniki , GREECE
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Hi All,
    ....
    I'm using a 12F683 that can only do a 10 bits resolution son what do I not understand? Why 16?
    Well my friend if you read carefully you would notice that Darell uses a method called 'Oversampling technique' to increase the resolution by software trick.
    more info at : http://www.darreltaylor.com/DT_Analog/

    So the actual hardware used is the onboard f683 10bit but with 'oversampling' by software you can archive 16 bit resolution result with speed penalty as a drawback.
    By using define you can use 10 to 16 bit 'sampling' with the most common use be the 12 bit sampling as a matter of speed.

    Have a nice day my friend!

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