Regulating depending on incoming value

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
Someone asked me this:
When the level (analogue input) is above 10% then Valve Q4.0 must be open. Valve Q4.1 must be open when the level is less then 95%. Then he wanted in MD104 a setpoint depending on the level. So below 10% MD104 must be 0, between 10 and 80% MD104 must be 100, between 80 and 90% he wants 50 in MD104, between 90 and 95% he wants 30 in MD104 and between 95 and 100% he wanted 10 in MD104.

So I wrote this :::: (anyone who can simplify it in an other way or sow, just curieous how you guys would do it).



L MD 200 // Analoge ingang
ITD
DTR
L 2.764800e+004
/R
L 1.000000e+002
*R
T MD 100 // Gescaleerde waarde 0-100%

L 1.000000e+001
>R
= Q 4.0 // Aansturing klep 1
TAK
L 9.500000e+001
<R
= Q 4.1 // Aansturing klep 2
L MD 100
L 1.000000e+001
<R
JCN NO3
L 0.000000e+000
T MD 104
BE
NO3: L MD 100
L 1.000000e+001
>R
JCN NO4
L MD 100
L 8.000000e+001
<R
JCN NO4
L 1.000000e+002
T MD 104
BE
NO4: L MD 100
L 8.000000e+001
>R
JCN NO5
L MD 100
L 9.000000e+001
<R
JCN NO5
L 5.000000e+001
T MD 104
BE
NO5: L MD 100
L 9.000000e+001
>R
JCN NO6
L MD 100
L 9.500000e+001
<R
JCN NO6
L 3.000000e+001
T MD 104
BE
NO6: L MD 100
L 9.500000e+001
>R
JCN BE
L MD 100
L 1.000000e+002
<R
JCN BE
L 1.000000e+001
T MD 104
BE: BE
 
Here's a quick go I had at it, it's a bit shorter, whether it's easier to follow is a matter of opinion!

Code:
//Scale analog input
	 L	 MD 200					//Analog input raw
	 ITD 
	 DTR 
	 L	 2.764800e+002
	 /R	
	 T	 MD 100					//Analog input scaled 0-100%
 
//Valve 1 - Open when AI>10%
	 L	 MD 100
	 L	 1.000000e+001
	 >R	
	 =	 Q	 4.0
 
//Valve 2 - Open when AI<95%
	 L	 MD 100
	 L	 9.500000e+001
	 <R	
	 =	 Q	 4.1
 
//SP = 0 when AI<10% 
	 L	 MD 100
	 L	 1.000000e+001
	 <R	
	 JCN _001
	 L	 0.000000e+000
	 T	 MD 104
	 BE	
 
//SP = 100 when AI>=10%, AI<80% 
_001: L	 MD 100
	 L	 8.000000e+001
	 <R	
	 JCN _002
	 L	 1.000000e+002
	 T	 MD 104
	 BE	
 
//SP = 50 when AI>=80%, AI<90%
_002: L	 MD 100
	 L	 9.000000e+001
	 <R	
	 JCN _003
	 L	 5.000000e+001
	 T	 MD 104
	 BE	
 
//SP = 30 when AI>=90%, AI<95%
_003: L	 MD 100
	 L	 9.500000e+001
	 <R	
	 JCN _004
	 L	 3.000000e+001
	 T	 MD 104
	 BE	
 
//SP = 10 when AI>=95%
_004: L	 1.000000e+001
	 T	 MD 104


Kevin H
 
Last edited:
I would do it this way:


after scalling:


-----
L 0
T MD 104
L MD 100
L 10
<R
BEC
L 100
T MD 104
L MD 100
L 80
<R
BEC
L 50
T MD 104
L MD 100
L 90
<R
BEC
L 30
T MD 104
L MD 100
L 95
<R
BEC
L 10
T MD 104
BE
----------

28 lines vs 51 lines in your code


P.S. I guess comparing input <0 and >27648 is in another place
 
Is this a real application ? if so , you may wish to consider what happens when the value of the level is just on 10 and fluctuating - that poor old valve might chatter all over the place .

If this is a real application , you may wish to "debounce" the analogue input , "dead band" it to prevent this .
 
Hey dude

Hey dude, I agree with your code, but, it's easy to write it that short if u eliminate the outputs Q4.0 and 4.1 and the scaling...

