Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   



PID Thermostat Controller with bult in AC dimmerAuthor
Hercules Trapierakis
February 24, 2012

PAGE 2 of 7 - The Software


The Updated Software for the Pid Controll

Set is the temperature ( 395 for 39.5 celsius )
Temp is the actual temperature

---------------------------------------

#define MinPID -5000
#define MaxPID 5000

#define MaxDIM 50
MinDIM = 2 * AC_Freq * 100; // 2*50*100 = 10000 microseconds

---------------------------------------

Error = Set - Temp;

P = Kp * Error;

I = Ki * Total_Error;

D = Kd * ( Error - Previous_Error );

PID_out = P + I + D;

Total_Error += Error;

Previous_Error = Error;

PID_out = (PID_out - MinPID) * (MaxDIM - MinDIM) / (MaxPID - MinPID) + MinDIM;

if ( PID_out < MaxDIM ) PID_out = MaxDIM;

if ( PID_out > MinDIM ) PID_out = MinDIM;

Dim = PID_out;


---------------------------------------

PID_out = (PID_out - MinPID) * (MaxDIM - MinDIM) / (MaxPID - MinPID) + MinDIM;

this line actually maps the PID_out from a range of

[ MinPID, MaxPID ] to a range of [ MinDIM, MaxDIM ]


The frequency mesurement

The uC measures the time that it takes to capture 256 zero cross

and then calculates the AC mains frequency like that

AC_Freq = 128000 / ( Stop_time-Start_time );

Stop_time - Start_time = the time in milliseconds that took to capture 256 zero crosses

128000 and not 256000 because on each period we have 2 zero crosses


Continue reading. Click here to go to the next page >>>.
 OR click here to view the presentation.



Comments

  Name

  Email (shall not be published)

  Website

Notify me of new posts via email


Write your comments below:
BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


      

  • At 22 October 2014, 21:55:20 user Luis wrote:   [reply @ Luis]
    • Greetings, congratulations on the project, I would like to experiment with this design but do not get the atmega328, I only get the atmega8 or ATmega88, too much to ask that you compile the program for one of these microcontrollers, Thanks.


  • At 21 May 2014, 16:49:31 user bob dillard wrote:   [reply @ bob dillard]
    • i just use a mercury thermostat, tilted at an angle to compensate for the higher temperature required for incubation. now a timed egg roller is something i would be interested in.


  • At 6 March 2013, 20:39:42 user nikki81 wrote:   [reply @ nikki81]
    • Are there any PCB design files for this project ?


  • At 28 August 2012, 21:24:09 user Markus wrote:   [reply @ Markus]
    • HI hi

      I did somthing very similar, i tested it with a light bulb that dims
      Just a quick question, i would like to read this "controlled wavform" back into a plc/labview. How would you suggest this be done ?
      Thanks


  • At 17 April 2012, 6:00:27 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Hercules Trapierakis you've turned your parrot into a carnivore!!! DAMN


  • At 17 April 2012, 5:39:50 user Hercules Trapierakis wrote:   [reply @ Hercules Trapierakis]
    • @Panagiotis Kalogeris

      This is George

      http://www.youtube.com/watch?v=O_Mg3CoALcE
      http://www.youtube.com/watch?v=U6yn3dX0beM

      there are not to many eggs

      it's not even half filled

      Not but you can use it here and on America without change the firmware


  • At 16 April 2012, 20:29:09 user Panagiotis Kalogeris wrote:   [reply @ Panagiotis Kalogeris]
    • Hello hercules nice project of yours!!!!!!!
      First of all what you intend to do so many birds?Hope to sell them because believe me i have 2 parrots and the one of it is a REAL PAIN IN THE ASS!!!!!Fantastic pcb did you develop it by yourself?Also you say that the circuit reads the ac frequency and it sets the dimmer parameters accordinally.Why is that?I mean the mains frequency isn't stable to your house?

      That's for start keep going :-) !!!!!!!!!!!!


  • At 16 April 2012, 16:04:33 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @herctrap poor bird...
      You did not have something to do with the explosion,,,, did you???


  • At 16 April 2012, 15:21:56 user herctrap wrote:   [reply @ herctrap]
    • yes i have changed the lamps from 40W to 60W

      The main power transformer near my house blown up two days before the incubation

      so the bird died from the cold


  • At 16 April 2012, 14:39:34 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • Herctrap, the writeup is excellent and the PCBs are awesome! The only thing that i am afraid of is this "overkill" temperament of yours... I hope you have installed the correct heating lamps, and that the birds that will come to life will not be roasted :D You did not change the lamps that your grandfather installed, did you :D

      What happened with the single egg incubator project? Will you develop the first "chicken of the tube" or not?



    delicious
    digg
    reddit this Reddit this
    Faves



     HOT in heaven!


    NEW in heaven!



    New Theory: AC electric motor working principle



     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy