Regulating depending on incoming value

If the look-up table contained 20 entries (for 5% increments), I would divide the percentage by 20 then use the resulting integer as the index into the lookup table - hence no comparisons.
 
do you mean using JL/JU scheme? if so, i have thought about it, but i guess it would make the code longer... i might be wrong though...
 
girevik said:
do you mean using JL/JU scheme? if so, i have thought about it, but i guess it would make the code longer... i might be wrong though...

He's talking about indirect addressing (as his name implies :nodi: )
 
Hey Combo,

Combo said:
Another thing I don't know anything about

Arrays, indirect adressing, pointers


...it would be good practice for you to you have a try at implementing Simon's (L D[AR2,P#0.0]) solution for output profiling...??

IMHO it's a more elegant solution than using comparators and I'm sure the guy's here would help if/when you get stuck.....
 
I've implemented a more generalised solution for the comparison method. I created a DB with a list of comparison values and associated output levels. (I also added an end of list indicator)
The FC starts at the first set of comparisons and if the comparison test is satisfied, the output level is read from the DB and transferred to MD104. If is not met, the end if list indicator is checked and if the end of the list is reached, the block ends. If not, then the next set of comparisons is used. This example uses indirect addressing. I've not included the scaling or control of the Q outputs and assumed the percentage is in MD100.
This is not the look-up table method I mentioned in an earlier post - the suggestion was that Combo would attempt to implement that himself and ask for help when needed.

Code:
DATA_BLOCK DB 1
TITLE =
VERSION : 0.1

  STRUCT  
   Regulator1 : STRUCT  
	LowComparison : REAL ; 
	HiComparison : REAL ; 
	OutputLevel : REAL ; //when LowComparison >= Percent < HighComparison
	EndIndicator : INT ; //-1 indicates end of list
   END_STRUCT ; 
   Regulator2 : STRUCT  
	LowComparison : REAL ; 
	HiComparison : REAL ; 
	OutputLevel : REAL ; //when LowComparison >= Percent < HighComparison
	EndIndicator : INT ; //-1 indicates end of list
   END_STRUCT ; 
   Regulator3 : STRUCT  
	LowComparison : REAL ; 
	HiComparison : REAL ; 
	OutputLevel : REAL ; //when LowComparison >= Percent < HighComparison
	EndIndicator : INT ; //-1 indicates end of list
   END_STRUCT ; 
  END_STRUCT ; 
BEGIN
   Regulator1.LowComparison := 0.000000e+000; 
   Regulator1.HiComparison := 5.000000e+000; 
   Regulator1.OutputLevel := 1.000000e+003; 
   Regulator1.EndIndicator := 0; 
   Regulator2.LowComparison := 5.000000e+000; 
   Regulator2.HiComparison := 1.000000e+002; 
   Regulator2.OutputLevel := 2.000000e+003; 
   Regulator2.EndIndicator := 0; 
   Regulator3.LowComparison := 1.000000e+002; 
   Regulator3.HiComparison := 1.000000e+003; 
   Regulator3.OutputLevel := 3.000000e+000; 
   Regulator3.EndIndicator := -1; 
END_DATA_BLOCK
FUNCTION FC 1 : VOID
TITLE =
VERSION : 0.1
BEGIN
NETWORK
TITLE =loop around a list of comparisons
	  OPN   DB	 1; 
	  LAR1  P#DBX 0.0; //point to start of list of comparisons
cmp:  A(	; 
	  L	 MD   100; 
	  L	 D [AR1,P#0.0]; //low level comparison
	  >=R   ; 
	  )	 ; 
	  TAK   ; 
	  A(	; 
	  L	 D [AR1,P#4.0]; //hi level comparison
	  <R	; 
	  )	 ; 
	  JCN   skp; //if comparison not met then skip
	  L	 D [AR1,P#8.0]; //else output level required
	  T	 MD   104; 
	  BEU   ; //end exit
skp:  L	 W [AR1,P#12.0]; //check for end of list
	  L	 -1; //indicated by -1
	  ==I   ; 
	  BEC   ; 
	  +AR1  P#14.0; //point at next set of comparisons
	  JU	cmp; 
END_FUNCTION
 
I think that type of solution is more suited to larger problems and the comparitor solution is fine for whats required.

There's hardly any code saved and it uses more memory, it may take longer to scan as well as indirect addressing often does. The larger the problem the more it can pay off as the amount of code can be greatly reduced.

It is a good practical learning aid for using indirect addressing though.
 

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
636
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,942
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,921
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,298
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,565
Back
Top Bottom