MPXA4115A picbasic code


Closed Thread
Results 1 to 40 of 104

Hybrid View

  1. #1
    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

  2. #2
    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.

  3. #3
    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   

  4. #4
    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

  5. #5
    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.

  6. #6
    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.

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


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

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


    Did you find this post helpful? Yes | No

    Default Re: MPXA4115A picbasic code

    I need to work at this a little to explain it well. But here is a shot at explaining it generally. I am still looking for the excel spreadsheet I did to make my lookup table ... but in the mean time...

    Using an excel spread sheet, put a formula for calculating altitude from pressure. Add the formula for your pressure sensor to convert its voltage to pressure. Add in the part that converts your A/D reading to a voltage. Once you get to a point where you can say a reading of xxx of your a/d conversion gives you x feet or meters, you can find some evenly spaced a/d readings, and input the corresponding feet or meters into a lookup table. I know this explanation kind of stinks, because you need some examples here. I will try to elaborate on this later.

    Anyway, once you have your lookup table, you need to divide your a/d reading by a number. If you look at my lookup table, you see that I am dividing by 1000 and subtracting 15. This is for a 16 bit A/D result. (In my code, even if you decide to use 12 bit resolution, it is shifted up to 16 bits so it can use the same lookup table). The subtract 15 lets you lower the start of your max altitude. Normal folks might just want to go up to 12,000 feet, or maybe even lower, so they would have a bigger subtraction number, and a different lookup table, that started at a lower altitude.

    You may notice that I am looking up two values. This is because the value from the adc will be between two of the lookup table values. The lookup values in my table are about 400 feet or so apart. To make this somewhat accurate, we need to lookup both readings in the lookup table, find the difference in feet, then take our remainder from divide by 1000 and multiply the fraction to the difference in feet. Then I subtract this from my TempAlt to get a final altitude. For this to work, my lookup table had to be made at Analog to digital steps of 1000. That makes the math a little easier.

    I am pretty sure I used Alain's spreadsheet as a base to calculate my lookup table. You can find his spreadsheet in Post 33 and another one of his previous. Also BitManiac has a spreadsheet in there as well. Here are my values, calculating for even 1000 steps for the A/D value. Table step number is shown, as is feet of altitude, and pressure in Pa.

    <table frame="VOID" rules="NONE" border="0" cellspacing="0" cols="4"> <colgroup><col width="83"><col width="93"><col width="107"><col width="107"></colgroup> <tbody> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20" width="83">A/D Value</td> <td align="CENTER" bgcolor="#E6E6E6" width="93">Table step </td> <td align="CENTER" bgcolor="#E6E6E6" width="107">Feet</td> <td align="CENTER" bgcolor="#E6E6E6" width="107">Pa</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">54000</td> <td align="CENTER" bgcolor="#E6E6E6">39</td> <td align="CENTER" bgcolor="#E6E6E6">-237</td> <td align="CENTER" bgcolor="#E6E6E6">102.2</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">53000</td> <td align="CENTER" bgcolor="#E6E6E6">38</td> <td align="CENTER" bgcolor="#E6E6E6">226</td> <td align="CENTER" bgcolor="#E6E6E6">100.5</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">52000</td> <td align="CENTER" bgcolor="#E6E6E6">37</td> <td align="CENTER" bgcolor="#E6E6E6">696</td> <td align="CENTER" bgcolor="#E6E6E6">98.8</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">51000</td> <td align="CENTER" bgcolor="#E6E6E6">36</td> <td align="CENTER" bgcolor="#E6E6E6">1172</td> <td align="CENTER" bgcolor="#E6E6E6">97.11</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">50000</td> <td align="CENTER" bgcolor="#E6E6E6">35</td> <td align="CENTER" bgcolor="#E6E6E6">1655</td> <td align="CENTER" bgcolor="#E6E6E6">95.41</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">49000</td> <td align="CENTER" bgcolor="#E6E6E6">34</td> <td align="CENTER" bgcolor="#E6E6E6">2145</td> <td align="CENTER" bgcolor="#E6E6E6">93.71</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">48000</td> <td align="CENTER" bgcolor="#E6E6E6">33</td> <td align="CENTER" bgcolor="#E6E6E6">2643</td> <td align="CENTER" bgcolor="#E6E6E6">92.02</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">47000</td> <td align="CENTER" bgcolor="#E6E6E6">32</td> <td align="CENTER" bgcolor="#E6E6E6">3148</td> <td align="CENTER" bgcolor="#E6E6E6">90.32</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">46000</td> <td align="CENTER" bgcolor="#E6E6E6">31</td> <td align="CENTER" bgcolor="#E6E6E6">3660</td> <td align="CENTER" bgcolor="#E6E6E6">88.62</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">45000</td> <td align="CENTER" bgcolor="#E6E6E6">30</td> <td align="CENTER" bgcolor="#E6E6E6">4181</td> <td align="CENTER" bgcolor="#E6E6E6">86.92</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">44000</td> <td align="CENTER" bgcolor="#E6E6E6">29</td> <td align="CENTER" bgcolor="#E6E6E6">4710</td> <td align="CENTER" bgcolor="#E6E6E6">85.23</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">43000</td> <td align="CENTER" bgcolor="#E6E6E6">28</td> <td align="CENTER" bgcolor="#E6E6E6">5247</td> <td align="CENTER" bgcolor="#E6E6E6">83.53</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">42000</td> <td align="CENTER" bgcolor="#E6E6E6">27</td> <td align="CENTER" bgcolor="#E6E6E6">5794</td> <td align="CENTER" bgcolor="#E6E6E6">81.83</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">41000</td> <td align="CENTER" bgcolor="#E6E6E6">26</td> <td align="CENTER" bgcolor="#E6E6E6">6349</td> <td align="CENTER" bgcolor="#E6E6E6">80.14</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">40000</td> <td align="CENTER" bgcolor="#E6E6E6">25</td> <td align="CENTER" bgcolor="#E6E6E6">6915</td> <td align="CENTER" bgcolor="#E6E6E6">78.44</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">39000</td> <td align="CENTER" bgcolor="#E6E6E6">24</td> <td align="CENTER" bgcolor="#E6E6E6">7490</td> <td align="CENTER" bgcolor="#E6E6E6">76.74</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">38000</td> <td align="CENTER" bgcolor="#E6E6E6">23</td> <td align="CENTER" bgcolor="#E6E6E6">8076</td> <td align="CENTER" bgcolor="#E6E6E6">75.04</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">37000</td> <td align="CENTER" bgcolor="#E6E6E6">22</td> <td align="CENTER" bgcolor="#E6E6E6">8672</td> <td align="CENTER" bgcolor="#E6E6E6">73.35</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">36000</td> <td align="CENTER" bgcolor="#E6E6E6">21</td> <td align="CENTER" bgcolor="#E6E6E6">9280</td> <td align="CENTER" bgcolor="#E6E6E6">71.65</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">35000</td> <td align="CENTER" bgcolor="#E6E6E6">20</td> <td align="CENTER" bgcolor="#E6E6E6">9900</td> <td align="CENTER" bgcolor="#E6E6E6">69.95</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">34000</td> <td align="CENTER" bgcolor="#E6E6E6">19</td> <td align="CENTER" bgcolor="#E6E6E6">10532</td> <td align="CENTER" bgcolor="#E6E6E6">68.26</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">33000</td> <td align="CENTER" bgcolor="#E6E6E6">18</td> <td align="CENTER" bgcolor="#E6E6E6">11176</td> <td align="CENTER" bgcolor="#E6E6E6">66.56</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">32000</td> <td align="CENTER" bgcolor="#E6E6E6">17</td> <td align="CENTER" bgcolor="#E6E6E6">11834</td> <td align="CENTER" bgcolor="#E6E6E6">64.86</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">31000</td> <td align="CENTER" bgcolor="#E6E6E6">16</td> <td align="CENTER" bgcolor="#E6E6E6">12507</td> <td align="CENTER" bgcolor="#E6E6E6">63.16</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">30000</td> <td align="CENTER" bgcolor="#E6E6E6">15</td> <td align="CENTER" bgcolor="#E6E6E6">13194</td> <td align="CENTER" bgcolor="#E6E6E6">61.47</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">29000</td> <td align="CENTER" bgcolor="#E6E6E6">14</td> <td align="CENTER" bgcolor="#E6E6E6">13896</td> <td align="CENTER" bgcolor="#E6E6E6">59.77</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">28000</td> <td align="CENTER" bgcolor="#E6E6E6">13</td> <td align="CENTER" bgcolor="#E6E6E6">14615</td> <td align="CENTER" bgcolor="#E6E6E6">58.07</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">27000</td> <td align="CENTER" bgcolor="#E6E6E6">12</td> <td align="CENTER" bgcolor="#E6E6E6">15351</td> <td align="CENTER" bgcolor="#E6E6E6">56.38</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">26000</td> <td align="CENTER" bgcolor="#E6E6E6">11</td> <td align="CENTER" bgcolor="#E6E6E6">16106</td> <td align="CENTER" bgcolor="#E6E6E6">54.68</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">25000</td> <td align="CENTER" bgcolor="#E6E6E6">10</td> <td align="CENTER" bgcolor="#E6E6E6">16879</td> <td align="CENTER" bgcolor="#E6E6E6">52.98</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">24000</td> <td align="CENTER" bgcolor="#E6E6E6">9</td> <td align="CENTER" bgcolor="#E6E6E6">17673</td> <td align="CENTER" bgcolor="#E6E6E6">51.29</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">23000</td> <td align="CENTER" bgcolor="#E6E6E6">8</td> <td align="CENTER" bgcolor="#E6E6E6">18489</td> <td align="CENTER" bgcolor="#E6E6E6">49.59</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">22000</td> <td align="CENTER" bgcolor="#E6E6E6">7</td> <td align="CENTER" bgcolor="#E6E6E6">19327</td> <td align="CENTER" bgcolor="#E6E6E6">47.89</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">21000</td> <td align="CENTER" bgcolor="#E6E6E6">6</td> <td align="CENTER" bgcolor="#E6E6E6">20190</td> <td align="CENTER" bgcolor="#E6E6E6">46.19</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">20000</td> <td align="CENTER" bgcolor="#E6E6E6">5</td> <td align="CENTER" bgcolor="#E6E6E6">21078</td> <td align="CENTER" bgcolor="#E6E6E6">44.5</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">19000</td> <td align="CENTER" bgcolor="#E6E6E6">4</td> <td align="CENTER" bgcolor="#E6E6E6">21995</td> <td align="CENTER" bgcolor="#E6E6E6">42.8</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">18000</td> <td align="CENTER" bgcolor="#E6E6E6">3</td> <td align="CENTER" bgcolor="#E6E6E6">22942</td> <td align="CENTER" bgcolor="#E6E6E6">41.1</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">17000</td> <td align="CENTER" bgcolor="#E6E6E6">2</td> <td align="CENTER" bgcolor="#E6E6E6">23921</td> <td align="CENTER" bgcolor="#E6E6E6">39.41</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">16000</td> <td align="CENTER" bgcolor="#E6E6E6">1</td> <td align="CENTER" bgcolor="#E6E6E6">24934</td> <td align="CENTER" bgcolor="#E6E6E6">37.71</td> </tr> <tr> <td align="CENTER" bgcolor="#E6E6E6" height="20">15000</td> <td align="CENTER" bgcolor="#E6E6E6">0</td> <td align="CENTER" bgcolor="#E6E6E6">25985</td> <td align="CENTER" bgcolor="#E6E6E6">36.01</td> </tr> </tbody> </table>

    I have attached one interesting pdf. It is not the formula I used for my lookup table, but it is interesting.

    Walter
    Attached Images Attached Images
    Last edited by ScaleRobotics; - 4th March 2011 at 15:35.

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