Posted 17 Feb 2020 Platform: Logix5000 I have a relatively simple task I am trying to complete. I need to track the status of a 100 part sequence to see how many parts have been rejected. Essentially, I need to keep track of the last 100 cycles and count how many parts of the last 100 have been vision rejects. I have written most of the logic, using FIFO with an integer with an array of size of 100. Where I am getting stuck a bit is how to accurately get the count of the array. I did make a for statement which will count the array and add it to a counter if the first bit is equal to 1, but this doesn't seem to be a clean way to do it, as I would also need to clear that counter before running the for statement. Thanks, Share this post Link to post Share on other sites
Posted 21 Feb 2020 If what you are looking for is a rolling count of defects in the last 100 the logic is relatively easy. You have a pair of FFL/FFU instructions and a Counter Register for defects. SO as you said , when you load the FIFO with the part if the first bit is 1 Increment or CTU the counter. When FFL is full as told by the .dn bit, perform and FFU and it the unloaded part has bit one true then decrement or CTD the counter. No need for a nasty for/next loop and cycling through the FIFO stack. 1 person likes this Share this post Link to post Share on other sites
Posted 24 Feb 2020 I did very similar to what you suggested last thursday and it worked out well. I got rid of the for loop and utilize an add instruction with a DINT, driven off a timer. When the timer.dn bit is on, i increment the DINT 1(every 5ms). I use this dint to look at which position in my tracking array to count. I then add the value of the array position to a separate integer. When my position integer hits 101 (I am only counting 0-100 using a limit test in the logic), I move the value accumulated to a new integer which is what I use in my logic for my alarm. This all worked super well. My initial struggle was counting the value in each part of the array. I used indirect addressing to do it. Share this post Link to post Share on other sites