Author Topic: Water cooling thermometer  (Read 17281 times)

0 Members and 1 Guest are viewing this topic.

Offline Eucyblues

  • Posts: 774
Re: Water cooling thermometer
« Reply #40 on: December 27, 2016, 06:31:03 PM »
Not sure what you mean by synchronised bluc- your write routines are sequential so lcd writes will precede lcd2 writes, and the delay function can't fix that - the processor is busy writing to lcd it can't simultaneously write to lcd2 - or am I missing your meaning ??

If my understanding of your query is correct, you could get a quasi-sync by alternating writing lines to each screen, that way at the end of each write you'll only be marginally out of sync (depending on how many lines are on each)   
« Last Edit: December 28, 2016, 02:19:36 AM by Eucyblues »

Offline bluc

  • Posts: 208
Re: Water cooling thermometer
« Reply #41 on: December 28, 2016, 09:18:50 AM »
Yep you nailed it. Ok so cant have them run at same time will try doing as you say and merge the two even more line by line. Cheers. Really not that bad as is anyway might just let it be..

Offline bluc

  • Posts: 208
Re: Water cooling thermometer
« Reply #42 on: December 29, 2016, 08:06:25 AM »
Just thought i would add anyone wanting to run my dual screen script you will need to change the address of one of the lcds backpack. There is 6 solder pad i solder bridged the first 4 going left to right. I have two rows of three pads. Gave me an adress 0x24 from memory you mileage may vary doesn't really matter what you change the adress to just as long as you change the adress in the sketch to match.

Offline bluc

  • Posts: 208
Re: Water cooling thermometer
« Reply #43 on: January 03, 2017, 04:44:01 AM »

If my understanding of your query is correct, you could get a quasi-sync by alternating writing lines to each screen, that way at the end of each write you'll only be marginally out of sync (depending on how many lines are on each)
I did this and it works great but one screen clears before the other how can I clear both at same time.

Code: [Select]
#include <Flash.h>
#include <OneWire.h>
#include <DallasTemperature.h>//
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); //thermometer screen
LiquidCrystal_I2C lcd2(0x24,20,4); //parrot screen
#include <EEPROMex.h>
#include <EEPROMVar.h>
#include <Button.h>
float VapourTemperatureOne ;
float VapourTemperatureTwo ;
float VapourTemperatureThree ;
#define ONE_WIRE_BUS 10                     //pin for eparrot dallas sensor
#define ONE_WIRE_BUS_CondenserIn 2
#define ONE_WIRE_BUS_CondenserOut 3
#define ONE_WIRE_BUS_ReCooled 1
//#define RelayPin 12                         //pin for relay output

Button button_up = Button(7, BUTTON_PULLUP_INTERNAL, true, 50);    //pin and variable for button up
Button button_down = Button(6, BUTTON_PULLUP_INTERNAL, true, 50);  //pin and variable for button down
Button button_set = Button(5, BUTTON_PULLUP_INTERNAL, true, 50);   //pin and variable for button set
Button button_esc = Button(4, BUTTON_PULLUP_INTERNAL, true, 50);   //pin and variable for button esc
OneWire oneWire(ONE_WIRE_BUS);              //for dallas sensor
DallasTemperature dallas_sensor(&oneWire);  //for dallas sensor
DeviceAddress insideThermometer;            //for dallas sensor

 char lcd_buffer[20];                        //LCD buffer used for the better string format to LCD

float Setpoint;                             //Setpoint variable
int mys=0;                                  //Potentiometer ADC variable   
float temperature_float;                    //temperature variable
float ABV_float;                            //%ABV variable
int temperature_int_x10;                    //temperature variable
int ABV_int_x10;                            //%ABV variable

boolean button_up_continuous;                //for buttons algorithm
boolean button_down_continuous;              //for buttons algorithm
int continius_delay;                         //for buttons algorithm
int min_continius_delay = 5;                 //for buttons algorithm
int max_continius_delay = 100;               //for buttons algorithm

int setpoint_eeprom_address = 0;            //EEPROM address for setpoint value storing

int buzzer=8;

#define conversionTable_size 220            //count of conversionTable elements

