Cant get FILO array to work to filter AI input

tarrant79

Member
Join Date
Jun 2020
Location
washington
Posts
23
Cant get FILO array to work to filter AI input

Hi, Probably some stupid mistake, I have a wildly fluctuating AI input. So Im trying to filter it by populating a Array[20] at first scan with the current AI values. Then I try to pop the oldest AI value from the array with LFU and push the newest AI value into the array with LFL. Then I use AVE to average the array and use that value. The AVE funct work, but my LFU/LFL just keeps loading Array[0] with the current value.....AND not pulling the old values out of the end of the array.

FILO logic.png
 
Yah, been there, done that: you want FIFO via FFL/FFU, not FILO via LFL/LFU. FILO is First-In-Last-Out so it is also LIFO Last-In-First-Out i.e Newest-In-Newest-Out i.e the LFU instruction will pop the newest value, rather than the oldest value.


Also, don't trigger the FFU until the Control.Position is equal to Control.Length (that may mean Control.DN is 1 i.e. [XIC Control.DN] is an alternative to EQU Control.Positon Control.Length).


Finally, the AVE should divide by the Control.Position; alternatively the code could scale the AVE (sum/20) value by 20/Control.Position, but beware of divide by zero.
 
Last edited:
You should be able to filter the signal per channel. Have you tried that? Also, try the RLIM instruction, it will probably do what you need. Lastly, don't forget that RA has a lot of code already written for a lot of applications. Take a look at their P_AIn AOI from PlantPax, specifically for Filtered PV. I don't use PlantPax as it's bloated, but I use some of their stuff in my own code, this filter is one of them. It works well. It looks like you are making things harder than they need to be.
 
Still having trouble with FFL and FFU, the position always stays 0 like its constant and if I manually edit it, it just resets it from POS=20 to POS=0
 
A simple filter would be a whole lot simpler.

But, why is it fluctuating?

See txt...
 
Last edited:
I considered a last 2 input average, to delete spikes, but unfurtunately I am seeing like a 10-20 second periodic undulations. They put in a TMF meter without enough up and down straight pipe distance.


Anyways I had no luck on FIFO stuff, so I ended up just using a counter to count through and populate an array[20] then (AVE) average that. So I could dampen down the undulation.
 
FIFO is best for this, LIFO won't work as stated.

Why are you using a timer bit to drive both your load and unload instructions? That will not work. You can use a timer to load the FIFO with FFL, but the unload should only be done each time the FIFO control block's .DN bit is set, as that unloads the oldest entry.


Using just a timer bit, you are loading, and immediately unloading the stack.
 

Similar Topics

I have a sysmac omron plc C200H CPU01,only the power led is ON,using CX-ONE programmer software, and connecting to the plc via Host link LK202-V1...
Replies
2
Views
697
Good morning, we have a lot of coolant mist around our machines and sometimes the fans on the drives inside our electrical cabinets will suck the...
Replies
7
Views
1,283
I cannot get CCW to add a controller, i keep getting a error message saying that the device is not authorized. This happens with any model and...
Replies
1
Views
1,341
Hey guys, Frustrating issue here. I have one particular PC with Proficy 8 installed that no matter what I try, I cannot get the variable...
Replies
6
Views
1,423
Hello Everyone i got a problem with Endress Hauser FlowMeter Promag W400, in his specification says it support Ethernet/IP protocol...
Replies
4
Views
1,768
Back
Top Bottom