select a mximum value

Lancie,

Okay, so I had a brain fade, MOSTLY because IDEC seems to be "indirect addressing" challenged. (in 1985 my TI994a could do it.) I'm still trying to figure out if IDEC has a way. I can get some input from the rep.

I'll let you know.

But enough about MY quest. This thread belongs to Speedcat. I've pursued this as far as I HAVE because MY questions were likely to help HIM as much as me. Now that I'm down to my specific brand issues, that's no longer the case.

Your program is an ingenious way to complete a lot of reps (comparisons in this case) with relatively few lines of programming. It seems PERFECT for Speedcat's situation. I hope he gets as much out of it as I have.

I will be intently "subscribed" while you explain it to him.

Stationmaster
 
Stationmaster

I'm not sure about Idec, but at least on Schneider's twido PLC, which is rebranded Idec MicroSmart you can use index addressing with command

%MW100:=%MW0[index address]


ps. Speedcat here is my program, it compares 10 values, biggest value will be saved to memory address %MW200, it takes only 5 rungs. I think that you can use it with Siemens if it supports index addressing...

Lare
 
sorting may not be needed, the way i see original post, he is only looking for maximum value. single loop would take care of that:

assume first value (element #1) is the max.

run loop for other elements (2-100) and see if there is any that has greater value. if you encounter value greater than maximum, just move that value into maximum. if you don't care about actual value but need to find out which of the 100 elements has the greatest value, then also keep track of index.

this is good example where indirect addressing is useful.
 
Last edited:
Lare,

Very good program. Yes, it does solve the original problem very nicely, with no extra baggage.
 
Finding the largest of 4 values
Well this solution is for S7 300.

And the following is my try of the same thing in S7200.
Have not tested it because of lack of S7200 PLC. But will come back after testing it. Meanwhile......we have the following

Code:
MOVD   &VB200, AC1                 //address of intial byte of VW200 in AC1
MOVD   &VB200, AC2                 //address of intial byte of VW200 in AC2

FOR    VW100, +1, +3               // set  3 loops for three comparisions starting from 1 
+D     +2, AC2                     // increment AC 2 so that it points to next word


MOVW   *AC1, VW102                 //perform *AC1-*AC2 and store the result in VW102
-I     *AC2, VW102


LD     SM1.2                       // this bit is set if result is negative
MOVW   *AC2, *AC1                  // if result is negative then *AC1=*AC2 


NEXT                               // jump to instruction below FOR instruction  


MOVW   *AC1, VW104                 // VW104 has the highest value
 
Well below is the working code:
Code:
LD     SM0.0              //always ON
MOVD   &VB200, AC1        //point AC1 to starting address ov VW200
MOVD   &VB200, AC2        //point AC1 to starting address ov VW200
FOR    VW100, 1, 3        //start 3 loops starting from 1
+D     2, AC2             //increment pointer AC2 so that it now points to next word
MOVW   *AC1, VW102        //move the value at address in AC1 to Vw102
-I     *AC2, VW102        //subtract value at address in AC2 from VW102 and store the result in VW102
LD     SM1.2              //this bit true if result is negative
MOVD   AC2, AC1           //if result is negative then move the address in AC2 to Ac1 (NowAC2=AC1)
NEXT                      // GOback
LD     SM0.0              // Alwya ON bit
MOVW   *AC1, VW104        //Move the value at Address in AC1 to VW104(it always has highest value)
 
More compact :D
LD SM0.0
MOVD &VB200, AC1
MOVD &VB200, AC2
FOR VW100, 1, 3
+D 2, AC2
AW<= *AC1, *AC2
MOVD AC2, AC1
NEXT
LD SM0.0
MOVW *AC1, VW104
 
Manmeet, you seem to have Speedcats's problem solved, so now back to our thread high-jack:

Okay, so I had a brain fade, MOSTLY because IDEC seems to be "indirect addressing" challenged. (in 1985 my TI994a could do it.) I'm still trying to figure out if IDEC has a way. I can get some input from the rep.
Stationmaster,

Here is a conversion of my SORT NUMBERS program. The Idec Microsmart will convert from the Allen-Bradley program almost line-by-line, except that it has no indirect-address comparison instructions. It should sort up to 393 numbers (entered randomly in locations D0001 to D0393). Enter the Number to be sorted (N) at D0394. Try it out and tell me how many errors you find!
 
Last edited:

Similar Topics

In the top bar of directsoft 6 while programming on a DL-262 I noticed a button that says "Select I/O" and it pops up a dialog box asking "old?"...
Replies
1
Views
67
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
107
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
153
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,510
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
605
Back
Top Bottom