Dimming Thermostat - general questions


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default Dimming Thermostat - general questions

    I'm considering developing a dimming version of my pulse proportional thermostat and would welcome some advice or comment on the following:

    I'm planning on using a PCA9685 16 channel PWM chip to handle the 0 - 4095 steps PWM rather than the on board HWPWM of the 18F4620 PIC, partly as I already have code for this, and partly because it doesn't hold up the running of the code. I was thinking of using a variable to store the difference between the actual temperature read from a DS18B20 and the set temperature, which is then used to generate the step value that gets sent to the PCA chip. This would give 0 when the both the set point and real temperature match and the heater would turn off, and then as the temperature fell, the power would slowly increase until the temperature would reach a stability close to the set point.

    So for example I could have something like to read the temperature
    Code:
     OWOUT TEMPIN,1,[$CC,$44]
        OWOUT TEMPIN,1,[$CC,$BE]   
        OWIN TEMPIN,0,[TempT.LowByte,TEMPT.HighByte] 
        TempC = (TempT*/1600)
        LCDout $FE,$80,"Temp ",DEC (TempC/100),".",#TempC dig 1,"C"    
        tempc=tempc/10
        Temperatures = TempC 
    
    Pulse = set_temp - temperatures
    And then something like this to set the pulse

    Code:
    pcaChannel = 0                                              
    lcdout $FE,$80,"CH1"
    i2cControl = $6 + 4*pcaChannel                              
    I2CWRITE SDApin,SCLpin,i2cWriteAddress,i2cControl,[0,0,pulse.lowbyte,pulse.highbyte]
    Now the problem is that the difference is never going to be 4095 degrees, so I need to scale the pulse value somehow so that it reached 4095 when the difference is, say 10 degrees or more. The other issue is that the pulse needs to be positive, so any negative values caused by the temperature overshooting the set point are ignored.

    Sounds reasonable? - any suggestions on the scaling ? - I'm guessing I could simply use an if pulse <0 the pulse =0 to stop the overshoot? Would the scaling need to be linear or log, so that the pulse width increases as the temperature difference increases ?

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


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Hi,
    First off, using the CCP module on the PIC to generate the PWM signal does not hold up the code any more than doing some I2C out to an external PWM controller.

    Second, what type of heaters are these, how are they controlled and from what are they being powered. I ask because I have a suspicion that the heaters are powered from AC-mains and controlled thru solid state relays? If that's the case simply PWM'ing them at some random frequency isn't likely to work very well - if at all.

    Third, your suggestion of a simple proportional control isn't going to work reliably.
    With low enough gain (ie the "scaling" you're asking about) it will never ever reach the setpoint since the applied power gets reduced the closer to the setpoint the actual temperature gets. At a certain point the loss in the system equals the power applied and the temperature stops climbing - there's a steady state error. (This is why there's an I-part in the PID regulator).

    /Henrik.

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Hi,

    Thanks for the reply. Dimming stats used for keeping reptiles tend to drive either normal incandescent bulbs, or ceramic elements like these



    Yes the intention would be to switch 240v AC either through SSR's or zero crossing driven triacs.

    So If I follow your drift, a PID routine would still be required, but rather than a low frequency pulse, the filter is used to determin the pulse width in a high requency PWM ?

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Yes the intention would be to switch 240v AC either through SSR's or zero crossing driven triacs.
    Won't work very well, if at all, with "high frequency" PWM. For "dimming" AC you would need to create a phase angle control.

    So If I follow your drift, a PID routine would still be required, but rather than a low frequency pulse, the filter is used to determin the pulse width in a high requency PWM ?
    First part yes, second part no.
    Using proportional control only will most likely give you the result I explained in my previous post. You will need at least PI.
    As before, you can not use a normal SSR to power a AC device and simply feed a "high frequency" PWM signal to it to "dim" it, it's not like dimming a LED with PWM. You need either a voltage controlled phase angle controller and drive that with a voltage created by low pass filtering the PWM output. Or you create a LOW frequency PWM signal with a period in the seconds range (which I believe is exactly what I beleive Darrel created for you in the version you have already) - and it's like that for a reason.

    If you where to rectify and filter the incomming AC you COULD then use a high voltage MOSFET or IGBT to PWM the load but, well....

    /Henrik.

  5. #5
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    I did a similar project; A PID algorithm temperature controlled laminator.
    It used HPWM to operate a zero crossing solid state relay.
    The PIC HPWM at lower settings operates the SSR more off than on and visa versa at higher settings.
    Darrel's low frequency PWM would be good however mine worked with regular HPWM.
    I included the light in the rocker power switch with the heater to give a visual indication of the on/off pulsing of the SSR.

    Norm
    Last edited by Normnet; - 10th December 2015 at 07:14.

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Don't light dimmers work by PWM ?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Normal dimmers for incandescent lamps doen not work with "normal" PWM, no. They work with phase angle control.

    They're using a triac. A triac, once turned on, doesn't turn off untill the current thru it goes to zero - which it does each zero crossing - you can not turn it off randomly. If you run a "high frequency" PWM signal into to the gate of such a device the lamp would flicker like crazy because the PWM signal isn't sync'ed to the AC mains. Sometimes it turns on at the end of the AC cycle, some times it turns on the start and some time it turns on the middle.

    The way they work is that they detect the zero-crossing and then waits for a certain amount of time untill it sends a trig pulse to the triac which then turns on and conducts untill the next zero-crossing. For 60Hz mains each half-cycle is 8.333ms. If the delay between the zero-crossing and triggering the triac is 4.16ms the lamp would be at 50% (well not really since it's not linear but you get the idea).

    Your typical AC SSR contains a triac on the output-side and works the same way. Once triggered it doens't turn off untill next zero-crossing.

    The dutycycle of the PWM signal feeding your SSR would not relate to the relative power sent to the heaters because the current to the load would be turned ON at the rising edge of the PWM signal but not turned OFF at the falling edge.

    /Henrik.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Hi,
    I created the following picture to further illustrate the issue with running a "normal" PWM signal into a triac or a random firing or random turn-on SSR:

    Name:  Capture.PNG
Views: 528
Size:  18.3 KB

    I choosed a random PWM frequency (which was easy to draw) relative to the 60Hz mains but it doesn't really matter.
    The triac/SSR is ON during the purple sections which, as you can clearly see, is a lot more than the 12% dutycycle of the PWM signal.

    I hope this helps illustrate my point.

    /Henrik.

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    you have 120- half cycles per second that you can cycle....... you can break that down to 60/half second or 30 per quarter second....... if you consider controlling for 4 times a second, then you can go from 1 cycle on and 29 cycles off up to the opposite on/off ratio.......
    that's 250 milliseconds each control loop.....so say 10 milliseconds on pulse and off 240 milliseconds for minimum......
    that's just pin hi, pin low functioning with some kind of counting loop and changing the ratios accordingly....
    That would use a zero-crossing SSR for ease of use.
    There could be a I cycle error unless you use some kind of zero cross detector to sync up...... probably not necessary because the error would probably average out.

  10. #10
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Dimming Thermostat - general questions

    Henrik, thanks for the detailed explanation...

Similar Threads

  1. A few general questions about the CODE
    By MOUNTAIN747 in forum General
    Replies: 2
    Last Post: - 12th January 2014, 16:13
  2. General USB questions
    By BobEdge in forum USB
    Replies: 2
    Last Post: - 21st April 2009, 04:19
  3. help w/ lamp dimming using Pic12f675
    By DUDONG in forum General
    Replies: 3
    Last Post: - 18th October 2007, 12:40
  4. need help with lamp dimming using Pic12f675
    By DUDONG in forum mel PIC BASIC
    Replies: 0
    Last Post: - 17th October 2007, 09:44
  5. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

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