how do I speed up an existing pic18f2525 program ?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Glasgow, Scotland
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Hi Alain, Thanks for your help. It turns out that the main reason I cant get it to go faster seems to be the time it needs to carry out the analog to digital conversions if I took out the get ADCloop and the getbatlevel it goes like the clappers. If I reintroduce either it slows right down. I have all the averaging loops for both and the signals are still steady and the speed went up to 40 samples per second. I then reduced the times it went to get the battary level to every 150 samples. I am now getting 80 samples per second which is quite acceptable. It didnt seem to make a differance changing the clock to 40mHz using HSPLL and a 10Mhz crystal, but I have left it at that.

    Again many thanks Alain for your help. Its great knowing that this forum is here with such helpful people.

    cheers and many thanks John

  2. #2
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    I realize you have reached your target, but here are some tips to help in the future.

    The shiftin/shiftout commands are dreadfully, painfully, pathetically slow. And also very slow. If you use an onboard a/d, or at the least, use the hardware SPI module to talk to an external a/d, you will gain a huge amount of thru-put... On the order of 10x faster, if the off-chip a/d can handle it.

    Another trick is to send the data as raw values, and format it on the receiving end since it's fixed width. That will save a minimum of 30% in your case, 20% if you want to leave an alignment byte.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by J_norrie View Post
    Hi Alain, Thanks for your help. It turns out that the main reason I cant get it to go faster seems to be the time it needs to carry out the analog to digital conversions
    Hi, John

    You also could reduce Adc sampling time to 100 or 200 µs ... instead of 5 ms !

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

Members who have read this thread : 1

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