PID algorithm in C

And everybody says it's tricky but nobody ever bothers to give even any hints as to how to determine the coefficients...

Reply to
Everett M. Greene
Loading thread data ...

Read some books on Linear Algebra, Feedback Stabilities, Matrix Algebra and Different Equations. We don't have to repeat the college courses that you should have taken.

Reply to
linnix

the robot smoothly back onto its proper path.

Mike, the code for a simple PID is a threeliner. Plus an additional line to stop the integrator when the output hits the rails. We're not talking autowhatever.

First one has to have a basic understanding on system behavious, whether a system is integrating or not. Then one has to estimate the nonlinearities. One has to have an idea about frequency response and phase. When you have heard about all this, then the threeliner is done. Just in case you have more sensors than the one for the eventual measurement, and the system is not acting as expected, a state control is the way to go further. Once you heard a semester about state control with virtual viewer, then the few more lines are also trivial, the parameters take a bit more then.

Rene

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Reply to
Rene Tschaggelar

The original post showed little detail of what was trying to be achieved except 'hand-waving' and technology 'buzzwords'. no information on expected travel time or distance, let alone how close to the end point is classed as being at 'set point'.

Until you know the scope of what is being attempted, PID or whatever algorithm is pointless. Especially if what is being used to determine error may cause more oscillations or drift than any algorithm can correct.

The points made refered to what was the original poster trying to achieve NOT what can be achieved with limitless budgets and limitless resources.

Until you know what is trying to be achieved, any assistance is just 'hand waving', based on personal experience which may be different to the questioners experience or expectations.

For all we know the original poster could be

a) tring to achieve the DARPA autonomous vehicle challenge

b) moving a CNC machine workpiece no more than 10 mm steps max distance of 1m in less than 0.1 seconds.

c) anything in between the two.

--
Paul Carpenter          | paul@pcserviceselectronics.co.uk
    PC Services
              GNU H8 & mailing list info
             For those web sites you hate
Reply to
Paul Carpenter

I would disagree - what a great way of learning about PID controllers. If the OP's software can accept the PID constants easily, then he can experiment with different setups and see the effects instantly with his robot.

He could:

- Try pure I (slow but quiet) and pure P and think about results

- Add some I (slow) to his P and some D and think about results

- try some anti reset windup on the I and see what happens

- think about the affects of his AD & DA resolution will have in his system

- think about sampling time, and what effect that will have (including on the D term)

Is there anything else (if the OP isn't trying to get maximum performance from his system)? I think that is it.

The OP would of course be recommended to do some reading on the subject from good sources, but that doesn't preclude him from getting some good practical experience with this stuff.

Regards,

Paul.

Reply to
Paul Taylor

I ignored this thread originally because it was another one of those where the poor new guy gets to hear all the "old timers" tell him/her about why they are too stupid/ignorant/inexperienced to try what they are attempting and if they don't fully understand the concept behind the X, Y or Z technology they are just ignorant and should go back to school, or bitch about how they didn't post a full spec on the project. That being said, I'm sure those "old timers" forgot that the best (and most memorable) lessons they ever learned were from jumping in to something WAYYYY over their heads and slogging it out until they understood what was going on. So, in a nut shell, I agree with you. By all means, get a good book on PID algorithms. Read it cover to cover, but then LIVE it by trying to make some real tangible thing and see what happens. It is pretty sad when we are discouraging a person from trying something that will educate them. Sure it might not work, but that is knowledge too. How many of you have a bin of prototypes around that didn't work? Why do you keep them? What did you learn?

Jim

Reply to
James Beck

On Mar 15, 10:59 am, James Beck

It's a shelf in my case, and I refer to it as the Wall of Folly. Products are positioned according to how expensive they were to make. Currently the top item is a little device that cost [the company for which I was working] almost $300,000 plus another $100,000 in miscellaneous marketing, shipping, returns acceptance, collections and interest. I wasn't involved in the design or debug of the piece of the product that didn't work, but that didn't help me...

Reply to
larwe

Lessons come in all price ranges ;) I have had a few thousand dollar Mondays. I hope to never have a $330K Monday though!

Jim

Reply to
James Beck

There are thousands, if not millions, of PID loops in mills and factories around the world that are specified, installed, maintained, and tuned by people who don't understand PID, yet build machines with them that do their jobs adequately, if not not optimally.

So I disagree.

Having said that, there are also innumerable applications where PID control is the correct answer, but where you'll never get it working without understanding the theory. Moreover, without the theory you won't necessarily know which type of problem you're dealing with unless you try and either succeed or fail.

For the former type of system there's my article on PID. For the latter, there's my book -- or me.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

Yes, efficiency is the key. You can run feedback loops with or without PID. But for robotics, using minimum energy might be desirable.

Unfortunately, many don't even know why they are needed, since they only learn about fancy interfaces and not about getting more mileages (auto is a good example).

Reply to
linnix

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.