Go Down

Topic: Programing help with temperature  (Read 760 times) previous topic - next topic

tobielepine

Hi all

I have an arduino uno with network shield, a twin relay board, an ultrasonic level sensor and a BMP180.

The whole thing works perfect. It controls a fairly complex machine that sucks out maple sap out of maples under vacuum. 

Maples sugar !

Anyways, temperature is the game with maples.

With the bmp180 i can read and control a relay based on temperature.

Right now, i only make it run between -5C -20C.

That works fine.

My issue becomes the introduction of this new issue.

I want the machine to RUN until FALLING temperature reach -5C.

But i dont want it to restart until RISING temperature reaches 1C.

I have been using

If ((T)  > -5) {then do this}

It works but makes no distinction between falling and rising temperature.

Any clue on where to start?

Thanks

T

Btw the machine is at

Http://macabanasuc.ddns.net:81



tobielepine

The only thing i could find is something like this.


I'll calculate average "1 hours" value, summing up 12 digit and divide a sum by 12.  S(i) = ( T1 + T2 +....+T12 ) / 12.
Than trend is a differential of two S,  current and previous:
 if ( S(i-1) > S(i) ) trend = "Down";
 if ( S(i-1) < S(i) ) trend = "Up";
 if ( S(i-1) == S(i) ) trend = "Steady";

But i cannot put it in the  perspective ofvariables ...

Im unexperimented and learning

T

Paul_KD7HB

Well, first you need to determine how fast the temperature can change 1 degree C. That tells you how often you need to check the temperature value. Then each time period, compare the new temperature to the previous temperature. If old temp < new temp, then temp is going up. If old temp > new temp, then temp, then temp is going down. After comparing, move new temp value to old temp value.

Paul

tobielepine

So basically create a

Int trend.

If ((trend = rising) &&
((T) > 1))
{Start the machine}

If ((trend = falling)&&
(Machine is on)&&
((T) < -5))
{Shut down the machine}

I just cannot comprehend how to create the falling and rising variables in a way to program the arduino.

Any help with this basics?

T

oswe

 Put your sketch or part of it.so we can help u.

How are you measuring T ?
Make an array where you store some values. Apply required delay between each T measure.
Calculate the slope of T.
 To implement you can use the idea for blink without delay ...a state machine

cattledog

Quote
I want the machine to RUN until FALLING temperature reach -5C.
But i don't want it to restart until RISING temperature reaches 1C.
Quote
I just cannot comprehend how to create the falling and rising variables in a way to program the arduino.
Instead of needing to define a rising or falling trend, I think you can just add hysteresis to the turn on and turn off with something like this.

Code: [Select]
if(T<= -5)
{turn machine off}

if(T>=1 && T<=18)
{turn machine on}

if(T>=20)
{turn machine off}


This code will run the machine if the temperature was greater than 1 but then varies up and down between 1 and -5 but doesn't actually reach -5.

If the temperature does reach -5, the machine will not be running if the temperature varies up and down between -5 and 1 but doesn't actually reach 1.

Is that what you want?




tauro0221

Hi,
I wrote small routine that will do what I thinking it is what you are looking for.  The only you need to do it is add the temperature variable  and see it is work. Again I do not know if this is what you are looking.


byte pinxx = 0;//turn on mchine pin output
int T ; //temperature variable
void setup() {
  // put your setup code here, to run once:
  pinMode(pinxx , OUTPUT); //nachine turn on pin
}

void loop() {
  // put your main code here, to run repeatedly:
  //instruction here to get the temperature T=xxxx
  if (T >= 1) {
    temp_falling(); //wait until temperature reach 1 degree +
  }
  delay(1000);
}
//***************************************************
void temp_falling() {
  digitalWrite(pinxx, HIGH); //turn the machine ON
  do {
    //loop here until temperature drop to -5
    //instruction to get the temperature T= xxxx
  } while (T < -4);
  digitalWrite(pinxx, LOW);  //turn the machine OFF
}
//****************************************************

TomGeorge

#7
Mar 18, 2017, 08:47 am Last Edit: Mar 18, 2017, 08:49 am by TomGeorge
Hi,

if  (Machine On and temp < -5)
{ turn Machine OFF}

if  (Machine OFF and temp > 1)
{ turn Machine ON}

Any simpler than that?
Takes care of trending.

Try it.

Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

tobielepine

here is the whole code.

it is too large to copy/paste so ive attached extracteurmaisonv4.ino



tobielepine

my relays have to be low to turn on my circuits.

Vacuum_relay_pin powers a relay that then sends 120v to another huge relay. the vacuum compressor runs on 240V

that's the output that needs a different shut-down temperature than start-up temp.


it needs to run until falling temps go under -5C

it needs to stay off until rising temp go over 1C

that's the part of code that deals with temperature, level sensors and relays.


Code: [Select]


char status;
  double T,P,p0,a;

  Serial.println(T);
  //check to see the state of the float switches.
  //empty
  if ((digitalRead(Startup_Pin) == HIGH) &&
      (digitalRead(Safety_Pin) == HIGH) &&
      ((T) < 20)
      )
  {
    digitalWrite(Pump_relay_Pin, HIGH); //Keep pump off
    digitalWrite(Vaccum_relay_Pin, LOW); //Start Vacuum
  
    Serial.println("empty, vaccum started");
    
    }
    
  //startup
  if ((digitalRead(Empty_Pin) == LOW) &&
      (digitalRead(Startup_Pin) == LOW) &&
      (digitalRead(Safety_Pin) == HIGH)
      )
  {
    digitalWrite(Pump_relay_Pin, LOW); //start pump
    digitalWrite(Vaccum_relay_Pin, LOW); //Keep vacuum running
    Serial.println("Pumping");
  }
  //safety shut-off

  if (digitalRead(Safety_Pin) == LOW)
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, LOW); //keep pump running for:
    Serial.println("ERREUR EXTRACTEUR!");
    delay(90000);
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    delay(500000000000000);
      
  }