FLASH_TABLE(int, conversionTable_int_x10, 2,
//const int conversionTable_int_x10[conversionTable_size][2] =     //temperature to %ABV table, I use int_x10 type because for the float type calculations arduino uno has no enough memory
//{
 
  {781, 955},
  {782, 920},
  {783, 902},
  {784, 890},
  {785, 885},
  {786, 880},
  {787, 875},
  {788, 871},
  {789, 867},
  {790, 864},
  {791, 859},
  {792, 854},
  {793, 851},
  {794, 848},
  {795, 846},
  {796, 843},
  {797, 841},
  {798, 838},
  {799, 836},
  {800, 834},
  {801, 832},
  {802, 830},
  {803, 827},
  {804, 824},
  {805, 822},
  {806, 819},
  {807, 816},
  {808, 814},
  {809, 812},
  {810, 808},
  {811, 804},
  {812, 803},
  {813, 801},
  {814, 799},
  {815, 798},
  {816, 796},
  {817, 795},
  {818, 793},
  {819, 791},
  {820, 790},
  {821, 788},
  {822, 787},
  {823, 785},
  {824, 783},
  {825, 782},
  {826, 780},
  {827, 779},
  {828, 777},
  {829, 775},
  {830, 774},
  {831, 772},
  {832, 770},
  {833, 769},
  {834, 767},
  {835, 765},
  {836, 764},
  {837, 762},
  {838, 760},
  {839, 759},
  {840, 757},
  {841, 755},
  {842, 754},
  {843, 752},
  {844, 750},
  {845, 748},
  {846, 747},
  {847, 745},
  {848, 743},
  {849, 741},
  {850, 739},
  {851, 737},
  {852, 736},
  {853, 734},
  {854, 732},
  {855, 730},
  {856, 728},
  {857, 727},
  {858, 725},
  {859, 723},
  {860, 721},
  {861, 719},
  {862, 717},
  {863, 715},
  {864, 713},
  {865, 711},
  {866, 709},
  {867, 707},
  {868, 705},
  {869, 703},
  {870, 701},
  {871, 698},
  {872, 696},
  {873, 694},
  {874, 692},
  {875, 690},
  {876, 688},
  {877, 685},
  {878, 683},
  {879, 681},
  {880, 679},
  {881, 676},
  {882, 674},
  {883, 671},
  {884, 669},
  {885, 667},
  {886, 664},
  {887, 661},
  {888, 657},
  {889, 654},
  {890, 650},
  {891, 645},
  {892, 640},
  {893, 637},
  {894, 634},
  {895, 630},
  {896, 627},
  {897, 624},
  {898, 621},
  {899, 617},
  {900, 614},
  {901, 609},
  {902, 604},
  {903, 597},
  {904, 591},
  {905, 588},
  {906, 584},
  {907, 581},
  {908, 577},
  {909, 574},
  {910, 570},
  {911, 567},
  {912, 563},
  {913, 560},
  {914, 556},
  {915, 552},
  {916, 548},
  {917, 545},
  {918, 541},
  {919, 537},
  {920, 533},
  {921, 529},
  {922, 525},
  {923, 521},
  {924, 517},
  {925, 513},
  {926, 509},
  {927, 505},
  {928, 500},
  {929, 496},
  {930, 492},
  {931, 487},
  {932, 483},
  {933, 477},
  {934, 472},
  {935, 468},
  {936, 463},
  {937, 458},
  {938, 454},
  {939, 449},
  {940, 444},
  {941, 439},
  {942, 434},
  {943, 429},
  {944, 424},
  {945, 418},
  {946, 413},
  {947, 408},
  {948, 402},
  {949, 397},
  {950, 391},
  {951, 385},
  {952, 380},
  {953, 374},
  {954, 368},
  {955, 362},
  {956, 356},
  {957, 350},
  {958, 343},
  {959, 337},
  {960, 330},
  {961, 324},
  {962, 317},
  {963, 310},
  {964, 303},
  {965, 300},
  {966, 298},
  {967, 295},
  {968, 288},
  {969, 280},
  {970, 273},
  {971, 265},
  {972, 257},
  {973, 249},
  {974, 240},
  {975, 232},
  {976, 223},
  {977, 215},
  {978, 206},
  {979, 198},
  {980, 190},
  {981, 182},
  {982, 174},
  {983, 166},
  {984, 158},
  {985, 150},
  {986, 140},
  {987, 130},
  {988, 120},
  {989, 110},
  {990, 100},
  {991, 90},
  {992, 80},
  {993, 70},
  {994, 60},
  {995, 50},
  {996, 40},
  {997, 30},
  {998, 20},
  {999, 10},
  {100, 0}
);

