---
title: "Create your first machine trigger"
slug: "create-your-first-machine-trigger"
updated: 2022-11-16T18:18:13Z
published: 2022-11-16T18:18:13Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.tulip.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create your first machine trigger

## How To Create Your First Machine Trigger

*Use Machine Triggers to update the history of every machine in the Machine Monitoring feature*

In this article, you will learn:

- How to use Machine Triggers to change state of the machine
- The full list of actions that you can use in Machine Triggers

Once you have set up [Attributes and Machine Types](https://support.tulip.co/docs/how-to-set-up-machine-types) you are ready to update the history of a machine based on the value of OPC UA fields.

In other words, you will want to create a history like this for every machine:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_195020626.png)

This guide will show you how to build the history above. In the machine history, every row in the Table is defined by a change in state of the machine. You can see the different states on the far left Field.

Here is how the data flows into machine triggers:

1. An OPC UA field shares an output.
2. That output is [mapped to an attribute](https://support.tulip.co/docs/how-to-add-individual-machines-and-view-their-history) on the page for that individual machine.
3. The attribute is used in machine trigger logic.

## Updating the State of the Machine

On the page for each individual Machine Type, you can define multiple Machine Triggers that will update the state of the machine (or any field).

Here's an example of machine states for one type of machine:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_194999389.png)

To create a machine trigger, click the **Edit** button at the top right of the Machine Type page.

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_235030227.png)

Click on the **+** sign in the top right of the **Machine Triggers** section.

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_195246313.png)

Then, you will need to add a **When** statement to define when the state should be updated. There are two types of **When** statements:

1. Based on the value of the last output from a specific OPC UA field.
2. Time-based i.e. "in the last 5 seconds".

Here's an example of the first condition:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_248589720.png)

**When**

- "Machine" outputs: "specific attribute" "Spindle"

**If**

- "Machine Attributes" "spindle" "current value" ">" "Static Value" "Number" "100" "since last output"

**Then**

- "Set Activity History" field: "State" value: "Enum" "Running"

For every machine that has this type, this Trigger will look at the last value of an OPC UA field that is tied to the "spindle" attribute. If that value is greater than 100, the machine will enter the "Running" state (or continue being in that state)

Here's an example that uses timing:

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_248590114.png)

**When**

- "timer fires" "every 30 seconds"

**If**

- "Machine Attributes" "spindle" "current value" ">" "Static Value" "Number" "100" "now"

**Then**

- "Set Activity History" field: "State" value: "Enum" "Running"

If the spindle value is greater than 100, then the machine state will change to "Running".

**This trigger is evaluated every second.** Within a second of the value rising above 100, the machine state will change to "Running" and stay there until 30 consecutive seconds pass without a value greater than 100 (30 consecutive values)

## Changing The Value of a Field (ie Defect Count, Part Count)

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_195020626.png)

By changing the state, you automatically add a new row to the Activity History for each machine. But, you can also update each individual field for the machine and group it with that particular status.

For example, you might have a machine Trigger that updates the machine status between "Running", "Idle", and "Stopped".

Then, you might have a separate trigger that updates the "Part Count" when an OPC UA field changes its value.

You can update the "Part Count" field just like you might [update a variable](https://support.tulip.co/docs/data-types-in-tulip) in the Trigger Editor in the App Editor.

Here are the different fields you can update:

- State
- Downtime Reason
- Program
- Ideal Run Rate
- Defect Count
- Part Count

These fields are automatically updated:

- Start Time
- End Time
- Duration

There are two actions in a machine trigger that can update these fields:

- **Create Machine State:** Set the value of the State field.
- **Data Manipulation:** Gives the option to: Clear, Decrement, Increment, or Store a value to a field.

In the following example, "part_counter" is a Boolean Attribute that would be updated when the machine finished a part and updated the resulting OPC UA field.

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/How%20To%20Create%20Your%20First%20Machine%20Trigger_248590434.png)

**If**

- "Machine Attributes" "Spindle" "current value" ">" "Static Value" "Number" "100" "now"

**Then**

- "Data Manipulation" "Increment" field: "Part Count" value: "Static Value" "1"

This would update the "Part Count" field for the current status that the machine is in and it would be immediately reflected in the Activity History.

## Further Reading

- [How To Add Individual Machines to Tulip](https://support.tulip.co/docs/how-to-add-individual-machines-and-view-their-history)
- [How to Use Machine Outputs in the App Editor](https://support.tulip.co/docs/how-to-use-machine-outputs-in-triggers)

---

Did you find what you were looking for?

You can also head to [community.tulip.co](https://community.tulip.co/?utm_source=intercom&amp;utm_medium=article-link&amp;utm_campaign=all) to post your question or see if others have faced a similar question!

**Machine**

A **Machine**is a digital representation of a physical datasource. Machines have **Attributes**that are updated through an OPC-UA Connector or the Tulip API.

**Trigger**

**Triggers** are groups of logic that are tied to an app event, such as step open, timer, widget interaction, etc. App builders can add triggers to **widgets**, **machines**, **devices**, **apps**, and **steps**.

**Triggers** can contain **actions**, **transitions**, and **conditions**.

**Attribute**

**Attributes**are properties. In Tulip, an attribute generally references a property of a machine. Attributes can be either set points or actuals.

*Ex. Cycle time, Spindle speed, Feed rate, ect.*

**Machine Type**

**Machine Types** are global definitions of what data to expect from machines of different types. Each Machine Type will have different states, **triggers**, and **attributes**.*EX. We have 5 makes/models of CNC mill, but they all have the same set of attributes (Spindle speed, feed rate, etc.) These can all be combined into a single "CNC Mill" Machine Type*

**OPC-UA**

**OPC Unified Architecture** is a cross-platform, open-source, IEC62541 standard for data exchange from sensors to cloud applications developed by the OPC Foundation.

**Tulip Tables**

**Tulip Tables** are a global location to store your production data. **Tables** are made up of **Records** (rows). A single can be accessed from multiple apps or stations at the same time. ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Tulip%20Tables%20Overview%20-%20Feature%20Overview(1).gif)

**Table Record Field**

**Table Record Fields**are single columns within a **Tulip Table.**

![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Table%20Record%20Field(1).gif)

**Trigger**

**Triggers** are groups of logic that are tied to an app event, such as step open, timer, widget interaction, etc. App builders can add triggers to **widgets**, **machines**, **devices**, **apps**, and **steps**.

**Triggers** can contain **actions**, **transitions**, and **conditions**.

**App Editor**

The web interface used for building applications. Where you design a user interface, add logic, and connect your applications to **Tables**. ![](https://cdn.document360.io/7c6ff534-cad3-4fc8-9583-912c4016362f/Images/Documentation/Screen%20Shot%202022-09-13%20at%207.50.23%20AM.png)

**Boolean**

**Boolean's**are a Tulip Datatype. Booleans can have True/False (Yes/No) values.
