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

    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 08:23.
    http://www.scalerobotics.com

  2. #2
    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 11:21.

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

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

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

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

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

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


    Did you find this post helpful? Yes | No

    Default Why "DEFINE" ?

    Thanks bitmaniac,

    I have read Alain's explanation about "oversampling" and "rolling mean value" in a previous post but I'm still not clear why it is necessary to declare a DEFINE to do so.

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Roger

  9. #9


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Thanks bitmaniac,

    I have read Alain's explanation about "oversampling" and "rolling mean value" in a previous post but I'm still not clear why it is necessary to declare a DEFINE to do so.

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Hello,
    You are correct you should set the pic to 10 bits:
    DEFINE ADC_BITS 10

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

    If you study Darrel's example in the above link, bottom of the article.
    You set your oversampling resolution in this line:


    ADbits = 12 ; set to 12-bit resolution

    Regards
    Mark
    Last edited by mark_s; - 3rd June 2010 at 15:45. Reason: add link

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Hello, Roger

    DEFINE only set a constant ... used to DEFINE some processor module or macros configs.

    the value is tested, and relevant settings are chosen by the compiler ( sort of conditionnal assembly - if you prefer ... sort of !!! )

    just look at the difference ( in the asm listing) between DEFINE ADC_BITS 8 and ADC_BITS 10 ...

    Should be little differences in the ADCONx setting values ... don't you think ???

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

  11. #11
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default ok

    Thanks Alain,

    I was confused because of the value (16) in Darrel's code example.

    I now understand what this particular DEFINE does
    Roger

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