STORAGE
This function calculates a sliding average on values stored in the memory.
On starting up the application, the FBD STORAGE function block is active by default. When rising edge appears at input VALIDATION, the byte value present on the input VALUE is stored. This value can be read on the MEMORY_1 output. At this point, when there is only one value in the memory, the average value read on the output AVERAGE is identical to the MEMORY_1 value. At the 2nd rising edge at the input VALIDATION, the byte value present on the input VALUE is stored in the MEMORY_2 output. The average value read on the output AVERAGE is equal to the value (MEMORY_1 + MEMORY_2) / INDEX and so on up to MEMORY_8. The INDEX output counts the number of values stored in the memory. Once 8 values have been stored, the next rising edge at input VALIDATION shift all values, MEMORY_8 replaces MEMORY_7, the new value is stored in the space freed in MEMORY_8 and all the bytes stored are shift by one MEMORY_7 to MEMORY_6 and so on down to MEMORY_1. The value previously stored in MEMORY_1 before the new capture is lost. The AVERAGE value is recalculated.The average calculated is rounded down to the nearest integer. A pulse at the input RESET resets all values stored to zero, including the AVERAGE and the INDEX.
INPUTS :
OUTPUTS :