0

I have an AB PLC where I am trying to read analog values to see if the values vary more than 1V in 5 minutes? I have 10 sets of values I need to read. What would the easiest way to implement this? I can think of creating arrays to save the values each time I read them but the part I am having trouble with is, how to keep a running average of the values and compare against each time I read them.

Any help with this would be greatly appreciated!!

user2840240
  • 87
  • 1
  • 1
  • 5
  • 1
    The question is a bit unclear to me. Can you please detail it a bit more. Why do you want a running average? Do you want to make an average before saving new min and max values? Should the average or each one of the 10 AIs not vary more than 1V? Should the 5 min check be done after a trigger and just for 5 minutes or is it a continuous check? – Felix Keil Dec 08 '15 at 06:38
  • 1
    Less than 0.2V/min is ok? Like going from 10V to 0V is fine, as long as it takes at least 50 minutes? What are you *actually* trying to do? This sounds like the wrong solution to the problem. – J... Dec 08 '15 at 11:09

3 Answers3

0

If I understand correctly all you want to do is see if your analog input is more or less than 1V from your set value? Just check if your value is greater than (set value + 1V) or less than (set value - 1V) every plc scan then set a bool value to true. That should be it.

I think finding an average of the analog input is not the way to go for this. But if you did want to find an average of an analog input over time you would need 3 things. Sample time, interval time, and total intervals. You would set up a sample time of, lets say 12 seconds. You will get the analog value every 12 seconds. After 60 seconds you would take the total and divide by (60/12 == 5). You would then add that value to the previous value average value that you totaled up and divide by the total number of intervals times (total intervals) you have accumulated. Hope I didn't make that to complicated.

mrsargent
  • 2,267
  • 3
  • 19
  • 36
0

What i understood from you question is you want check whether input voltage changed or not using the analog value you got, in my case i'm using 0 to 10v. Just simple store the analog value at max input i mean at 10v and just do the same for 0v and you can simply calculate the value for 1v. All you have do is compare the value with +/- 1v value you got from the calculation. you can do this dynamically with n-number of analog inputs(n= max analog inputs supported by your PLC.)

0

Have a look at FFL and FFU. They are First-In-First-Out buffers. You specify the length of the buffer you want and use FFL and FFU in pairs on the same buffer. Running averages are not that difficult to compute, and there are a number of ways to best implement depending on the platform (SLC vs CLX). The simplest method that would work on both platforms is to use a counter.ACC as a value to indirectly reference the element number of the FIFO for an addition function, then divide by the number of elements in your FIFO. This can all be done in a single multi-branch rung.

1. Load your value into FIFO buffer at some timer interval using FFL.

2. If you don't need the FIFO values 'Popped out' for use elsewhere, just set .POS to 0 when the FIFO is full and let it continue to update with new values, the values aren't cleared so they are still readable for your Running Average. But you MUST either use FFU to step the .POS back or use a MOV function to change the .POS once it's full or it will stop taking values.

3. Create a counter with a .PRE equal to the .LEN of your FIFO

4. On a parallel Rung, with each increment of the counter.ACC use an ADD function. Here's an example assuming CLX. If you're using SLC you can do the same thing but obviously you can't use tag names:

ADD Value1: AllValues Value2: FIFO[IndexCounter.ACC] Destination: AllValues

5. When your counter.DN bit is set, divide AllValues by FIFO.LEN and store in a RunningAverage Tag, then reset the counter. Have your counter step once for each scan or put it all in a Periodic Function to execute the routine.

Jack Galt
  • 83
  • 8