Monday, February 26, 2007

Let the cool stuff begin.

After a month of messing around, I finally got my act together and started working on my PID heating pad controller. Well, actually it is only a P heating pad controller right now, but I will go into that later.

The Goal: Create a PID controlled heating pad to regulate the temperature of a Bio-Dome.

I got two Arduinos for Christmas, so I had most of the hardware to control the heating pad. I was hoping that I would just be able to modify the pad's circuits, but it is not just an on and off switch and the only IC on it was made in China by some unknown company so I could not find any info on it.

Arduino with thermistor


History:
I used to work for a company in SC called Kryotech. They started overclocking PCs (Super G2) in the late 90s, but when that was not commercially viable, they moved to Industrial test equipment. I helped develop a push-pull PID controller for a system we sold to a Japanese company, Advantest. The company was run horribly, and Intel forced us to be sold to one of their buddies in summer 2004.

I got some free samples from Thermistor.com so that was very helpful. Just your basic NTC thermistors.
The ideal temperature for germination of tomato seeds is 75-85F. The resting temp in the house is about 67, to 60 at night.

Heater Pad(removed standard control system) with fuse holder.
Thermistor in Biodome sponge

The next issue was how to control the heating pad since I could not use the built-in system. I asked around, and someone on the Makezine forum suggested hacking an AC light timer. I found one at Target for about $10. It was pretty easy finding out how to switch the relay despite the LCD falling off the second I opened it. Once I figured out the control line, I just ran the GND and the control line to the port that I was switching on the Arduino. The only problem right now with the relay is that it clicks on and off very loudly. It did not seem like it was getting very hot, so I just wrapped a blanket around it to muffle the noise.

Timer with control line and GND wires. I should have taken a pic of the underside of the board.

Coding:
Thermistors are non-linear, so I created a piece-wise linear table for temperatures between 50-77F and 77-104F. I don't need very precise termperatures, so that is a simplified version of the actual table. Temperatures below 50F and above 104F turn the controller off.

All my experience is with PIC18s, and we used a commercial compiler so we had plenty of room for code. From what I have heard, the GCC compiler is not very optimized so I ran out of space quickly on the Atmega8.

The other system I worked on was push-pull; it had cooling as well as heating capabilities. That was a little more complicated, but this is pretty easy. I choose a 10hz square wave because the period is 100ms. The duty cycle is the control variable from 0-100ms, 0= GND and 100= ~5v output. The basic equation is duty = P* error. The P is a constant that is input manually to control the behavior of the system. Error in my case is target temperature - current temperature.

Example:

setpoint = 80
current temp = 70F
P= 5

Duty = 5*(80-70)=50% duty cycle(50ms high,50ms low)

Since I ran out of room on the Atmega8, I was not able to put the I in. I have upgraded to a Atmega168 on the other Arduino but there is something wrong with the timing of the square wave so I have yet to implement that.

I is Integral control. It uses the error from the last two readings to boost the performance.

duty = P* error + I*(error + last error)/2

The best example would be in a situation where the proportional cannot get to the setpoint unless the P is changed and this results in a large overshoot. Then I can add just a little to the P so that it can get to the setpoint without overshooting the target.

The Derivative is the opposite of the integral. It measures the dynamic change, and since this system is so slow, it is not going to have those issues. I am probably not going to use it. So in the end, it is a PI system right now with only the P currently working, haha.



Phase One Setup


Hope you enjoyed this. The next phase is going to be the lighting. Orginally, I wanted to dim the light based on the time of day, but DC control AC dimmers are kind of expensive and/or time consuming. I am working on hacking a motor to an AC dimmer switch, but in the end, I might just buy another AC timer, unhacked this time.

The third phase should be pretty easy to implement. I just have to figure out how to interpret the information. It is going to be a mositure sensor. Three resistors in series with the middle being very large somewhere around 1-2 Mohms. Wires will be placed on either side of the resistor creating an open circut in parellel. The wires with be inserted in the soil and the resistance of the soil will change based on the water content of the soil, i.e. more water = lower resistance. I am going to have to do some tests with how much water I put into the soil to find out what value dictates that I need to water the plants.

Hopefully I will update the blog sooner than in a month.












2 comments:

Anthrax442 said...

The Derivative is kind of the opposite of the integral

Somewhere, Mr. Hess is crying...

AndyHigg said...

Hey Seth and Noelle!

How's life? This is Andrew Higginbotham from USC RUF! Write me sometime!