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 ?
Bookmarks