Yes, I've done some PID controllers. There are a few basic questions: 1. Do you have on-off or proportional control of your Peltier junction? 2. How fast can your system respond - tenths of seconds, seconds, or tens of seconds? 3. YUou might set your loop time - how often you measure, to be something less than the amount of time your system can respond, but not too much less. Way longer ansd the system gyrates wildly, way shorter and you'll be going 100% one way and 100% the other way in no time. Here's a basic approach to PID: 1. Measure your input variable (temperature) and decide if it is too hot or too cold (via the reflection technique) 2. Subtract your measured variable from your desired variable. Call this DIFFERENCE 3. P = DIFFERENCE * Pconstant. Pconstant is the first critical thing you'll have to tune in. Start by trying 1/4 to 1/10. 4. I = DIFFERENCE * Iconstant + OLD I keep a running tab of how far you are from the setpoint. Start with a small number, 1/100. 5. D = (NEW DIFFERENCE - OLD DIFFERENCE) * Dconstant. Once again, Dconstant should be small. 6. Check that your output signal is in range. If not set it at 100% heating or 100% cooling (to avoid setting it 110% which will wrap around to some crazy number) many controllers only use P or P+I or P+D and get fine results. I have used P+I very successfully in an oven (see recent discussion.) The math isn't hard, the hard thing is keeping inside the capabilities of a PIC with a teeny stack and a tiny memory! -----Original Message----- From: Darren Logan To: PICLIST@MITVMA.MIT.EDU Date: Saturday, May 15, 1999 5:31 AM Subject: PID algorithms in PIC C >Hi, > >My problem: >------------------- >I want to control the thickness of condensation of a sample gas on a metal >surface by controlling the temperature of the surface. >This is a fundamental method of measuring humidity, where the temperature of >the surface which causes the sample gas to begin to condense is directly >proportional to humidity. (Clever hey ? - but no real secret, the method has >been around for donkeys years). > >The temperature measurement needs to be precise (within 0.3 degC accuracy) >using a PRT-100 (Platinum Resistance Thermometer). > >The method to detect moisture or condensation is by light transmission & >detector. The light is directed onto the surface and the detector measures >the reflected light from it. >When condensation occurs, the reflected light is scattered and the detector >sees this and attempts to control the temperature of the surface at this >point. This temperature is then displayed and is known in the industry as >Dewpoint (the point at which dew forms!) and is of course a derivative unit >of humidity. > >The device for cooling and heating the surface is a peltier heat pump. > >Anyway... >I want to control the temperature of the surface with a PIC using PID control. >And i want to program the PIC in CCS C, of which i already have some >experience. > >Obviously, i would like to be able to easily change the P, I and D settings >in software so I can experiment. > >My question is... >Can anyone help me on PID control ? >Has anyone already done PID control with a PIC ? - or have algorithms already >? > >Anyone any experience on adaptive tuning or self tuning PID controllers ? > >Any help or advice very, very much appreciated. > >Darren