# PID library question

Hello everyone!

I really love the site I have a quick question on how the Proportional loop is programmed in the PID library.

I am trying to maintain a temperature and I have my Proportional algorithm working great but I am having trouble understanding a few things.

Let me give an example, when I run my controller I have an initial temperature of 80F. I set my desired temperature to 90F and my program calculates the error of 10 (error = set point - present value). My code generates a scale factor using 0 and 10 and maps it to 0 to 100% (duty cycle of my PWM output controlling the solid state relay). I multiple the error by a gain and everything works great!

Now the next day I run my controller and my initial temperature is 70F. My desired temperature is once again 90F. My program once again calculates the scale factor equation using 0 and 20 and maps it to 0 to 100%. But now the gain value from yesterday needs to be tuned once again.

I was wondering if anyone knew how this was programmed in the PID library. My calculation must be wrong or I am missing something.

Any help will be appreciated.

It looks like I need to create a proportional band that is a percentage value that is calculated by 100/gain. Something doesn't make sense though. lets say my initial value is 39F and my set point is 40F. How does the proportional band work for such small discrepancy.

Pretend I know nothing about PID, which is almost true.
How would you explain PID to me?

This is something I learned from watching Richard Feynman and it's worked for just about everything reasonable. And besides, I could use learning a bit more about PID and the lesson would become part of the forum for others as well. Are you game?

GoForSmoke:
Pretend I know nothing about PID, which is almost true.
How would you explain PID to me?

This is something I learned from watching Richard Feynman and it's worked for just about everything reasonable. And besides, I could use learning a bit more about PID and the lesson would become part of the forum for others as well. Are you game?

That's a great idea. There is nothing like trying to teach someone else something to reinforce the concepts for the teacher.

I can consider every program as teaching the computer how to do every bit of something.

And here is a video that explains a very effective way to approach that.

But also, I'd really like to see more on using PID effectively. The OP's questions are also mine and I am pretty sure there are other forum members who would be interested now and in the future. It could be a multiple win.

Hello Guys, i figured it out. As soon as I write it out I will post it!