4 Channel Thermostat using PID loops


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest

    Default 4 Channel Thermostat using PID loops

    Guys,

    Over the past few months I've been working with DT on a project which I will now share with the PBP community. Darrel put together 99% of the code and routines (some of which have already been published on his website and here on the forum). My contribution was constructing the test equipment and running the real life trials and then tweaking the values to get the best accuracy for the equipment used.

    Background

    I keep reptiles, well snakes to be exact. These need to be maintained in a controlled environment, with a steady heat source at one end of their enclosure, which needs to be thermostatically controlled.



    Whilst there are already commercially available pulse proportional thermostats on the market, these are single units. I really wanted to use one unit that had 4 separate pulse proportional thermostats which would cut down on lots of wiring etc.

    The original idea was to have 4 pots to set the target temperature for each vivarium with the temperature displayed on an LCD, however for ease of testing we opted for using hyper terminal and a simple RS232 connection.

    Development

    I have an EasyPIC5 development board, and to make life simple purchased a few of their add on modules such as the 1307 based real time clock, pot board, and several connection boards to connect the solderless breadboard to.



    To test the code and develop the project as we went along I constructed a box from 18mm melamine board, approx 400mm x 400mm x 200mm (LWH) and installed a 50w powerplate (a flat panel ceramic heater) to the roof inside the box. A 240v 4amp solid state relay was used as the means to turn the heater on and off, especially as the opto isolation could be driven directly from the PIC.

    DS18B20's were used for the sensors, and one was connected via lengths of wire to the EasyPIC5 board. The sensor was placed inside the box which was placed on a flat surface. The SSR connected to the mains and it's input connected to the EasyPIC board too.

    Darrel produced the 1st version of the PID code to drive just one channel. I then compiled and ran it to see how it performed. Over the course of several evenings I managed to get the values tweaked enough to maintain a stable temperature that would drift no more than 0.5 a degree in the course of the evening.

    Armed with the feedback, DT then went on to work on multiple channel PID loops, and after a few weeks of frantic PM's between him and Henrik came back with some further code for me to test and try. The result was that after some further tweaking at my end, we managed to have 4 independent channels all running at the same time and in the test rig, maintaining a constant temperature.

    Future Development

    The plan was to now develop the fancy options such as using the clock module to program a night time drop in temperature if required, menu buttons, and possibly a means of monitoring / setting via software on a computer, even to storing temperature data in an eprom for use with the PC software. However this meant porting the code to a different chip and so Darrel suggested the 18F4550.

    We got as far as having testing out the USB coms, and getting the PID loops running, however due to personal reasons we've had to halt development of this side of the project, at least for the present time.

    I'm now going to concentrate on developing a prototype PCB based on the 16F877A code, which has achieved the main goal, which was 4 independent pulse proportional thermostats. I'll use this prototype in the two vivs that house my two Royal pythons, which was my original intentions. However if anyone would like to contribute and take this project further, possibly to its full potential then please feel free to drop me an e-mail or PM. I've attached the code and all the includes for use in MCS (PBP 2.60 is required).

    In the meantime I would like thank Darrel for all his hard work and contribution to the project. It's guys like him that make this forum a pleasure to visit. Whilst I may not entirely understand the complicated maths that goes on in a project such as this, I've learned a lot by way of his examples. - Darrel, Thank you !
    Attached Images Attached Images   
    Attached Files Attached Files
    Last edited by malc-c; - 20th February 2010 at 13:26.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You're welcome Malcolm, and thank you too.

    And I'll add a "Thank You" to HenrikOlssen, who wrote the Multi-Channel PID filter that is at the core of the program.
    It allows any number of PID loops to be running concurrently, and it works really well.

    Cheers,
    DT

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Update

    Well, I didn't continue the development with the 16F877A... I ported the code to an 18F4580 which has a lot more code space instead

    I've added the clock module and used Mel's example code for RTC and with her help and assistance with other forum members I'm now able to release a fully working beta version of this project.

    Now need to do some further testing and then build the prototype PCB

    Please note the header at the top of the main code. It details the history, development and contributors. If I've missed off anyone in the credits please accept my apologies
    Attached Files Attached Files

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default schematic

    I've just drawn up the schematic in Eagle (yet un-proven as I've yet to prototype this project). I've attached the image here for reference.
    Attached Images Attached Images  

  5. #5
    Join Date
    May 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Your project is very interesting, thank you for sharing it. I am doing the same kind of work (also for BP snakes). I need to control radiant heat panels and heat pads. I use some DS18B20 as well, and right now I am at the power stage part. I have several questions:

    1. You use a SSR for driving the heat channels. The ceramic heater elements are powered via main AC line right? I saw many thermostats circuits using an optotriac in combination with a triac. What is the difference between using SSR and a combination of an optotriac such as a MOC3022 and a triac? Does the SSR heat a lot?

    2. What is the period of the heating cycle? In other words, for how long are you triggering the SSR to have for example 10%, 50% and 90% power?

    Thank you very much.

    Denis.

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    interesting to see you are working on a similar project.



    The SSR's I'm using are Opto's MP240D4 which are rated at 4 amp - 240V, and in the test I was driving a 50 watt ceramic power plate, and the relay wasn't hot at all, using Ohms law a 200w heater (typical rating for a ceramic bulb heater used in vivariums) will pull 0.8A at 240v, and that would be driven 100%, so they wouldn't need any thermo bonding to a heat sink. If you were running 1Kw heaters then I guess you would need to bond them to a large heatsink.

    The reason I used them is because I had them, they can be driven directly from the PIC, and means you don't have to mess around with lots of isolators, FETs etc etc. The downside is they can be expensive $15 / £15 - although I paid around £2 each for mine a few years back from an e-bay listing (£10 inc shipping for NIB ). However you could use an opto isolator and triac / thyristor combo to drive the heaters

    To answer your second question, there is no set % the heat is applied. The PID loop works by reading the temperature then through Henriks complicated maths routines works out how long to apply the power to maintain the temperature. Thus as it gets near the set point the pulse gets shorter and shorter. Ideally it works out the ideal pulse length to maintain that temperature, but in reality, due to the nature of ceramics, it often over shoots a degree or so for the first time, and then settles down. My test vivaruim consisted of a box 500mm x 500mm x 300mm (l x w x h ) made from 18mm wood, and I was able to maintain the temperature to withing 0.5C of the set point, which is ideal for boa's and pythons (and most tropical reptiles).

    I've also added a couple of routines to a further version of the code that uses the RTC to turn on and off the two lights I have in the vivs. I'm still trying to work out the best way to prototype the board as it's proving difficult to produce a single sided PCB and my skills at producing a double sided PCB are lacking. I guess I'll start by using stripboard and see how it performs.
    Last edited by malc-c; - 19th May 2010 at 21:45. Reason: additional info

  7. #7
    Join Date
    Feb 2013
    Posts
    1


    Did you find this post helpful? Yes | No

    Default Re: 4 Channel Thermostat using PID loops

    Sorry for being such a noob I'm good with soldering but that's about it. The question I have is I noticed that several of the pins on the pic are not connected to anything I am assuming that they are used to program the pic, can someone tell me how to connect them or point me in the right direction.

    Thanks much

  8. #8
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 4 Channel Thermostat using PID loops

    I don't use them for programming the PIC, they are just unused ports. The PIC is programmed via the EasyPIC development board shown at the start of the thread

Similar Threads

  1. Simple 4 channel DMX controller
    By eggman in forum Code Examples
    Replies: 19
    Last Post: - 18th July 2012, 01:40
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  3. 4 pin 4 x 4 keypad interface using pic basic pro
    By dunlao_john in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th January 2009, 05:21
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 19:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts