---
title: Use the Moving Window Processor Function
slug: manufacturing-connect-edge/use-the-moving-window-processor-function
docTags: 
createdAt: 2024-05-24T20:16:45.173Z
---

You can use a single input to perform calculations over a sliding or moving window of data from your PLC device. Single inputs are to be provided with the events-type connection and then the respective functions are calculated as the names suggest.

# Understanding Different Moving Window Functions

Use one of the following functions for your inputs:

- **Moving Average:&#xA0;**&#x43;alculates the average of the moving window of input values in the Flow.
- **Moving Maximum:&#xA0;**&#x52;eturns the maximum value among the moving window of input values in the Flow.
- **Moving Minimum:&#x20;**&#x52;eturns the minimum value among the moving window of input values in the Flow.

# User Scenario

Review the following scenario for the moving window processor function. Then, you will simulate PLC data and calculate KPIs using multiple moving processor functions.

In a production facility, several PLCs use multiple sensors to monitor parameters such as temperature, pressure, and speed.

- You can monitor temperature trends and detect anomalies in machines by using the **Moving Average** function over a specific time frame.
- You can identify any sudden spikes by extracting the highest pressure readings from sensors using the **Moving Maximum** function over a specific time frame.
- You can pinpoint periods when machine performance drops below acceptable levels by using the **Moving Minimum** function within a defined window.

# Step 1: Add a Device

Follow the steps to [Connect a Device](docId\:nm1lQfefyA-DSIfFitIty) and configure the following parameters:

- **Device Type**: Simulator
- **Driver Name**: Generator
- **Enable Alias Topics**: Select the checkbox.&#x20;

# Step 2: Add Tags

After connecting the device, add the following tags. See [Add a Tag](docId\:h5heqIcXrCY3NCH9KBg9I) to learn more. Only one tag will be used for simulating the different Moving processor outputs mentioned above.

## Tag 1: tag1

- **Name**: Select **S - Random value generator**
- **Value Type:** Select **float64**
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **tag1**
- **Min\_value**: Enter **1**
- **Max\_value**: Enter **99**

# Step 3: Create Analytics Flows

You can now create the analytics flows using data from the device and tag you previously created. Follow the appropriate step out of 3a, 3b, or, 3c based on the Moving Window Processor Function you want to use.

**To create an analytics flow with the Moving Window Processor function:**

1. Navigate to **Analytics**.&#x20;
2. On the analytics canvas, click **Add processor**.
   The *Create a processor* dialog box displays.
   ![](https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/fJAuEgg13oVKechigUBLK_image.png "The Add processor option")
3. Select **DataHub Subscribe**.
4. In the *Topic&#x20;*&#x66;ield, click the **Search&#x20;**&#x69;con, select the device you previously created, and then select the alias topic for the **tag1**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/j5J-q_vCHKPs0dg0yM_cU_image.png" size="80" width="1141" height="571" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.

## Step 3a: Configure Moving Average Processor

1. Click **Add processor** again and select **Moving Average**.
   The following information defines this function:
   - **Field Name**: Select the field name for which you want to apply the function. For example, **value&#xA0;**&#x6F;r **downtime**.
   - **Processing Type**: Select **float&#x20;**&#x66;rom the drop-down list.
   - **Window Size:&#x20;**&#x45;nter the number of values you want the function to consider.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Tcii8nHzbQK9byFA-jJgn_image.png" size="80" width="1137" height="665" position="center" caption="Moving Average dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *tag1)* to the Moving Average processor with a wire and use the **events&#x20;**&#x63;onnection.
4. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following:

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/-ouIAzJUUkXWQby0h6GXH_image.png" size="80" width="748" height="395" position="center" caption="Completed Moving Average flow canvas" showCaption="true"}

## Step 3b: Configure Moving Maximum Processor

1. Click **Add processor** again and select **Moving Maximum**.
   The following information defines this function:
   - **Field Name**: Select the field name for which you want to apply the function. For example, **value&#xA0;**&#x6F;r **downtime**.
   - **Processing Type**: Select **float&#x20;**&#x66;rom the drop-down list.
   - **Window Size:&#x20;**&#x45;nter the number of values you want the function to consider.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/a5BizMaPXwnkA3_FjWLk7_image.png" size="80" width="1134" height="663" position="center" caption="Moving Maximum dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *tag1*) to the Moving Maximum processor with a wire and use the **events&#x20;**&#x63;onnection.
4. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following:&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/emvjRsJjAvVUyMGybw4ug_image.png" size="80" width="747" height="373" position="center" caption="Completed Moving Maximum flow canvas" showCaption="true"}

## Step 3c: Configure Moving Minimum Processor

1. Click **Add processor** again and select **Moving Minimum**.
   The following information defines this function:
   - **Field Name**: Select the field name for which you want to apply the function. For example, **value&#xA0;**&#x6F;r **downtime**.
   - **Processing Type**: Select **float&#x20;**&#x66;rom the drop-down list.
   - **Window Size:&#x20;**&#x45;nter the number of values you want the function to consider.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/DZTcpqLheZKy7UHrD-NNz_image.png" size="80" width="1130" height="660" position="center" caption="Moving Minimum dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *tag1*) to the Moving Minimum processor with a wire and use the **events&#x20;**&#x63;onnection.
4. On the analytics canvas, click **Save**.

The configured analytics flows should look like the following:&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/rjQ3AxYYqQG9m2LjJ09K4_image.png" size="80" width="751" height="367" position="center" caption="Completed Moving Minimum flow canvas" showCaption="true"}

# Step 4: View Output of Processor

Click the **View&#x20;**&#x69;con in the *Moving&#x20;*&#x70;rocessor to view the output values.

## View Moving Average Output

The average function calculates the average of last 10 values from the defined *tag1* values.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/Qtr_85Lpu7QmFVxHj5BEh_image.png" size="80" width="769" height="649" position="center" caption="Moving Average Processor Output" showCaption="true"}

## View Moving Maximum Output

The maximum function finds the largest of last 10 values from the defined *tag1* values.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/aUm09HmGw4yxVoZPb-ttQ_image.png" size="80" width="755" height="653" position="center" caption="Moving Maximum Processor Output" showCaption="true"}

## View Moving Minimum Output

The minimum function finds the smallest of last 10 values from the defined *tag1* values.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/ZrbM0_YvAF_W-njyLUX-W_image.png" size="80" width="744" height="643" position="center" caption="Moving Minimum Processor Output" showCaption="true"}

