User manual

Toolbox 32 User Manual 1.47d www.cse-semaphore.com/mykingfisher
Page
135
Example - Time Based Rolling Averages
This example counts the number of rainfall pulses each minute and then adds the total to a 60-register
queue. Each minute a new value is added to the queue and the oldest value is removed and then the
average value of all the one-minute totals is re-calculated. This provides the average rainfall per minute for
the last hour. The amount of ladder logic required is greatly reduced by using indirect addressing as shown
below.
The following registers are used:
#R498 Current number of rain pulses for this minute
#R499 Total number of rain pulses for the last minute
#R500 Average rainfall (pulses) per minute for the last 60 minutes (updated every minute)
#R501-560 Last 60 rainfall totals, oldest to newest totals respectively
#R1001 Queue pointer (pointer to next register to add)
#R1002 Loop counter
#R1003 Accumulated total (for averaging)