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