Forum Software Ferduino code Changes in the code to 2 sinks - this correct?

Changes in the code to 2 sinks - this correct?


Post Number:#1 Post Tue Oct 28, 2014 12:23 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 38
Gender: None specified
National Flag:
Brazil
Hi ! again... :((

In my project I will have two heatsinks, and ferduino there is only one sensor to sink, Fernando Garcia asked about adding one more sensor for a second heatsink and he showed me an example.
With this example I modified the code by adding a second sensor to the heatsink without losing the features that already exist in the management of Arduino fans due to the temperature.

This second sensor will receive the address manually, by passing the address code.

Show here the modification, I'm not good programmer x_x , so I'm putting here to aid others with the same need and if necessary correct or can someone give an idea to improve this change.

I still did not upload the code to arduino.

hugs

Code Changes:

In Ferduino_with_webcontrol_beta
This changes:

//****************************************************************************************************
//***************** Variáveis dos sensores de temperatura ********************************************
//****************************************************************************************************
DeviceAddress sensor_dissipador1; // Atribui os endereços dos sensores de temperatura.
DeviceAddress sensor_dissipador2 = {0x28, 0x9C, 0xA9, 0xAA, 0x03, 0x00, 0x00, 0x44}; // Find the address using the example "tester" available in DallasTemperature. // Atribui os endereços dos sensores de temperatura.
---
//*****************************************************************************************
//*********************** Variáveis de controle da temperatura do dissipador **************
//*****************************************************************************************
float tempH1 = 0;   // Temperatura do dissipador1
float tempH2 = 0;   // Temperatura do dissipador2
//*****************************************************************************************
//*********** Variáveis temporárias de controle da temperatura do dissipador **************
//*****************************************************************************************
float temperatura_dissipador1_temp = 0; // Temperatura temporária
float temperatura_dissipador2_temp = 0; // Temperatura temporária
-------------------------------------------------------------------------------------------------------------------------------------------


IN tab A_Portuguese
This changes:

prog_char texto257[] PROGMEM = "T.DISSIP. 2:"; // tabela_textos[257]


and add in tabela_texto
..texto257...
-------------------------------------------------------------------------------------------------------------------------------------------


In tab emprom
This changes:
void ReadDallasAddress()
{
  for (byte i = 0; i < 8; i++)
  {
    sensor_agua[i] = EEPROM.read(766 + i);    // sensor address
    sensor_dissipador1[i] = EEPROM.read(775 + i);
    sensor_ambiente[i] = EEPROM.read(784 + i);
  }

void SaveDallasAddress ()
{

  for (byte i = 0; i < 8; i++)
  {
    EEPROM.write(766 + i, sensor_agua[i]);
    EEPROM.write(775 + i, sensor_dissipador1[i]);
    EEPROM.write(784 + i, sensor_ambiente[i]);
  }
----------------------------------------------------------------------------------------------------


In tab Inicio
This Changes:
    strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[183])));
    myGLCD.print(buffer, 212, 14);  // tabela_textos[183] = "T.DISSIPADOR1:" 
   
    strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[257])));
    myGLCD.print(buffer, 212, 28); // tabela_textos[257] = "T.DISSIP. 2:

    strcpy_P(buffer, (char*)pgm_read_word_near(&(tabela_textos[184])));
    myGLCD.print(buffer, 212, 42); // tabela_textos[184] = "TEMP. AGUA:"
...

  myGLCD.setColor(0, 255, 0); 
  myGLCD.printNumF(tempH1, 2, 316, 14);   // Temperatura dissipador1
  myGLCD.printNumF(tempH2, 2, 302, 28);   // Temperatura dissipador2
  myGLCD.printNumF(tempC, 2, 327, 42);     // Temperatura da agua
** change variable PHA to tempC in line 3**


comented this lines

//  if (bitRead(status_parametros,2)==true)
//  {                               
//    myGLCD.printNumF( tempC, 2, 302, 28);     // Temperatura em vermelho
//  } 


and changed PHA to tempC below

  if (bitRead(status_parametros,3) == true)
  {                               
    myGLCD.printNumF(tempC, 2, 327, 42);       // Temperatura em vermelho
  }   

---------------------------------------------------------------------------------------------------------


In tabs Leds

//---------------------------LED levels---------------------------
Changed this

  if((tempH1 >= tempHR) || (tempH2 >= tempHR) )
  {
    reduzir = (1 - (potR *.01));
    temperatura_alta = true;
    temperatura_baixou = false;
  }
  if(temperatura_alta == true)
  {
    if((tempH1 <= (tempHR - 5)) || (tempH2 <= (tempHR - 5)) ) // Se a temperatura estiver 5°C abaixo do especificado a potência volta ao valor normal.   
    {
      reduzir = 1.00;
      temperatura_alta = false;
      temperatura_baixou = true;
    }
    else
    {
      reduzir = (1 - (potR *.01));
      temperatura_baixou = false;   
    }
  }   
-------------------------------------------------------------------------------------------


In tab parametros

This changes:

