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


    Did you find this post helpful? Yes | No

    Default

    Hi Denis,

    I think you are missing the point of the PID routine. There is no set period that the pulse is on / off for.

    Lets say you make the set point 32 deg C, and the current temperature is 25 deg C. You switch on the thermostat and the PIC reads the current data from the sensor, then using the PID routines works out that it's way below the set point and turns the output on 100%. The heater thus starts to get hot and the increasing temperature is monitored by the sensor until it is within a few degrees of the set point at which time the maths in the PID routine calculates the percentage period to turn off the heater. The frequency at which the PID routine runs it's cycle is around half a second. Eventually as the temperature reaches the set point the PID should be just turning on the heater for the shortest of pulses, and if it is over the set point then the output remains off until the heater cools down and the temperature falls below the set point, at which the pulses increase to maintain the temperature.

    This method doesn't use any paused pauses etc as you describe, and is by far the safest method as the actual temperature is controlling the feedback loop and it's almost impossible for the drive to lock hard on and over heat the vivarium. If the DS sensor develops a fault or becomes disconnected the code makes the pin low so there is more risk of the vivaruim cooling than overheating, which most reptiles can tolerate better. Having said that it would be a simple matter to have a buzzer or some other audible warning if the temperature exceeded 5C above or 15 degree C below the set point for example.

    The SSR requires no additional circuitry, connect one input pin to GND the other to the port pin, then I connect the neutral wire from the mains to one of the output pins, and then the neutral from the heater to the other output pin - the data sheet can be found here http://www.opto22.com/documents/0859...data_sheet.pdf

    Hope that helps

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default

    Hi Malcolm,
    I don't think Denis is missing anything. What you are doing is some form of PWM, probably at a reasonably low frequency. 100% means the output is on all the time 0% means it's off all the time. At 50% it's on half of the time and off for the other half.

    The question Denis is asking is how long in terms of milliseconds, seconds, hours or days is one period of this PWM signal.

    On slow responding systems or "loads" like your heater for example one period can be long, like several seconds or even longer while on fast responding systems like regulating the current thru a motor or whatever the period needs to be MUCH shorter.

    A 50% duty cycle or output means the output is on 50% of the time but in the first case, with the heater, it means it's on for 5 seconds and off for 5 seconds while in the later case with the motor it means it's on 5us and off for 5us. Still 50% in both cases but in the first the period is 10 seconds, in the later the period is 10us.


    Really it's all a matter of how much "jitter" you can live with on the resulting response from whatever it is you're driving. There's usually no need to use 20kHz PWM if regulating the temperature in an oven where applying "100% power" for one minute will result in a temperature rise of 0.5° - as an example.

    Sorry for the long winded response.

    /Henrik.
    Last edited by HenrikOlsson; - 20th May 2010 at 20:27.

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


    Did you find this post helpful? Yes | No

    Default

    Henrik,

    I think we were / are describing the same thing, IE a low frequency PWM signal. In that the frequency of the cycle is approx half a second, with a varying pules width between 100% and 0% depending on the closeness the current temperature is to the set point.

    I thought Denis was simply running a loop with a set mark / space ratio for a given cycle period. If I thought wrong then I apologize

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


    Did you find this post helpful? Yes | No

    Default Prototype

    Well a few months have passed and I'm able to get back to this project.

    I used Eagle to design a PCB, but every time I ran the build it required a double layer PCB and my DIY PCB skills resulted in several coasters ! I've just found one of many stripboard design applications and have come up with the attached. Hopefully it won't need modding too much, and will either update the image when completed and tested, or confirm that I've got it right first time (be a miricle )

    I'll also take some pictures of the unit as it's put together and will add them to this thread as I progress.

    Note that before anyone jumps in and states that I need to break tracks around the relays, due to the lack of being able to design a custom component, I had to compromise, the real relay doesn't have all the pins on the package as shown
    Attached Images Attached Images  
    Last edited by malc-c; - 19th June 2010 at 22:59. Reason: note on design

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


    Did you find this post helpful? Yes | No

    Default Prototype takes shape

    Well due to work and other personal commitments I've been too busy to turn the drawing into a practical prototype... until today.

    I called into Maplin and purchased some stripboard and a suitable box this morning and then spent an enjoyable afternoon building the board. I've not fully tested it yet, bit on powering up the EasyPIC board and taking a 5v supply and using a test LED, the pins to the LCD flashed the same way as they did on the development board (and there was no smoke )

    Wife has plans to get me to sort out the garden tomorrow... but hopefully I'll find time to build the PSU board, and LCD and test this further before hooking up the mains to the relays. For convenience I'll probably take the sensors straight in through the back panel rather than rig up some connectors... we'll see.

    It's taken me six months since DT (and Henrik) assisted me with developing the code to get this far. With out their help it would of taken me a lot longer. I'm determined to see this through to the end - I feel I owe it to you guys to prove the project works in the real world
    Attached Images Attached Images   

  6. #6
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Hi Malcom,

    A truly nice project Sir. May I ask if you've developed menu and display subsystems and would you have display examples you might share? Just curious to see how your user interface works.

    Cheerful regards, Mike

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


    Did you find this post helpful? Yes | No

    Default

    Hi Mike,

    The menu's as they stand are fairly basic. If the option button is pressed the main menu is displayed.

    Code:
    LCDOUT $FE,2,"Main Menu"
    lcdout $FE, $C0, "Select Option"
    
    IF Option = 1 THEN lcdout $FE, $D4, "Set Time and Date  "
    if option = 2 then lcdout $FE, $D4, "Set Night Period   "
    if option = 3 then lcdout $FE, $D4, "Set Normal Temps   "
    if option = 4 then lcdout $FE, $D4, "Set Lighting Period"
    if option = 5 then lcdout $FE, $D4, "Run                "
    Depending what state you leave the option button set to the LCD display reads

    Code:
    Main Menu
    Select Option
    
    Set Time and Date
    The normal temp sub menu simply displays the A/D from the four pots.

    The sub menu for the lighting period simply shows the time which gets changed by the +/- buttons so you can set the on time and then repeated for the off time (for each viv).

    If I get chance I'll take some photo's of each menu and post them up at a later stage.

Similar Threads

  1. Simple 4 channel DMX controller
    By eggman in forum Code Examples
    Replies: 19
    Last Post: - 18th July 2012, 02:40
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 08: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, 06:21
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  5. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 20:03

Members who have read this thread : 0

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