select a mximum value

speedcat

Member
Join Date
Mar 2009
Location
cairo
Posts
27
i have a number of registers (vw200,vw202,vw204....)each of the contain a certain value i want to know the maximum value among these registers ,how can i do thaton s7-200?????
 
siemens s7-200 cpu 222,microwin.....& i want to get the maximum of 100 variables so using compare instruction between every 2 variables will be very hard
 
Last edited:
I was shown just recently that the quickest way to select the register with the maximum or minimum value from a number of registers requires doing a compare between each register.

There are only two possibilities I can think of that would allow using less:

1. If the PLC you are using has a special function of some type that does sorting,

2. If there is some type of special relationship between the registers ie: grouped in some way that the highest value is certain to appear in a particular group with another characteristic in common.

I'm interested to see if there are any creative suggestions too..........

Stationmaster
 
When you write to each of the variables, perform a comparison at that time and maintain the current max value. You will still have to perform the same number of comparisons. Are all 100 values written in one scan or what ? 99 compares is not difficult - you could train a monkey to do the typing for you (that would be difficult):)
 
Last edited:
Stationmaster,

Here is a creative suggestion just for you. This is a RSLogix routine that will sort any quantity of numbers (up to 255 numbers without any changes) with the same 15 rungs of logic.

It has two For-Next loops, and compares two numbers at a time until all are sorted. The J-loop does "For J = 2 to N Step 1", where N is the number of values to be sorted. The I-loop runs inside the J-loop and does "For I = J-1 to 1 Step -1".

The sorted numbers appear in memory locations N7:0 (smallest) to N7:x, where x is the location of the last and largest number.
 
Last edited:
Stationmaster,

If it is like most PLCs, it will do them if it can accept labels, jumps, and indirect addressing. The For-Next Loops are not built-in functions in this program, but are created using simple add, subtract, label, and jump instructions.

Off-Topic: Stationmaster, I just gave away the lay-off plow. My 87-year-old uncle called and said he heard I was moving and could he have my layoff plow since I wouldn't need it anymore and he sure could use it in his garden. What could I say except yes?
 
Last edited:
Stationmaster,

If it is like most PLCs, it will do them if it can accept labels, jumps, and indirect addressing. The For-Next Loops are not built-in functions in this program, but are created using simple add, subtract, label, and jump instructions.

Sorry for the delay, one of my MATER packers called an I had to switch to "packing plant" mode for a while. There are a LOT of distractions on this end.

Yes Lancie, it WILL do those functions and I see how to make the loops using counters. I may need a little help translating, but I'm pretty sure I can adapt it to IDEC. I use the IDEC Microsmart Pentra slim type. (I feel ssssooo inadequate.)

Off-Topic: Stationmaster, I just gave away the lay-off plow. My 87-year-old uncle called and said he heard I was moving and could he have my layoff plow since I wouldn't need it anymore and he sure could use it in his garden. What could I say except yes?

Did he at least leave it BACK to you in his WILL?

I heard you were moving and I could sure use your TRACTOR......

: )
 
Stationmaster,

You could use counters, but I just looked at my copy of WindLDR, and you have a JMP (Jump) and JEND (JumpEnd instead of Label) so you can almost translate the program line for line, using the JMP and JEND to define the loop boundaries, instead of Jump to Label and Label. You also have an Indirect Address Move (IMOV) so you are in business if you need a sort routine.

No, my uncle didn't mention his will. He can and got the plow just now. I will build another one if I need it. I built the old one from scrap metal from Roberson's Scrap Metal yard.
 
Last edited:
Stationmaster,

You could use counters, but I just looked at my copy of WindLDR, and you have a JMP (Jump) and JEND (JumpEnd) (instead of Label) so you can almost translate the program line for line, using the JMP and JEND to define the loop boundaries, instead of Jump to Label and Label.

Lancie, In WindLDR, if you select the PLC "Microsmart Pentra slim type" you'll see the instructions for branching, including LABEL and LJMP.
 
Word (W) registers max values :

signed:
Decimal - 0 to 65,535
Hex - 0 to ffff

unsigned:
Decimal - -32,768 to 32,767
Hec - 8000 to 7fff
 
Last edited:
Stationmaster,

Yes, I see those. I do not see how to do indirect addressing for the comparision instructions however. That may require a work-around.
 
Stationmaster,

Yes, I see those. I do not see how to do indirect addressing for the comparison instructions however. That may require a work-around.

Okay.... pardon this next question, but by "indirect addressing" do you mean specifying a data register instead of a numerical constant? Or something else?
 

Similar Topics

Im trying to install a Siemens upgrade license using Automation License Manager v6.0. I clicked D: mistakedly, and now I can not find a way to...
Replies
2
Views
54
Hello, We recently upgraded our control server to a newer model. After the transition we are experiencing issues with our trend graphs to where...
Replies
2
Views
123
Hi all, I really need help with this one. I'm at a complete loss... For months and months, I've had no problems with pressing a NEXT button to...
Replies
14
Views
1,450
Hello everyone, I'm having trouble solving this one and was hoping someone could help. I have a AB CompactLogix L16ER PLC connected to a AB...
Replies
2
Views
591
Is there a way to select a parameter file when loading a given screen based on the value of a variable? I see that under "Global Connections" the...
Replies
2
Views
1,118
Back
Top Bottom