On 4/15/2016 1:32 PM, Tim Wescott wrote:> On Fri, 15 Apr 2016 14:43:03 +0100, Paul wrote: > >> In article <wpydnbi9wr9Ujo3KnZ2dnUU7-WXNnZ2d@giganews.com>, >> seemywebsite@myfooter.really says... >>> >>> Embedded Systems Design (or whatever they call themselves) kept moving >>> this around -- so I've revamped it, updated it, and posted it on the >>> web. >>> >>> Take a gander. Please comment on anything you like/don't like. I'm >>> not sure if the way that I'm setting off the math is a Really Good Idea >>> or a Really Bad Idea -- I'm trying to make it easy for the math-averse >>> to skip over it, without breaking up the flow too much for folks who >>> can read math without breaking stride. >>> >>> http://wescottdesign.com/articles/pid/pidWithoutAPhd.pdf >> >> OOps just spotted a terminology blunder >> >> Page 2 >> The "PID" in "PID Control" stands for "Proportional, Integral, >> Derivative". >> >> Page 19 >> >> Section Title is "Differential" Should be "Derivative" >> >> From there on you interchange differential and derivavtive all over the >> place. > > That calls for clarification. "Derivative" is the correct term if you're > doing the work with continuous-time hardware (i.e. op-amps, resistors and > capacitors). "Differential" is the correct term if you're doing the work > in sampled time. > > So I need to figure out how to work that in.I was going to make that comment, but then I recalled the term my professor actually used was "difference equations". "Differential equations" means something else, no? I couldn't find any sources on this, so I didn't make the comment. It's been far too long to trust my memory. -- Rick
PID Without a PhD, Finally
Started by ●April 14, 2016
Reply by ●April 15, 20162016-04-15
Reply by ●April 15, 20162016-04-15
On 4/15/2016 12:31 PM, Tim Wescott wrote:> rickman <gnuarm@gmail.com> Wrote in message: >> On 4/15/2016 5:28 AM, Tauno Voipio wrote: >>> On 15.4.16 02:11, rickman wrote: >>>> >>>> Page 4, equation 1, you might explain the basis of this equation. I >>>> assume the voltage actually controls the torque. Friction force is a >>>> result of velocity and the acceleration is from the excess force until >>>> the motor speeds up. Contrasted to the equation for the frictionless >>>> platform. >>> >>> >>> Rick: >>> >>> Every motor is also a generator. For a motor with constant >>> magnetization, the back EMF is proportional to the speed and >>> the motor torque is proportional to the current. >>> >>> You can model such a motor with a series connection of the >>> supply voltage, the motor (and line) resistance and the back >>> EMF. The motor settles to a speed near such speed that the >>> difference between supply voltage and back EMF runs just enough >>> current in the circuit to compensate for torque needed to keep >>> the speed. >>> >>> If you feed a constant-magnetized motor with a constant current >>> supply, the torque stays constant until the compliance limit >>> of the feed supply. >> >> Ok, that all makes sense and is what is being described in the paper. >> The drive is current rather than voltage and will produce the result >> shown in the diagram until the max voltage of the supply is reached. >> Thanks. >> >> I still don't get equation 3. I searched a bit and could not find >> anything similar. All the other references I found on the web use the >> Laplace transform to perform the math and don't produce a similar equation. >> >> Trying to find info on the web for control theory really opens a rabbit >> hole, lol. >> >> -- >> >> Rick >> > > Thermal systems are generally far more complex than equation 3 > implies. That one really should be taken just add the equation > used to generate the plant model, nothing more. > > Pragmatically, if you need to wrap a control loop around a thermal > plant, you should probably close your eyes to the theory and > either tune it up by the seat of your pants (as in that paper), > or you should use measured responses (which I cover briefly in > another paper, and at length in my book).Yes, I understand a real system may be more complicated. But as I've said before, if I can't understand what an equation means, I have a very hard time understanding how to use it. I just need to "get" the equations you use as examples. This one eludes me and you seem to be saying you sort of made it up without a physical basis. You said you invented not one, but two time constants. -- Rick
Reply by ●April 15, 20162016-04-15
On Fri, 15 Apr 2016 13:51:41 -0400, rickman wrote:> On 4/15/2016 12:31 PM, Tim Wescott wrote: >> rickman <gnuarm@gmail.com> Wrote in message: >>> On 4/15/2016 5:28 AM, Tauno Voipio wrote: >>>> On 15.4.16 02:11, rickman wrote: >>>>> >>>>> Page 4, equation 1, you might explain the basis of this equation. I >>>>> assume the voltage actually controls the torque. Friction force is >>>>> a result of velocity and the acceleration is from the excess force >>>>> until the motor speeds up. Contrasted to the equation for the >>>>> frictionless platform. >>>> >>>> >>>> Rick: >>>> >>>> Every motor is also a generator. For a motor with constant >>>> magnetization, the back EMF is proportional to the speed and the >>>> motor torque is proportional to the current. >>>> >>>> You can model such a motor with a series connection of the supply >>>> voltage, the motor (and line) resistance and the back EMF. The motor >>>> settles to a speed near such speed that the difference between supply >>>> voltage and back EMF runs just enough current in the circuit to >>>> compensate for torque needed to keep the speed. >>>> >>>> If you feed a constant-magnetized motor with a constant current >>>> supply, the torque stays constant until the compliance limit of the >>>> feed supply. >>> >>> Ok, that all makes sense and is what is being described in the paper. >>> The drive is current rather than voltage and will produce the result >>> shown in the diagram until the max voltage of the supply is reached. >>> Thanks. >>> >>> I still don't get equation 3. I searched a bit and could not find >>> anything similar. All the other references I found on the web use the >>> Laplace transform to perform the math and don't produce a similar >>> equation. >>> >>> Trying to find info on the web for control theory really opens a >>> rabbit hole, lol. >>> >>> -- >>> >>> Rick >>> >>> >> Thermal systems are generally far more complex than equation 3 >> implies. That one really should be taken just add the equation used >> to generate the plant model, nothing more. >> >> Pragmatically, if you need to wrap a control loop around a thermal >> plant, you should probably close your eyes to the theory and either >> tune it up by the seat of your pants (as in that paper), >> or you should use measured responses (which I cover briefly in >> another paper, and at length in my book). > > Yes, I understand a real system may be more complicated. But as I've > said before, if I can't understand what an equation means, I have a very > hard time understanding how to use it. I just need to "get" the > equations you use as examples. This one eludes me and you seem to be > saying you sort of made it up without a physical basis. You said you > invented not one, but two time constants.Here's how you use that equation within the intended context of the paper: * Look at it. * Say "oh, it's math". * move on. Seriously. If you're not trying to duplicate the examples, you _do not need the math_. That's the point of the paper. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●April 15, 20162016-04-15
On Fri, 15 Apr 2016 13:44:54 -0400, rickman wrote:> On 4/15/2016 1:30 PM, Tim Wescott wrote: >> >> Thank you for your pertinent comments. I think I'll apply most of >> them. The only scary part of your comments are the "if someone uses the >> code" -- I originally meant this code to be for illustrative purposes >> only, not for use in production systems. My assumption was that people >> would read the article, grok the material, then go off and write code >> from scratch. >> >> Thus, the first time I got feedback along the lines of "we copied your >> code into our production software and it works GREAT!" my response was >> >> "WHAT!?! NOOOO!" > > That is why papers often use pseudo code rather than real code that can > be copied. > > >> So I would be tempted to take your real_t and change it to >> do_not_use_this_for_real_t. >> >> I have a question, since you brought it up and since I'm lazy. In many >> control systems, 32-bit IEEE floating point is inadequate, because a 24 >> bit significand just doesn't cut it. So the choice of double, with its >> bigger significand, is usually necessary. >> >> Is there a better way to express the "you damned well need 'double' >> here, >> bub" in code than just using "double", or a comment to that effect? > > How about a comment that you shouldn't be doing this unless you actually > understand what is happening?Because then you would never start. Possibly 90% of the control loops in the world are implemented by people who have no greater understanding of control theory than what's presented in that paper. I'm not trying to turn people into control engineers, I'm trying to supply a pragmatic solution to a large class of real-world problems. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●April 15, 20162016-04-15
On Fri, 15 Apr 2016 13:47:18 -0400, rickman wrote:> On 4/15/2016 1:32 PM, Tim Wescott wrote: >> On Fri, 15 Apr 2016 14:43:03 +0100, Paul wrote: >> >>> In article <wpydnbi9wr9Ujo3KnZ2dnUU7-WXNnZ2d@giganews.com>, >>> seemywebsite@myfooter.really says... >>>> >>>> Embedded Systems Design (or whatever they call themselves) kept >>>> moving this around -- so I've revamped it, updated it, and posted it >>>> on the web. >>>> >>>> Take a gander. Please comment on anything you like/don't like. I'm >>>> not sure if the way that I'm setting off the math is a Really Good >>>> Idea or a Really Bad Idea -- I'm trying to make it easy for the >>>> math-averse to skip over it, without breaking up the flow too much >>>> for folks who can read math without breaking stride. >>>> >>>> http://wescottdesign.com/articles/pid/pidWithoutAPhd.pdf >>> >>> OOps just spotted a terminology blunder >>> >>> Page 2 >>> The "PID" in "PID Control" stands for "Proportional, Integral, >>> Derivative". >>> >>> Page 19 >>> >>> Section Title is "Differential" Should be "Derivative" >>> >>> From there on you interchange differential and derivavtive all over >>> the >>> place. >> >> That calls for clarification. "Derivative" is the correct term if >> you're doing the work with continuous-time hardware (i.e. op-amps, >> resistors and capacitors). "Differential" is the correct term if >> you're doing the work in sampled time. >> >> So I need to figure out how to work that in. > > I was going to make that comment, but then I recalled the term my > professor actually used was "difference equations". "Differential > equations" means something else, no? I couldn't find any sources on > this, so I didn't make the comment. It's been far too long to trust my > memory."Differential equations" are what you need to describe things in a continuous-time world (the three equations in the paper are differential equations). "Difference equations" are what you need to describe things in a discrete- time world. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●April 15, 20162016-04-15
On 04/15/2016 01:35 PM, Tim Wescott wrote:> On Fri, 15 Apr 2016 09:31:49 -0700, Tim Wescott wrote: > >> rickman <gnuarm@gmail.com> Wrote in message: >>> On 4/15/2016 5:28 AM, Tauno Voipio wrote: >>>> On 15.4.16 02:11, rickman wrote: >>>>> >>>>> Page 4, equation 1, you might explain the basis of this equation. I >>>>> assume the voltage actually controls the torque. Friction force is a >>>>> result of velocity and the acceleration is from the excess force >>>>> until the motor speeds up. Contrasted to the equation for the >>>>> frictionless platform. >>>> >>>> >>>> Rick: >>>> >>>> Every motor is also a generator. For a motor with constant >>>> magnetization, the back EMF is proportional to the speed and the motor >>>> torque is proportional to the current. >>>> >>>> You can model such a motor with a series connection of the supply >>>> voltage, the motor (and line) resistance and the back EMF. The motor >>>> settles to a speed near such speed that the difference between supply >>>> voltage and back EMF runs just enough current in the circuit to >>>> compensate for torque needed to keep the speed. >>>> >>>> If you feed a constant-magnetized motor with a constant current >>>> supply, the torque stays constant until the compliance limit of the >>>> feed supply. >>> >>> Ok, that all makes sense and is what is being described in the paper. >>> The drive is current rather than voltage and will produce the result >>> shown in the diagram until the max voltage of the supply is reached. >>> Thanks. >>> >>> I still don't get equation 3. I searched a bit and could not find >>> anything similar. All the other references I found on the web use the >>> Laplace transform to perform the math and don't produce a similar >>> equation. >>> >>> Trying to find info on the web for control theory really opens a rabbit >>> hole, lol. >>> >>> -- >>> >>> Rick >>> >>> >> Thermal systems are generally far more complex than equation 3 >> implies. That one really should be taken just add the equation used to >> generate the plant model, nothing more. >> >> Pragmatically, if you need to wrap a control loop around a thermal >> plant, you should probably close your eyes to the theory and either >> tune it up by the seat of your pants (as in that paper), >> or you should use measured responses (which I cover briefly in another >> paper, and at length in my book). > > I double-checked, and I kind of allude to this but I need to SAY this in > the text. Thermal systems are generally sluggish with lots of high- > frequency roll-off. The model chosen is sluggish with lots of high- > frequency roll-off. That's about the extent of the accuracy of the > model, in general. On a good day the chosen model may actually match a > real thermal system well enough to work with -- but it's not to be taken > as a generally accurate model, where equations 1 and 2 are generally much > more applicable.Lots of high frequency rolloff and even more high frequency phase shift. In thermal diffusion, you get another radian for every 1/e amplitude decay, which makes PID kind of disappointing IME. My TC loops are always pretty simple--diode lasers on TECs, or resonators with a heater--but after the nonlinearity is taken out, I can usually get away with a plant model of a time delay followed by an integrator. You can read the parameters right off the scope trace. I'm perfectly sure that was invented a very long time ago, but it works great for smallish stuff. Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
Reply by ●April 15, 20162016-04-15
On Fri, 15 Apr 2016 14:04:05 -0400, Phil Hobbs wrote:> On 04/15/2016 01:35 PM, Tim Wescott wrote: >> On Fri, 15 Apr 2016 09:31:49 -0700, Tim Wescott wrote: >> >>> rickman <gnuarm@gmail.com> Wrote in message: >>>> On 4/15/2016 5:28 AM, Tauno Voipio wrote: >>>>> On 15.4.16 02:11, rickman wrote: >>>>>> >>>>>> Page 4, equation 1, you might explain the basis of this equation. >>>>>> I assume the voltage actually controls the torque. Friction force >>>>>> is a result of velocity and the acceleration is from the excess >>>>>> force until the motor speeds up. Contrasted to the equation for >>>>>> the frictionless platform. >>>>> >>>>> >>>>> Rick: >>>>> >>>>> Every motor is also a generator. For a motor with constant >>>>> magnetization, the back EMF is proportional to the speed and the >>>>> motor torque is proportional to the current. >>>>> >>>>> You can model such a motor with a series connection of the supply >>>>> voltage, the motor (and line) resistance and the back EMF. The motor >>>>> settles to a speed near such speed that the difference between >>>>> supply voltage and back EMF runs just enough current in the circuit >>>>> to compensate for torque needed to keep the speed. >>>>> >>>>> If you feed a constant-magnetized motor with a constant current >>>>> supply, the torque stays constant until the compliance limit of the >>>>> feed supply. >>>> >>>> Ok, that all makes sense and is what is being described in the paper. >>>> The drive is current rather than voltage and will produce the result >>>> shown in the diagram until the max voltage of the supply is reached. >>>> Thanks. >>>> >>>> I still don't get equation 3. I searched a bit and could not find >>>> anything similar. All the other references I found on the web use >>>> the Laplace transform to perform the math and don't produce a similar >>>> equation. >>>> >>>> Trying to find info on the web for control theory really opens a >>>> rabbit hole, lol. >>>> >>>> -- >>>> >>>> Rick >>>> >>>> >>> Thermal systems are generally far more complex than equation 3 >>> implies. That one really should be taken just add the equation used >>> to generate the plant model, nothing more. >>> >>> Pragmatically, if you need to wrap a control loop around a thermal >>> plant, you should probably close your eyes to the theory and either >>> tune it up by the seat of your pants (as in that paper), >>> or you should use measured responses (which I cover briefly in >>> another paper, and at length in my book). >> >> I double-checked, and I kind of allude to this but I need to SAY this >> in the text. Thermal systems are generally sluggish with lots of high- >> frequency roll-off. The model chosen is sluggish with lots of high- >> frequency roll-off. That's about the extent of the accuracy of the >> model, in general. On a good day the chosen model may actually match a >> real thermal system well enough to work with -- but it's not to be >> taken as a generally accurate model, where equations 1 and 2 are >> generally much more applicable. > > Lots of high frequency rolloff and even more high frequency phase shift. > In thermal diffusion, you get another radian for every 1/e amplitude > decay, which makes PID kind of disappointing IME. > > My TC loops are always pretty simple--diode lasers on TECs, or > resonators with a heater--but after the nonlinearity is taken out, I can > usually get away with a plant model of a time delay followed by an > integrator. You can read the parameters right off the scope trace. I'm > perfectly sure that was invented a very long time ago, but it works > great for smallish stuff.I may change my model. Probably the most important temperature loop I've ever closed (the temperature of a focal plane array, cooled by a split-cycle Stirling cooler) had a simple 1st-order dominant pole, with no discernible excess phase shift or attenuation until well past the practical loop closing frequency. I was happily astonished. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Reply by ●April 15, 20162016-04-15
DaveC <not@home.cow> writes:>> I'm reminded of a YouTube video about how NOT to weld > > Can you remember the guy--and find the link to that video series?ChuckE2009 https://www.youtube.com/watch?v=PJDv7Y6dUi0 mig welding https://www.youtube.com/watch?v=akvv4ApYMVE stick welding https://www.youtube.com/watch?v=CVAByfuZXIY tig welding
Reply by ●April 15, 20162016-04-15
On 04/15/2016 02:11 PM, Tim Wescott wrote:> On Fri, 15 Apr 2016 14:04:05 -0400, Phil Hobbs wrote: > >> On 04/15/2016 01:35 PM, Tim Wescott wrote: >>> On Fri, 15 Apr 2016 09:31:49 -0700, Tim Wescott wrote: >>> >>>> rickman <gnuarm@gmail.com> Wrote in message: >>>>> On 4/15/2016 5:28 AM, Tauno Voipio wrote: >>>>>> On 15.4.16 02:11, rickman wrote: >>>>>>> >>>>>>> Page 4, equation 1, you might explain the basis of this equation. >>>>>>> I assume the voltage actually controls the torque. Friction force >>>>>>> is a result of velocity and the acceleration is from the excess >>>>>>> force until the motor speeds up. Contrasted to the equation for >>>>>>> the frictionless platform. >>>>>> >>>>>> >>>>>> Rick: >>>>>> >>>>>> Every motor is also a generator. For a motor with constant >>>>>> magnetization, the back EMF is proportional to the speed and the >>>>>> motor torque is proportional to the current. >>>>>> >>>>>> You can model such a motor with a series connection of the supply >>>>>> voltage, the motor (and line) resistance and the back EMF. The motor >>>>>> settles to a speed near such speed that the difference between >>>>>> supply voltage and back EMF runs just enough current in the circuit >>>>>> to compensate for torque needed to keep the speed. >>>>>> >>>>>> If you feed a constant-magnetized motor with a constant current >>>>>> supply, the torque stays constant until the compliance limit of the >>>>>> feed supply. >>>>> >>>>> Ok, that all makes sense and is what is being described in the paper. >>>>> The drive is current rather than voltage and will produce the result >>>>> shown in the diagram until the max voltage of the supply is reached. >>>>> Thanks. >>>>> >>>>> I still don't get equation 3. I searched a bit and could not find >>>>> anything similar. All the other references I found on the web use >>>>> the Laplace transform to perform the math and don't produce a similar >>>>> equation. >>>>> >>>>> Trying to find info on the web for control theory really opens a >>>>> rabbit hole, lol. >>>>> >>>>> -- >>>>> >>>>> Rick >>>>> >>>>> >>>> Thermal systems are generally far more complex than equation 3 >>>> implies. That one really should be taken just add the equation used >>>> to generate the plant model, nothing more. >>>> >>>> Pragmatically, if you need to wrap a control loop around a thermal >>>> plant, you should probably close your eyes to the theory and either >>>> tune it up by the seat of your pants (as in that paper), >>>> or you should use measured responses (which I cover briefly in >>>> another paper, and at length in my book). >>> >>> I double-checked, and I kind of allude to this but I need to SAY this >>> in the text. Thermal systems are generally sluggish with lots of high- >>> frequency roll-off. The model chosen is sluggish with lots of high- >>> frequency roll-off. That's about the extent of the accuracy of the >>> model, in general. On a good day the chosen model may actually match a >>> real thermal system well enough to work with -- but it's not to be >>> taken as a generally accurate model, where equations 1 and 2 are >>> generally much more applicable. >> >> Lots of high frequency rolloff and even more high frequency phase shift. >> In thermal diffusion, you get another radian for every 1/e amplitude >> decay, which makes PID kind of disappointing IME. >> >> My TC loops are always pretty simple--diode lasers on TECs, or >> resonators with a heater--but after the nonlinearity is taken out, I can >> usually get away with a plant model of a time delay followed by an >> integrator. You can read the parameters right off the scope trace. I'm >> perfectly sure that was invented a very long time ago, but it works >> great for smallish stuff. > > I may change my model. > > Probably the most important temperature loop I've ever closed (the > temperature of a focal plane array, cooled by a split-cycle Stirling > cooler) had a simple 1st-order dominant pole, with no discernible excess > phase shift or attenuation until well past the practical loop closing > frequency. I was happily astonished. >Plus you were a hero. It's nice when things work out that way. One time when I was a post-doc, a colleague needed a notch filter to get rid of a 30-kHz resonance in the piezo tube actuator of the STM he was building. I reached into my bench drawer, pulled out a largish Pulse Engineering transformer, and parallel-resonated both sides with a 0.1 uF cap on it, just as a first try. Stuck a sweep generator and scope on it, and what came out was a nearly symmetrical two-bump notch exactly at 30 kHz, with a Q of about 30. Then of course I just quietly handed it to him, smiled, and went back to work. Never did let slip that it was a total fluke. ;) I still don't know where the beautiful two-bump notch shape came from--leakage inductance and capacitor tolerance, I suppose. Cheers Phil Hobbs -- Dr Philip C D Hobbs Principal Consultant ElectroOptical Innovations LLC Optics, Electro-optics, Photonics, Analog Electronics 160 North State Road #203 Briarcliff Manor NY 10510 hobbs at electrooptical dot net http://electrooptical.net
Reply by ●April 15, 20162016-04-15
On 15/04/16 19:30, Tim Wescott wrote: <snip>> Hi David: > > Thank you for your pertinent comments. I think I'll apply most of them. > The only scary part of your comments are the "if someone uses the code" > -- I originally meant this code to be for illustrative purposes only, not > for use in production systems. My assumption was that people would read > the article, grok the material, then go off and write code from scratch. > > Thus, the first time I got feedback along the lines of "we copied your > code into our production software and it works GREAT!" my response was > > "WHAT!?! NOOOO!"You might want to give that section a better title than "The Complete Controller", with the program description "Here is the full text of the PID controller code" :-) Perhaps a big warning in red that this is example code to get started.> > So I would be tempted to take your real_t and change it to > do_not_use_this_for_real_t. > > I have a question, since you brought it up and since I'm lazy. In many > control systems, 32-bit IEEE floating point is inadequate, because a 24 > bit significand just doesn't cut it. So the choice of double, with its > bigger significand, is usually necessary. > > Is there a better way to express the "you damned well need 'double' here, > bub" in code than just using "double", or a comment to that effect? >In a good many systems, double is not good enough either - it will be too slow. The developer needs to use some sort of scaled integers to get 32 bits of precision (especially in the integrator), and may even need to use 64-bit integer arithmetic for intermediary results. It would be nice if there were some equivalent to <stdint.h> that defined types like float32_t and float64_t, but there isn't one. There are some macros in <float.h> defining aspects of floating point types, but they are a bit ugly - and since you are always going to have 32-bit IEEE floats and 64-bit IEEE doubles (unless your compiler cheats by using 32-bit doubles, as you sometimes see on small micros), there is nothing there worth checking. If 32-bit IEEE is not good enough, just write "double" - and make a note that it has to be a /real/ double, not a non-standard 32-bit version.







