RSLogix5000. How to write Expression to find Greater Than other values


Hey DB. I have applied (most) of your suggestions. I have attached the complete routine as a pdf. The jpg shows the crux of the changes.

It took me a few attempts, then a few reviews of the FIFO mechanics. Good news is i now better understand how the FIFO works :).

I understood what you meant about using the "On scan with rising edge of this GRT..." to replace 32 rungs with a single rung branched 48 times to produce the same outcome that i have settled for (16 rungs with 3 branches each rung using the OSR as a trigger).

Reason why i kept the trigger and a less streamlined footprint is so i can clearly see the demarcation between each wind direction. Useful structure for beginners like me.

Anyhow. Thank you again. I will be hitting you up again soon i think as i will be reviving an earlier thread i started last year:

http://www.plctalk.net/qanda/showthread.php?p=897811#post897811

I noticed you provided input on this thread, but it was outside of my knowlege.

The best, (or most suited) response i received from my query directed me to a previous thread;

http://www.plctalk.net/qanda/archive/index.php/t-122267.html

This thread provides some tidbits of key info that i think is very relevant/interesting.

1. Can communicate directly to a PLC via a modem over the internet.
2. Port forwarding details and port numbers were provided.
3. The OP ended the communication confirming that the method worked and he was happy with the outcome.

It is of course possible the OP was later hacked and was responsible for a sitewide network failure. But let us not worry about this too much.

I will not revive it for a few weeks from now though i think. I plan to prepare a few things first:

1. Set up a new Compactlogix backplane. Compactlogix 1769-L32E.
2. Connect it to a dedicated modem, (Asus modem).
3. Set up a new (dedicated) internet connection at the cheapest possible plan
4. Connect it to my new backplane and attempt to communicate
5. Present the setup to PLCTalk community and ask for suggestions around security without using a VPN.

In the long term, i hope to eventually connect my main backplane to the internet so i can communicate with it (securely) over the internet without using a VPN.

I want to solve the commincation (without VPN) issue because i have seen others do it. Others on PLCTalk have confirmed they have succeeded doing it. So i do not understand why i should restrict myself to using a VPN which in my opinion is a pretty clunky way of communicating offsite.

Wind FIFO reroute.png
 

Attachments

  • Dominant_Wind_Direction.pdf
    139.3 KB · Views: 5
Nice!

l think the code is still averaging only 9 values, as can be seen e.g. from the 9 as the value of FIFO_Wind_Dom_CONTROL_E.POS on rung 68.
 
Last edited:
Don't bother sorting.

Create two tags: DIR, MAX. Initialize to 0.

On the rung with each CTU[index], if .CU is closed and .ACC is greater than MAX, set MAX = .ACC and DIR = index.

That's it; whenever you want to resample, just set DIR & MAX to 0.

edit: wow sorry didn't even notice the original date.
 
Last edited:
Here's a basic algorithm for finding the element with the maximum value.
  • MOV the 16 values into an array DIRECTION_LIST[ ] (make a note of which index receives which value)
  • Create a MAX_INDEX tag and initialize it to 0
  • Create a loop index iterator tag 'i' and initialize it to 0.
  • Loop over the array:
    • Check if DIRECTION_LIST is greater than DIRECTION_LIST[MAX_INDEX]
      [*]If YES, MOV i into MAX_INDEX
      [*]Increment i
      [*]If i exceeds array length, reset i to 0

    [*]At the end of the loop, the MAX_INDEX value will point to the maximum value. You can use this value to indicate which wind direction had the greatest number of recordings. (i.e. 0 == NORTH, 1 == NE, 2 == E, 3 == SE, etc...)
 
You don't have to move anything. The OP had an array of 16 counters. One can accomplish finding the max wind value and max wind direction with one rung using the FSC instruction. Simply use the .IN bit to record the max value found so far (MOV counter[fsc.pos].ACC Max) and the current index of the array that it was found (MOV fsc.pos Dir_Index) then reset the .IN to continue. The FSC compares current counter[fsc pos].ACC > Max. When the FSC completes (DN), the Max value is known and the Index into the counter with the max value is known.
 
You don't have to move anything. The OP had an array of 16 counters. One can accomplish finding the max wind value and max wind direction with one rung using the FSC instruction. Simply use the .IN bit to record the max value found so far (MOV counter[fsc.pos].ACC Max) and the current index of the array that it was found (MOV fsc.pos Dir_Index) then reset the .IN to continue. The FSC compares current counter[fsc pos].ACC > Max. When the FSC completes (DN), the Max value is known and the Index into the counter with the max value is known.
Nice. That's the easiest one yet I think.
 

Similar Topics

I am replacing a PLC5 with a 1756-L73 and i am trying to reuse a 1771-DB Basic Module. I am leaving the PLC5 in the chassis setup as RIO adapter...
Replies
7
Views
5,108
Need good example/sample of aoi RSLogix5000 code to read&write through RS232 port on Need good example/sample of aoi RSLogix5000 code to...
Replies
0
Views
1,841
Hey All, As the title states, how do I write a MinorFault generated by an instruction, for example a negative .PRE value was entered for a timer...
Replies
12
Views
2,998
Is it possible to partially restrict the types of communications allowed through a ControlLogix communications module? Ideally I'd like something...
Replies
7
Views
3,319
Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
114
Back
Top Bottom