---
title: Use the Rise and Fall Function
slug: manufacturing-connect-edge/use-the-rise-and-fall-function
docTags: 
createdAt: 2024-05-24T20:16:19.506Z
---

You can use the Rise and Fall function to calculate the difference in upper and lower thresholds between consecutive values from the PLCs.&#x20;

# Understanding Different Rise and Fall Functions

Use one of the following functions for your inputs:

- **Rise:&#x20;**&#x4F;nce you enter a lower and upper threshold, this function will show you the timestamp at which the current value starts to rise from the upper threshold.
- **Fall:&#x20;**&#x4F;nce you enter a lower and upper threshold, this function will show you the timestamp at which the current value starts to fall from the lower threshold.
- **RiseAndFall:&#x20;**&#x4F;nce you enter a lower and upper threshold, this function will show you the timestamp at which the current value starts to rise from the upper threshold and fall from the lower threshold.

# User Scenario

Review the following scenario for the rise and fall processor function. Then, you will simulate PLC data and calculate KPIs using a single input processor function.

Suppose you are monitoring a manufacturing process where a motor's temperature is being recorded by a PLC. You want to know when the temperature rises above 80 degrees Celsius and when it falls below 70 degrees Celsius. Using the RiseAndFall function with the appropriate thresholds, you can get the exact timestamps when the temperature rises above 80 degrees and falls below 70 degrees. This information can help you optimize the process and prevent any potential issues.

# 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.&#x20;

## Tag 1: temperature

- **Name**: Select **S - Random value generator**
- **Value Type:** Select **float64**
- **Polling Interval**: Enter **5**
- **Tag Name**: Enter **temperature**
- **Min\_value**: Enter **60**
- **Max\_value**: Enter **90**

# Step 3: Create Analytics Flows

You can now create the analytics flows using data from the device and tag you previously created.&#x20;

**To create an analytics flow with the Rise and Fall 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/Wzh4SvgxWBR755-Hz6VJe_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 **temperature&#x20;**&#x74;ag.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/vDAlficoSk8N8D2tYis9X_image.png" size="80" width="1141" height="571" position="center" caption="Create a Processor dialog box" showCaption="true"}
5. Click **Save**.

## Step 3a: Configure rise KPI&#x20;

1. Click **Add processor** again and select **Rise and Fall&#x20;**&#x70;rocessor.
   The following information defines this function\:v
   - **KPI:** Select **rise**.
   - **Tolerance:** Enter a value to determine the range of values considered acceptable.
   - **Upper:** Enter **80** for upper threshold value.
   - **Lower:** Enter **70** for lower threshold value.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/9HzFq5wfwFzVat-z_FRCy_image.png" size="80" width="1141" height="770" position="center" caption="rise and fall dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *temperature*) to the Rise and Fall processor with a wire and use the **events** connection.
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/kdEQZTm1XxOwkd5Jl7sq7_image.png" size="80" width="723" height="301" position="center" caption="Completed analytics flow canvas" showCaption="true"}

## Step 3b: Configure fall KPI&#x20;

1. Click **Add processor** again and select **Rise and Fall&#x20;**&#x70;rocessor.
   The following information defines this function:
   - **KPI:** Select **fall**.
   - **Tolerance:** Enter a value to determine the range of values considered acceptable.
   - **Upper:** Enter **80** for upper threshold value.
   - **Lower:** Enter **70** for lower threshold value.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/_QiSlH4rj0iudem-EbKWE_image.png" size="80" width="1124" height="785" position="center" caption="rise and fall dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *temperature*) to the Rise and Fall processor with a wire and use the **events** connection.
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/qHxOiKCNjEVUeCNREV78D_image.png" size="80" width="753" height="313" position="center" caption="Completed analytics flow canvas" showCaption="true"}

## Step 3c: Configure riseAndFall KPI&#x20;

1. Click **Add processor** again and select **Rise and Fall&#x20;**&#x70;rocessor.
   The following information defines this function\:v
   - **KPI:** Select **riseAndFall**.
   - **Tolerance:** Enter a value to determine the range of values considered acceptable.
   - **Upper:** Enter **80** for upper threshold value.
   - **Lower:** Enter **70** for lower threshold value.
2. Click **Save**.
   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/N0RubrPerQGSyPghifEHa_image.png" size="80" width="1121" height="777" position="center" caption="rise and fall dialog box" showCaption="true"}
3. Connect the DataHub Subscribe processor (tag: *temperature*) to the Rise and Fall processor with a wire and use the **events** connection.
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/Fhz-4FpvEq1kfsEUzPE4o_image.png" size="80" width="741" height="283" position="center" caption="Completed analytics flow canvas" showCaption="true"}

# Step 4: View Output of Processor

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

## View rise KPI Output

As the generated value is **85**, which is more than the upper threshold, the output shows the `riseEnd`, `riseStart` and `riseTime` fields.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/AWpDHniXSh9Ks26huYewa_image.png" size="80" width="1056" height="525" position="center" caption="rise KPI Output" showCaption="true"}

## View fall KPI Output

As the generated value is **67**, which is less than the lower threshold, the output shows the `fallEnd`, `fallStart` and `fallTime` fields.&#x20;

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/ynowiyYYq5MUKRZpBBl2-_image.png" size="80" width="1012" height="530" position="center" caption="fall KPI Output" showCaption="true"}

## View riseAndFall KPI Output

After generating values falling outside the lower and upper thresholds, the corresponding fields are displayed.

::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/qG4MJ0C9npmhw4KWUO-Up_image.png" size="80" width="1435" height="535" position="center" caption="riseAndFall KPI Output" showCaption="true"}