//actions for the button up
void onPress_button_up(Button& b){
  Setpoint = Setpoint + 0.1; if (Setpoint > 100) Setpoint = 100;
}
void onRelease_button_up(Button& b){
  button_up_continuous = LOW;
  continius_delay = max_continius_delay;
}
void onHold_button_up(Button& b){
  button_up_continuous = HIGH;
  continius_delay = max_continius_delay;
}
//actions for the button down
void onPress_button_down(Button& b){
  if (Setpoint > 0) Setpoint = Setpoint - 0.1; if (Setpoint <0) Setpoint = 0;
}
void onRelease_button_down(Button& b){
  button_down_continuous = LOW;
  continius_delay = max_continius_delay;
}
void onHold_button_down(Button& b){
  button_down_continuous = HIGH;
  continius_delay = max_continius_delay;
}
//actions for the button set
void onPress_button_set(Button& b){
  EEPROM.writeFloat(setpoint_eeprom_address,Setpoint);
}
//actions for the buttons up and down
void up_down_button_continious_action(){
   if (button_up_continuous == HIGH) {
    delay(continius_delay);
    if (continius_delay > min_continius_delay) continius_delay = continius_delay - 5;
    Setpoint = Setpoint + 0.1; if (Setpoint > 100) Setpoint = 100;
  } 
  if (button_down_continuous == HIGH) {
    delay(continius_delay);
    if (continius_delay > min_continius_delay) continius_delay = continius_delay - 5;
    if (Setpoint > 0) Setpoint = Setpoint - 0.1; if (Setpoint <0) Setpoint = 0; 
  }
}
// Setup Three oneWire instances to communicate with the Dallas sensors
OneWire oneWireCondenserIn(ONE_WIRE_BUS_CondenserIn), oneWireCondenserOut(ONE_WIRE_BUS_CondenserOut), oneWireReCooled(ONE_WIRE_BUS_ReCooled);


//DallasTemperature sensors(&oneWire);
DallasTemperature SensorCondenserIn(&oneWireCondenserIn), SensorCondenserOut(&oneWireCondenserOut), SensorReCooled(&oneWireReCooled);
//initilize screen and sensors
void setup(void)
{
 
  lcd.begin();
  lcd.backlight();
  lcd2.begin();
  lcd2.backlight();
  SensorCondenserIn.begin();
  SensorCondenserOut.begin();
  SensorReCooled.begin();
  delay (500);
  lcd.setCursor(2,1); //intro
  lcd2.setCursor(0,1);   //intro 
  lcd.print(F("Cooling Temp by"));//intro
  lcd2.print(F("The eParrot v1.0 by")); //intro   
  lcd.setCursor(0,3);                       //intro
  lcd2.setCursor(0,3);                       //intro
  lcd.print(F("bluc & Vissionstills"));            //intro 
  lcd2.print(F("    VISIONSTILLS"));            //intro
  delay(4500);                              //intro
  lcd2.clear(),lcd.clear();
                                //intro

  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Pins Initialization ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  //pinMode(RelayPin, OUTPUT);                //RelayPin as output
  //digitalWrite(RelayPin,LOW);               //write LOW to the RelayPin
  //pinMode(Tone,OUTPUT);
 
 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Read Setpoint from the EEPROM ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  Setpoint = EEPROM.readFloat(setpoint_eeprom_address);                //read setpoint from EEPROM
  if (isnan(Setpoint)) EEPROM.writeFloat(setpoint_eeprom_address, 0);  //if the value in this EEPROM address was empty then set this value 0, this need for a first starting of the board
 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Buttons Initialization ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  button_up.pressHandler(onPress_button_up);          //define the action functions for the buttons
  button_up.releaseHandler(onRelease_button_up);      //define the action functions for the buttons
  button_up.holdHandler(onHold_button_up, 500);       //define the action functions for the buttons 
 
  button_down.pressHandler(onPress_button_down);      //define the action functions for the buttons
  button_down.releaseHandler(onRelease_button_down);  //define the action functions for the buttons
  button_down.holdHandler(onHold_button_down, 500);   //define the action functions for the buttons
 
  button_set.pressHandler(onPress_button_set);        //define the action functions for the buttons
 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dallas Sensor Initialization +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  dallas_sensor.begin();                                //dallas sensor initialization
  //dallas_sensor.getAddress(insideThermometer, 0);       //dallas sensor initialization
  //dallas_sensor.setResolution(insideThermometer, 12);   //dallas sensor initialization
 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Intro Indication +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  lcd2.setCursor(0,1);                       //intro
  lcd2.print(F("The eParrot v1.0 by"));         //intro 
  lcd2.setCursor(0,3);                       //intro
  lcd2.print(F("    VISIONSTILLS"));            //intro 
  delay(2000);                              //intro
  lcd2.clear();                              //intro

}
 


