PID-filter routine (2nd try).


Results 1 to 40 of 132

Threaded View

  1. #18
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: PID-filter routine (2nd try).

    Hi,
    OK, lots of information here and I'm having a bit of a hard time following it all but here are a couple of thoughts.

    Since you have the pid_OutClamp set to 240 and a proportional gain of 1 it means that the output will only "swing" when the CHANNEL1 variable is above 240 (because SetPoint is hardcoded to 480). If it's anything below 240 then the error * Kp is more than the clamp value so the output saturates. For example, if the CHANNEL1 value is 235 the error will be 480-235=245, the clamp is 240 so that's what you'll get.

    If you do a step change of the PWM dutycycle, (ie. if you go from 20% to 80% dutycycle) how fast does the current in the system change?
    I mean, you have a PAUSE 10 in there meaning you're only running the loop at 100Hz, it also looks like you're writing to EEPROM in the GetAD routine, which also takes around 10ms per byte so then we're down to around 50Hz. I'm not sure but 50Hz sounds awfully slow for a current control loop. You say that you've tried without any PAUSE at all but I still think you have around 10ms delay due to the WRITE instruction in the GetAD routine.

    Not sure I understand what you mean with there is a 50% duty cycle between a full on clamp and whatever the pid value should be. Can you clarify?

    May I suggest you try to implement this on something slower to begin with? Try a temp-sensor tightly coupled to lightbulb driven by the PWM signal for example - I think it'll make it a lot easier to begin with.

    /Henrik.
    Last edited by HenrikOlsson; - 6th March 2012 at 07:23.

Similar Threads

  1. Darrel's latest 16 bit averaging routine?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 17th October 2009, 01:57
  2. 2nd order Low-pass passive RC filter on PWM
    By munromh in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th January 2009, 19:03
  3. Atod Digital Filter
    By GeoJoe in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd April 2008, 17:04
  4. PID controller in 16F737
    By joeri in forum mel PIC BASIC
    Replies: 8
    Last Post: - 24th June 2006, 11:39
  5. 2nd Order Digital Filter for 24-bit
    By sefayil in forum mel PIC BASIC
    Replies: 0
    Last Post: - 2nd December 2005, 21:55

Members who have read this thread : 2

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts