Hi Tom, -----Original Message----- From: Tom Handley To: PICLIST@MITVMA.MIT.EDU Date: Wednesday, May 05, 1999 2:47 PM Subject: PIC-based Oven Controller > Lawrence Lile earlier started a topic relating to PID control of an oven. >I'm starting this new topic as I've been working on a very similar project. > > In my case, I have an old oven that my elderly mother still uses to bake >the same great things she baked when I was a child and I'm 49... The nice >thing about this old oven is the insulation. And probably mass as well.... > My first question is to Lawrence. Where `in the heck' did you find a >thermistor probe that will deal with 500F? I've looked at thermocouples >and cold-junction/interface ICs from Analog Devices and Linear Tech. >Right now I'm looking at the more expensive option of a Platinum RTD. Fenwall Electronics GEC series glass encapsulated thermistor. Good for 300C = 572F. I crimp silicon insulated leads on them (solder gets too hot) and encase them in silicon rubber shrink tubing ($$$$$ per foot but I only need 3/4 inch) which has to be shrunk in a bunsen burner flame. You probably could get away with a simpler electrical isolator for a single prototype, such as a pair of mica sheets between aluminum plates. Remember the more insulation you have around your temperature sensor, the worse it is. Clamp that temp sensor between a couple layers of thick aluminum, and stick it inside your over about 3/4 the way up the side, a little away from the sidewall. Use some heat sink grease on it, don't insulate it too well. Fenwall is at (508) 478-6000, no web presence. They have a GREAT technical guide on thermistors and are free with samples. Just claim you'll buy a few thousand someday. > As far as the user-interface, one side of me wants a digital display with >a keypad and an embedded internet interface with a web page. That way, I >could fly over to the former Soviet Union and visit with our friend Dmitry >and call home to start the oven, using a touch-tone phone, for the BBQ ribs. >Then Dmitry and I could fly back to Oregon and enjoy the ribs over a couple >of bottles of beer and vodka ;-) Complex Displays: Forget it. My ovens use a plain old dial, cuz your grandmother is used to it and I sell ovens to grandmothers and other people who know how to use dials. I have a 100K potentiometer, measure it, divide by a number to scale it to 32, and shove it into a 32 number lookup table. The lookup table generates a setpoint for the thermistor. Getting these setpoints right is the key. It also prevents a lot of compelx math calculating thermistor equations. the display is a printed label stuck onto the front of the oven. Pretty easy to program with a Bic Pen. > > The practical side of the user-interface has to deal with my mother... >I've selected a rotary encoder with an absolute binary output. This would >provide a range from 150F to 500F in 25F increments with 0x00 = Off... I have found that, although stats read out in 25F increments, you need at least three times that number of increments or you get way too much quantization error and a grainy control. My dial SAYS 275, 300, 325, 350, etc. but what it actually does is 275, 283, 291, 300... I cheat a little on the low end of the oven stat, to get 250 on the dial, by removing a few numbers. > > I've looked at both PID and Fuzzy methods. The Fuzzy method would allow >me to tailor the oven to my mother's experience with the oven but it would >require a great deal of testing. I'd rather use PID which would require less >testing... The oven was fine about a year ago from my mother's standpoint. >So I think using PID would bring the oven environment back to what she was >use to. PID works great. My ovens climb until they hit the setpoint then stick to it like glue. No hunting, no overshoot. I don't know about fuzzy logic, since I am not in Sociology, Philosohy or Marketing. < sarcastic G> > > To control the heating element, I was considering simple On/Off as >opposed to PWM. I want to use standard logic/AC solid-state relays. I have a >few 20A `blocks' in stock but this will require 40A with a good heat sink. >These are widely available and they all provide zero-crossing but I'm still >interested in using PWM. Forget PWM, too complex. Use a relay. PWM will result in heating elements that are way too cool. Ovens work by convection, conduction and radiation. The insides of your food get cooked mostly by conduction and convection. But the outsides get browned by radiation. The elements getting hot and shiny red help to brown your biscuits at higher temperatures. THe elements NOT getting shiny red help to not burn your biscuits at lower temperatures. PWM controlled elements won't get near as hot. The balance between radiation and absolute temperature control is tricky. I simulated this by using a variac and setting oven temperatures on a locked -on oven. Doing the math, I found that the actual duty cycles in a regular oven don't correspond well to the theoretical power delivered by my variacs. I was real puzzled by this. Built a great controller around the idea that burned food at the low end and made it raw at the top end while hold ing exactly the right temperatures. Puzzling as hell until I realized I was not taking into account radiaton. Here's my scheme: 1. The PID loop calculates a duty cycle, from 0 to 256. 2. One loop of the duty cycle takes 256 DELAYSUBROUTINE's 3. DELAYSUBROUTINE is based on the oven setppoint. Hot setpoints generate a delay of 2000*4 cycles, cooler setpoints generate a delay of up to 9000 *4 cycles. 4. This means the oven cycles faster at higher setpoints, once in 10 seconds, and slower at cooler setpiuints, once in a minute (don't check the math - I've left out a lot of details and it won't add up) 5. WHY? Real ovens work this way and it cooks food in the right amount of time. If you have your duty cycle loop always a constant time, you'll either burn cinamon rolls at 350F or have raw biscuits at 450F. Beleive me, I know. (They were yucky.) This balances the radiation. 6. At the beginning of the duty cycle loop, it turns the elements on, then begins counting. When the duty cycle loop counter is greater than the duty cycle setpoint, it turns off the heaters. PID works like this: I use a lot of math with numbers like 4, 8, and 16 because I am out of program memory ans these are very eficcient to calculate. In a bigger part I would use less restrictive numbers. I've got P and I terms turned on. Everybody sez that's backwards, I should use D not I, but this works and that didn't. I use a 32 position, single byte lookup table to calculate the setpoint. My thermistor range reads out in a 16 bit number, so I multiply the numbers in my table by 16 to get the right range. This keeps the table simple, since I don't know how to implement a 16 bit lookup table. I read the thermistor and knob at the beginning of each duty cycle loop. I read them with the power to the elements turned off, for various reasons but mostly because I think the power supply voltage is most stable then. I then subtract them. If the number is negative, the oven is too hot and I set dutycycle = 0. I also set integral term = 0 to prevent it from affecting the next cycle. I don't have any signed math in this routine, so this is neccesary. If the number is positive, and greater than 256, I set dutycycle to 250. I wanted it to turn off a little before I read my thermistor next round. If the number is less than 256, I divide the difference by PCONSTANT which is 4 (8 was too sluggish) to keep math simple. This is shoved into the dutycycle. Then I add an integral term which is equal to (old intergral term) + (new dutycycle/16) This makes the integral term about 1/64th as large as the original difference term. The results? THis last week I've been cooking food all day, and my coworkers eagerly snap it up. Perfect biscuits, crisp pizza, etc.