Question about temperature control with a fan

Hi I am trying to use a fan to keep the temperature constant. For this I've been learning to use PID control.

So for my purpose, the input would be the measured temperature, setpoint would be the desire temperature, and output would be the fan speed?

I use DHT 11 temperature sensor. So do I need to convert the measurement in Celcius into byte by using map() function?

Thanks for your help

You need to post your code. I don't understand why you are asking about changing Celsius to a byte value.

I imagine the fan run-time will determine the change in temperature and, maybe, the difference between the actual and the desired temperature should determine the fan speed. Can you measure (separately) the temperature of the cooler (or warmer) air supply that is feeding the fan ? Where does it come from?

If the fan is just circulating air it will only warm the space due to the heat generated by the fan motor and the energy imparted to the air by the fan.

...R

So for my purpose, the input would be the measured temperature, setpoint would be the desire temperature, and output would be the fan speed?

Yes, although to Robin's point, you need to be sure that the fan is actually providing a cooling effect. You'll need to declare the PID with REVERSE too, since more fan will give you less temperature (hopefully).

I use DHT 11 temperature sensor. So do I need to convert the measurement in Celcius into byte by using map() function?

No. The PID parameters are all double and it expects that the set point and input will have the same units (centigrade in this case).

The reason I am asking about mapping the value of the input and output is because I saw that the speed of the motor would be from 0-255 (bytes) so I am not sure if the input as in merely Celcius value (0-50 for DH11 range) would be able to generate the proper motor speed output.

Thanks

qpham26:
The reason I am asking about mapping the value of the input and output is because I saw that the speed of the motor would be from 0-255 (bytes) so I am not sure if the input as in merely Celcius value (0-50 for DH11 range) would be able to generate the proper motor speed output.

I now understand what you are thinking but I don't think it will be sufficient (or necessary) to relate the fan speed directly to the temperature.

It may be more appropriate, as I said earlier, to relate the fan speed to the difference in temperature - but I'm not even confident of that.

I think you need to do some practical experiments to measure how the fan affects the temperature before you can design your control system.

...R

From the PID page in the playground:

The PID controller is designed to vary its output within a given range. By default this range is 0-255: the arduino PWM range.

Output is taken care of. Just make your Setpoint and Input Centigrade values and the PID will take care of the rest.