PID Process Control

tonymillar

New Member
Hi. Has anyone developed a PID controller in software? Tried searching but PID doesn't work & controller brings too many unrelated responses. Looking to control a 2kW element in a brewery. TIA
Tony
 

eclectic

Moderator
Try using the Advanced Search with, for example
proportional
integral
derivative
brew*

eg


e
 

AllyCat

Senior Member
Hi,

A PICaxe should be "fast enough" for a system as slow as a 2kW heater. :)

However, you will probably need to use mainly Word variables (at least), and some "tricks" to get satisfactory resolution and/or accuracy. Sorry, I haven't written any specific PID programs, but several reasonably "advanced" mathematical routines, particularly for the Code Snippets section of this forum, should they be needed.

The linked thread above doesn't seem to contain much definitive PID code and I can't say that I'm very impressed with the potential long-term reliability of the proposed "mechanical" control methods (neither a 2kW relay nor a model-makers Servo driving a Potentiometer) :( . But a PICaxe should be able to manage either "half-cycle" (On/Off) or "phase" (triggering during each mains half-cycle) control of a Solid State Relay (or perhaps a Thyristor/Triac). For 2kW you also should be paying attention to RFI and even basic "Mains Pollution" issues.

Of course "PID" is another 3-letter word that the Forum Search refuses to find, so a general Google with "PICaxe" as an included qualifier may help. For example THIS is an even older thread (2008); the PICaxe Basic language hasn't changed very much since then (but sadly most internet URLs have). ;)

Post details of your proposed Hardware configuration, and some program code, commenting how it does (or doesn't) work. Then we may be able to suggest how best to proceed.

Cheers, Alan.
 
Last edited:
Hi. Has anyone developed a PID controller in software? Tried searching but PID doesn't work & controller brings too many unrelated responses. Looking to control a 2kW element in a brewery. TIA
Tony
Tony: I deal with the same types of problems, so here are some thoughts:
1. PID is a popular "buzzword", but was really developed for analog systems that had "overshoot", had a "spring rate" and needed "damping". I don't remember a lot of my engineering control course (53 years ago) but we are dealing with a different world now with really fast ADC's, etc. Controlling a 2KW oven is a slow process (from a microcontroller perspective), and one needs to think about: How accurate is the temperature sensing device? how many bits with the ADC (10 bits for the PIC micros). How accurate do you really need to be?
2. For a heating element, lets say you use a thermocouple and need 300 deg F (sorry, I'm in the US). So, with a 10 bit ADC, you can measure 1024 steps or 1/3 of a degree F from 0-300 degrees. Well, there isn't a thermocouple around that is good to that type of accuracy, except maybe at the Nat Bur of Stds. Also, do you really need that kind of precision? 299.7 degrees versus 300.3 ?
3. I recently started trying to use an I2c device from Adafruit - an MCP9600 board (with a PICAXE 28x2). The combination of the thermocouple and the board MIGHT give me +/- 3 deg F accuracy, or 10 times more "slop" than the 10 bit ADC. In fact, an 8 bit (256 divisions) ADC would work just fine. However, it will probably be repeatable (precision) so I can calibrate it with a really good thermometer (maybe) and put that calibration in the software.
4. I build a controller that uses a simple upper and lower routine on the PICAXE. It reads a 4-20mA signal with the ADC and then sends pulses to solenoids, then measures a pressure transmitter with the ADC, then opens or closes the solenoids to maintain the pressure demanded from the 4-20ma signal. The combination of the sensors, ADC, PICAXE, etc is so fast that a PID loop isn't necessary. The system will maintain a pressure to within fractions of a psi, which is about the resolution of a typical 4-20mA signal (and the transmitter). It just gets the pressure within a very narrow limit (above and below) and holds it there.
5. You may have been asked to develop a "PID controller", for marketing reasons, but I don't think you need one.
6. If you are interested, I can send the upper/lower limit code I use. It's pretty simple, but works due to the speed of the system. Basically, it gets close, then shuts down to see where the system is, then starts again with less time, then just repeats with certain limits above and below the desired point. BIM, a PID control has limits also, just implemented differently because the old analog systems were so slow to start and stop.

Good luck, hope that helps. David
 

lbenson

Senior Member
If you are interested, I can send the upper/lower limit code I use
Please post the code. I appreciate your analysis and your conclusion that in some cases, modern microprocessors and sensors are fast enough to maintain a desired band of sensor values without complicated code.
 
Top