New Object for the Exchange- PID Loops
crgwbr
Posts: 614
Hey Everyone,
I finally got some spare time, so I decided to write a PID loop for the propellor. It implements the Proportional, Integral, and Derivative equations. If your application doesn't require on of those functions, just comment it out of the code. It can be found on the object exchange here.
Hope this helps someone out,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
I finally got some spare time, so I decided to write a PID loop for the propellor. It implements the Proportional, Integral, and Derivative equations. If your application doesn't require on of those functions, just comment it out of the code. It can be found on the object exchange here.
Hope this helps someone out,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
Comments
Graham
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
Graham
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
PID and quad encoding are two issues that have remained at a distance for me. Your very nice code and a visit to the Wikipedia on PID have cleared up PID... really simple when it is done right[noparse]:)[/noparse]
I really wish you or one of the other regulars would document a physical implentation using both PID and quad encoding, with commonly available parts.
Thanks again.
Rich
Regards,
Craig
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -
"If Python is executable pseudocode, then perl is executable line noise."
"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."
"My software never has bugs. It just develops random features."
"Windows isn't a virus, viruses do something."
"Programmers are tools for converting caffeine into code."
"Enter any 11-digit prime number to continue."
The link: http://members.aol.com/pidcontrol/pid_algorithm.html
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
But if you wanted to combine quadrature encoding, PID and some PWM for good luck then this would do the trick: http://ww1.microchip.com/downloads/en/AppNotes/00964A.pdf but with an encoder instead of a potentiometer (would need an index pulse too).
Graham
I am only slightly confused by the encoding... the hardware is unknown territory. I need to google some more[noparse]:)[/noparse]
Rich
After a couple of thousand school kids the pots get all scratchy and useless.
Quadrature encoders last many times longer and are mechanically compatible with pots also if you get the right kind a lot less torque is required to spin.
Making the signal useful is the interesting part.
Generally I use a jk flipflop (usually a 4013) to give a direction signal and clean up the clock then, I either pop on a digital pot (ad5330 or similar), or
use a micro controller with a hall effect sensor to set a centre point. From there some form of DAC.
~mumfy