I like krk his method
 
a quick effort

Code:
	 SET				// Pre Set Outputs
	 R	 Q	 4.0
	 S	 Q	 4.1
 
	 L	 MD 200	   // Analoge ingang
	 ITD 
	 DTR 
	 L	 2.764800e+004
	 /R	
	 L	 1.000000e+002
	 *R	
	 T	 MD 100		// Gescaleerde waarde 0-100%
 
	 RND				 // Convert to Integer
 
	 L	 10
	 <I				  // Less than 10, then = 0
	 JC	zero
 
	 >I				 // Greater than 10
	 =	 Q	 4.0	// Then set Q 4.0
 
	 TAK 
	 L	 80		   // >= 10 and < 80
	 <=I				// Then make = 100
	 JC	_100
 
	 TAK 
	 L	 90		   // >=80 and <90
	 <=I				// Then make = 50
	 JC	_50
 
	 TAK			   // >=90 and <95
	 L	 95		 // Then make = 30
	 <=I 
	 JC	_30
 
	 SET			   // >=95 so reset Q 4.1
	 R	 Q	 4.1
 
	 L	 1.000000e+001  // Then make = 10
	 JU	T_MD
zero: L	 0.000000e+000
	 JU	T_MD
_100: L	 1.000000e+002
	 JU	T_MD
_50: L	 5.000000e+001
	 JU	T_MD
_30: L	 3.000000e+001
	 JU	T_MD
_10: L	 1.000000e+001
T_MD: T	 MD 104
 
Last edited:
Combo,

it has nothing to do with scalling and q4.0, q4.1, i did not include it assuming that i'm agree with your way of scalling, so whole decision would be:

L MD 200 // Analoge ingang
ITD
DTR
L 2.764800e+004
/R
L 1.000000e+002
*R
T MD 100 // Gescaleerde waarde 0-100%
L 1.000000e+001
>R
= Q 4.0 // Aansturing klep 1
TAK
L 9.500000e+001
<R
= Q 4.1 // Aansturing klep 2L 0
T MD 104
L MD 100
L 10
<R
BEC
L 100
T MD 104
L MD 100
L 80
<R
BEC
L 50
T MD 104
L MD 100
L 90
<R
BEC
L 30
T MD 104
L MD 100
L 95
<R
BEC
L 10
T MD 104
BE


so 41 lines vs 66 lines in your code

so i'm not sure what you mean by "it's easy to write it that short if u eliminate the outputs Q4.0 and 4.1 and the scaling..."
 
gerivik

girevik

I used you're way of thinking, end the function when a compare is okay. It's also great code, even better.
 
and even 2 lines shorter ;) if to put q4.0/q4.1 into another place:

SET
S Q 4.1
L MD 200
ITD
DTR
L 2.764800e+002
/R
T MD 100
L 0 //missed in my previous post
T MD 104
L MD 100
L 1.000000e+001
<R
R Q 4.0
BEC
S Q 4.0
L 100
T MD 104
L MD 100
L 8.000000e+001
<R
BEC
L 50
T MD 104
L MD 100
L 9.000000e+001
<R
BEC
L 30
T MD 104
L MD 100
L 9.500000e+001
<R
BEC
R Q 4.1
L 10
T MD 104
BE
 
Instead of doing loads of comparisons, I would create a look-up table that specifies the setpoint level and convert the percentage into the index into the look up table.
 

Similar Topics

Hi, i have made a PLC programing for a CO2 cooling system, i just cant get the valves for the gas cooler to work right. first of im using...
Replies
9
Views
623
Hi, I'm no expert in PID regulating so I need some advise. I have a VFD controlled deepwaterpump that is maintaining the pressure in a closed...
Replies
24
Views
11,905
Hi, I am using the GX developer for a Q series CPU first time. We added a new temperature regulating module Q64TCRTN in expansion rack. In main...
Replies
1
Views
1,918
Hello, we are a group of students doing a school project, who stumbled upon a problem with regulation. We have to automatize the part of the...
Replies
19
Views
4,268
Hi.. I want to know something about Pressure Reducing valves & pressure regulating valves. I understand their purpose. But wanted to know whether...
Replies
4
Views
1,555
Back
Top Bottom