Ds1820 -> pid -> pwm


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default

    Hi,
    What you want to do is very much doable with pretty much any PIC, a 16F877 will be plenty. Make sure you read thru the complete PID filter thread (if you haven't already) as it covers several things - and provides an updated version of the PID filter in post #57.

    The easiest way is to use a solid state relay as it isolates the load from the PIC and is easy to drive (it's basically just a LED). But to give a more detailed answer we'd need to know if the heater is AC and you by PWM really mean phase angle control. Or if it's DC and you intend to use the CCP-module in the PIC to produce a PWM signal - or (if it's either AC or DC) you intend to create a slow speed PWM with a period of several seconds or longer (I beleive this is what Malcolm did) where the fact that a triac or solid state relay for AC doesn't switch off until next zero crossing doesn't matter.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post

    The easiest way is to use a solid state relay as it isolates the load from the PIC and is easy to drive (it's basically just a LED). But to give a more detailed answer we'd need to know if the heater is AC and you by PWM really mean phase angle control. Or if it's DC and you intend to use the CCP-module in the PIC to produce a PWM signal - or (if it's either AC or DC) you intend to create a slow speed PWM with a period of several seconds or longer (I beleive this is what Malcolm did) where the fact that a triac or solid state relay for AC doesn't switch off until next zero crossing doesn't matter.

    /Henrik.
    I agree, an SSR is the simplest way to interface the output from a PIC to mains device. In the development of the thermostat project I'm now using zero-crossin opto-triac isolators to drive 16A triacs, but the original prototype used 4A SSR.

    As Henrik stated, my thermostat project uses low speed pwm to apply power to the heaters, the result is that the heaters remain at a nice stable temperature rather than the normal method of heating which results in large temperature swings

    Here's an example of the frequency

    Last edited by malc-c; - 11th October 2010 at 21:55. Reason: added video

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default

    Hi Again, and thanks for all of your answers!!

    Here is my 1º schematic of the PID Controller. As i say in my revious post, the Buttons, is to set the SetPoint, and change the Ki, Kp, Kd, variables.




    malc-c
    Good advice Al

    @gadelhas
    Most of the code in the PID thermostat thread was written by Darrel and Henrik, and contains a means of tuning the values you mention. Later this evening I'll go back through the early versions of the code I have for a single PID channel that can be configured via a PC running Hyperterminal and communicating via the serial port. I'll zip it up and attach that to the post. You can then experiment with the values and compose your report
    @ malc-c , if possible put the code here as you had mension. I would appreciate.

    @ HenrikOlsson, I'm reading and trying to understand your PID routine, i will post some questions soon about it, i have some questions!!
    The Heater resistor that i have is 220V AC, i think it's better to do, like malc-c did, with a Solid State Relay, and low speed PWM.

    @ malc-c Again. I see your video, and i think the result its really great. If you change the Kp, Ki, Kd, variables, do you see any change to the process? Like, more slow/ fast to achive the SetPoint, for instance?

    Thanks once again for everything.
    Hope you can understand my english, sorry for all the errors!
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by gadelhas View Post

    @ malc-c , if possible put the code here as you had mension. I would appreciate.
    To be honest you could use the code attached to my first post in the thermostat thread http://www.picbasic.co.uk/forum/showthread.php?t=12712
    You would need to build / breadboard your hardware to match that used in the included hardware file.

    Quote Originally Posted by gadelhas View Post
    @ HenrikOlsson, I'm reading and trying to understand your PID routine, i will post some questions soon about it, i have some questions!!
    The Heater resistor that i have is 220V AC, i think it's better to do, like malc-c did, with a Solid State Relay, and low speed PWM.
    I've not tried it, but I would of thought that it would be kinder on the resistive element of the aquarirm heater, especially as with it immersed in water the heater has less chance to cool as a similar element would in air. A SSR is the way to go - bit costly, but a lot safer

    Quote Originally Posted by gadelhas View Post
    @ malc-c Again. I see your video, and i think the result its really great. If you change the Kp, Ki, Kd, variables, do you see any change to the process? Like, more slow/ fast to achive the SetPoint, for instance?

    Thanks once again for everything.
    Hope you can understand my english, sorry for all the errors!
    From memory, changing the values altered things like the amount of over-shoot of the set point, the range at which the output started pulsing, and the length of pulse. The advantage with the code that Darrel and Henrick had put together was that using a serial cable and Hyperterm I was able to change the values via the PC and see what effect it had on my test rig which comprised of a heater in a wooden box with the sensor 6" below a ceramic heater. Over several weeks the values were adjusted and tuned until the temperature set point either maintained or was within half a degree either side (as you can see by the video - in the real environment it's almost spot on)

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Working with ac and resistive load, phase angle control is the choice (dimmer principle), PWM works very well only with dc.

    Since you will have 50 Hz main, every half cycle will last 10 millisecs, so once you have found the zero crossing moment, you will fire your triac with a delay from 0 millisecs to max 10 millisecs.

    where:

    0 millisecs delay = 100% duty
    .
    .
    5 millisecs delay = 50% duty
    .
    .
    10 millisecs delay = 0 % duty

    Remember that your triac will turn off at every zero crossing, which make phase angle control a rather efficient and easy way to control resistive loads with ac.

    Cheers

    Al.
    Last edited by aratti; - 12th October 2010 at 11:53.
    All progress began with an idea

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default

    Hi Al,

    I agree, phase angle control is nice but IMO overkill for a system like this.

    The heater itself and the system as whole is most likely quite "slow". Creating a low frequency PWM with a period of 1 or even 10 seconds will likely work just fine.

    That way the slight error introduced by the solid state relay (or triac) not shutting off until next zero-crossing can be disregarded. (Max 1% with 1s period or 0.1% with a 10 second PWM period.) Depending on if the SSR is "random firing" or not it'll be a little bit different but still good enough IMHO.

    Of course it depends on the power of the heater, the amount of water in the tank and the amount of "temperature ripple" you can tolerate but I don't think the tank will "respond" fast enough that a 1 or even 10 second PWM period won't work.

    /Henrik.

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    The heater itself and the system as whole is most likely quite "slow". Creating a low frequency PWM with a period of 1 or even 10 seconds will likely work just fine.
    Hi Henrik, Let me say that I could accept your statement only if we talk about an amatour project. But since the OP opened the thread with the following statement:

    I need to do a university project, for "Computer Control. The project consists of performing a PID controller based on a Microcontroller.
    In this case I will expect from him to challenge the highest performace he could think of.
    He will be a tomorrow electronic designer and he will have to face an extremely aggressive global market, so I do expect from him something more than "something that will likely work just fine"

    Herik, I Hope you will agree with me!

    Cheers

    Al.
    Last edited by aratti; - 12th October 2010 at 17:45.
    All progress began with an idea

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