milesburton / Arduino-Temperature-Control-Library

Arduino Temperature Library

Home Page:https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-127.00 c° When start a fan

zonalimitatore opened this issue · comments

It's a strange problem. I use 2 DS18B20 to control temp of 2 motors.
Sometimes, one sensor (it's random) read -127c°, and the entire program it's lock.
I've to reset the board.

I've tried to set more timings, delay, less resolution, change the definition.Also, tried to request temp by index,address,ecc... But nothing help.
When a fan start, one of two sensors lock all, and i read -127.00c°.

What's wrong?

Sensors in pin2, no parasite mode. 4,7Kohm resistance. 5v regulated and stable.
Fans are in pins 10-11 and each one have a mosfet.
i2c lcd

first thought: You might need to try shielded wires to the sensors.

Ok. But why that -127 ? The sensor can't reach that

  • -127 is an error code, it was chosen as it is out of range of the ds18b20 series

In your DallasTemperature.h there is this line

#define DEVICE_DISCONNECTED_C -127

there is also a DEVICE_DISCONNECTED_F

Oh amazing! So. I've to shield the signal wire, or all?

Normally you should shield all of them, GND to shield.

this book might be interesting

Ok,thanks. And all the shield to Arduino's ground, or to supply power ground?

I would connect the cable of the sensor to the Arduino.
how are the fans powered?

Are powered with a separate stepdown. 24v to 10v. But I've all the grounds in common

Are the sensor wires close to the Fan wires?

Unfortunately yes...I need to find another way to pass the wires

Maybe I've solved. I had to give up PWM fan control. However, by lowering the step down voltage, I am able to accept the compromise of having an on / off situation. It seems that noise is generated (or interferes) in the "analogWrite" on the digital pins.
Tomorrow I will test thoroughly; if, how, when and after how long it happens (even if it seems to me, a few seconds after switching on). For the moment, HIGH / LOW "digitalWrtite" , seems to give no problem.
Both with fan 1, with fan 2, and with both on.

If you measure temperature once per minute or less, you could switch off the fans during temperature measurement. That could be enough to reduce the electric noise and would take less than a second so the fans would not even stop moving. If you use the async calls the "interrupts" would be so short that they might be hard to notice. That might even work if you measure the temperature continuously.

Alternative is to switch the fans to 100% during measurement but I expect that will be more noticeable.

just another solution direction.

Normally fans are off. They switch on, only when target temp is reach. And stay on until the temp return below the target temp. I've set a kind of "steps" ( if temp is 36, turn on at 25%, if is 37 at 30%, 38 at 35%, ecc...). But, doesn't matters. I prefer a "full power" instead the risk of total "lock situation"!!!!

I test it all. Work nice! Thanks

@zonalimitatore
Did you solve it with PWM or just an on/off?
Is it possible to share your (minimized) code for future reference? Might be a nice example!

I've solved by on/off

After the standard define, i've solve with;

#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#define PRECISIONE_TEMP 10 //  9:0.5°c(95ms)  10:0.25°c(187ms)  11:0.125°c(375ms)  12: 0.0625°c(750ms)
DeviceAddress indirizzoY = { 0x28, 0xBA, 0x65, 0x79, 0x97, 0x19, 0x03, 0xC0 };
DeviceAddress indirizzoX = { 0x28, 0x34, 0x08, 0x94, 0x97, 0x07, 0x03, 0x20 };
unsigned long tempX;
unsigned long tempY;


void setup
  sensors.begin();                // INIZIALIZZO I SENSORI
  sensors.setResolution (indirizzoY, PRECISIONE_TEMP); 
  sensors.setResolution (indirizzoX, PRECISIONE_TEMP);

    sensors.requestTemperaturesByAddress(indirizzoX); 
    delay(250);                                       
    sensors.requestTemperaturesByAddress(indirizzoY); 
    delay(250);                                      
    lcd.setCursor(7, 0);
    lcd.print(sensors.getTempC(indirizzoY));          
    lcd.setCursor(7, 1);
    lcd.print(sensors.getTempC(indirizzoX));


loop
// INIZIO REGOLE ASSE Y
{
   tempX = sensors.getTempC(indirizzoX); 
    if ((tempX) <= (34.75))               
        digitalWrite(fanx, LOW);          
       if ((tempX >= 35.00))              
      digitalWrite(fanx,HIGH);            
    }
    
     // INIZIO REGOLE ASSE Y
    { 
    tempY = sensors.getTempC(indirizzoY); 
    if ((tempY <= 34.75))
      digitalWrite(fany, LOW);
      if ((tempY >= 35.00))
      digitalWrite(fany,HIGH);
    }