In this video we connect the Arduino OPTA PLC to the popular and powerful Ignition for Makers SCADA Software using the Modbus TCP Comms Protocol! This allows us to Build HMI Graphical Displays from tags on the PLC!
You can get your Arduino Opta here: https://amzn.to/4426ILO Download Ignition for Makers Here:
A PLC or Programmable Logic Controller is the staple of industrial automation and controls, and Arduino has made one of the most affordable ways to get into the industry! This micro-PLC has Relay outputs, and programmable digital or analog input and output channels as well.
It also supports Modbus OPC communications for easy integration into SCADAs or larger controls systems, RJ45 ethernet communications and WI-FI connectivity! Additionally there are no licensing fees to use the Arduino PLC IDE where you can program in Ladder, Structured Text, FBD, SFC or using the regular Arduino IDE/C++ based language!
Ignition for Makers puts an incredibly powerful, next generation SCADA software available for makers and hobbyists and learners to start developing industrial automation and controls skills for free!
Don't forget to leave a like, subscribe to the channel, and comment what you want to see next!
Hello and welcome back to Le Master Tech. In today's video we're going to continue our
introduction to the basics of controls and automation through practical tutorials. Today
we are going to take a look at tying a PLC into an HMI service and building your first HMI or
human machine interface. Our specific setup is going to be the Arduino Opta PLC using the Arduino
IDE, the PLC IDE, and we're going to talk to Ignition for Makers.
So we've previously done a setup video on how to get started with the Opta PLC
as well as your first structured text and ladder logic languages. We'll continue building on those
skills in this video. And then we've previously done how to set up Ignition for Makers.
So the basics, if you want to start from the same point that I'm starting this tutorial from,
would be have Ignition for Makers. It can run on any computer. It can run on your laptop.
Ignition for Makers and the Arduino PLC and PLC IDE hooked up, and we'll be in the exact same
spots when we start this video. So today we're going to look at setting the IP address of the
Arduino Opta PLC, setting up variables to talk over Modbus TCP, tying a Modbus TCP device into
Ignition, adding tags from that device, and building an HMI or human machine interface,
a graphical screen that looks at the PLC. You don't need any project built in either of these
already. So what we'll be starting from is an Ignition project that has no HMI. So we'll build
a brand new project together and an Arduino PLC that has nothing running on it other than the
base code that is on there when you load a new project on there. So I have this count
equals count plus one, which if we watch it live, you can see that is the only thing running on the
PLC is the default main code. So without any further ado, without me explaining to you where
we're starting and what we're doing, let's just get into some of the basics together. So up to
this point, we've seen a little structured text, we've seen a little ladder diagram,
but we haven't tied the PLC into anything. So what we want to do is we want to give this
Arduino Opta PLC, an IP address because Modbus TCP uses RJ 45 connection, it uses an Ethernet
connection to talk and send data over Modbus. And what's interesting is if you go to the resources
tab of your Opta project, and then you go to sketch, there will already be a commented out
section for configure IP address, which is really nice, super useful. So all we're going to do
actually is remove the comments. And this is actually just giving us what we need for it to
talk over the network. The only difference is we don't want to keep this IP address 192 168.1 is
kind of fine for home use. But usually, and if you're in any kind of industrial setting, they'll
have a different block of IPs they want you to adhere to super easy to adjust that you just type
in what you want the IP to be here. So I'll use 420 69 169. That's nice and secure. And then in
the gateway, I'll say 420 69.1, that would be pretty normal for a gateway on any sort of like
corporate network to be the same first three blocks as your as your device IP, but then dot
one for the gateway. So that's all we're going to do to set the IP address on on the machine. And
that's really simple. We don't have to do anything additional beyond that. But what we do want to do
so that this actually does something when we tied into ignition is we want to come into parameters
and we want to just add a few variables here that will actually be able to monitor from ignition. So
if you go to parameters, this is going to be your Modbus addresses. So if we just add four things
here real quick, we could add let's say we want to add some tags for monitoring the user push
button. So if you remember the Arduino optic PLC from previous videos, we have a push button on the
front and then we have some LEDs as well we have the red light we'll just call it red, we have the
blue light and we have the green light and it's important to note that we are not tying these
currently to the red light blue light green light or user push button. We're creating new variables
and we want to change them all to Booleans. But what we're doing is we're assigning those variables
to Modbus addresses where they'll actually populate when something that can read data over
Modbus TCP connects to these addresses. So this addressing is important when we get to the ignition
piece and we'll take a look at it. But right now they're not going to do anything because we haven't
tied them to anything yet. So let's take user push button red blue and green and let's tie them to
the actual values that they need to be tied to. And to do that we also want to come to LED outputs
and here we have LR and so we'll call that LR, LG, and LB. And if you've been following along
with the tutorial series you know why we're doing this piece. And if you aren't following along with
the tutorial series maybe consider doing that. But basically we are assigning the actual red,
green, and blue lights on the front of the Arduino Opta as well as the user push button
to variables that we can use in our main PLC program now. So if in here we just come in and
we say like first thing we want to do is set the red light to be equal to true, the green light
to be equal to false, and then the blue light to be equal to the state of the user push button.
So the blue light will change as we press and release the user push button. Then that would
give us sort of those four variables populated and then what we need to come down here and do
is we need to say blue should be equal to LB. So now we're taking our Modbus variables and we're
setting them equal to the status of the variables we're controlling in the program. So the first
lines were to actually set the state of our outputs. I'm trying to talk and type and that
never goes well. And then user underscore PB is equal to user. So to recap what we're doing here,
we're just telling the red light to be true, the green light to be false, the blue light to turn
on and off with the user push button, and then we're telling the blue, red, green, and user push
button Modbus variables that they should be equal to these variables that we're using in the code.
So if we download this to the PLC and we hit yes and compile, it should compile without error. I
don't always write perfect code but I'm not that bad at it. It'll want us to restart and that's
okay. And then we'll initialize and that's okay. Okay, so it looks like it completed.
If we connect to the PLC, we can also enter this cool mode that I don't think I explicitly
called out before called live debug mode. And this actually lets us see the value of all of
those variables. And what's cool is my PLC which is on some DIN rail and connected to a power supply
so it's a little harder to show on camera than before. But what's cool is you can see the red
light is on, the green light is off, and if I push the push button, the blue light turns on
and off with the push button. So that's cool. That means that the PLC program took
and we should be all set now to actually tie it into Ignition. Okay, so let's go ahead now. We
have an IP address set on this. We have a few variables that we can address here in our Modbus
addresses. So let's jump over to the Ignition gateway. So you go to your web page. I have a
mine very secure. Alright, so for a Modbus device, it's a little different than adding most
like tier one PLC manufacturers. Most Alan Bradley Siemens back off devices like major PLC
manufacturers that you talk to, you may go to OPC connections and create a new OPC connection.
But if you have a device using a slightly older or slightly less common communication protocol,
a lot of that times you're just going to go to config and then you're going to go to
device connections instead. And for us, we'll create a new device, you can see a lot of their
default browser, default data types that they have in here. And we're just looking for Modbus
TCP. Okay. And it's cool. It just needs a name and then a description. It can be
first Opta PLC to ignition for description, that part's optional. And then here you can enter your
IP address, that's all you need to enter. And then port 502 is by default, you can leave that be and
that should work. And just go ahead and create new device, you don't have to look at any of the
advanced options or anything like that. If you hit Create device, and it says connected your money,
if it says failure to connect, it may give you a reason why here it may give you information,
you can try to open the command window, and you can try to just ping, you can try to just ping
your IP address. And you should be able to get a reply from it. If you haven't, I didn't explicitly
call this out, make sure your network adapter is on the same subnet. So make sure your laptop
that is plugged into your Arduino, or whatever computer is plugged into your PLC, make sure that
Ethernet port is on the same 420.69 or whatever you're using, make sure it's on the same subnet
because ignition can't see devices on different subnets unless you open them up and configure
your network that way. The industrial networking side of controls and automation might be the least
fun part of the job. But important thing while we're here on the device, it says connected,
and that's awesome. But if we were to like, for example, use the OPC quick client,
to try to browse the opta for tags, we have basically nothing we have diagnostics, which
is nice. And it's proof that the device connected, but we have no useful data, we can't find those
four tags that we added, because they don't exist yet. Because after you add a Modbus device,
you have to hit more and you have to go to addresses. And then you need to add a row of
the tags that you want to read from. So if for us specifically, and find my notes, good, we want to
go add row. And then if we look back at the Arduino PLC, we started at 16384, which means back in
ignition, minimize this, we can go to prefix. And here's where you just call it something you want
to reference this. So we'll call we'll just call it opta tags is fine. We'll start from one and
we'll go to four because we only have four tags. And then you give it a unit ID. This part doesn't
matter so much. I've used 255 multiple times. It really doesn't matter. You can put any unit ID
number you want here. You just need to remember what that is when you're looking at the tags.
This is the part that matters. 16384 is where it starts. So now it knows to grab 16384 and then go
four bytes or words or addresses registers is what they're called from the first 16384. So if we hit
save, disconnected should turn to connected pretty quick. And now the difference is if we go to OPC
quick client, and we go to devices and the opta and now we have unit ID 255, which we just added
opta tags one through opta tags four. And now if I subscribe by hitting this little s on all four of
those down here in the bottom window, it shows me the value of all four of those tags. It'll take a
second to update because this is not the fastest tool. This isn't like scanning the tags live.
But you can see we have 0100. If we were back in the Arduino PLC, we know that correlates to the
red light, the blue light and the green light. So if I were to go ahead and hold down the user push
button, you can see that zero the first tag and the third tag both turn to one because that's me
pushing the user push button and the blue light turning on. So that's cool. Now we have tags that
live in the PLC that are reading to ignition. We haven't built an HMI yet, but we've verified that
we can get tags into ignition. So that's half the battle. It's actually over half the battle.
So let's go to the designer launcher now, which is for ignition. That's where you,
you know, build your visualization. And let's go ahead to our ignition session. Let's open the
designer and we're going to make a new project together so that we can do every step of this
together. Username will be the master tech because it's cool.
This is top secret and definitely totally different. Okay, so rather than open Arduino
PLC tutorial, but I promise you there's nothing in there. We'll do Arduino opta HMI.
Project must start with a letter or underscore and contain only. Okay, so it'll be Arduino
opta HMI like that. Smushed together. We'll copy that three times. I don't need to inherit
anything. Leave all these as defaults. Let's just create a project. Okay, so should be pretty
similar to the default window you get when you open this up. Let's just go to perspective and
let's go to views and let's right click and hit new view and we will just call this homepage.
Okay, so it's going to give you a default window. I'm going to hit save real quick force of habit
like every three seconds. I impulsively do control s and hit save. You don't have to
perspective components. Let's go over on the right. You should have a little palette here.
If you ever want to play around with the tools and toolbars and ignition, feel free to. There's
always adding new features to this stuff, so it's not a bad idea to comb through toolbars
and check for updates and whatnot, but I use labels for a lot of stuff. So for this label,
let's just call this our Arduino opta PLC and let's take three seconds real quick to make this
label kind of look like our PLC. Okay, I'm going to go to style over here on the right. I'm going
hit plus and I'm going to go to background color and I'm going to make it dark gray and I guess
actually before we get too deep into this or while I'm building this, we'll also go to style.
We'll go to color, just just color and we'll make the text color white and now I'm going to make it
a little bit bigger because I'm going to drop a bunch of images and icons on it and then I'm
going to align vertical top. So now I have this rectangle. I'm going to drop inputs and outputs
and lights and statuses on this HMI so that it looks like the PLC. I'm going to hit save and I'm
going to pause for just a second about what an HMI is meant to be and what you want to put on an HMI.
So HMI, human machine interface, is what a conventional software programmer would refer
to as their GUI or graphical user interface. It is where the person interacts with a virtual system
so that they can control the outputs and monitor the inputs and interact with the physical system
from an easy to use and easy to understand screen. So while it may look like I'm kind of rapidly
building a thing and it's sort of like PowerPoint, the important extra piece to know is that you're
linking tags and you're creating animations of objects based on those tags and the animations
of those objects as well as the output actions from clicking on buttons and things like that
should go back and affect your PLC. So in addition to reading things like the statuses of lights
and the status of your push button, you can also click buttons from an HMI that go and activate
sequences in the PLC. So for basic first step, let's tie those three lights and the push button
in so that we can get an HMI just working and then we'll start building sequences that really
show how powerful this is. So let's go into Icon and let's look for a light. I went into
Perspective Components. I know some of these tabs are a little small and I'm going kind of fast.
I went to Perspective Components and I grabbed an Icon. There's Symbol Factories, Drawings, you can
import SVGs, you can do a lot of different ways in a lot of different HMIs. There's also different
syntax and all these different icons and whatever. But icons are kind of nice in Ignition because
they're all simple objects just like circles or smiley faces or light bulbs and they're pretty
easy to animate. So like if I want this to be tied to the user push button, I can grab it and I
can say that I want to add a custom property that I'll call Tag and I'll put a tag path in here
in just a second because I haven't added my Ignition tags yet. But what I want is the color
of this button to change with the tag and to do that I'll go to Indirect, which means I'm calling
a parameter on this tag. Again, I do several Ignition tutorial introductions videos on
my channel. It would take a lot of time to do all of the basics of Ignition and then a practical
example together. So to keep this tutorial moving I'm not going to deep dive every concept that
we're doing but I will try to still gear this at beginners. But basically we're going to do an
indirect tag binding, click the sort of hamburger menu over on the right and go to View, Route,
Icon 0. Icon 0 is actually what we're working on. You can see that highlighted on the left.
And then Custom Parameters and then Tag. But what it really shakes out to is the tag path is curly
brackets around Tag and then the property is this.custom.tag. All I'm saying is I'm going to
grab a tag that I just want to pass in that text field and I'm going to add one transform which is
just going to be map the true false boolean of whether or not the button is pressed to a color.
So the output will be the color and the input will be the value. And what I'll do is I'll say
if it's true then I want it to be, it's a push button so color doesn't actually change. Let's
say if it's true then I want it to be black, if it's false I want it to be light gray, and if I don't have
any reading I want it to be white. Okay so it's white right now because there's no tag which is a great
opportunity for us to go and add our first tag. So I'm going to hit the little plus in the Tag
Browser menu on the left side of Ignition and I'm going to say Arduino Tags and I'm going to make a
new folder. Now I'm going to browse devices, I'm going to expand out my devices, go to the opta,
go to unit 255, and I'm going to add opta tags one through four to my Arduino Tags folder. Okay
and what you probably can see so that a little arrow populates and all these zeros and ones
populate, Modbus by default is going to call pretty much everything a short when you add it
but these are all booleans they're lights and push buttons so I can I can select all the tags
right click go to edit tags and at the same time I can make them all boolean so I can bulk edit
all of these tags. I could change them all to arrays or strings or whatever at the same time
I can make them all booleans and hit okay or apply and they'll all update to be booleans.
Now opta tags one through four isn't that useful and if we go back to our PLC you can see that
it's user push button and then red blue and green so what I'm going to do is I'm going to rename
these user underscore push button as the name and then red and then green
and then blue okay cool so now close now I can right click on user push button
and I can go to copy path and I can paste that path right here control v into tag and now you
can see hopefully you can see that went from gray to uh or that went from white to gray because now
the tag exists now I'm going to push the button now on my HMI or on my PLC and you can see it
changes to black that's really cool I think it's really cool if you don't I don't care
now let's get rid of this smiley face because we're not using it and let's add in some additional
stuff so this is the push button which is cool let's go ahead and just add the three lights as
well so the blue light on the PLC is kind of physically right above it so let's say if that
one's true we want it to be blue and then let's copy this over here and the green and red lights
are actually in the same spot so I'll just put them right next to each other so that we can see
two different lights and let's say that this one should be green okay and this one should be red
so all I'm going to all I'm doing is I'm changing the linking the color animation on these circles
to be different colors but now I have to go and I have to copy that tag path so I copy the path
for blue and I'm going to replace user push button with blue but what's cool is the way we
did that custom tag pathing this will now update just when I click the blue button but what you'll
see is right now I've only updated the blue light and not red or green so when I push the button
okay all of them except blue updated so my blue light tag is not actually working let's check that
out in the code we'll live debugging together oh yeah I called the green light blue and the blue
light green that can get you in trouble if you're not very careful about the order that you do things
in so we'll correct this to blue we'll move this to green so basically what happened there is
because the optitags got added as optitags one through three I misnamed I got blue and green
backwards so now if we go in here and we correct this tag path to be just tied to red
okay and then this tag path to be just tied to green
okay we have now if I push the button you can see the black button getting pushed in and the
blue light turning on at the same time if we were to go back in the arduino plc let's say
and just change from lr being equal to true to setting lr equal to we gotta go offline
let's say we want lr to be false now and we want lg to be true and we want to compile that and say
yes and send the new code now we should be able to go to yep we can go to our plc I can push the
button in and I can have blue and the blue light turns on and then the green light turns on
and red never turns on because of the code that we have running on it so this is really cool we
have an arduino plc connected to ignition and we've built our first hmi actually looking at
tags off of the ignition plc so in the next video I think what we'll do is we'll build
multiple sequences in ladder logic and structured text that actually interact back and forth with
hmi so we'll take a look at controlling sequences from the hmi reporting statuses
doing enumeration and a lot more interesting skata hmi plus plc development together so
today's video was a great way to get you connected get tags reading back and forth
if you're a somewhat competent programmer this can be a fun spot to play around and explore with
animations and things like that but this is really also the legwork so that the next
uh chunk of this tutorial series can move along really well and we can focus on programming and
we can focus on hmi development and we don't have to get all of the basic interconnections done
so I hope you found this video useful I hope you've been finding this tutorial series useful
I have really been enjoying using ignition for makers and the arduino opta plc all right so I'll
leave you with that I'm looking forward to the next video please leave comments with any questions
on what you saw here today or things you want to make sure we cover on future videos on the channel
I appreciate all the support and as always good luck with your projects and thanks for watching
we'll see you next time thanks bye