Jump to content
ELFORUM - Forumul electronistilor

Masurare debit, temperatura si COP


Cortex

Recommended Posts

Salutare, inca din primul rand  vreau sa va spun ca e primul meu program pe care il fac si tot o data prima oara cand pun  mana pe un IDE :nas:, evident inspiratii din diverse videouri, deci nu dati cu paru' prea tare:rade:

Am un UNO legat la un lcd 16x2 cu care ( vreau sa ) monitorizez temperaturi si waterflow ( cu YF-S201), ce imi da mie cu virgula, nu intepreteaza corect puterea de iesire respectiv COP ( coeficinet de putere ), daca printez pe lcd "delta", nu il intepreteaza cu virgula si de aici ( cred eu) ca e eroarea ( daca conteaza... am construit o pompa de caldura si vreau sa o monitorizez pt a ii gasi punctele optime de functionare) . Multumiri in avans !

//config lcd16x2
#include <LiquidCrystal.h>
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

volatile int flow_frequency;
float vol = 0.0,l_minute;
float volt = 0.3; //read voltage
float amp = 0.2; //read amps to pin 2
float temp1 = 0.0; // read adc to pin 0
float temp2 = 0.1; //read adc to pin 1
unsigned char flowsensor = 2; // pin 2 in, pwm
unsigned long currentTime;
unsigned long cloopTime;


void flow () // Interrupt function
{
   flow_frequency++;
}
void setup()
{
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   lcd.begin(16, 2);
   attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("HeatPump Monitor");
   lcd.setCursor(0,1);
   lcd.print(" Water-to-Water "); 
   delay(3000);
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{
  int volt = analogRead(A3); //read voltage in DC
  int amp = analogRead(A2); //read amps
  int temp1 = analogRead(A0); //read temp T1
  int temp2 = analogRead(A1); //read temp T2
  float volt_1 = (volt * 5.25) / 1023.0;
  float amp_1 = (amp * 5.25) / 1023.0;
  float temp_1 = (temp1 * 5.25) / 1024.0*100;
  float temp_2 = (temp2 * 5.25) / 1024.0*100;
  float power_in = (volt_1 * amp_1);
  float delta = (temp2 - temp1) /2;
  float power_out = (500 * (temp2 -temp1) * 1.16) * 0.001;  // acel 500 e debitul pompei L/h
  float COP = (power_out / power_in);
  
  currentTime = millis();
   if(currentTime >= (cloopTime + 1000))   // 0..to 1000mS = 0..to 1sec
   {
    cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      l_minute = (flow_frequency / 6.45); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print(l_minute); //value in L/M
      l_minute = l_minute/60;
      lcd.setCursor(11,0);
      lcd.print(temp_1);
      lcd.setCursor(11,1);
      lcd.print(temp_2);
      lcd.setCursor(6,0);
      lcd.print(power_in);
      lcd.setCursor(6,1);
      lcd.print(delta);
     // lcd.print(power_out);
      lcd.setCursor(0,1);
      lcd.print(COP);
      flow_frequency = 0; // Reset Counter
    }  
}

 

Link to comment
  • Replies 15
  • Created
  • Last Reply

Top Posters In This Topic

Incearca cu varianta asta:

 

#include <LiquidCrystal.h>

volatile int flow_frequency;
int ADC_raw = 0;
int vol = 0.0;//l_minute;
int volt = 0.0; //read voltage
int amp = 0.0; //read amps to pin 2
int temp1 = 0.0; // read adc to pin 0
int temp2 = 0.0; //read adc to pin 1
float ampf = 0.0;
float voltf = 0.0;
float temp1f = 0.0; // read adc to pin 0
float temp2f = 0.0; //read adc to pin 1
float power_in = 0.0;
float delta = 0.0;
float power_out = 0.0;
float COP = 0.0;
unsigned char flowsensor = 2; // pin 2 in, pwm
unsigned long currentTime;
unsigned long cloopTime;
unsigned long Lminute;

const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);