void checkTempC()
{
  contador_temp ++;

  sensors.requestTemperatures();                                          // Chamada para todos os sensores.
  temperatura_agua_temp += (sensors.getTempC(sensor_agua));               // Lê temperatura da água
  temperatura_dissipador1_temp += (sensors.getTempC(sensor_dissipador1));   // Lê temperatura do dissipador
  temperatura_dissipador2_temp += (sensors.getTempC(sensor_dissipador2));   // Lê temperatura do dissipador
  temperatura_ambiente_temp += (sensors.getTempC(sensor_ambiente));       // Lê temperatura do dissipador

  if(contador_temp == 12)
  {
    tempC = temperatura_agua_temp / 12;
    tempH1 = temperatura_dissipador1_temp / 12;
    tempH2 = temperatura_dissipador2_temp / 12;
    tempA = temperatura_ambiente_temp / 12;
    contador_temp = 0;
    temperatura_agua_temp = 0;
    temperatura_dissipador1_temp = 0;
    temperatura_dissipador2_temp = 0;
    temperatura_ambiente_temp = 0;
  }


 int tempval1 = int(tempH1 * 10);
  int tempval2 = int(tempH2 * 10);
  int fanSpeed1 = map(tempval1, (HtempMin * 10), (HtempMax * 10), 0, 255);       // Controle de velocidade das ventoinhas do dissipador
  int fanSpeed2 = map(tempval2, (HtempMin * 10), (HtempMax * 10), 0, 255);       // Controle de velocidade das ventoinhas do dissipador

  if ((fanSpeed1 < 0) || (fanSpeed2 < 0))
  { 
    fanSpeed1 = 0;
    fanSpeed2 = 0;
  }   
  if ((fanSpeed1 > 255) || (fanSpeed2 > 255))
  {
    fanSpeed1 = 255;
    fanSpeed2 = 255;
  }
  analogWrite(fanPin, fanSpeed1);
  analogWrite(fanPin, fanSpeed2);

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


In tab processMyTouch

This changes:

         contador_temp = 0;
          temperatura_agua_temp = 0;
          temperatura_dissipador1_temp = 0;
          temperatura_dissipador2_temp = 0;
          temperatura_ambiente_temp = 0;
          sensors.requestTemperatures();   // Chamada para todos os sensores.
          tempC = (sensors.getTempC(sensor_agua));  // Lê a temperatura da água
          tempH1 = (sensors.getTempC(sensor_dissipador1)); // Lê a temperatura do dissipador.
          tempH2 = (sensors.getTempC(sensor_dissipador2)); // Lê a temperatura do dissipador.
          tempA = (sensors.getTempC(sensor_ambiente)); // Lê a temperatura do ambiente.


Setup:

  sensors.begin();     //Inicia as leituras das sondas de temperatura.
  sensors.setResolution(sensor_agua, 10); // Define a resolução em 10 bits.
  sensors.setResolution(sensor_dissipador1, 10); // Define a resolução em 10 bits.
  sensors.setResolution(sensor_dissipador2, 10); // Define a resolução em 10 bits.
  sensors.requestTemperatures();   // Chamada para todos os sensores.
  tempC = (sensors.getTempC(sensor_agua));  // Lê a temperatura da água
  tempH1 = (sensors.getTempC(sensor_dissipador1)); // Lê a temperatura do dissipador.
  tempH2 = (sensors.getTempC(sensor_dissipador2)); // Lê a temperatura do dissipador.
  tempA = (sensors.getTempC(sensor_ambiente)); // Lê a temperatura do ambiente.

:D
Last edited by Fernando Garcia on Tue Oct 28, 2014 10:37 pm, edited 3 times in total.
Reason: Please do not put codes without tags.

Post Number:#2 Post Tue Oct 28, 2014 10:36 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!

Here:

..texto257...


the right is:

, texto257


Here:

if (bitRead(status_parametros,3) == true)


The right is:

if (bitRead(status_parametros, 2) == true) // Bit 2 is water temperature.


Replace:

if((tempH1 <= (tempHR - 5)) || (tempH2 <= (tempHR - 5)) )


With:

if((tempH1 <= (tempHR - 5)) && (tempH2 <= (tempHR - 5)))


Here is wrong:

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


You need 1 pin "desativarFanPin" to each fan.

In ProcessMyTouch remove:

temperatura_dissipador2_temp = 0;

tempH2 = (sensors.getTempC(sensor_dissipador2)); // Lê a temperatura do dissipador.
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 Fri Oct 31, 2014 5:37 pm
Posts: 45
Topics: 9
Solve rating: 0
Joined: Thu Apr 10, 2014 12:21 pm
Topics: 9
Age: 38
Gender: None specified
National Flag:
Brazil
Thank you for support and help Fernando,

I can choose any free pin or swap for another who will not use such as pins 16:17 of STAMPS or has to be some specific pin to create another "desativarFanPin2"?

Best regards

Post Number:#4 Post Sat Nov 01, 2014 9:51 am
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 use any free pin.

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




  • Similar Topics
    Replies
    Views
    Last post

Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest