Show Posts
Pages: [1] 2 3
1  Topics / Home Automation and Networked Objects / Re: Four way valve control on: January 21, 2014, 02:02:47 pm
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
2  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 21, 2014, 05:02:40 am
This code works fine(last 3 days):
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);
      }
    }
   
  }
3  Topics / Home Automation and Networked Objects / Re: Four way valve control on: January 21, 2014, 04:58:33 am
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);
      }
    }
   
  }
4  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 17, 2014, 07:34:27 am
If multiple operations on the valve leave you unsure how it is positioned, perhaps a simpler algorithm than PID is called for. Is there a problem if you try to open the valve more when it's already fully open?
valve servo have end moving protection.
If not, at startup, close the valve, then open it half way. Wait for the temp to stabilize. Then, if it's too hot, close the valve a bit. If too cold, open it a bit. Wait and try again.

You'll need a dead zone around the setpoint so that you're not constantly tweaking the valve position. You may need some fixed delay after a change before you're satisfied that it has taken effect too.
by this algorithm output temperature varies from 33-34 degrees to 46-47 degrees, if the setpoint - 40.
5  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 17, 2014, 06:13:44 am
My valve works in a heating system, as in this diagram:
6  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 17, 2014, 02:08:44 am
Sorry, my English is really bad...
Does "Valve does not have a positioning mechanism" mean that the control servo has no mechanism to set the valve to an intermediate position?
The valve moves from the start to the end of 150 seconds. During that time, I can stop valve servo motor. This will be an intermediate position.
I have no idea what this means "What would the positioning opportunity?"
Knowledge of valve position  does not guarantee the right temperature.
This "The valve position will not provide an output temperature" seems to me to mean that you do not get an intermediate output temperature when the valve is at an intermediate position? If so. what do you get?
Do I know or do not know the position of the valve, still need to measure the temperature
Because of inertia, the correct temperature is measured with a time delay of up to 10-15 seconds.
I presume this means that you can stop the valve at any intermediate position "If the signal LOW to HIGH I change this valve will stop at an intermediate position." But the words I quoted in my previous paragraph imply that this is not useful.
Code:
// START closing the valve
      digitalWrite(Relay_Valve_close, LOW); // START closing the valve
      digitalWrite(Relay_Valve_open, HIGH); // STOP opening the valve
// start opening valve servo
      digitalWrite(Relay_Valve_close, HIGH); // STOP closing the valve
      digitalWrite(Relay_Valve_open, LOW); // START opening the valve
// SLEEPING valve servo
      digitalWrite(Relay_Valve_close, HIGH); // STOP closing the valve
      digitalWrite(Relay_Valve_open, HIGH); // STOP opening the valve
I don't understand why you say this "Valve position knowing nothing will not help". Is it because intermediate positions do not give intermediate temperatures?
Yes, temperature is independent of the position or the position of the valve is independent of temperature
I think you need to tell us in detail what the valve does if it is controlled by hand without any electronics.
7  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 16, 2014, 03:03:06 pm
Valve does not have a positioning mechanism. What would the positioning opportunity? The valve position will not provide an output temperature. If the signal LOW to HIGH I change this valve will stop at an intermediate position.
Valve position knowing nothing will not help. I'll try to adjust it according to the PID algorithm for measuring the output of the temperature.
8  Topics / Home Automation and Networked Objects / Re: Four way valve control on: January 16, 2014, 09:20:37 am
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);
}

}
9  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 16, 2014, 08:36:39 am
I'll try 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);
}

}
10  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 16, 2014, 04:03:28 am
"digitalWrite (Relay_Valve_close, LOW)" successfully closes the valve after 150 seconds. "digitalWrite (Relay_Valve_open, LOW)" - Opens after 150 seconds. In what position is the valve can be found in the calculation of the opening / closing times. But after 100 openings / closings it will be a big error.

The valve must operate at an intermediate position. Situation complicates finding the temperature change, changes very slowly.
11  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 16, 2014, 01:42:10 am
You are right. I began to study the PID algorithm ...
Valve documentation only Czech-http://www.ktr-adex.cz/komex/mk_cn.pdf
The actuator has a rear button. Closing takes 150 seconds .
Servo drives  closing without temperature measurement program is simple:
Code:
    if (Valve_stop == true && Valve_opening == false){
      Valve_stop = false; // the valve is already moving
      Valve_closing = true; // indicates that the valve is closing already
      digitalWrite(Relay_Valve_close, LOW); // signal to close the valve
The goal is: the valve at the input temperature varies from 30 to 95 degrees C. Output needed to maintain a constant temperature of 40 degrees C.
12  Using Arduino / Motors, Mechanics, and Power / Re: Four way valve servo motor control on: January 15, 2014, 07:31:59 am
This is my Skech and connection diagram
13  Topics / Home Automation and Networked Objects / Re: Four way valve control on: January 15, 2014, 07:15:53 am
Thanks, I'll try and let you know the results  smiley
14  Using Arduino / Motors, Mechanics, and Power / Four way valve servo motor control on: January 14, 2014, 03:09:58 pm
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, a servo drive, as in this picture:
http://www.komfort-eco.ru/files/catalog/rubs/imgs/37/kat10_003.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 ...
15  Using Arduino / Project Guidance / Re: Central heating controller on: January 14, 2014, 03:00:10 pm
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,  a servo drive, as in this picture:
http://www.komfort-eco.ru/files/catalog/rubs/imgs/37/kat10_003.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 ...
Pages: [1] 2 3