Forum Software Ferduino code Problem with heater

Problem with heater  [SOLVED]


Post Number:#1 Post Wed Apr 29, 2015 6:09 pm
Posts: 20
Topics: 4
Images: 0
Solve rating: 0
Joined: Sun Apr 19, 2015 2:35 pm
Topics: 4
Age: 45
Gender: None specified
National Flag:
Italy
hi

I'm new in the forum sorry for my english but I use google translator ...

I have a problem with the heater, when the temperature drops to below the set minimum level the relay becomes on but just reaches the minimum level becomes off without reaching the reference temperature.
in this way the relays are constantly changing state.
to remedy this problem is corrected to change the code so ??

if (offTempC > 0)
  {
    if ((tempC > (setTempC + offTempC)))            // Liga o chiller
    {
      while(tempC)
      {
      bitWrite(status_parametros,0,1);
      digitalWrite(chillerPin, HIGH);
      }
    }
    if ((tempC < (setTempC - offTempC)))             // Liga o aquecedor
    {
      while(tempC)
      {
      bitWrite(status_parametros,1,1);
      digitalWrite(aquecedorPin, HIGH);
      }
    }
  }


thank you very much for your attention

danilo

Post Number:#2 Post Thu Apr 30, 2015 12:01 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

It's completely wrong check this page: http://www.arduino.cc/en/Reference/While

You need work with this lines:

if ((tempC > (setTempC + offTempC)))

if ((tempC < (setTempC - offTempC)))


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Thu Apr 30, 2015 5:46 pm
Posts: 20
Topics: 4
Images: 0
Solve rating: 0
Joined: Sun Apr 19, 2015 2:35 pm
Topics: 4
Age: 45
Gender: None specified
National Flag:
Italy
hi

I understand that there is a compilation error of the while statement.
is correct to use the while istruction or using this type of instruction there is a risk that the controller goes into an infinite loop?

I thought to correct the statement with these two.

while((tempC < setTempC ))
while((tempC > setTempC ))

Post Number:#4 Post Thu Apr 30, 2015 9:48 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

What are the values possible to tempC and setTempC?

Replace this values and tell me if will make what you want.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Fri May 01, 2015 11:30 am
Posts: 20
Topics: 4
Images: 0
Solve rating: 0
Joined: Sun Apr 19, 2015 2:35 pm
Topics: 4
Age: 45
Gender: None specified
National Flag:
Italy
hi Fernando

I now set so:

setTempC = 25.5
offTempC = 0.7

I wish that when the temperature of the aquarium (tempC) descends for example at 24.7 ° C the heater turning on and remain on until 25 ° .5 and not turn OFF as it happens now at 24.8 ° C.
my only fear is that during the entire period in which the heater is on the controller does not perform most other commands

Post Number:#6 Post Fri May 01, 2015 1:11 pm
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

You can't use a "while" on this case.

Try another method.

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Sat May 02, 2015 11:22 am
Posts: 20
Topics: 4
Images: 0
Solve rating: 0
Joined: Sun Apr 19, 2015 2:35 pm
Topics: 4
Age: 45
Gender: None specified
National Flag:
Italy
hi fernando
let's see if this method can go :-s :-s :-s .
I do not know anything about programming but I'm trying to apply myself to understand how to make and I hope also with your help :D :D :D :D

I defined three boolean variable is then thought to modify the code like this:
 
 if (tempC < (setTempC + offTempC + alarmTempC) && tempC > (setTempC - offTempC - alarmTempC))
  {
    bitWrite(status_parametros,2,0);
  }

  if (alarmTempC > 0)                        // Aciona alarme
  {
    if ((tempC >= (setTempC + offTempC + alarmTempC)) || (tempC <= (setTempC - offTempC - alarmTempC)))
    {
      bitWrite(status_parametros,2,1);
    }
  }

  if ((tempC < (setTempC + offTempC)) && (tempC > (setTempC - offTempC)))          // Desliga aquecedor e chiller
  {
    bitWrite(status_parametros,0,0);
    bitWrite(status_parametros,1,0);
    digitalWrite(aquecedorPin, LOW);
    digitalWrite(chillerPin, LOW);   
  }

  if (offTempC > 0)
  {
    if ((tempC > (setTempC + offTempC)))            //   ocorre entre ligar o chiller
          {
            temperatura_max_set = true;
            temperatura_ok = false;
            temperatura_min_set = false;
           }
     
     
   
   
    if ((tempC < (setTempC - offTempC)))             // ocorre entre ligar o aquecedor
              {
                temperatura_min_set = true;
                temperatura_ok = false;
                temperatura_max_set = false;
              }
   
    if (temperatura_max_set == true)            // ocorre entre desligar o chiller
      {
         if ((tempC <= (setTempC)))
               {
                 temperatura_max_set = false;
                 temperatura_ok = true;
                } 
      }
    if (temperatura_min_set == true)
      {
        if ((tempC >= (setTempC)))             // ocorre entre desligar o aquecedor
            {
              temperatura_min_set = false;
              temperatura_ok = true;
             }
      }
   

 
    if (temperatura_max_set == true)            // Liga o chiller
    {
      bitWrite(status_parametros,0,1);
      digitalWrite(chillerPin, HIGH);
    }
    if (temperatura_min_set ==true)             // Liga o aquecedor
    {
      bitWrite(status_parametros,1,1);
      digitalWrite(aquecedorPin, HIGH);
    }
 

 if (temperatura_ok==true)                    //desliga o chiller e aquecedor
  {
    bitWrite(status_parametros,0,0);
    bitWrite(status_parametros,1,0);
    digitalWrite(aquecedorPin, LOW);
    digitalWrite(chillerPin, LOW);
  }
  }
  if ((tempC > 50) || (tempC <10))
  {
    bitWrite(status_parametros,0,0);
    bitWrite(status_parametros,1,0);
    digitalWrite(aquecedorPin, LOW);
    digitalWrite(chillerPin, LOW);
  }

  if ((bitRead(status_parametros, 0) == true) &&  (bitRead(status_parametros, 1) == true)) // Evita aquecedor e chiller ligados ao mesmo tempo.
  {
    bitWrite(status_parametros,0,0);
    bitWrite(status_parametros,1,0);
    digitalWrite(aquecedorPin, LOW);
    digitalWrite(chillerPin, LOW);
  }

  int tempval = int(tempH * 10);
  fanSpeed = map(tempval, (HtempMin * 10), (HtempMax * 10), 0, 255);       // Controle de velocidade das ventoinhas do dissipador
  if (fanSpeed < 0)
  { 
    fanSpeed = 0;
  }   
  if (fanSpeed > 255)
  {
    fanSpeed = 255;
  }
  analogWrite(fanPin, fanSpeed);

  if(tempH < HtempMin) // Desativa os coolers se a temperatura estive abaixo da mínima definida.
  {
    digitalWrite(desativarFanPin, LOW);
  }
  else
  {
    digitalWrite(desativarFanPin, HIGH);
  }
}




Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest