Changeset 21 for trunk/Arduino


Ignore:
Timestamp:
Sep 10, 2019, 8:56:08 PM (7 years ago)
Author:
markus
Message:

+ Calculate bailer temperature in OT_Boiler sub-class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Arduino/projects/OT_boiler/OT_boiler.ino

    r19 r21  
    2121volatile bool  _connected = false;
    2222
    23 OT_Slave        boiler;
     23class OT_Boiler : public OT_Slave {
     24
     25protected:
     26        int             a2;
     27
     28public:
     29        virtual float   GetBoilerTemperature ();
     30        virtual float   GetReturnTemperature ();
     31
     32friend void loop();
     33};
     34
     35OT_Boiler       boiler;
    2436
    2537EthernetClient  client;
    … …  
    8395  unsigned long periode = msTicks / (boiler.IsActive() ? 500 : 2000);
    8496  static unsigned long prev = 0;
    85 
    86   int a2 = analogRead(A2);   // read the input pin
    87 #ifdef _R9_22K_
    88   const double m = 0.1309;
    89   const double b = -9.4535;
    90 #elif defined(_R9_15K_1_)
    91   const double m = 0.1746;
    92   const double b = -13.164;
    93 #else
    94   const double m = 0.1848;
    95   const double b = (-12.936 - 5.5);
    96 #endif
    97   double ta2 = m*double(a2)+b;
    98  
    9997  if (prev != periode) {
    10098          prev = periode;
    10199          int led = (periode & 1) ? HIGH : LOW;
    102100          if (Serial) {
     101                  float tBoiler = boiler.GetBoilerTemperature();
    103102                  Serial.print("Time: ");
    104103                  Serial.print(msTicks);
    … …  
    107106                  Serial.print("\tLED: ");
    108107                  Serial.print(led);
    109       Serial.print("\tA2: ");
    110       Serial.print(a2);
    111       Serial.print("\tT(A2): ");
    112       Serial.println(ta2);
     108                  Serial.print("\tA2: ");
     109                  Serial.print(boiler.a2);
     110                  Serial.print("\tT(A2): ");
     111                  Serial.println(tBoiler);
    113112          }
    114113          digitalWrite(ACTIVITY_LED_PIN, led);
    … …  
    179178  }
    180179}
     180
     181float OT_Boiler::GetBoilerTemperature ()
     182{
     183        a2 = analogRead(A2);   // read the input pin
     184        const double m = 0.1848;
     185        const double b = -17.4056;
     186        tBoiler = double(m*double(a2)+b);
     187        return tBoiler;
     188}
     189
     190float OT_Boiler::GetReturnTemperature ()
     191{
     192        return OT_Slave::GetReturnTemperature ();
     193}
Note: See TracChangeset for help on using the changeset viewer.