LM 335 in the fridge...

Hi all!
I want to build my own thermostat for my fridge, using a LM 335 and a 5V PS, 1K resistor i get this values:

2,518V the compresor go OFF
2,631V the compresor go ON

the difference is: 0,113 V in digital: (0,005V = 1 step)

ADC= 526 OFF
ADC= 503 ON

Now this LM335 is not fully thermaly conected to the fridge evaporator (the cold part of the fridge), the freon go to -20ºC when is boiling.

So, what i need to know is if this values are rigth, i never use this sensor, can be this LM test negative temps? in the default configuration?, because in the PDF file for use it in a full range application i need a lm 334 like current source generator.

2,518V is the minimum valule or it can be less?, in the PDF file said....0V at -218ºC :o.. that is true?.

So, that was my test at the LM 335 .

Best Regards
Frank

Well, according to the datasheet the voltage changes 10mV per 1 kelvin change of temperature and should go to 0V at T=0K (-273.15°C).

So

U[V] = 0.01V/K * (T[°C] + 273.15)

-->

T[°C] = U[V] / (0.01V/K) -273.15

2.518V => -21.35 °C
2.631V => -10.05 °C

To check if the calibration is right, just use 2 known reference points:

a) water/ice mixture at 0°C (measured in the water, not on dry ice)
b) boiling water at sea level at about 100°C

Looks like the LM335 is working correctly to me...

With reference to the datasheet found here: http://www.national.com/ds/LM/LM135.pdf, I assume you have the LM335 connected as per the "Basic Temperature Sensor" on page 6 and are measuring the performance of the fridge with the existing thermostat?

The schematic in the data sheet indicates that the output is 10 mV per degrees Kelvin, which is essentially the same as Celsius, but referenced to absolute zero ( -273 degrees C), and the LM335 is rated to operate from -40 to +100 degrees C so yes, it works with negative temperatures.

Converting the voltages you measure :

(2.518 V / 0.01) - 273 = -21.2 degrees C compressor OFF
(2.631 V / 0.01) - 273 = -9.9 degrees C compressor ON

So it appears to be working to me, you just might need to take into account that the numbers read by the ADC need to be scaled correctly to give the correct temperature. However the numbers you give of ADC= 526 OFF and ADC= 503 ON seem back to front to me - are you sure they are correct? I'd expect the ON value to be higher than the OFF value...

ADC = VIN * 1024 / VREF

Where VREF = 5V for the Arduino

So:

VIN = ADC * VREF / 1024

What you are seeing with the on/off temperature difference is the hysteresis Hysteresis - Wikipedia of the thermostat. Hysteresis is often added to make sure that thermostats and the like don't continuously switch around the set point due to electrical noise and minor tolerable variations in signal levels. Hysteresis can be used to reduce unnecessary switching of comparator (thermostat) outputs.

The fridge's compressor is switching on when the temperature of the coolant reaches -10 deg C then driving it until it hits -20 deg C then turning off again. The temperature of the coolant is actually experiencing a 10 degrees C change over time and the 10 degrees C window is the effect of hysteresis.

Continually switching the compressor on and off will likely reduce its operating life unless other steps are taken, such as cooling the motor.

So check your ADC readings for the ON/OFF states again, they look back to front to me, the sensor appears to be working.

Very thank you!.

That values i get from a fridge that works great, but i have a small fridge and is for that i want to build my own thermostat.

The problem of this fridge is this, the fridge have a strange hysteresis cycle.

ON 1 minute
OFF 3 minute

So i suspect is the thermostat, i change it for a new one but still doing this cicle less or more.

The fridge have FREON but for some reason it have this cycle, i don't know if the compresor is bad...or what!

Best Regards
Frank

I'd say that 1 minute on, 3 minutes off just means that the fridge warms up slower than the refrigeration system cools it down, which is kind of what you want in a fridge isn't it?

All this is for protect the compresor, i think the compresor needs a bigger cycle to work, the timing relation is fine, it's working in a 1:3 cycle.

My idea is make that cycle a little bit bigger, for example 5 minutes on and 15 minutes off.

This fridge is an older fridge, and it's new for me so i don't know if this cycle is rigth, i meen i don't know if is the original timing from factory. It's a small fridge embeded in the kitchen furniture. :o

I do not know, but it can be wrong or the colling system have problems. :-?

Best Regards!

Doing maths...

V1=2,513V
V2=2,628V

Temp OFF =(2,513V/0,01) -273,15 = -21.85ºC [T1]
Temp ON =(2,628V/0,01) -273,15 = -10.35ºC [T2]

So, > ADC1= 2,513 * 1024/5 = 515

ADC2=2,618 + 1024/5 = 538

ADC2 - ADC1 = 23

That meens i have 23 steps for the 11,5ºC, so i think that each step is:

11,5ºC / 23 = 0,5 ºC for each ADC step? i'm rigth? :o

I think if i use a lot of maths never go to find a better number and a Vref to adjust my thermostat...1 ADC step = 0,5ºC looks greatt! ;D

So using a LCD to adjust both values, T1 and T2, i can use the 0,5ºC to get up and down the both values and easly convert ºC to ADC and test with the ADC input, i forget about use Fix() functions to get a round number.

Best Regards!

What i'm seeing is this, if the REF terminal in the LM335 is no conected, looks like a high impedance input.

Who i set-up that input?, i want to get down this impedance for have less noise at the sensor.

a low impedance voltaje reference??

Best regards

Personally, if I were having an arduino controlling a fridge I'd use a 'dallas' 1 wire digital sensor and have it well away from the evaporator, so its controlling the temperature of the air and hence the food, rather than the temperature of the refrigerant. Because the feedback isn't as harsh as measuring the temperature of the evaporator, it would also have the effect of increasing the times of the on/off cycle which is the object of the exercise. A digital sensor whilst a little more expensive won't suffer the analogue noise problem you get with the LM335 and an ADC. I have an arduino with digital sensors controlling my central heating, I stop it rapid cycling by only processing the boiler on/off part every 5 minutes, it can't possibly run for less than 5 minutes or be off for less than 5 minutes. 5 minutes is neither here nor there with the extreme latency of a CH system :wink:

My ugly code:

A better way to do a MENU in the LCD?, i have one button labeled like MENU and other two like + or -.

That menu let me adjust: :sunglasses:

AIR On/Off Temp
FRIO (Evaporator) On/Off Temp
And control by what, AIR or FRIO (Evaporator temp).

Have too a simple timer to mesure the On/Off time.

Some better idea to a better coding? :o

#include <string.h>
#include <DespLCD2.h>
#include <Button.h>

LCD4Bit lcd = LCD4Bit(2);

Button mas = Button(10,PULLUP);
Button menos = Button(9,PULLUP);
Button menu = Button(11,PULLUP);

int Evaporador = 5;
int Aire = 4;
int Compresor = 2;
float ADC1 = 0;
float ADC2 = 0;
float Temp1 = 0;
float Temp2 = 0;

float ActualFrio=-10.5;
float ActualAire=99.9;
float FrioOn=-10.0;
float FrioOff=-20.0;
float AireOn=7;
float AireOff=3;

char strTemp1[16];

int estoyenmenu=0;
int menucual=0;

int MaxTempoOn=0;
int MinTempoOn=0;
float ActualTempoOn=0;
float ActualTempoOff=0;

int controlpor=0;
int statechanged=0;

void setup(){
pinMode(Compresor, OUTPUT);
lcd.init();

}

