# Design of P-controller (of PID)

Joined Mar 23, 2013
3
Hi,

I design a temperture P controller (later I will add I and D too). Heater element is rated for 24V, 40W and suplied with 24V PWM 10bits.

Setpoint - Output = Error

Error * Kp = "number". How to set PWM duty cycle regarding to the value of the "number" To use a rato of 1:1 or multily it by constant <1 or multiply it by constant >1 ?

Currently I am using the option 1:1, but the Steady state values between calculated closed loop transfer function (CLTF) and measured CLTF from the graph are not equal nor similalr.

#### crutschow

Joined Mar 14, 2008
27,028
Error * Kp = "number". How to set PWM duty cycle regarding to the value of the "number" To use a rato of 1:1 or multily it by constant <1 or multiply it by constant >1 ?
That multiplication factor affects the closed-loop gain of the circuit.
The higher the gain the lower the error between the set point and the actual temperature, but the more likely the loop will go unstable.
That's why an I and D are added to the P, to stabilize the loop.

Last edited:

Joined Mar 23, 2013
3
That multiplication factor affects the closed-loop gain of the circuit.
The higher the gain the lower the error between the set point and the actual temperature, but the more likely the loop will go unstable.
That's why an I and D are added to the P, to stabilize the loop.
crutschow, thanks for reply. That is clear.

My problem is that I plotted the open loop transfer function of my "plant". Heater (24V 40W) in the small aluminum block (10mmx25mmx40mm) with temp. sensor DS18B20 in 10 bit resolution mode (1bit = 0.25°C, can be set up to 12 bit -> 1bit = 0,0625°C). The plant transfer function (read from the graph) is 1/(700s + 1). If my controller is P regulator, plant will be multiplied by Kp. If I chose Kp=1 then he plant transfer function will be the same and for closed loop transfer function(G1*G2)/(1 + G1*G2) I will get 0.5/(350s + 1). This is only for K=1.
Example at 30°C:
Set point for 50°C is 200 (temperature is measured 1bit=0.25°C). Temperature is 30°C =>sensor reading is 30*40=120.
Setpoint - Current temp. = 200 - 120 = 80. This value 80 is the number above in my previous post. So my question is how I trasform this value for my controller output?

By other hand, how I will setup PWM regarding to this value?
1. Will I set the PWM for heater element to 80% duty cycle?
2. Or will I use this number as value for microprocessor PWM register value what will be only 7.82% duty cycle (at 10 bit PWM resolution).
But If the PWM resolution will be 9 bits then the PWM duty cycle will be set to 15.62%. SO there must be some rule how to set the controller output for heater regarding to the error. That is my question.

More over I have plotted (attached picture) the close loop transfer function response for step input 21°C->50°C, K=1, and the tau was not 350 sec as it should be by following the control theory. I used error as the value for PWM register as in question 2. above. The temperature was settled around 44°. It should be 36.5°C. (50-21=29, 29*0.5=14.5, 15.5+21=36.5).

What did I do wrong? What did I missed?

So, what I did wrong? Why the tau of the ploted response is not 350 sec?

#### Attachments

Joined Mar 23, 2013
3
NOTE: I could not edit the prevoius post (after 10 minutes), so this is edited version.

That multiplication factor affects the closed-loop gain of the circuit.
The higher the gain the lower the error between the set point and the actual temperature, but the more likely the loop will go unstable.
That's why an I and D are added to the P, to stabilize the loop.
crutschow, thanks for reply. That is clear.

My problem is that I plotted the open loop transfer function of my "plant". Heater (24V 40W) in the small aluminum block (10mmx25mmx40mm) with temp. sensor DS18B20 in 10 bit resolution mode (1bit = 0.25°C, can be set up to 12 bit -> 1bit = 0,0625°C). The plant transfer function (read from the graph) is 1/(700s + 1). If my controller is P regulator, plant will be multiplied by Kp. If I chose Kp=1 then he plant transfer function will be the same and for closed loop transfer function(G1*G2)/(1 + G1*G2) I will get 0.5/(350s + 1). This is only for K=1.
Example at 30°C:
Set point for 50°C is 200 (temperature is measured 1bit=0.25°C). Temperature is 30°C =>sensor reading is 30*40=120.
Setpoint - Current temp. = 200 - 120 = 80. This value 80 is the number above in my previous post. So my question is how I transform this value for my controller output?

By other hand, how I will setup PWM regarding to this value?
1. Will I set the PWM for heater element to 80% duty cycle?
2. Or will I use this number as value for microprocessor PWM register value what will be only 7.82% duty cycle (at 10 bit PWM resolution).
But If the PWM resolution will be 9 bits then the PWM duty cycle will be set to 15.62%. SO there must be some rule how to set the controller output for heater regarding to the error. That is my question.

More over I have plotted (attached picture) the close loop transfer function response for step input 21°C->50°C, K=1, and the tau was not 350 sec as it should be by following the control theory. I used error as the value for PWM register as in question 2. above. The temperature was settled around 44°. It should be 36.5°C. (50-21=29, 29*0.5=14.5, 15.5+21=36.5). As you can see at 21°C the error was 29°C => 29*4=116 used this walure for PWM register => 116/1024=11.32% duty cycle. As the temperature setled at 44°C, the error was 6 => 6*24/1023=2.34%duty cycle.

What did I do wrong? What did I missed? Why the real steady state value and tau is not as I have calculated?

Note: This is only school project, focused to learn how to implement theory in to practical example.

Thanks for help.