void flow () // Interrupt function
{
   flow_frequency++;
}
void setup()
{
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   lcd.begin(16, 2);
   attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("HeatPump Monitor");
   lcd.setCursor(0,1);
   lcd.print(" Water-to-Water "); 
   delay(3000);
        lcd.clear();
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{
  ADC_raw = analogRead(A3); //read voltage in DC
  amp = analogRead(A2); //read amps
  temp1 = analogRead(A0); //read temp T1
  temp2 = analogRead(A1); //read temp T2
  voltf = (ADC_raw * 5.25) / 1024.0;
  ampf = (amp * 5.25) / 1024.0;
  temp1f = (temp1 * 5.25) / 1024.0*100;
  temp2f = (temp2 * 5.25) / 1024.0*100;
  power_in = (voltf * ampf);
  delta = (temp2 - temp1) /2;
  power_out = (500 * (temp2 -temp1) * 1.16) * 0.001;  // acel 500 e debitul pompei L/h
  COP = (power_out / power_in);
  
  currentTime = millis();
   if(currentTime >= (cloopTime + 1000))   // 0..to 1000mS = 0..to 1sec
   {
    cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      Lminute = (flow_frequency / 6.45); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
 
      lcd.setCursor(0,0);
      lcd.print(Lminute); //value in L/M
      Lminute = Lminute/60;
      lcd.setCursor(3,0);
      lcd.print(temp1f);
      lcd.setCursor(11,0);
      lcd.print(temp2f);
      lcd.setCursor(0,1);
      lcd.print(power_in);
      lcd.setCursor(3,1);
      lcd.print(delta);
     // lcd.print(power_out);
      lcd.setCursor(11,1);
      lcd.print(COP);
      flow_frequency = 0; // Reset Counter
    }  
}

Si dovada functionarii, ca program. NU stiu cum vrei sa fie afisate valorile, dar ar trebui sa fie pe acolo. Te mai joci tu la partea de afisare.

forum.png

Link to comment

Mulțumesc domul Nico, cum ajunga acasa il si pun la treaba, de afisat ..ma mulțumesc sa am valorile pe lcd, vroiam  sa fac cu scris( mai multe  ecrane)  insa ma depaseste momentan.

Am in drum un grafic 128x64,  acolo o sa desenez schema de princiupiu a pompei cu valori aferente senzorilor, astfel va fi mai intuitiv

Link to comment

Salut, am bagat programelul, insa mai am ceva probleme legt de afisare/intepretare, in sensul ca la pornire, daca afiseaza o valoare peste ce-a citita, ultima cifra ramane afisata si nu dispare,

Nu stiu cum sa setez lungimea efectiva a valorii:26

De exemplu as vrea asa 

Temp1   27.3

Temp2   20.9

L/h 542

Power_in 1.2  (  sau 1200)

P_out  5.6    ( sau 5600)

COP  3.41

Link to comment
Acum 51 minute, mihaicozac a spus:

Ai nevoie de un lcd.clear()

Pff...cat de simplu era...eu il pusesem la sfarsit si nu apuca sa afiseze...porma l--am pus la inceput..la fel....acum l-am pus dupa calcul debit si merge perfect :aplauze

Am mai invatat ceva  .Multumesc !

Link to comment

Cum as putea implementa sa masoare COP in timp real ? actual debitul apei din formula este setat la 500 L/h ,,insa as vrea sa ia valoarea masurata de senzorul de debit care variaza in functie de...tevi...robineti...etc

 

  delta = (temp2 - temp1);
  power_out = (500 * delta * 1.16*0.001)/2;  // acel 500 e debitul pompei L/h
  COP = (power_out / power_in)*1000;

 

 mai pun o data tot codul pentru a fi mai usor de intepretat.

#include <LiquidCrystal.h>

volatile float flow_frequency;
int ADC_raw = 0;
int vol = 0.0;  //l_minute;
int volt = 0.0; //read voltage
int amp = 0.0; //read amps to pin 2
int temp1 = 0.0; // read adc to pin 0
int temp2 = 0.0; //read adc to pin 1
float ampf = 0.0;
float voltf = 0.0;
float temp1f = 0.0; // read adc to pin 0
float temp2f = 0.0; //read adc to pin 1
int power_in = 0.0;
float delta = 0.0;
float power_out = 0.0;
float COP = 0.00;
unsigned char flowsensor = 2; // pin 2 in, pwm
unsigned long currentTime;
unsigned long cloopTime;
unsigned long Lminute;

const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void flow () // Interrupt function
{
   flow_frequency++;
}
void setup()
{
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   lcd.begin(16, 2);
   attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("HeatPump Monitor");
   lcd.setCursor(0,1);
   lcd.print(" Water-to-Water "); 
   delay(3000);
        lcd.clear();
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{
  
  ADC_raw = analogRead(A3); //read voltage in DC
  amp = analogRead(A2); //read amps
  temp1 = analogRead(A0); //read temp T1
  temp2 = analogRead(A1); //read temp T2
  voltf = (ADC_raw * 5.110) / 1023.0;
  ampf = (amp * 5.110) / 1023.0;
  temp1f = (temp1 * 5.12) / 1023.0*100;
  temp2f = (temp2 * 5.12) / 1023.0*100;
  power_in = (voltf * ampf)*100;
  delta = (temp2 - temp1);
  power_out = (500 * delta * 1.16*0.001)/2;  // acel 500 e debitul pompei L/h
  COP = (power_out / power_in)*1000;  // Putere afisata in kw
  
  currentTime = millis();
   if(currentTime >= (cloopTime + 1000))
   {
    cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      Lminute = (flow_frequency / 10.3)*100; // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
      lcd.clear();  // asta imi lipsea mai devreme :))
      lcd.setCursor(0,0);
      lcd.print(Lminute);   // value in L/h
      Lminute = Lminute;    // sau Lminute = Lminunte/60
      
      lcd.setCursor(11,0);
      lcd.print(temp1f);
      
      lcd.setCursor(11,1);
      lcd.print(temp2f);
      
      lcd.setCursor(0,1);
      lcd.print(COP);
     
     // lcd.setCursor(3,0);
     // lcd.print(delta);
      
      lcd.setCursor(6,1);
      lcd.print(power_out);
      
      lcd.setCursor(5,0);
      lcd.print(power_in);
      flow_frequency = 0; // Reset Counter
      
    }  
}

 

Te rog sa folosesti butonul "<>" din editor pentru a insera cod!

 

Link to comment

Scuze,nu stiam de "<>". Chiar vroiam sa intreb cum fac sa arate ca un cod postat,acum stiu ,multan'!

Am pus sa calculeze  Lminute*delta*1.16 chiar inainte de afisare power_out ...e aporape ok insa cand valorile tind spre zero, se muta virgula aia de apar cifre suprapuse ( ca ma limiteaza lcd-ul ) de nu mai intelegi nimic. 

Gen 0.0023. As fi preferat sa ramana 0.01,mai studiez problema. Va mulțumesc de ajutor !

Link to comment

am incercat 

float COP_f = Lminute * delta * 1.16;
COP_f = constrain (COP_f, 0.01, 5.00);

e la fel, 

Cop poate fi si subunitar ( daca depasesc temepraturile de lucru ale freonului ,,am doar cosum in compresor,,,,freonul nu mai face nimic la peste 60 C

Sau mai e varianta sa ii inversez sensul, sa pun pompa pe "racire" astfel am cop cu "minus" fiind acelasi lucru 

Link to comment

Salutare din nou, mi-a sosit un lcd 128x64, deoarece inca imi prind urechile, apelez la d-voastra in a ma lumina cum sa afisez valorile, si poate chiar cum pot creea un desen care sa ramana si in jurul lui sa am valorile. Multumesc frumos

 

#include <U8glib.h>
U8GLIB_ST7920_128X64_1X u8g(13, 11, 10); 

volatile float flow_frequency;
int volt = 0.0; //read voltage
int amp = 0.0; //read amps to pin 2
int temp1 = 0.0; // read adc to pin 0
int temp2 = 0.0; //read adc to pin 1
float ampf = 0.0;
float voltf = 0.0;
float temp1f = 0.0; // read adc to pin 0
float temp2f = 0.0; //read adc to pin 1
int power_in = 0.0;
float delta = 0.0;
float power_out = 0.0;
float COP = 0.00;
unsigned char flowsensor = 2; // pin 2 in, pwm
unsigned long currentTime;
unsigned long cloopTime;
unsigned long Lminute;


void flow () // Interrupt function
{
   flow_frequency++;
}
void draw(void){
  u8g.setFont(u8g_font_5x8);     //probe fonturi
  u8g.drawStr(30, 20, "Font 5x8");
  u8g.setFont(u8g_font_unifont);
  u8g.drawStr(30, 40, "unifont8");
  u8g.setFont(u8g_font_9x15);
  u8g.drawStr(30, 55, "font9x15");

}

void setup(void) {
  u8g.setFont(u8g_font_5x8);  
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
   pinMode(flowsensor, INPUT);
   currentTime = millis();
   cloopTime = currentTime;
}
void loop (){
  volt = analogRead(A3); //read voltage in DC
  amp = analogRead(A2); //read amps
  temp1 = analogRead(A0); //read temp T1
  temp2 = analogRead(A1); //read temp T2
  voltf = (volt * 5.110) / 1023.0;
  ampf = (amp * 5.110) / 1023.0;
  temp1f = (temp1 * 5.12) / 1023.0*100;
  temp2f = (temp2 * 5.12) / 1023.0*100;
  power_in = (voltf * ampf)*100;
  delta = (temp2 - temp1);
  power_out = (500 * delta * 1.16*0.001)/2;  // acel 500 e debitul pompei L/h
  COP = (power_out / power_in)*1000;  // Putere afisata in kw
  currentTime = millis();
  if(currentTime >= (cloopTime + 1000))
   {
    cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      Lminute = (flow_frequency / 10.3)*100;
  currentTime = millis();
  u8g.firstPage();
  do{
    draw();
  }while(u8g.nextPage() );
  
  }
 }

 

Link to comment

Hai ca l-am biruit..doar n-o fi nava extraterestra :rade:

#include "U8glib.h"
U8GLIB_ST7920_128X64_1X u8g(13, 11, 10); 

volatile float flow_frequency;
int volt = 0.0; //read voltage
int amp = 0.0; //read amps to pin 2
int temp1 = 0.0; // read adc to pin 0
int temp2 = 0.0; //read adc to pin 1
float ampf = 0.0;
float voltf = 0.0;
float temp1f = 0.0; // read adc to pin 0
float temp2f = 0.0; //read adc to pin 1
float delta = 0.0;  //(temp2f-temp1f)
int power_in = 0.0;
int power_out = 0.0;
float COP = 0.00;
unsigned char flowsensor = 2; // pin 2 in, pwm
unsigned long currentTime;
unsigned long cloopTime;
unsigned long Lminute;

void draw(void) {
                 // graphic commands to redraw the complete screen should be placed here  
                //astea raman afisate
//u8g.setFont(u8g_font_5x8);//setare font
  u8g.setFont(u8g_font_6x10); 
  u8g.drawStr( 00, 7, "*Heat Pump Monitoring*");
  u8g.drawStr( 00, 16, "Kw in   :"); 
  u8g.drawStr( 00, 25, "Kw out  :");
  u8g.drawStr( 00, 34, "COP     :");
  u8g.drawStr( 00, 43, "Temp in :");
  u8g.drawStr( 00, 52, "Temp out:");
  u8g.drawStr( 00, 61, "L/h     :");
}
void flow () // Interrupt function
{
   flow_frequency++;
}

void setup(void) {
   pinMode(flowsensor, INPUT);
   digitalWrite(flowsensor, HIGH); // Optional Internal Pull-Up
   attachInterrupt(digitalPinToInterrupt(flowsensor), flow, RISING); // Setup Interrupt
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{  //de aici incep citire valori
    currentTime = millis();
  if(currentTime >= (cloopTime + 1000))
   {
    cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      Lminute = (flow_frequency / 10.3)*100;  //10.3...in functie de durata rularii programului
  currentTime = millis();
  volt = analogRead(A3);     //read voltage in DC
  amp = analogRead(A2);      //read amps
  temp1 = analogRead(A0);    //read temp T1
  temp2 = analogRead(A1);    //read temp T2
  voltf = (volt * 5.112) / 1023.0; // 5.12 tensiunea reala la pinul Vref
  ampf = (amp * 5.112) / 1023.0;
  temp1f = (temp1 * 5.12) / 1023.0;  
  temp2f = (temp2 * 5.12) / 1023.0;
  power_in = (voltf * ampf);
  delta = (temp2 - temp1);
  power_out = (delta * 1.16);  // formula completa este L/h x delta x 1.16
  COP = (power_out / power_in);  // Putere afisata in kw
  

 u8g.firstPage();
  do{
    draw(); //de aici incepe afisarea valorilor setate
   u8g.setPrintPos(58, 16);  u8g.print(power_in);
   u8g.setPrintPos(58, 25);  u8g.print(power_out);
   u8g.setPrintPos(58, 34);  u8g.print(COP);
   u8g.setPrintPos(58, 43);  u8g.print(temp1f);
   u8g.setPrintPos(58, 52);  u8g.print(temp2f);
   u8g.setPrintPos(58, 61);  u8g.print(Lminute);
  }while(u8g.nextPage() );
  
  }
}

 

https://postimg.cc/fkDyLDYX

Edited by Cortex
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines