Trigger Messages Using Bits of a Variable
Messages are triggered by a state change in the PLC. If HELIO detects such a change, it'll add the corresponding message to the list of Active Messages. Once the condition changes again, the message will enter the Message Archive.
Here's where it gets really handy — HELIO takes care of all the low-level tasks like setting up databases in the background, so all you need to worry about is defining the messages and the trigger rules that tell HELIO when to actually trigger them.
In this first step, we'll look at the simplest way to trigger a message: by toggling the bits of a Data Variable.
1. Create a PLC Connection
Our first job is to create a PLC Connection and bring in some variables.
PLC Mode is Required!
It is not possible to trigger messages using Placeholders for Offline Editing.
- Download & Start the
Playground PLC
Setting up a PLC that we can connect to sounds pretty complex, right? It's a software-based demo PLC that you can download for free and
run on your development computer right away. A handy tool when you want
to learn how to connect HELIO to an industrial machine that
communicates using OPC-UA. → Download the latest version and start it.The
HELIO Playground PLC
Got Your Back
- Add the Connection
Good job on getting the PLC set up and running. Let's keep going:
- If you haven't set up a new project just yet, now is a great time to Create a New Project.
- Open your new project in the Project Editor and switch to the Data View.
- In the Data Source Explorer, add a new OPC UA Connection using the default settings.
- Explore the Structure
2. Import Trigger Variables
Next, we need to create a variable that we can use to trigger messages based on certain bits. Fortunately, there's already one we can use. Let's add it to our project.
- Locate the
BitSet/AsInteger
Variable
Locate the variable in the Data Source Explorer.
You should spot it under:
Objects > Examples > Concrete > Messaging > ProcessVariable
.
- Import the Variables
Let's import
the variable into your HMI Data so that we can use it in our
project. Since we are also going to use the two additional helper variables
called The two helper variables are needed so that we can set the
bits of our actual Process Variable SetBit0
and SetBit1
, simply import the whole ProcessVariable
folder.Why Do We Need those Helper Variables?
BitSet/AsInteger
. In a real project
this is of course done by the PLC when certain conditions are met.
- Loosen Restrictions
To be able to write those variables, make sure to loosen the restrictions of the variables, so that we can read and write them.
Your HMI Data Explorer should look something like this:
3. Define Message Types
Now that we've got the source, we need to figure out what the actual message
should be. Let's get started on creating some Message Types
.
- Add an
Information
Message
- Switch to the Message Types View view
- Choose the
Add Type
action and enter the details for our first message - The first message we are going to trigger is an Information message, so
let's choose
INFO-1
as the code and choose the appropriate level.
- Add a
Warning
Message
4. Setup the Triggers
Now that we've got a possible source, we need to define an actual Message Type that will get triggered and displayed.
- Add Your First Trigger
Switch to the Message Triggers View view, click
the Add Type
action and choose Process Variable
as a trigger type.
- Configure the Trigger
Our first trigger is going to show our INFO-1
message whenever the bit
with the 0
index of our variable is set.
- Make sure to choose the right
Source
variable. - Enter the
Code
that goes with the message we just talked about. - As the
Condition Bit Index
you'll want to choose the0
here because the condition should be watching the first bit of this variable.
- Add Your Second Trigger
5. Create a Simulation Page to Trigger Messages
The excitement is building because we're all set to start sending messages to our HMI. All we need to do is create a small page to simulate the whole thing. Thanks to HELIO, it's pretty simple. So let's get started!
- Add a Page
First things first, we need to create a page. To keep it simple, we're just going to create a basic Parameter Page:
- Switch to the Content View.
- Add a Parameter Page.
- Add two Magic Inputs and connect them
Next we're gonna need two Magic Input elements so we can toggle our Boolean (Data Variable Type) simulation variables we imported into our HMI in a previous step.
Once one of those variables is enabled, the PLC will set a bit in our
Bitset/AsInteger
variable, which will then trigger our message.
- Select the
Parameters
slot and add two Magic Input elements - Connect the
Value
property of the first one with the/BitSet/SetBit0
and the second one with the/ProcessVariable/BitSet/SetBit1
variable
- Simulate the Messages
Let's Get Those Messages Fired Up!
- To connect to the actual PLC data, just switch to
PLC Mode
. - Switch to
Test Mode
so you can toggle the inputs. - Activate each of the two bits by toggling the inputs and you'll see the messages pop up.
Your HMI should behave something like this…
You've created your first message types and triggered them using an actual PLC. Ready to learn more how to display all active and archived messages? Check out the next step of the guide…