Posted 20 Dec 2018 Hi Guys! I have a problem. I have a leaser sensor, I already set the sampling frequency to 0,1 s. So 1 second I will get 10 data. I need to use the average of the datas. My problem is I dont know how can I solve that, after the 10. data every new data I have to recount, the last 10 data's average. I think maybe I have to use the FFL instrucion or something like that. I need to solve this problem in ladder diagram. I use RS-logix 5000 software. Anyone can help me? Unfortunatelly I havent the the software, so I cant show you what am I think. Maybe the sliding window solution is the right, or is it not related to this? Im a bit confused. Share this post Link to post Share on other sites
Posted 20 Dec 2018 (edited) So you want to collect the average?, or?.. Why not use a 100ms pulse to catch 10 datas then divide the sum by 10? So then the average updates every second... Edited 20 Dec 2018 by collinsd70 Share this post Link to post Share on other sites
Posted 20 Dec 2018 +1 collinsd70 http://www.plctalk.net/qanda/showthread.php?t=58217http://www.plctalk.net/qanda/showthread.php?t=106876 Here are a couple of threads that also deal with averaging (filtering). They may help you out. Regards. Garry Share this post Link to post Share on other sites
Posted 20 Dec 2018 If you want your average to be updated every 0.1s with the 10 most recent samples, set up an array of 10 elements and use a COP instruction. I created an array called SAMPLES, DINT[10], and wrote some code to increment the data source every 50ms. The rung you see below executes every 100ms. This will copy element 1 into element 0, then element 2 into element 1, and so on until it copies element 9 into element 8. You would then use a MOV (or whatever) to grab your current sample and store it in element 9. In this arrangement, element 0 will have the oldest sample and element 9 the newest. You can then average the 10 elements in the array. Share this post Link to post Share on other sites