// temperature shut off

if ((T) < -5)
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop frette!");
  
  }

  if ((T) > 20)
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop chaud!");
  
  }




tobielepine

would this work?

Code: [Select]



char status;
  double T,P,p0,a;

  Serial.println(T);
  //check to see the state of the float switches.
  //empty
  if ((digitalRead(Startup_Pin) == HIGH) &&
      (digitalRead(Safety_Pin) == HIGH) &&
      (digitalRead(Vaccum_relay_Pin) == HIGH) && //vaccum has to be off to start
      ((T) > 1)
      )
  {
    digitalWrite(Pump_relay_Pin, HIGH); //Keep pump off
    digitalWrite(Vaccum_relay_Pin, LOW); //Start Vacuum
  
    Serial.println("empty, vaccum started");
    
    }
    
  //startup
  if ((digitalRead(Empty_Pin) == LOW) &&
      (digitalRead(Startup_Pin) == LOW) &&
      (digitalRead(Safety_Pin) == HIGH)
      )
  {
    digitalWrite(Pump_relay_Pin, LOW); //start pump
    digitalWrite(Vaccum_relay_Pin, LOW); //Keep vacuum running
    Serial.println("Pumping");
  }
  //safety shut-off

  if (digitalRead(Safety_Pin) == LOW)
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, LOW); //keep pump running for:
    Serial.println("ERREUR EXTRACTEUR!");
    delay(90000);
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    delay(500000000000000);
      
  }
// temperature shut off

if (((T) < -5) &&
 (digitalRead(Vacuum_relay_Pin) == LOW))
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop frette!");
  
  }

  if (((T) > 20) &&
 (digitalRead(Vacuum_relay_Pin) == LOW))
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop chaud!");
  
  }





I have added

Code: [Select]


if ((digitalRead(Startup_Pin) == HIGH) &&
      (digitalRead(Safety_Pin) == HIGH) &&
      (digitalRead(Vaccum_relay_Pin) == HIGH) && //vaccum has to be off to start
      ((T) > 1)
      )
  {
    digitalWrite(Pump_relay_Pin, HIGH); //Keep pump off
    digitalWrite(Vaccum_relay_Pin, LOW); //Start Vacuum
  
    Serial.println("empty, vaccum started");
}



and

Code: [Select]


// temperature shut off

if (((T) < -5) &&
 (digitalRead(Vacuum_relay_Pin) == LOW))
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop frette!");
  
  }

  if (((T) > 20) &&
 (digitalRead(Vacuum_relay_Pin) == LOW))//
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop chaud!");
  
  }



that solves it ? doesn't it ?


tobielepine

here is my latest version

I made a few changes ..


I run a pump in the setup section to make sure some float goes high so the loop works no matter what situation it was shut down under.



could you please help me check to make sure the vacuum will turn on at -1C and shut off at -5C or over 20C



T

PaulS

Code: [Select]
  double T,P,p0,a;

  Serial.println(T);

Create a local variable, but don't initialize it. Print its contents as though they meant something.

Why?

Code: [Select]
    delay(500000000000000);
Get f**king real.

Quote
could you please help me check to make sure the vacuum will turn on at -1C and shut off at -5C or over 20C
Of course it won't. Would you care to show which line(s) of code actually assign a value to T?
The art of getting good answers lies in asking good questions.

cattledog

Code: [Select]
status = pressure.getTemperature(T);

I assume this line reads the temperature. Then

Code: [Select]
// temperature variables

if (((T) < -5) &&
 (digitalRead(Vaccum_relay_Pin) == LOW)); // vaccum has to be on to shut off
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, LOW);
    delay(90000);
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop frette!");
   
  }

  if (((T) > 20) &&
 (digitalRead(Vaccum_relay_Pin) == LOW)); //vaccum has to be on to shut off
  {
    digitalWrite(Vaccum_relay_Pin, HIGH); //shut the vacuum off!
    digitalWrite(Pump_relay_Pin, HIGH); //shut off the pump
    Serial.println("toute a OFF Trop chaud!");
   
  }

     if (((T) > -1) &&
 (digitalRead(Vaccum_relay_Pin) == HIGH)); //vaccum has to be OFF to start
  {
    digitalWrite(Vaccum_relay_Pin, LOW); //turn on the vacuum
    Serial.println("vacuum parti");
   
  }


Where does the pump get turned back on when T>-1?

Why is there no delay time on the pump turn off at hight temp but there is at low?


tobielepine

#14
Mar 18, 2017, 07:38 pm Last Edit: Mar 18, 2017, 07:48 pm by tobielepine
The pump is tripped by liquid level

Not temperature


Seems to work


But still an issue with temperature

Delay (tons)
Is a safety shut down ...

I want to make sure the whole thing quits for a long time. The only way it will restart is with a manual reset.

If the liquid level goes past that safety point, i wreck a vacuum pump.

Liquid will freeze unless i make the pump pump it out before it shuts down. No need for that on a high temp shutdown.



T


Go Up