void loop(){

if (menu.isPressed()){
lcd.clear();
delay(5); //1111111111111111
lcd.printIn(" MODO AJUSTES");
estoyenmenu++;}

if (estoyenmenu==1){
lcd.clear();
delay(5); //1111111111111111
lcd.printIn(" MODO AJUSTES");
if (menos.isPressed()){FrioOn=FrioOn + 0.5;}
if (mas.isPressed()){FrioOn=FrioOn - 0.5;}
lcd.cursorTo(2,0);
lcd.printIn("ON Frio= ");
lcd.printIn(floatToString(strTemp1, FrioOn, 1, 5));

}

if (estoyenmenu==2){
lcd.clear();
delay(5); //1111111111111111
lcd.printIn(" MODO AJUSTES");
if (menos.isPressed()){FrioOff=FrioOff + 0.5;}
if (mas.isPressed()){FrioOff=FrioOff - 0.5;}
lcd.cursorTo(2,0);
lcd.printIn("OFF Frio= ");
lcd.printIn(floatToString(strTemp1, FrioOff, 1, 5));}

if (estoyenmenu==3){
lcd.clear();
delay(5); //1111111111111111
lcd.printIn(" MODO AJUSTES");
if (menos.isPressed()){AireOn=AireOn + 0.5;}
if (mas.isPressed()){AireOn=AireOn - 0.5;}
lcd.cursorTo(2,0);
lcd.printIn("ON Aire= ");
lcd.printIn(floatToString(strTemp1, AireOn, 1, 5));}

if (estoyenmenu==4){
lcd.clear();
delay(5);
lcd.printIn(" MODO AJUSTES");
if (menos.isPressed()){AireOff=AireOff + 0.5;}
if (mas.isPressed()){AireOff=AireOff - 0.5;}
lcd.cursorTo(2,0);
lcd.printIn("OFF Aire= ");
lcd.printIn(floatToString(strTemp1, AireOff, 1, 5));}

if (estoyenmenu==5){
lcd.clear();
delay(5);
lcd.printIn(" MODO AJUSTES");
if (menos.isPressed()){controlpor--;}
if (mas.isPressed()){controlpor++;}
lcd.cursorTo(2,0);
lcd.printIn("Control:");
lcd.cursorTo(2,9);
if (controlpor >1){controlpor=0;}
if (controlpor <0){controlpor=1;}
if (controlpor==0){lcd.printIn("FRIO");}
if (controlpor==1){lcd.printIn("AIRE");}

}

if(estoyenmenu>5){estoyenmenu=0;}

if(estoyenmenu ==0){
float VTemp1=0;
float VTemp2=0;
ADC1 = analogRead(Evaporador);
ADC2 = analogRead(Aire);

VTemp1 = (ADC1 * 4.16) / 1024;
VTemp2 = (ADC2 * 4.16) / 1024;

ActualFrio = (VTemp1 / 0.01) - 273.15;
ActualAire = (VTemp2 / 0.01) - 273.15;

lcd.clear();
delay(5);
lcd.printIn("F:");
lcd.printIn(floatToString(strTemp1, ActualFrio, 1, 2));
lcd.cursorTo(1,9);
lcd.printIn("A:");
lcd.printIn(floatToString(strTemp1, ActualAire, 1, 2));

Termostato();
Tempo();

}

delay(250);
}

void Termostato(){
float VTemp1=0;
float VTemp2=0;
float OnTemp=0;
float OffTemp=0;
float NowTemp=0;

ADC1 = analogRead(Evaporador);
ADC2 = analogRead(Aire);

VTemp1 = (ADC1 * 4.16) / 1024;
VTemp2 = (ADC2 * 4.16) / 1024;

ActualFrio = (VTemp1 / 0.01) - 273.15;
ActualAire = (VTemp2 / 0.01) - 273.15;

// Evaporator Control:
if (controlpor==0){OnTemp=FrioOn; OffTemp=FrioOff; NowTemp=ActualFrio;}

//Air Control:
if (controlpor==1){OnTemp=AireOn; OffTemp=AireOff; NowTemp=ActualAire;}

//Main Control:
if (NowTemp>OnTemp){
if(digitalRead(Compresor)== LOW){
digitalWrite(Compresor,HIGH); }
statechanged=1;}

if (NowTemp<OffTemp){
if(digitalRead(Compresor)== HIGH){
digitalWrite(Compresor,LOW); }
statechanged=2;}

}

void Tempo(){
char strTempo[16];
int On = digitalRead(Compresor);

//if (statechanged==1){
// ActualTempoOn=0;
// statechanged=0;}

//if (statechanged==2){
// ActualTempoOff=0;
// statechanged=0;}

if (On == LOW){ActualTempoOff=ActualTempoOff + 1;}

if (On == HIGH){ActualTempoOn=ActualTempoOn + 1;}

//ActualTempoOff=ActualTempoOff /4;
//ActualTempoOn = ActualTempoOn /4;

lcd.cursorTo(2,0);
lcd.printIn("ON:");
lcd.cursorTo(2,3);
lcd.printIn(floatToString(strTempo, ActualTempoOn, 0, 2));
lcd.cursorTo(2,8);
lcd.printIn("OFF:");
lcd.printIn(floatToString(strTempo, ActualTempoOff, 0, 2));

}