digital integrator algo for bipolar sigs?


Closed Thread
Results 1 to 3 of 3
  1. #1
    pwhitt's Avatar
    pwhitt Guest

    Default digital integrator algo for bipolar sigs?

    I am using an 18F4520 in a PI control loop and am having problems with the integrator code that I suspect may have been more elegantly dealt with by others. I'd love to see examples or suggestions from those with more experience.

    Currently I am able to generate the error signal and was previously using an external analog integrator. To move the integration into the PIC I have to overcome several things - mainly that the integrator doesn't just sum, it subtracts when the new value is below zero (in this case my signals going into the PIC are between 00 and FF, with 7F corresponding to zero in the analog portions). There must also be checks so that values below 00 or above FF saturate, not roll over.

    I cannot imagine that I am the only person to do this in this way, and there must be a simpler way to approach it rather than to use a separate PIC to integrate - or use a series of nested IF/THEN statements that slows things dramatically.

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


    Did you find this post helpful? Yes | No

    Default

    Hi pwhitt,

    Although it was written for the Basic Stamp, you may find this usefull.

    http://www.parallax.com/dl/docs/books/edu/ic.pdf

    Look at experiment #6<br><br>
    DT

  3. #3
    pwhitt's Avatar
    pwhitt Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel,

    This is actually a slower approach than what I am doing. It is more nicely coded - but the branching would greatly reduce the speed. I'm trying to run a loop that will iterate at over 100kHz, and I am not concerned with regular periodicity, ie if it runs a few times at 125kHz and a few periods are at 110kHz all is well.

    i have proportional control running at 800kHz. However when i add the integral calculation, check for saturation and sum the result, it's at nearly 50kHz. I've managed to get the calculations as clean as possible, but the IF/THENs are killing me.

    I was really hoping a CE out there would have a suggestion as to how to deal with this. For instance, the first condition in my current loop checks to see if the result is between 00 and FF, then writes it, then immediately returns to the sample. It only checks for saturation if that condition fails, resulting in an aperiodic signal, but it is only slow when the output is saturated - so I'm not worried about that.

    Even if it requires raw assembly I'll be happy to implement it. I'm also trying to come up with a very long routine that would branch only once or twice while continusously resampling and writing when not saturated.

Similar Threads

  1. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 22:48
  2. PIC 18f4680 DIGITAL INPUTS
    By MegaADY in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2008, 07:34
  3. I2C Comm with Digital Compass HMC6352
    By jihlein in forum Serial
    Replies: 10
    Last Post: - 9th April 2008, 22:25
  4. Replies: 4
    Last Post: - 24th January 2007, 22:20
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 03:38

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