PID-filter routine (2nd try).


Results 1 to 40 of 132

Threaded View

  1. #17
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

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

    I set pid_Out_Clamp = 240 which is max duty cycle. At that max duty cycle current at the LED with an input voltage of 27.5V should never go above 2.5A, but it does. The set target is an ADC of 480. At those figures the following it the duty cycle:

    Code:
    0000- 240 000 000 000 255 240 240 240 0008- 240 240 240 240 240 240 240 240 
    0010- 240 240 240 240 240 240 240 240 
    0018- 240 240 240 240 240 177 240 240 
    0020- 240 240 240 240 240 240 240 240 
    0028- 240 240 240 240 240 240 240 240 
    0030- 240 240 240 240 240 240 240 240 
    0038- 240 240 030 240 240 240 240 049 
    0040- 240 240 240 240 240 240 240 240 
    0048- 203 240 240 240 240 116 110 240 
    0050- 007 240 240 240 240 081 240 240 
    0058- 240 240 240 240 240 240 240 240 
    0060- 158 240 021 129 240 240 240 240 
    0068- 240 240 240 075 240 240 240 240 
    0070- 240 240 240 240 149 240 240 240 
    0078- 240 190 240 240 041 240 240 240 
    0080- 240 112 240 240 240 240 240 240 
    0088- 240 147 240 240 203 240 240 240 
    0090- 240 240 096 240 240 240 240 240 
    0098- 240 240 240 240 141 240 240 240 
    00a0- 240 240 240 240 240 126 240 240 
    00a8- 240 240 240 240 240 240 240 240 
    00b0- 240 240 240 240 240 240 240 240 
    00b8- 240 240 240 240 240 240 240 102 
    00c0- 240 240 240 240 240 082 240 240 
    00c8- 240 188 240 240 240 240 129 240 
    00d0- 240 131 240 240 240 240 240 240 
    00d8- 240 192 240 240 240 240 240 240 
    00e0- 240 108 240 240 240 240 116 240 
    00e8- 240 224 240 240 240 013 240 079 
    00f0- 240 240 240 240 240 240 240 240 
    00f8- 240 240 240 240 240 240 042 240
    And this is the ADC reading: (multiply these numbers by 4 to get the 10 bit actual value 166 = 664 etc etc.)

    Code:
    0000- 165 000 000 000 255 166 166 166 0008- 165 165 166 166 166 165 166 166 
    0010- 166 166 165 165 166 166 166 165 
    0018- 165 165 166 166 166 166 165 165 
    0020- 166 166 166 165 165 166 166 166 
    0028- 165 165 166 166 166 166 165 165 
    0030- 166 166 166 166 165 165 165 166 
    0038- 166 166 166 166 166 165 165 166 
    0040- 166 166 166 166 166 165 166 166 
    0048- 166 166 165 166 165 165 166 166 
    0050- 166 166 166 166 166 166 165 165 
    0058- 165 165 165 165 166 166 166 166 
    0060- 166 166 166 165 165 166 165 165 
    0068- 165 166 166 165 166 166 166 166 
    0070- 166 166 166 165 166 165 165 166 
    0078- 166 166 166 166 166 166 165 166 
    0080- 166 166 166 166 166 166 166 166 
    0088- 166 166 165 165 165 166 165 166 
    0090- 165 165 165 165 166 166 165 165 
    0098- 165 166 166 165 165 165 166 166 
    00a0- 166 166 165 166 166 166 166 165 
    00a8- 166 166 165 166 166 166 165 165 
    00b0- 166 165 166 166 165 165 165 165 
    00b8- 166 166 165 166 166 165 166 165 
    00c0- 165 166 165 165 166 166 165 166 
    00c8- 165 165 166 165 165 166 166 165 
    00d0- 166 166 165 166 166 165 166 166 
    00d8- 166 165 165 166 166 166 166 165 
    00e0- 165 166 166 166 166 166 166 166 
    00e8- 166 165 165 166 165 165 166 165 
    00f0- 165 165 166 166 166 165 166 166 
    00f8- 166 165 166 166 165 166 166 166
    And finally, this is the result of pid_Error = Setpoint - CHANNEL1

    [CODE0000- 077 000 000 000 255 076 077 076 0008- 077 077 076 076 077 077 076 075
    0010- 075 077 076 076 076 077 077 076
    0018- 076 077 077 076 076 077 077 077
    0020- 077 076 076 077 077 076 076 077
    0028- 077 076 076 075 077 076 077 077
    0030- 077 076 077 077 077 076 076 077
    0038- 076 077 077 076 075 077 076 076
    0040- 077 077 076 076 077 077 076 077
    0048- 077 076 077 077 076 077 077 076
    0050- 075 075 076 076 077 077 076 077
    0058- 076 076 077 076 075 077 077 076
    0060- 075 076 076 075 077 076 076 077
    0068- 076 077 077 076 077 076 076 077
    0070- 076 076 075 076 075 076 076 075
    0078- 075 076 076 077 076 076 077 076
    0080- 076 077 076 076 077 076 075 077
    0088- 076 076 075 076 076 077 076 075
    0090- 076 076 077 077 076 077 077 076
    0098- 076 077 075 077 076 075 077 076
    00a0- 075 076 076 077 077 076 076 077
    00a8- 076 077 076 076 077 077 076 077
    00b0- 077 077 077 078 076 076 076 076
    00b8- 077 076 076 076 076 077 077 077
    00c0- 077 076 076 077 077 077 077 077
    00c8- 076 076 076 077 077 077 076 076
    00d0- 076 076 077 076 077 077 077 077
    00d8- 077 077 076 076 076 076 077 077
    00e0- 076 077 077 077 077 077 077 076
    00e8- 076 076 076 076 077 076 077 077
    00f0- 077 076 076 076 076 077 077 077
    00f8- 077 077 077 077 077 077 076 076


    [/CODE]

    So, if the max ADC value is supposed to be 480, why is it clamping at a duty cycle of 240 giving a ADC value 664?
    Last edited by jmgelba; - 6th March 2012 at 00:19.

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