Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Salman on May 22, 2008, 02:40:37 PM

Title: PID controller programming in AVR controller
Post by: Salman on May 22, 2008, 02:40:37 PM
 ???
I have searched the internet but have failed to find sufficient info on how to program a controller to work as PID...........can u pls help me solve this problem...............also can we use hardware format PID in conjunction with AVR that too how...........pls help me out ;D
Title: Re: PID controller programming in AVR controller
Post by: pomprocker on May 22, 2008, 04:13:39 PM
Here is how to do it in BASIC on the BS2

http://forums.parallax.com/forums/default.aspx?f=6&m=66982 (http://forums.parallax.com/forums/default.aspx?f=6&m=66982)


If you know C then you should be able to convert the code yourself
Title: Re: PID controller programming in AVR controller
Post by: benji on May 23, 2008, 09:50:17 AM
good link pomprocker
Title: Re: PID controller programming in AVR controller
Post by: Salman on May 23, 2008, 10:43:30 PM
I wish to be using this PID controler for controlling a heater , compresser and a piltier module. I am basically making a final year project in which i have to control the temprature of an incubator between -10c to +40c..........so how will I use the error should I use a comparator and till the time the value doesnot become 0 keep the related equipment on some thing like that.........Also as the user needs to set the temprature the setpoint would become the input temprature..........Pls provide me with some usefull tips........
is this block diagram ok
sensor-->ADC-->PID-->controller-->relay-->heater
Title: Re: PID controller programming in AVR controller
Post by: benji on May 24, 2008, 03:55:55 AM

Quote
..........so how will I use the error should I use a comparator and till the time the value doesnot become 0 keep the related equipment on some thing like that.........
yea osmthing like that ,,but lets put it this way
when your error is 0 (that means the heat is the same as the setpoint) then Kp*0=0 so no output and no changin anything
when your error has a number then you need to react someway,, this is how you determine kp.
so what you mentioned is just P ,,

, do you want to make all controls? P and I and D?

D helps you to run faster towards fixing your error when the error changes

do you need this property?

anyways that was a block diagram to understand the concept
you can turn it into a circuit the way you like,,
you can use a microcontroller,,or not ,,
the design can take many forms,
Title: Re: PID controller programming in AVR controller
Post by: Salman on May 24, 2008, 12:06:13 PM
well yes I have to use all of the three P,I and  D. how will i determine Kp, Ki and Kd.........I i wish to use a PID controller which work for diffrent tempratures so it needs to be made through programming so that it can be easily varied........
Title: Re: PID controller programming in AVR controller
Post by: benji on May 24, 2008, 03:29:16 PM
this is what is stated in the link above

Quote
The resulting actuator output exerts a correcting influence on the system.  By definition, this influence is proportional to the measured error.  Since the actuator output has some effect on the system, the sensor value is checked again, and the whole process is repeated, over and over again to maintain the level(s) in the system

your answer is here ,read it over and over,,the explains the whole thing
you determine your constants depending on how your system works,,your circuit,,
you just have to build a circuit that resembles this concept
i dont know whats your type of actuator output to answer that,, it could be a pwm signal , an analog signal,, ,,etc
i hoped this helped ya a little
Title: Re: PID controller programming in AVR controller
Post by: Rebelgium on May 24, 2008, 05:25:35 PM
well yes I have to use all of the three P,I and  D. how will i determine Kp, Ki and Kd.........I i wish to use a PID controller which work for diffrent tempratures so it needs to be made through programming so that it can be easily varied........

I don't think you fully understand what PID control means, as banji also said, read the link through.
Title: Re: PID controller programming in AVR controller
Post by: JesseWelling on May 24, 2008, 06:30:12 PM
One of the best articles for Novices who want to use PID, entitled "PID without a PhD (http://www.embedded.com/2000/0010/0010feat3.htm)"