Go Down

### Topic: Four way valve servo motor control (Read 8417 times)previous topic - next topic

#### alvydas001

#15
##### Jan 17, 2014, 12:13 pm
My valve works in a heating system, as in this diagram:

#### wildbill

#16
##### Jan 17, 2014, 01:08 pm
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?

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.

I like the PID and virtual valve position idea, but if you don't really know where the valve is, maybe simpler is best.

#### alvydas001

#17
##### Jan 17, 2014, 01:34 pm

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.

#### wildbill

#18
##### Jan 17, 2014, 01:54 pm
Quote
by this algorithm output temperature varies from 33-34 degrees to 46-47 degrees, if the setpoint - 40.

Do you think that's because the algorithm is too basic, or could it be that the inaccuracy of the servo movement is hurting you?

I'd be interested to measure the input temperatures too - presumably, there's a need to compensate for variation there too. PID does seem to be your answer, I just can't see how to do it well unless you know where the valve is.

Could you perhaps, as suggested, keep track of where you think you are and periodically, reset the valve to a known position? i.e. move to fully open or fully closed whichever is closest and then back to your desired position.

#### Robin2

#19
##### Jan 17, 2014, 04:10 pm

by this algorithm output temperature varies from 33-34 degrees to 46-47 degrees, if the setpoint - 40.

If you had said this earlier it would have saved me wasting a lot of time (this is NOT an english language problem).

Are you allowing sufficient time for the temperature to stabilize before measuring it?

I think you said earlier that the position of the valve does not guarantee a particular temperature. I think you need to investigate why this is the case. Maybe you also need to sense the input temperatures? Is it possible that moving the valve to increase the temperature sometimes causes the boiler to start up and increase the incoming temperature?

You might consider an algorithm which moves the valve only a few degrees (much less than what you think is needed to correct the temperature) and check the resulting temperature after each of these small movements before deciding if more movement is needed.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

#### Hasseklas

#20
##### Jan 17, 2014, 05:40 pm
The thing is that if you are trying to control the heating of a house your sensors are not really measuring what you need. The interesting parameter is the heat load put out by tye radiators needed to keep the temperature fixed in the house. Therefore for theboverall control the indoor and outdoor temperature gives a better performance. If it is cold outside the temperature fed to the radiators need to be higher to keep the room temperature fixed. The heat load will also be proportional to the temperature difference between the forward and return lines to the radiators so you could measure it there. This measurement is not what you take since you take the temperature of the return from the valve to the storage tank. The flow in this line will not be the same since it will depend on the valve position. If you would measure all four lines from the valve the flow ratio qradiator/qboiler would equal deltaTboiler/deltaTradiator. This is since the heat load passing "through" the valve is equal to qboiler*deltaTboiler*cp and also to qradiator*deltaTradiator*cp and cp differences here can be neglected.

Another thing: Are you measuring the temperature on the outside of the pipes? If so I am not surprised by the 15 s  delay.

#### zoomkat

#21
##### Jan 17, 2014, 06:50 pm
Have you checked the torque to turn the below valve? If you know the valve will operate as intended to control the liquid temperature, then you need to decide on how to mechanically operate it. Bottom are some projects that turn wiper motors into large servos.

http://www.komfort-eco.ru/files/catalog/rubs/imgs/133/duomix_ao.jpg

http://www.youtube.com/results?search_query=servo%20wiper&sm=1
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

#### Robin2

#22
##### Jan 17, 2014, 08:15 pm
Perhaps the answer is to replace the valve with a thermostatic mixer valve. Turn it by hand to the desired temperature and just leave it alone.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

#### alvydas001

#23
##### Jan 21, 2014, 11:02 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: [Select]
`/* ******************************************************************************* */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);       }    }     }`

Go Up