Saturday, March 21, 2009

Aquarium temperature controller (PID loop)

Store-bought aquarium heaters suck. It's just that simple. They're cheap too, so maybe the suckage-to-price ratio is correct, but I felt that the temperature in my tank could be a whole lot more stable than it was a with a standard submersible heater. The main problem with the glass-tube heaters is that the temperature sensing device (a bi-metallic strip) is located inside the heater itself! How does the heater know what the tank water's temperature is? It doesn't. These submersible heaters are setup to maintain a relatively constant temperature inside the heater tube. The assumption is that the heat load on the aquarium is approximately constant, therefore the water temperature will be fairly steady. In my house, the ambient temperature changes quite a bit, so the heat load on the aquarium changes, and the submersible heater does a poor job of temperature regulation.

The solution is to use a sensor that is mounted some distance away from the heater. The sensor will accurately measure the water's temperature -- not the heater's. Systems of this type are available to aquarists, but they are overpriced, and offer only on/off control. Instead, I bought a PID (proportional, integral, derivative) controller with a platinum resistance temperature device (fancy thermometer). The whole thing with a solid-state relay was $70 on eBay! I mounted the controller in an electrical box and wired the solid-state relay to control the outlet. I am still using the tank's original submersible heater, but I set its temperature control wheel all the way up, so that it is on whenever it receives power. It is switched on and off via the relay.

The controller is a Eurotherm 2132. This is a very complicated piece of equipment. It has numerous settings, menus and modes of operation. It's definitely overkill for controlling an aquarium's temperature, but I really enjoy tinkering. My favorite feature is the auto-tuning of the PID loop parameters. I set the controller up, and let the tank's temperature drop to about 78*F. I programmed the controller to bring the temperature up to 80* and to initiate its "learning process". It switches the heater on and off and records how quickly the tank rises and falls in temperature. This way, it knows the time constant of the system, and how to best choose the PID parameters. The learning process took an hour or two since the system has an inherently slow response. For those that are really curious, here are the parameters that the controller calculated:

proportional band: 1.45 *F
integral time: 3923 sec
derivative time: 655 sec

This means that the controller uses proportional control when the tank temperature is within .725*F of the setpoint (half of the total 1.45*F band). Below the band, the heater is constantly on. Above the band, the heater is constantly off. Proportional control means the heater is switched on/off rapidly to generate a percentage of its full output power.

The integral time is very large, which means the system reacts very slowly, and the integral action should be very gentle. Specifically, the controller will modify the proportional output up or down at a rate of one full proportional band per 3925 seconds of 1*F error. So, if the tank is constantly 1* too cold, after 3925 seconds, the controller will boost the output by %100

The derivative time indicates how much the controller responds to rapidly changing tank temperatures. 655 seconds means that if the tank temperature were changing at a rate of 1*F per second, the output would be adjusted by 655%. If the tank temperature were changing at a rate of 1*F per hour, the output would be adjusted by 18%.





I also added a chiller to my tank, and have it controlled by the same PID controller. Check it out here:
http://benkrasnow.blogspot.com/2009/03/diy-aquarium-chiller.html

2 comments:

  1. Hello, Ben. I am interested in making a DIY chiller for my 12 gallon Nano reef tank. After reading your posts, I went off in search of supplies. Would you tell me if this is the same controller/relay/RTD that you purchased on Ebay:

    http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=140476876789

    I was also interested in knowing if you discovered any issues with placing a platinum RTD in your tank.

    Thanks so much for your time.

    Regards,

    David

    ReplyDelete
  2. Dub, yes that is the same eBay seller from whom I purchased the same item. It's a great deal! The platinum RTD is encased in stainless steel. It's been in my tank for almost 2 years and shows no signs of rust. It gets covered with coralline algae which I scrape off every once in a while to check for corrosion. I added some silicone to seal the stainless steel probe to the cable insulation. The RTD/Eurotherm combo can deliver amazing temperature precision, but the accuracy on mine was off by a couple degrees F*. Submerge the probe in a mixture of distilled water and crushed ice made from distilled water. It should read 32.00*F. Search for the Eurotherm manual on the web, and you can calibrate the system with the probe in the ice water. Single-point calibration should be all that is necessary since the RTD is unlikely to have much scaling error.

    ReplyDelete