void loop(void)
{
 
  VapourTemperatureOne = (SensorCondenserIn.getTempCByIndex(0));
  VapourTemperatureTwo = (SensorCondenserOut.getTempCByIndex(0));
  VapourTemperatureThree = (SensorReCooled.getTempCByIndex(0));
  SensorCondenserIn.requestTemperatures();
  lcd.setCursor(13, 0);
  lcd.print(SensorCondenserIn.getTempCByIndex(0));
   if (VapourTemperatureOne == -127)
{
  lcd.setCursor(0, 0);
 lcd.print("Sensor Fault");
}
else
{
  lcd.setCursor(0, 0);
  lcd.print("Conden In  c ");
}
 
  SensorCondenserOut.requestTemperatures();
  lcd.setCursor(13, 1);
  lcd.print(SensorCondenserOut.getTempCByIndex(0));
  if (VapourTemperatureTwo == -127)
{
  lcd.setCursor(0, 1);
 lcd.print("Sensor Fault");
}
else
{
  lcd.setCursor(0, 1  );
  lcd.print("Conden Out c ");
}
 
  SensorReCooled.requestTemperatures();
  lcd.setCursor(13, 2);
  lcd.print(SensorReCooled.getTempCByIndex(0));
 if (VapourTemperatureThree == -127)
{
  lcd.setCursor(0, 2);
 lcd.print("Sensor Fault");
}
 else
{
  lcd.setCursor(0,2);
  lcd.print("Re Cooled  c ");
  delay(1000);
}
 
  lcd.setCursor(3, 3);
  lcd.print("Cooling Temp ");
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Temperature Measurement +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  dallas_sensor.setWaitForConversion(false);  //for fast dallas reading
  dallas_sensor.requestTemperatures();        //reading temperature from dallas sensor
  dallas_sensor.setWaitForConversion(true);   //for fast dallas reading
  temperature_float = dallas_sensor.getTempCByIndex(0)*10;     //rounding temperature to 0.1 celsius resolution
  temperature_float = (float)round(temperature_float)/10;      //rounding temperature to 0.1 celsius resolution
 
  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %ABV Finding ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  temperature_int_x10 = temperature_float*10;                                                                //convert temperature float to int_x10 
  ABV_int_x10 = 0;                                                                                           //if array do not contains the measured temperature then %ABV will be indicate as "0"
  for (int i=0; i < 220; i++){                                                                               //find %ABV for the measured temperature
    if (conversionTable_int_x10[i][0] == temperature_int_x10) ABV_int_x10 = conversionTable_int_x10[i][1];   //find %ABV for the measured temperature
  }                                                                                                          //find %ABV for the measured temperature                                                                     
  ABV_float = ((float)ABV_int_x10)/((float)10);                                                              //convert %ABV int_x10 to float

  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Buttons Processing ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  button_up.process();                  //buttons processing
  button_down.process();                //buttons processing
  button_set.process();                 //buttons processing
  up_down_button_continious_action();   //buttons processing

  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Alarm Action ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//  if(temperature_float < Setpoint) digitalWrite(RelayPin,LOW);      //alarm
//  if(temperature_float >= Setpoint) digitalWrite(RelayPin,HIGH);    //alarm
 
  if(temperature_float < Setpoint) noTone(8); // buzzer on pin 8
  if(temperature_float >= Setpoint) tone(8, 4040, 200);//make a sound on buzzer  440, 200

    delay(30);//delay 1ms
    noTone(8);
    delay(25);//delay 1ms

  //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Indication ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  lcd2.setCursor(0,0);                                                                         //set cursor
  dtostrf(ABV_float, 1, 1, lcd_buffer);                                                       //float to string formatting
  lcd2.print(lcd_buffer); lcd.print("  ");                                                     //print ABV
 
  lcd2.setCursor(7,0);                                                                         //set cursor
  dtostrf(temperature_float, 1, 1, lcd_buffer);                                               //float to string formatting
  lcd2.print(lcd_buffer); lcd2.print("  ");                                                     //print temperature
 
  lcd2.setCursor(15,0);                                                                        //set cursor
  dtostrf(Setpoint, 1, 1, lcd_buffer);                                                        //float to string formatting
  lcd2.print(lcd_buffer); lcd2.print("  ");                                                     //print setpoint
  lcd2.setCursor(19,0);lcd2.print("c");                                                       //print "C"
 
  lcd2.setCursor(0,1);                                                                         //LCD indication
  lcd2.print(F("% ABV"));                                                                         //LCD indication
  lcd2.print(F("  VAPOR"));                                                                       //LCD indication
  lcd2.print(F("   ALARM"));                                                                      //LCD indication
  lcd2.setCursor(0,3);                                                                         //LCD indication
  lcd2.print(F("VISIONSTILLS eParrot"));                                                          //LCD indication

}

