-------------------------------------------- CONPROSYS Script sample programs No. 014 -------------------------------------------- Process name: Maximum, minimum and average of analog input values Date of creation: April 18, 2016 Processing content: Calculate the maximum, minimum and average values within 1minute of analog inputs, with an input interval of 1 second [Signals] AI0 - Analog Input 1 [Operation] 1. Read the value of analog input 1 every second. 2. Measure the analog input for one minut (60 times), then calculate the maximum value, the minimum value and the average value. 3. Save the results to TAG00 (the average value), TAG01 (the minimum value) and TAG02 (the maximum value.) [Description] The sample program has a time measurement task (TASK8), a main task (TASK9), an initializing subroutine (SUB7), a measuring subroutine (SUB8) and a calculation subroutine (SUB9). To use this sample program, restores this sample program to the M2M controller and names the task number and the subroutine number. If the subroutines are renamed to the numbers that are not the same as SUB7, SUB8 and SUB9 respectively, change the calling numbers to the new definitions. TASK8: Set 1 second flag to TAG90 and 1 minute flag to TAG91. TASK9: Every 1 second, call SUB8 subroutine to read analog input. Every 1 minute, call SUB9 subroutine to calculate the results. (The results of calcultation are set to LTAG97 (average value), LTAG98 (the minimum value) and LTAGE99 (the maximum value)) * User can modify the TASK8 and SUB9 to shorten measurement intervals.