MPXA4115A picbasic code - Page 2


Closed Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 41 to 80 of 104
  1. #41
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Hi, Scalerobotics

    Could you tell us what it shows for some close to another calibrated pressures ( water column i.e.) I'm really curious about this "oversampling method" application ...

    And moreover after having carefully read the relevant AN 1152 from Microchip ...

    Alain

    " Surely overpaid Engineer ... ( lol ) , but Graduate Engineer ... "
    ************************************************** ***********************
    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. #42
    Join Date
    Jan 2004
    Location
    Thessaloniki , GREECE
    Posts
    61


    Did you find this post helpful? Yes | No

    Default

    @Acetronics
    VERY good infos in AN thanks for sharing!

    @ Scalerobotics

    You have done excellent job That was exactly I was thinking to do trying oversampling on 12f pics! so you did the job for me THANKS!

    So the conclusion is that we can use 12f675 ir 12f683 as I want to just measure an alt difference of 200m

    I did some calculation and I have attaches 2 XL one is the previous 10,12,14bit calculation and bolded out the 200m measurements just to see what is going on and the second one is use pic 10bit ADC but with Dual AMP LMC662 (Acetronics suggestion) to give a narrow-window measurements and the resolution improved to about 4m .

    Also attached a fast schematic of my thoughts (not checked , improvements are welcome!)

    Final conclusion I take the amp route or MPX connected directly to pic (with oversampling). I think as I will only want to measure 200m difference. the pcb must/and can be kept simple (low weight) and low part count.

    (dual amp trick: first subtracts 2.5V from MPX vout and the result is multiplied by 3 , so we have a range just from
    0-2300meters but better resolution for 10bit pic adc -see AZAltitude10bit_DUALAMP.xls)

    Scalerobotics about oversampling on 12f do you think you can 'go with' just the internal 8Mhz rc oscilator or it will not do the trick?!
    Attached Files Attached Files
    Last edited by bitmaniac; - 4th June 2009 at 12:03.

  3. #43
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    bitmaniac, Check your J1 and J2 power wiring....

    Dave Purola,
    N8NTA

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    bitmaniac, Check your J1 and J2 power wiring....

    Dave Purola,
    N8NTA
    Oh! you have a sharp eye!
    I told you it was a fast schematic he!he!

    corrected.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Scalerobotics

    Could you tell us what it shows for some close to another calibrated pressures ( water column i.e.) I'm really curious about this "oversampling method" application ...

    And moreover after having carefully read the relevant AN 1152 from Microchip ...
    At my location and 14 bits, I get an output of 13255. This calculates to a pressure of 1004.86 mBar, and an altitude of 229.85 feet. I don't have a barometer here, so I can't really give you a side by side comparison on the figures. On the internet, it said a nearby weather barometer read 1014.42. But I think this is more a function of the accuracy of the MPX4115a, and to a bigger extent (since I don't have a calibrated barometer side by side) my altitude. The altitude from my calculations seem very close. I think I am between 250 and 285 feet altitude.

    Oversampling is really just a form of averaging. So it can't skew your results. At worst, you could have no noise in your A/D conversion, which would give you a 10 bit result with lots of useless bits to the right. Once I find a 470pf capacitor around here, I plan to test results again. I think this will filter the result a bit too much, and take away some of the needed noise. Here, white noise is our friend.

    On a side note, at 16 bits, when you watch the results at first power up, you can really see the effects of the MPX4115a and maybe the PIC12F675 warming up. For about two minutes the values really move!
    Last edited by ScaleRobotics; - 4th June 2009 at 18:36.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default Altitude from lookup example PIC12F675

    Here's a little code to calculate altitude from 0 to about 17,000 feet. I could not quite fit the full 85 value lookup2 table without getting some errors, so it is more of a 74 value lookup table. I may try a 74 value lookup table that covers the range to 36,000 feet later. Also will not work for Death Valley where the altitude goes to negative.

    It is a pretty short program. I am using about 900 words of the PIC12F675 though, so not much space left over. Have not tested it too much, so if anyone finds issues, let me know.

    Code:
    DEFINE OSC          20
    INCLUDE "DT_Analog.pbp"     ; DT's 16-bit Analog Module
    
    DEFINE ADC_BITS     10  '10 BIT A/D CONVERSION RESULT
    DEFINE ADC_CLOCK    2   '
    DEFINE ADC_SAMPLEUS 5  'SET SAMPLE TIME IN MICROSECONDS
    
    
    CMCON = 7               'TURN COMPARATORS OFF
    TRISIO = %000100        'Set GSIO 0 INPUTS, others to OUTPUT
    ANSEL = %00100100 	    '
    ADCON0.7 = 1	        'Right Justify for 10-bit
    ADCON0 = %10001001 
    
    ADbits = 14                ; set to 14-bit resolution
    
    
    DEFINE DEBUG_REG	GPIO
    DEFINE DEBUG_BIT	0
    DEFINE DEBUGIN_BIT	1
    DEFINE DEBUG_BAUD	2400
    DEFINE DEBUG_MODE	0
    ALTresult var word       'lookup table output
    tempALT var word         'base altitude of lookup from table
    ADtemp var byte          'lookup table input
    ALTdifference var word   'difference of two nearby altitudes
    finalALT var word        'final calculated altitude in feet
    
    ;---------------------------------------------------------------------------
    Main:
        ADchan = 2       ; Do only AN2 channel
        GOSUB GetADC            ; Get A/D value
        ADtemp = (ADvalue/100) - 60 ' get to table acceptable value for lookup
        gosub lookmeup
        tempALT = ALTresult   'save first result for use in math
        ADtemp = ADtemp - 1  'run another lookup for nearby altitude for diff calc
        gosub lookmeup
        ALTdifference = ALTresult - tempALT   'get difference in nearby alt
        finalALT = tempalt - (((ADvalue//100)* ALTdifference)/100) 
        'use difference to calculate slope & adjust altitude accordingly
        debug "Alt= ",DEC finalALT," A/D= ",DEC ADvalue,"   "
        pause 1000
    GOTO Main:
    
    End
    
    lookmeup:
    lookup2 ADtemp,[_
    17646,17327,17011,16699,16389,16083,15780,15480,15183,14888,14597,14308,14022,_
    13739,13458,13179,12903,12630,12359,12090,11823,11559,11297,11037,10779,10524,_
    10270,10018,9769,9521,9275,9031,8789,8549,8310,8074,7838,7605,7373,7143,6915,_
    6688,6463,6239,6017,5796,5577,5359,5143,4928,4715,4502,4292,4082,3874,3667,_
    3462,3257,3054,2852,2652,2452,2254,2057,1861,1666,1472,1280,1088,898,708,520,_
    332,146],ALTresult
    return
    Last edited by ScaleRobotics; - 5th June 2009 at 00:33.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bitmaniac View Post
    Scalerobotics about oversampling on 12f do you think you can 'go with' just the internal 8Mhz rc oscilator or it will not do the trick?!
    You can go with the internal, but at least on the 12F675 you have 4mhz internal, so your conversions are a little slower. See the TAD vs device operating frequencies part of your schematic. 1.6 us if fastest. Looks like 4mhz would be 2.0 us. So as long as you are not using 16 bit, you probably won't notice the difference in speed, and you will save one more part in your part count.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    @scalerobotics

    I have import your code to Proteus Sim and playing around with your code.

    It seems to work ok (I have to use meters instead of feets here ).

    My MPX4115A arrived yesterday (4pieces) so it is time to make the real thing and figure out how it works. I am going to use my schematic ommiting the opamp and hope oversampling method works (12f683,internal 8Mhz,MPX,3caps -> total part count 5!)

    For the moment I put everythimg in SIM (i used 12f683 with internal 8Mhz) and here what I found:
    According to simulation at 50.400kPa I read 17646 feet ALT (lower limit) and
    at 99.900kPa I read 5 feet ALT (upper limit) that is with this code we measure aprox. 49,500Kpa difference. (two screenshots attached)

    Note: We must also use calibration data and/or Level0 default presure

    (Please note that in the sim I can only vary sensor kPa in .100 increaments)
    Attached Files Attached Files
    Last edited by bitmaniac; - 5th June 2009 at 09:22.

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


    Did you find this post helpful? Yes | No

    Default

    Sounds good. If you beat me to it, try it with and without C3. I am guessing it may work better without it. If not without, it may work best with a much smaller capacitor. That defies most filtering logic, but I think oversampling likes a little bit of noise. I can't find my 470pf, but I know they are around here somewhere.....
    Last edited by ScaleRobotics; - 5th June 2009 at 09:36.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    .....I can see your 470pf.... over there... yes there.....next to your Pickit2 he!he!

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


    Did you find this post helpful? Yes | No

    Default

    3d visualization of a test pcb attached...

    As you notice I didn't care much about the placement of sensor caps.
    Just wanted to see the size of the board and best placement of connectors

    (pcb measured... 45mm X 30 mm)

    PLEASE NOTE all connectors will be male (not as seen) except for the sensor that it will be soldered on board
    The sensor will be layed above C3 C2 and C1 (low profile cap)
    Attached Images Attached Images  
    Last edited by bitmaniac; - 5th June 2009 at 12:47.

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


    Did you find this post helpful? Yes | No

    Talking 1st try :SUCCESS

    SUCCESS!

    Scalerobotics your code worked ok.

    I put together a 12f675 , two caps on MPX supply pins , one 100n on pic supply pin one resistor to PC serial RX port and guess....

    I get 54-55m ALT here from our MPX4115 project on the desk.

    I also turned on my other project with a gps module next to it and I get 54-58m ALT!

    PERFECT right on the SPOT!!! I am very please with the result.

    May be we must also include a calibration initial setup.

    pic settings 4Mhz internal , Clk source Fosc/8 , Define ADC clock 2 (I will try 1 later) and ADC_SAMPLEUS 5.

    The only thing left to verify is the accuracy in meters.

    I am very happy now!

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


    Did you find this post helpful? Yes | No

    Default

    First try success? Nice!

    Maybe you are already converting feet to meters in your code, but this seems to work for me. And I think it is better than a new metric lookup table, because there are more feet per increment, which should make it more accurate.

    Code:
        if metric = 1 then   'convert from feet to meters
            finalALT = finalalt * 2500
            finalALT = div32 8203
        endif
    So it looks like you are making an altitude hold circuit. An altitude hold has been on my back burner for a few years now. Darrel's code has really made part of this easy, so it looks like I may be able to move this up a burner or two myself!

    How smooth is your servo at 4 mhz and 8 mhz? I would think that 20 mhz would be a bit smoother for sensing pulse width, but have not tried the lower mhz.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Altitude hold : oh! you gave me another idea!

    For the moment it will be an ALT+TIMER motor cut-out for moto-gliders for F5J-GR . I am trying to make a circuit that will cut motor after 30sec or to an ALT of 200m what comes first!

    about your question I think we will have problems with internal 4mhz. I am thinking of going to 12f683 (8 Mhz internal) and more code space , we are in the limit here with f675. Also may be asm is used to pass servo pulses through and/or maybe as final solution we will go to an external low profile crystal and two decopuling caps.

    I will experiment and see....

    (Now I get 51m here (project running!) the funny thing is that I have closed the door of my lab now , the weather got very hot here now . I think there will be no problem with the calibration because the only think I want to measure is ALT differece of 200m so 1st you have to power the device just 1minutes before flight. It will read the ground alt and if 200m reached motor will cut that's all.
    Last edited by bitmaniac; - 5th June 2009 at 18:18.

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


    Did you find this post helpful? Yes | No

    Default

    Modified the code to handle 0 to 25,900 feet, and a 16 bit conversion lookup table. Now you can select your conversion oversampling rate for Darrel's code, and your result gets shifted to match the 16 bit lookup table for altitude conversion. Works for 10 to 16 bit oversampling rates. My favorite is the 15 bit for accuracy and speed, but it is selectable.

    See http://sites.picbasic.net/component/...,91/pageid,81/ for more info.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    scalerobotics , you have done excellent work again my friend!.

    But you made me wonder ... (as I have already design the pcb of my ALTMTR) MUST I include a Crystal (20Mhz) after all or I can leave/ and rely on internal 8Mhz oscillator (12f683) with any drawbakcs of it?
    May be I need to redesign my mcb and loose button activation option.
    Or may be I use led indication both as input and / or output this will make me think.... )

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


    Did you find this post helpful? Yes | No

    Default

    Thanks Bitmaniac,

    Don't let me worry you! The speed difference will probably have a bigger affect on your PWM sensing and pass through, than altitude conversion. But I think 8mhz is reasonable for this. Yours is the motor control for a glider, so even if it is a little glitchy, you are not going to notice much, since to get to altitude you will probably be at 50 to 100 percent throttle, or you will be at 0 looking for lift.

    I was originally thinking of speed for the higher bit conversions, like 15 and 16 bit. But I think the speed of your conversion will be 2 us, where with 20 mhz, the conversion is 1.6 us. So just the 16 bit analog oversampling takes 100 ms with 20 mhz and 125 ms with your 8mhz internal. Not a big difference there! Of course the 15 and 14 bit samples are MUCH quicker.

    So no, really, I think you will be fine.
    Last edited by ScaleRobotics; - 13th June 2009 at 09:23.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    So you think I have to stick to my already made pcb and don't try an 20 MHZ crystal.
    Here it is the final pcb in 3d and shematic I am going to use.
    I am finishing the firmware part now thanks to Darrel ADC convertion and your help. I will use 14bit with 8mhz internal (12f683). The pcb will support ICSP an optional button and a led indicator. I have not try the pcb (in real) only in Proteus sim. I will let you know of the progress. for the moment take a look...

    EDIT: in schematic the 100n pic decoupling is missing (in pcb is ok)
    Attached Images Attached Images   
    Last edited by bitmaniac; - 13th June 2009 at 12:21.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bitmaniac View Post
    So you think I have to stick to my already made pcb and don't try an 20 MHZ crystal.
    I think your design is feasible. There is no harm in designing the board before the firmware is completed. But there might be some harm ($$$) if you have them made before testing. I would recommend that you wait till you write your PWM sensing and generating code, and test it, before you decide on a final layout. On a breadboard, adding a crystal is easy, if you need to...
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    One change you might consider would be to change pin 5 (CCP1 HPWM pin) to your servo connector. That way if you decide to use the HPWM function for PWM out, you could go ahead and do it. You could always reverse your connectors if you decide you want to use the HPWM for PWM in. And if you wanted to make it really flexible, consider moving your two least important inputs/outputs to the crystal pins. You have enough space on your board for a resonator. Why not make some pads for inserting a resonator, and run your LED and Serial connector off of those traces. That way (if you have to) you can sacrifice the LED and serial for a crystal.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    You are in my mind actually I have already daone what you suggest but I had already develop and etced the above pcb version so I 'll give a try as it is and I have already residign the pcb with extra crystal pads BUT I have not implement the HPWM idea you suggest . It is a perefect idea I will add this too this weekend. Thanks.

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


    Did you find this post helpful? Yes | No

    Default

    Reviced sch & and pcb...

    I improved pcb (after suggestion from Scalerobotics).
    Arm button removed (arm will be done by throtle or by default min ALT).
    20Mhz crystal included. (although I did notice according to manual at 20Mhz HPWM for THR out has min limit to around 1221Hz not so good!)
    (...also In Circuit fw update)

    Working on Fw now. I have problems with HPWM though!
    Attached Images Attached Images   

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


    Did you find this post helpful? Yes | No

    Default

    Well, it looks like I convinced you to go with a crystal, and you convinced me to go without one. Pretty funny. Sorry about the bad advice I gave about the pwm. I didn't do enough homework.



    Code and schematics here: http://sites.picbasic.net/component/...,91/pageid,81/
    Attached Images Attached Images  
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Hi Scalerobotics,

    I liked your smd version (smaller pcb is always a good one!)

    I think I will keep the 20Mhz crystal because I have problems here with the servo read/send signals (passtrough) .The problem is inside adc oversampling convertion routine. I think ot is a liitle bit slow convertion that slows things down and as I only use pulsin and pulsout to read and regenarate servo pulses at tghis point I notice that servo works ok but with speed control (so I can cut the motor) I have no response.
    Last edited by bitmaniac; - 20th July 2009 at 06:47.

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


    Did you find this post helpful? Yes | No

    Default

    Hi! back again with this unfinished project.
    Well after a lot of experiment I will alter my schematic again.
    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.
    So I am thinking of using a MAX187 12bit ADC (and maybe an op-amp in the future).
    I have already put together a 12f683 + MPX4115 and a MAX187 on a raster and SC seems to work now. I will keep you inform of my future proggress.....
    Last edited by bitmaniac; - 7th September 2009 at 16:11.

  26. #66
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink At last !!!

    Hi, Alexandros

    Now we can make good work ... there was no other serious solution than having REAL bits as inputs ... 12 is a minimum.

    Just have to find MAX 187 ... ( 4.096v internal ref is a good thing ! ) ... may be we could try to find another ADC with both LoVref and HiVref pins available ... some more bit to win here !!!

    An LTC1286 could be the one ... with 4.096v ext ref !!!

    The MS5534 was the other solution : a bit expensive, but better resolution !!! ( it's the one used in commercial altitude related devices ... eh ! ). It just needs a 12F683 for 32 khz generation ( HPWM ) ...

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

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


    Did you find this post helpful? Yes | No

    Default

    Hi! Alain

    Well max 187 is a very good ADC I think and you can also use External Vref (as I can see from datasheet)

    I tried tie external Vdd to ref pin (according to datasheet you have to leave pin 3 floatting) and change pin 4 cap from 4.7uf to 100nf.
    I tried internal 4.096V ref. but as I did not use op-amp I think I was at the limit of 4.096v so I decide to go roughly with Vdd external but I noticed a jerky ADC reading -/+ 10 values up and down. Maybe this was to a not clear 5v external source (I used an ATX pc supply). I will try again with Speed contrller Bec and let you know.
    I must finish this project....

    (...Alain maybe we can use a 14bit 8pin SPI IC if exists! ....(I want too much eh!?)

    Also about MS5534 you suggest I follow some links you gave me in previous posts but as I have already ordered 5 MPX sensors and as I want a simpler project (just read 200m ALT change) and not even real ALT in meters measurements I think we can just go with an F683 and a 12bit ADC(or 14bit ADC 8 pin if available).
    Last edited by bitmaniac; - 7th September 2009 at 18:58.

  28. #68
    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

  29. #69
    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!

  30. #70
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    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 " !!!
    *****************************************

  31. #71
    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!!)

  32. #72
    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

  33. #73
    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

  34. #74
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by bitmaniac View Post
    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.
    Hey Bitmaniac, any chance you could post what you have? I am interested in the pass through, and I know others are too. I just worked on a DT Interrupt servo pass through on a 18F device (just a single channel right now), and I would like work it out for the 12F683. I always enjoy seeing a new perspective to help me think outside my box. In case you are intersted, mine is here: http://www.picbasic.co.uk/forum/show...3186#post83186

    Thanks,

    Walter

  36. #76
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by bitmaniac View Post
    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.
    Hi, Alexandros

    Could you explain a bit ??? I must admit I'm not sure what you mean here ... the altitude measurement routine could take too much time ???

    did you notice you send the servo signal twice ... just at this moment ...

    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    did you notice you send the servo signal twice ... just at this moment ...
    Alain
    Hey Alain,

    Can you explain more? I have not seen any code from Bitmaniac, did I miss something?

    I think Bitmaniac is saying his code works fine with a servo, but when connected to a motor controller, it does not work, and he thinks it is due to the delays used in his routine for servo output.

    Thanks,

    Walter

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


    Did you find this post helpful? Yes | No

    Default

    Well my friends
    I was a bit confusing trying to explain things!
    Well see previous post #65 (http://www.picbasic.co.uk/forum/show...3&postcount=65) to see what I mean exactly.

    If /when using oversampling method this introduces a delay to my pulsin /pulsout routines (simple pass through) .
    I even try omiting meter/feet convertion all together and calculating 200m ALT reach by raw data as it comes from ADC only!

  39. #79
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default A/D and the number of bits/levels

    I don't see the problem with dividing by 1024?
    The process is quantising a variable. Say our variable voltage lies in the range 0 to 10 Volts and we have one bit to use for the digital result of the quantising (2 to the power of 1 = 2, so we have two levels to play with):

    A. The result 0 means that the voltage was in the range 0 to 5 Volts (not that it was zero).
    B. The result 1 means the voltage was in the range 5 to 10 volts (not that it was 10 volts)

    So each level is 10/2 volts wide. Not 10/1 volt wide.

    The bit of cake after carving it up into portions has a slice 0 - it is not any smaller than any other slice.

    This is not jibberish created by highly paid engineers it is simple maths.

    I wonder how many devices you have launched on the world that are happily 'over' measuring analog quantities by assuming that each slice is bigger than it actualy is?

    Kind regards to you all

    Bill Legge

  40. #80
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink the problem ... without the solution.

    Hi,

    The problem is very simple : the servo signal frame length is too long ( or too short ??? ) and the ESC do not recognise it as a valid frame ...

    The solution is not so simple : the total time of the frame must be 30 or 35 ms as a MAXIMUM and , say 17-18 ms as a minimum.

    That's why servo works and not the ESC ...

    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 " !!!
    *****************************************

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 : 3

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