Offline Eucyblues

  • Posts: 774
Re: Water cooling thermometer
« Reply #44 on: January 03, 2017, 06:00:34 AM »
Hi bluc

Afraid you can't - each screen is independently addressed and written to so every operation is sequential -

If you really want to you could do the same thing as the 'quasi-sync' by writing blank lines alternatively to each screen

Do it like this for a 20x4 screen

Code: [Select]

void clr2scrns(){
  char blank[21] ="                    "; //20 blanks+1 for the terminator
for (int i = 0; i=3; i++){
lcd.setCursor(0,i);
lcd.print (blank);
lcd2.setCursor(0,i);
lcd2.print (blank);
}
}

Then just call clr2scrns();


« Last Edit: January 03, 2017, 08:58:42 AM by Eucyblues »

Offline bluc

  • Posts: 208
Re: Water cooling thermometer
« Reply #45 on: January 03, 2017, 11:18:24 AM »
Hey eucy thanks for the post I tracked down the issue I had the eparrot intro duplicated so it was loading the same intro twice. With the eparrot after the intro there is a pause and then the parrot loads all at once how is that done? mine loads as you say sequentialy and it loads in drips and drabs.

Here is the latest file I also added a fourth sensor so I know what the ambient temp is.

Offline ShiFu

  • eParrot.org
  • Admin
  • Posts: 1984
Re: Water cooling thermometer
« Reply #46 on: January 03, 2017, 12:09:18 PM »
Hum, ambient temperature...  another good idea, Bluc.
Too often I forget to take that into account on my list of constantly changing variables.

Some day, when I grow up, would like to try data logging. I view that as 'note taking' on steroids. 
In all honesty, if information is in a spreadsheet on the computer it has a fighting chance of being useful.
After that would be hand written notes (but few survive the weekly or monthly desk de-cluttering / garbage dump).
A FAR distant last place is believing that I'll recall, from memory, any technical details from anything ever. 

You have certainly made your dual display idea a reality, kudos! 
Stay calm and follow the screaming people.

Offline Eucyblues

  • Posts: 774
Re: Water cooling thermometer
« Reply #47 on: January 03, 2017, 01:02:37 PM »
With the eparrot after the intro there is a pause and then the parrot loads all at once how is that done? mine loads as you say sequentialy and it loads in drips and drabs.


Which eparrot code are you referring to??

Offline bluc

  • Posts: 208
Re: Water cooling thermometer
« Reply #48 on: January 03, 2017, 02:57:37 PM »
Sorry shifus simple parrot i merged it with my thermometer sketch..

Offline Eucyblues

  • Posts: 774
Re: Water cooling thermometer
« Reply #49 on: January 03, 2017, 04:14:10 PM »
bluc - I've had a quick look - it's a bit hard to see what issues you may have without actually seeing it running but you probably need to do some tidying on your code -

Suggestion 1 - You have 2 into print routines (lines 333 to 338 and 371 to 376) both of which have delays and both of which are different. (check spelling in line 336) These are separated by lines of definitions.  Move the print routines together after present line 370 and delete the delay now in line 337 and remove line 338 lcd.clear unless you want the first screen to clear before writing to the second.

Screen 1 will still display the intro while Screen 2 is being written - put in whatever delay you need in the second print routine (current line 375) - (2 secs seems a bit short?)

Then when screen 2 writing is done you can clear both screens at once - either with the code i sent or just using 2 lines of lcd.clear/lcd2.clear.

You just need to crawl through the logic flow of the program and maybe tighten it like the above where possible

Merging programs is always more difficult than it seems in this regard

Cheers
Eb