Pages: [1]   Go Down
Author Topic: Four way valve control  (Read 1922 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to make the management of heating systems Four way valve with Arduino. Valve as this- http://www.komfort-eco.ru/files/catalog/rubs/imgs/133/duomix_ao.jpg.  I want to maintain a constant temperature in the valve output. The valve control motor unit has three wires-forward, rewind and GND. Maybe you have an algorithm for such management. Maybe you have an example, and you can share. I can not do it. Valve wanders back and forth ...
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2263
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The picture shows a manually controlled mixer. It might be simpler to replace it with a pair of solenoid valves.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

valve with a servo drive, as in this picture:
http://www.komfort-eco.ru/files/catalog/rubs/imgs/37/kat10_003.jpg
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I just finished a very similar project with an UNO.
The sketch measures internal temperature, external temperature and water temperature, makes up a water temperature value based on these, then moves the valve. here is the sketch, feel free to reuse if you like it.

* 4way_valve.ino (8.92 KB - downloaded 52 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I'll try and let you know the results  smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Such a task should use the PID algorithm. I'll try to combine the  following code
Code:
#include <PID_v1.h>
void loop()
{
Input = analogRead(0);
myPID.Compute();

/************************************************
* turn the output pin on/off based on pid output
************************************************/
if(millis() - windowStartTime>WindowSize)
{ //time to shift the Relay Window
windowStartTime += WindowSize;
}
if(Output==0)

{ //PID thinks we shouldn't activate either relay. Do nothing
digitalWrite(Relay_Valve_close, HIGH);
digitalWrite(Relay_Valve_open, HIGH);
}
else if(Output>0)

{ //Pid thinks we should be activating Relay_Valve_open
if(Output > millis() - windowStartTime) digitalWrite(Relay_Valve_open,LOW);

else digitalWrite(Relay_Valve_open,HIGH);
digitalWrite(Relay_Valve_close,HIGH);
}
else //PID thinks we should be activating Relay_Valve_close
{
if(-Output > millis() - windowStartTime) digitalWrite(Relay_Valve_close,LOW);
else digitalWrite(Relay_Valve_close,HIGH);
digitalWrite(Relay_Valve_open,HIGH);
}

}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
emzeperx, alvydas001, I have two questions:

1. do you use NTC sensor and the value,
2. which is a scheme to connect key (button)?

Thank you
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1. I use ds18b20 sensors.
2. I use Dfrobot LCD Key pad and MenuBackend library.
this code works fine:
The valve is closing / is opening 6 seconds
Pause for 20 seconds
If the difference  input-setpoint is less than 2 degrees, closing time 4 seconds + difference
If the difference  input-setpoint is more than 10 degrees, timeout=0
Code:
/* ******************************************************************************* */
void Four_way_valve_control()
  {

/* ********* OPEN VALVE ***************** */
    if (Input_t <= SetPoint_t -1.5 && Valve_stop == true && Valve_closing == false && millis() > Valve_opening_time){
valve_error = SetPoint_t -1.5 -Input_t;
if (valve_error <= 2){ // if the difference is small
        Valve_stop = false; // valve moving
        Valve_opening = true;
        Valve_pause = millis() + 6000 - 2000 + (valve_error * 1000);
        digitalWrite(RelayPinClose, HIGH);
        digitalWrite(RelayPinOpen, LOW);
}else{
        Valve_stop = false;
        Valve_opening = true;
        Valve_pause = millis() + 6000;
        digitalWrite(RelayPinClose, HIGH);
        digitalWrite(RelayPinOpen, LOW);
 }
   }
   /* ********* P A U S E 20 second after each valve switching ***************** */

   if (Valve_stop == false && millis() > Valve_pause) {
   //If the difference is greater than 10 degrees,
if (Input_t > SetPoint_t + 10) { //there is no pause
      Valve_closing_time = millis();
      Valve_opening_time = millis();
      Valve_stop = true;
} else {
      Valve_pause = millis() + 20000;
      Valve_closing_time = Valve_pause;
      Valve_opening_time = Valve_pause;
      Valve_stop = true;
        digitalWrite(RelayPinClose, HIGH);
        digitalWrite(RelayPinOpen, HIGH);
}
   }
/* ********* CLOSE VALVE ***************** */

    if (Input_t >= SetPoint_t + 1.5 && Valve_stop == true && Valve_opening == false  && millis() > Valve_closing_time){
      valve_error = Input_t - SetPoint_t + 1.5;
      if (valve_error > 2){// if the difference is small
        Valve_stop = false;
        Valve_closing = true;
        Valve_pause = millis() + 6000 - 2000 + (valve_error * 1000);
      digitalWrite(RelayPinOpen, HIGH);
      digitalWrite(RelayPinClose, LOW);
      }else{
        Valve_stop = false;
        Valve_closing = true;
        Valve_pause = millis() + 6000;
      digitalWrite(RelayPinOpen, HIGH);
      digitalWrite(RelayPinClose, LOW);
      }
    }
   
  }
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

alvydas001, I would ask you if you can to post your code, so that we beginners can correctly understand and apply learned. Greetings  smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

of course, but all my comments Lithuanian language smiley-red.
P. S. I'm really not a very good programmer...
https://github.com/SauleVire/KKK_valdiklis_v2
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OOoooo big thank you, language is not a problem,
There is a always google translate  smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi Yovca,

I used tmp36gz for temperature sensing, and this schematic for buttons (2nd pic):
http://ygyfreezone.blogspot.hu/2013/10/arduino-starter-kit-chapter-07-and-08.html
all timings can be set with the predefined variables. easy to find the right one, just check the comments
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Thanks, emzeperx  smiley
Logged

Pages: [1]   Go Up
Jump to: