Intro to Controls and Automation Engineering Full Course! — Transcript
Full transcript
- 0:00Hi, I'm Pete LeMaster, creator of the
- 0:02LeMaster Tech YouTube channel, and for
- 0:04the last 10 years, I've been working in
- 0:06industrial automation and controls
- 0:08engineering. This is a field I feel very
- 0:10passionately about. It's an often
- 0:12overlooked or seldom talked about in
- 0:14university field of engineering. It's
- 0:16adjacent to what some may call
- 0:18mechatronics or robotics, but in
- 0:21particular, it's in an industrial
- 0:23setting, and it's the hidden backbone
- 0:24driving all of manufacturing forward
- 0:27worldwide. Last 4 years since starting
- 0:30my YouTube channel, I've slowly been
- 0:31trickling certain videos and tutorials
- 0:34on this field out on the channel, but
- 0:36never really painted a comprehensive
- 0:38picture of a crash course start here how
- 0:41to become and how to learn about
- 0:43controls and automation engineering.
- 0:45Until now. In this tutorial series, we
- 0:47mix talking about concepts with actual
- 0:50practical hands-on exercises using free
- 0:53software and very affordable hardware,
- 0:56so that you can learn about PLC
- 0:58programming, SCADA and HMI development,
- 1:01SQL and historian, electrical
- 1:02schematics, in an approachable and
- 1:05affordable way. This video is a
- 1:0717-chapter video, and while I do believe
- 1:10they play logically back to back, you do
- 1:12not need to watch the entire 5-plus hour
- 1:15video in one sitting. You don't have to
- 1:18watch it in order if you find more value
- 1:20in certain concepts than others.
- 1:22There'll be timestamps and chapters
- 1:23breaking up everything as you go. The 17
- 1:26videos were recorded over the past 4
- 1:28years since I started my YouTube
- 1:30channel. While I do think they play in a
- 1:32logical order, not be always the
- 1:34smoothest flow between one video and the
- 1:36next. By the end of this video, you
- 1:38should have a really great comprehensive
- 1:41understanding of the basic concepts of
- 1:43what is controls and automation
- 1:45engineering, feel confident that you've
- 1:47been exposed to the basic concepts of
- 1:49the field, and feel empowered to go out
- 1:51and further your depth of knowledge in
- 1:53the field. It's an incredibly important
- 1:55field of engineering. I feel very
- 1:56passionately about it, and I'm very
- 1:58excited to bring you this series.
- 2:00useful, please consider leaving a like
- 2:02on the video, subscribe to LeMaster Tech
- 2:04on YouTube, and thank you so much for
- 2:06watching. Enjoy the series.
- 2:14By the end of this course, you should
- 2:16have an excellent understanding of what
- 2:18controls and automation is. You should
- 2:20also be pretty familiar with what
- 2:22industries and companies would be
- 2:23looking for these skills and trades, be
- 2:25equipped to know whether getting into a
- 2:27career in this field or an education in
- 2:29this field is something that would
- 2:30interest you. And lastly, you should
- 2:32feel very equipped to know the right
- 2:34ways to get more information if you're
- 2:36curious in pursuing this field further.
- 2:39So, for episode 1, introduction to
- 2:41controls and automation engineering
- 2:42today, what we're going to cover is what
- 2:44controls and automation engineering is,
- 2:46the tools and technologies as well as
- 2:48some lingo that you'll need to know, the
- 2:50biggest industries that need automation,
- 2:52average salary ranges you can expect.
- 2:54So, if you're completely new to the
- 2:55field, in just a few sentences, what is
- 2:58controls and automation engineering? In
- 3:00my words, it's the field of engineering
- 3:02pertaining to improvements to a process
- 3:04by increasing throughput and
- 3:06manufacturing speed, increasing safety
- 3:08and system reliability, or both.
- 3:12And this is most commonly achieved by
- 3:14writing code for a dedicated industrial
- 3:16computer known as a programmable logic
- 3:19controller or PLC that controls input
- 3:21and output devices referred to as IO,
- 3:24and often interfacing with the engineers
- 3:27and operators through a human-machine
- 3:29interface or HMI. There's a little bit
- 3:31of industry lingo in there, but the
- 3:33essence of it is we make things faster,
- 3:35higher quality, or safer. And ideally,
- 3:38we would do all three. So, bit of a
- 3:40funny meme here, um but I think it's
- 3:42actually super applicable. A controls
- 3:44and automation engineer most commonly is
- 3:46not something you go to school for, at
- 3:49least not specifically for. You have to
- 3:51have enough mechanical or chemical
- 3:53knowledge to be able to be helpful in
- 3:56the process that you're automating, but
- 3:58you also have to have enough electrical
- 3:59engineering knowledge that you'll know
- 4:00what you're doing with a panel design
- 4:02schematic. But you're also going to have
- 4:04to be enough of a software developer,
- 4:06computer science engineer to be able to
- 4:08write some functional, elegant, easy to
- 4:11read, and easy to debug PLC code. And on
- 4:13top of all of that, you're going to need
- 4:15to dip your toes in the IT field of
- 4:16knowing a little bit about industrial
- 4:18networking. And it's not that you have
- 4:20to enter the field with all of these
- 4:21skills, but you should enter the field
- 4:24with some of them and be ready to learn
- 4:26the rest of them. So, some of the key
- 4:27technologies and tools of the trade,
- 4:29words that you will absolutely need to
- 4:31be familiar with if you have any
- 4:32interest in getting into this field or
- 4:34knowing about the field. The
- 4:35programmable logic controller, the PLC.
- 4:38There are definitely some industries
- 4:40moving towards an industrial PC, which
- 4:42is just like a really robust computer
- 4:44running Windows sometimes, or even some
- 4:47smaller automation systems now relying
- 4:50on microcontrollers like a Raspberry Pi
- 4:52or an Arduino if it's a really simple
- 4:54application. But far and away, the
- 4:56industry standard for years and years,
- 4:58and likely continuing for years and
- 5:00years to come, is the programmable logic
- 5:02controller. There are so many
- 5:04manufacturers of PLCs. The biggest ones,
- 5:07and if you're in the US, the ones you'll
- 5:08almost certainly get exposed to at some
- 5:10point, Allen-Bradley, Rockwell, ABB.
- 5:13Those are kind of three of the giants,
- 5:15but there are so many companies that
- 5:17make PLCs as well. Mitsubishi,
- 5:19Panasonic, Wago, um to name a few.
- 5:23There's There's more. And so, a PLC is a
- 5:26specific type of computer optimized for
- 5:29high reliability, synchronous
- 5:31programming, meaning time-cycled code,
- 5:34and converting commands to electrical
- 5:36signals to control devices known as
- 5:38outputs, and read electrical signals
- 5:41back from devices known as inputs.
- 5:43Specific programming languages exist to
- 5:46write code for these PLCs. The most
- 5:48common two, and the two that you should
- 5:49have on your radar right off the bat,
- 5:51are ladder logic and structured text.
- 5:54Ladder logic looks a lot like relays and
- 5:57kind of an electrical-based programming
- 5:59language. It's very visual. It's like a
- 6:01flowchart, um that combines programming
- 6:04concepts with electrical concepts. And
- 6:06structured text is somewhere between
- 6:08like a C++ C# Python hybrid, more of a
- 6:12traditional programming language to
- 6:14where people with a software background
- 6:16often feel more comfortable writing in
- 6:17structured text. People with a
- 6:19mechanical or electrical background
- 6:21often pick up ladder logic. But to talk
- 6:23a little more about input and output
- 6:25devices, there are really only two types
- 6:27of input and output devices here, and
- 6:29I'm simplifying, but this is a crash
- 6:31course. Digital inputs and outputs are
- 6:33also known as discrete, Boolean, on-off,
- 6:38binary. Think just a simple light
- 6:41switch, an on-off light switch where the
- 6:43light bulb turns on or turns off. It's
- 6:46only two states, and examples of this in
- 6:49the field could be a start-stop pump or
- 6:51motor, a valve that is open or closed,
- 6:55and information back like a light that
- 6:58is either on or off, a push button that
- 7:00is either pressed or not pressed.
- 7:02Discrete, digital, on-off, or analog
- 7:06inputs and outputs, aka variable range,
- 7:090 to 100% position control. And for
- 7:12this, you can think of like a dimmer
- 7:14switch in your home where there's a 0 to
- 7:16100% setting, and the variable range is
- 7:20known as analog. So, in process, the
- 7:23most common ones you might see for
- 7:24inputs are like temperature sensors,
- 7:27flow sensors, pressure sensors. And the
- 7:29most common outputs you might see are
- 7:31like uh pumps that can ramp up in speed
- 7:34known as variable frequency drives, or
- 7:37motors that have adjustable speed
- 7:38parameters, or 0 to 100% open control
- 7:41valves. And a lot of devices now are
- 7:43smart enough to actually use an advanced
- 7:45communication protocol like Ethernet,
- 7:48EtherCAT, Profinet, Modbus TCP/IP, just
- 7:52to name a few. There are a lot of
- 7:53others, but even when you boil it down,
- 7:56if they are talking over those advanced
- 7:58communication protocols, the end devices
- 8:00you're interfacing with still typically
- 8:02fall into either digital or analog.
- 8:05Determining what type of IO you have and
- 8:07how many total points you have typically
- 8:09is one of the key drivers in a lot of
- 8:11the hardware decisions you'll make in a
- 8:13project. And one of the last huge things
- 8:16you need to be aware of is the
- 8:17human-machine interface or HMI. Some
- 8:20very simple systems might be
- 8:22controllable just from a few push
- 8:24buttons or indicator lights, and not
- 8:26actually require custom graphics to be
- 8:28made, but the vast majority of
- 8:30automation systems are going to require
- 8:33well-designed, simple, and easy to use
- 8:35HMI graphics. Software developers and
- 8:38people with a programming background
- 8:40might think of these as GUIs or
- 8:41graphical user interfaces, but in the
- 8:44industry world, because you're
- 8:45controlling machines, the phrase
- 8:47human-machine interface or HMI is
- 8:49typically used more often. And these can
- 8:51range from simple displays with a few
- 8:53buttons or device statuses to super
- 8:56complicated plant overviews with
- 8:58thousands of data points being pulled
- 8:59back in. A standalone HMI, a very simple
- 9:02display, could be used to control one
- 9:04piece of equipment, sometimes called a
- 9:06skid, but a complicated graphical
- 9:08display environment with embedded
- 9:10trending and alarms and security is
- 9:13typically going to fall more in the
- 9:15category of a SCADA or supervisory
- 9:18control and data acquisition system.
- 9:20Which brings us to the supervisory
- 9:22control and data acquisition system.
- 9:24Plus, we're going to talk about the
- 9:26whole automation pyramid thing. This is
- 9:27kind of a very important concept that's
- 9:30really a lot of jargon, but it does
- 9:32actually hold true for the industry.
- 9:35Supervisory control and data acquisition
- 9:37system, more commonly called a SCADA, is
- 9:39like a blend of the HMI that allows
- 9:42operators to interface and control with
- 9:44devices, but also like a corporate
- 9:46software tool that can pass data up to a
- 9:49data aggregation system. But what you
- 9:51need to know about the automation
- 9:52pyramid is basically every control
- 9:54system has the lowest two levels, the
- 9:56field level, meaning devices that are
- 9:59being controlled and giving you
- 10:00feedback, and the control level, which
- 10:02is like where your PLCs and smart
- 10:04devices and switches and networking
- 10:06live. And then very often a plant or a
- 10:08system will stop at the supervisory
- 10:10level. So a SCADA might be as high as a
- 10:13plant goes. Not everyone has an ERP
- 10:16controlling production, and not everyone
- 10:18has an MES for data aggregation, but
- 10:20that is technically the automation
- 10:22pyramid. That's enough about that for
- 10:24now. Let's move on. Other things to keep
- 10:27on your radar, we're not going to do a
- 10:28deep dive in episode one. Industrial
- 10:30networking standards and protocols are
- 10:32very important. Basics of servers,
- 10:34operating systems, and
- 10:36computer-to-computer communications are
- 10:38super important as well. Industrial
- 10:40control panel design and electrical
- 10:42schematics, we talked about this a
- 10:43little bit earlier, but that is
- 10:44guaranteed to come up in a career as an
- 10:47automation engineer. Data reporting and
- 10:49logging, historian, SQL database,
- 10:51creating Power BI reports and trends,
- 10:54these types of things are also super
- 10:56important, and there's so much more, but
- 10:58not for lesson one. So now you know a
- 11:00little bit about what it is, but is this
- 11:02in demand? Where could you work if you
- 11:04did this? And I honestly encourage you
- 11:06if you're curious about that, to spend a
- 11:07little time on LinkedIn or just Google
- 11:10poking around and seeing if your
- 11:11favorite companies need an automation
- 11:13engineer. Because if you just type in
- 11:15blank company automation and controls
- 11:18engineer, odds are something is going to
- 11:20pop up. They're very in demand, and
- 11:22because it's a slightly more niche field
- 11:24of engineering, if you have some of
- 11:26these skills, a lot of the time you can
- 11:29get an interview and get your foot in
- 11:30the door with some pretty big companies
- 11:32pretty quickly. While most of the time
- 11:34this job is not going to be fully
- 11:35remote, there are definitely a lot of
- 11:37hybrid opportunities out there in pretty
- 11:39much every city in the world and every
- 11:41company in the world to some extent that
- 11:43does manufacturing or anything
- 11:45industrial will need some automation and
- 11:47controls engineering. So if you're
- 11:49heading to school and you're thinking
- 11:51about getting this field or you're an
- 11:52undecided major of engineering, and
- 11:54you're thinking about going to this
- 11:56field, should you go specifically for
- 11:59controls and automation engineering? I
- 12:01would actually say not really. It's just
- 12:04my advice, and you do not have to take
- 12:06it, but I think getting a mechanical
- 12:08engineering degree, an electrical
- 12:10engineering degree, a computer science
- 12:12degree, a broad field of engineering
- 12:14degree, and focusing on electives,
- 12:17school projects, and internships or
- 12:19co-ops that help get you in this
- 12:21direction is actually probably going to
- 12:23be better for you in the long run, than
- 12:26looking for a hyper-focused degree like
- 12:28controls and automation engineering. I'm
- 12:30not saying you won't love the field of
- 12:31controls and automation engineering, but
- 12:33I am trying to say that a mechanical
- 12:35engineer who wants to get into controls
- 12:38can usually do it. A controls engineer
- 12:40who wants to go be a mechanical engineer
- 12:43can't usually just make that switch. And
- 12:45most places are looking for individuals
- 12:48with a four-year engineering degree for
- 12:49their automation and controls
- 12:51engineering roles, but they're usually
- 12:53very open as to what specific
- 12:55engineering discipline those people
- 12:57have. They're far more focused on
- 12:58finding driven and motivated individuals
- 13:01with some practical on-hand knowledge.
- 13:03So if you are an automation and controls
- 13:05engineer, what can you kind of expect
- 13:07your career path to look like? And the
- 13:09two most common types of controls and
- 13:11automation engineer are either an
- 13:13integrator or an internal resource to a
- 13:16company. And an integrator is
- 13:18essentially an engineering contractor.
- 13:20There are a lot of companies that don't
- 13:22have the internal resources to do
- 13:24large-scale automation upgrades and
- 13:26projects on their own. So companies like
- 13:28RoviSys, my first job, uh and other
- 13:31similar companies will be called into a
- 13:33big factory to do a large automation
- 13:36project. Integration can be very
- 13:38intense. It's project-driven, so a lot
- 13:40of the time there will be slower periods
- 13:42as you develop systems in the office,
- 13:45and then very intense periods of travel
- 13:47and long hours as you commission systems
- 13:50on site. But these organizations are
- 13:52often very focused on controls and
- 13:54automation, and they promote from
- 13:55within. So if your main goal is to rise
- 13:58to the top of a company, you might want
- 14:00to look for a company that is primarily
- 14:02engineers doing what you're doing,
- 14:04because your odds of making it to
- 14:05manager, director, senior levels are
- 14:08probably better at an integrator. But on
- 14:10the flip side, as an internal resource,
- 14:12there's often a much smaller team of
- 14:14automation and controls engineers. A lot
- 14:16of the time that comes with larger
- 14:18responsibility, or more people looking
- 14:21to you to take on whole system
- 14:23ownership. At my second company, I was
- 14:25one of two controls engineers and the
- 14:26only one on site, so anytime an
- 14:28opportunity for automation or controls
- 14:30arose, it was on my shoulders. This was
- 14:33a mix of awesome responsibility and
- 14:35quite a bit of stress. But these
- 14:37organizations could be larger and much
- 14:39broader than just an automation firm,
- 14:42and for that reason, you could get tied
- 14:44up in your career path in layers of
- 14:46bureaucracy, and find yourself kind of
- 14:48stalled as a senior engineer unable to
- 14:50move into management or break any
- 14:52higher, because you're at a company that
- 14:55does a lot of different things, not just
- 14:56automation. So now let's take a look at
- 14:58salaries and typical controls and
- 15:01automation engineering salaries. I want
- 15:03to caveat this with I am talking about
- 15:05US-based. I don't have a good
- 15:07understanding of the international
- 15:09salary ranges and how they vary. If
- 15:11you've had a wildly different
- 15:12experience, higher or lower, let me know
- 15:15about it in the comments below. So most
- 15:17interns and co-ops in this position are
- 15:20finding paid internships. They're kind
- 15:22of on the low end. The Midwest, maybe
- 15:24the lower markets for this field, might
- 15:27find 16, 17, the high teens per hour,
- 15:30but there are internships paying in the
- 15:32high 20s as well. Most new full-time
- 15:35hires right out of school with an
- 15:37engineering degree doing automation and
- 15:39controls engineering can expect to be
- 15:41around the $70,000 benchmark. There are
- 15:44definitely companies hiring higher than
- 15:46that, sort of right on par with the
- 15:48average of most engineering disciplines
- 15:50right now in the US. Once you're in the
- 15:51middle of your career and you've been
- 15:53technical for 5 to 10 years, you can
- 15:55kind of know you're at a decent spot
- 15:57right now if you're around the $90,000
- 16:00mark. Now as you get kind of beyond the
- 16:0210-plus years, there's kind of two paths
- 16:04at this point. You've entered management
- 16:07and you're like an engineering manager
- 16:08or director, or you're still technical
- 16:11like as a senior or lead engineer.
- 16:13Technical resources typically just make
- 16:16less money than management resources.
- 16:18That's the nature of industry. But even
- 16:20as a technical resource, once you're in
- 16:22kind of deep into your career, 10 or
- 16:24more years, you should be finding
- 16:26yourself into six figures in 2024. I
- 16:29consistently found that mid-career
- 16:32controls and automation engineers were
- 16:34averaging around $110,000.
- 16:36And this is where the ranges start to
- 16:39get really wide. And of course, if
- 16:40you're an engineering manager or
- 16:42director, you can expect to be outpacing
- 16:44that a little bit. Again, some things
- 16:46like stock incentives and bonuses cannot
- 16:48really be captured in these numbers, but
- 16:51if you're in management and automation
- 16:53controls engineer, you can expect that
- 16:55you'll be doing pretty well. But kind of
- 16:57a truth of engineering is that you'll do
- 17:00very well for yourself, and it's not a
- 17:02path to instant and immediate riches. So
- 17:05it's a great salary, it's a good field
- 17:07option, but it might not be the single
- 17:09highest-earning field that you could go
- 17:11into. And so that pretty much wraps up
- 17:13episode one, introduction to controls
- 17:15and automation engineering. And I wanted
- 17:17to finish some free and cheap ways to
- 17:20learn more about the field. I have to
- 17:22first plug the RealPars YouTube channel.
- 17:25It's kind of funny as a YouTube channel
- 17:26to tell you to go watch a different
- 17:28YouTube channel, but they have so many
- 17:30short videos on just individual concepts
- 17:34of controls and automation engineering.
- 17:36Almost their entire page is dedicated to
- 17:38controls. They have really compelling
- 17:41animations. They're not sponsoring the
- 17:43channel. I'm not being asked to plug
- 17:45them or anything. Um they're just a
- 17:47really good YouTube channel. If you
- 17:48search anything like what is a PLC,
- 17:51they're probably going to be the top or
- 17:52one of the top results. I really like
- 17:54the RealPars YouTube channel. We'll see
- 17:56you next time. Good luck with your
- 17:57projects. Thanks for watching. Bye.
- 18:05In today's video, I'm going to show you
- 18:07the basics of the most important
- 18:09components of controls and automation
- 18:11hardware. In this video, we're going to
- 18:13cover everything from main power coming
- 18:15into a panel to power supplies and
- 18:18transformers to terminal blocks. Then
- 18:20we'll look at the PLCs including inputs
- 18:22and outputs, as well as relays and
- 18:25networking components. There's no way to
- 18:27cover all of the intricacies you could
- 18:29see in controls and automation hardware
- 18:30in one video, but this video should
- 18:32hopefully give you a basic understanding
- 18:34of most of the core components you'll
- 18:37find everywhere in controls and
- 18:38automation engineering. So without any
- 18:40further ado, let's dive right into
- 18:42looking at a lot of these core
- 18:43components. First thing you'll probably
- 18:45notice is that every component I have is
- 18:47mounted to this specific bent piece of
- 18:50metal that's called DIN rail.
- 18:56Okay, and DIN rail, D I N rail, is a
- 18:59specific standardized type of metal that
- 19:02is bent at a specific angle for controls
- 19:05and automation components to be able to
- 19:06easily clip on and unclip from it.
- 19:09Anytime you're searching for a component
- 19:11and you want to mount it in a controls
- 19:13cabinet, it's a good idea to look up a
- 19:15DIN rail mountable power supply, DIN
- 19:18rail mountable PLC. And ordinarily, all
- 19:21of the components you see here would be
- 19:22inside an industrial control panel, but
- 19:25I want to showcase a lot of it to you,
- 19:27so it's easier to just have it on a
- 19:28backer plane. Now, let's take a look at
- 19:30the power into this cabinet.
- 19:37I have it on this specific small piece
- 19:39of DIN rail just so that I could zip tie
- 19:41it for some cable management, but
- 19:42basically I take a 120-V
- 19:45power into the cabinet. If you have
- 19:47larger components like motor starters
- 19:49that might require three-phase power
- 19:51like 480 volts, you would need something
- 19:54a little heavier duty than what I have.
- 19:56But since I'm just dealing with 120
- 19:58voltage or household outlet voltage,
- 20:00it's okay to just have it come in and
- 20:02land on our next components. Which
- 20:04brings us to the next component, which
- 20:06is the circuit breaker.
- 20:12Circuit breaker, which can sometimes be
- 20:14replaced with a fuse, is meant to be
- 20:16your panel's local protection against
- 20:19overcurrent. There's a lot more than we
- 20:20can cover in this video on properly
- 20:22protecting all of your components from
- 20:24short circuits. But you should
- 20:26definitely be aware that basically every
- 20:28industrial control cabinet is either
- 20:30going to have circuit breakers or fuse
- 20:32terminal blocks for the main power
- 20:34coming into your enclosure. Next
- 20:36component you see here is the 24-V DC
- 20:39power supply.
- 20:45This is a really critical component
- 20:47because in modern industrial controls
- 20:49and automation, you see less and less
- 20:51stuff getting powered off of AC voltage.
- 20:53Low voltage is inherently safer, so
- 20:55dealing with DC is safer than dealing
- 20:58with AC in almost every application. And
- 21:01since the industry is moving towards DC
- 21:03voltage applications, you need a power
- 21:05supply that can step down AC to DC.
- 21:08Next, hopefully you see these wires
- 21:10coming out of the power supply, and I
- 21:12have them landing on these blocks here,
- 21:14which are distributing the power to
- 21:16multiple zones. These are called
- 21:18terminal blocks.
- 21:24And I have a whole bunch of spares over
- 21:25here. And what you can kind of see is
- 21:28that there's ordinarily plain gray or
- 21:30white or black, like a plain color. And
- 21:32those are just meant to be somewhere
- 21:34that you can land wires on one side and
- 21:37a partner wire on the other side of the
- 21:39same terminal block. You can think of
- 21:41them like industrially rated wire nuts.
- 21:43It's a spot where two different wires,
- 21:46or sometimes more than two wires, meet
- 21:48up and it's best used for organization
- 21:51and keeping your cables manageable. It
- 21:53also can let you land inputs and outputs
- 21:56from a PLC on terminal strips in your
- 21:59panel, and then you have somewhere to
- 22:01land the wires that come from the actual
- 22:02devices in the field. So terminal blocks
- 22:05are super important. Green ones
- 22:07ordinarily correspond with a ground
- 22:09wire. Some variations on these, you can
- 22:11find some that you lift up and they have
- 22:13a fuse in them. These are known as
- 22:15fusible terminal blocks, which offer you
- 22:17an additional level of built-in
- 22:19overcurrent protection. You can also
- 22:20find two-tier terminal blocks, which
- 22:22have two completely independent circuits
- 22:24that you can use. These are great for
- 22:26very dense panels. And a lot of the
- 22:28times you can find terminal blocks with
- 22:29three or four multi-connections. These
- 22:32are really great for things like power
- 22:33disbursement or anywhere that you need
- 22:35one signal in a lot of places. Okay, the
- 22:37next thing we're going to zero in on
- 22:39real quick here are relays.
- 22:45In a time before PLCs, most of
- 22:48industrial controls was done using
- 22:50relays. They didn't always look exactly
- 22:52like this, but basically what a relay is
- 22:55something that can take an input
- 22:57electrical signal and transform that to
- 22:59an output of either normally open or
- 23:01normally closed wiring. And that output
- 23:03signal can be completely electrically
- 23:06isolated from the input. So for example,
- 23:08the relays I have on here can be turned
- 23:10on and off using a 24-V signal, but they
- 23:14can be used to control 120-V outputs.
- 23:17Now, in modern times, it's very unusual
- 23:19to see more than basic logic being done
- 23:22with relays. And the reason for that is
- 23:24the PLC.
- 23:30Programmable logic controller is able to
- 23:32read statuses into the device and
- 23:35control the status of field devices.
- 23:38When it reads something into it, it's
- 23:40known as an input. When it controls
- 23:43something going out from it, it's known
- 23:45as an output. If you're familiar with
- 23:47Arduinos or hobby electronics, you're
- 23:50probably familiar with this terminology.
- 23:51So PLCs are able to be programmed,
- 23:54typically using the five IEC 61131
- 23:58programming languages. That numbering
- 24:00and acronym and abbreviation is a little
- 24:02bit unnecessary. Basically, the two most
- 24:05prevalent PLC programming languages are
- 24:07ladder logic and structured text. Ladder
- 24:10logic looks a lot like reading an
- 24:11electrical schematic, while structured
- 24:13text looks a lot like a conventional
- 24:15programming language. I've done entire
- 24:17past videos on these programming
- 24:19languages and we'll be covering them
- 24:20more in coming videos. So for the
- 24:22specific example I have here, I just
- 24:25have one input and one output hooked up
- 24:27to my PLC. And so for my input, I just
- 24:30have a simple push button. And when I
- 24:31press it, my PLC receives 24 volts on
- 24:34that channel saying it's energized. And
- 24:37when I release it, my PLC receives zero
- 24:39volts saying it's de-energized. For my
- 24:41output, I have a conventional work
- 24:44light, just to kind of show you that
- 24:46anything can be used as an output. If
- 24:48it's controllable in some way from
- 24:50electricity, it can be a PLC output. For
- 24:53this specific application, to show using
- 24:56a few different pieces of electronics, I
- 24:58have the output signal from my PLC
- 25:00coming into a relay. So the PLC is
- 25:03outputting 24 volts, and then on the
- 25:06other side of the relay, when this turns
- 25:08on, you can see a little green LED right
- 25:10here. And that's when 120 volts makes
- 25:13connection with the wire going to the
- 25:14light. So, my input of a push button
- 25:18tells the PLC, "Hey, I see this input. I
- 25:21programmed it to turn on that output
- 25:24when it sees the push button." So, I
- 25:26press the button,
- 25:27it turns on the output channel from the
- 25:29PLC because of code that I wrote, which
- 25:32activates this relay because now it's
- 25:34getting 24 volts, which connects this
- 25:36120-V signal to the light. This specific
- 25:40application, it's obviously unnecessary
- 25:42to use the relay and the PLC in this
- 25:45circuit because a simple push button
- 25:47turning on and off a light on its own is
- 25:49not a great use case for a PLC and
- 25:52industrial automation. But the purpose
- 25:54of this video is to show you the
- 25:55hardware, not necessarily build an
- 25:57advanced automation and controls
- 25:59project. The last component I think it's
- 26:01important to cover today because it
- 26:02comes up in almost every industrial
- 26:04controls and automation scenario is the
- 26:06switch. In this case, I have an
- 26:08eight-port Ethernet-compatible switch,
- 26:11which would allow me to connect things
- 26:12like my PLC or smart hardware like a VFD
- 26:16or variable frequency drive or any other
- 26:18networked components back to a master
- 26:21controller or my main laptop, which
- 26:23could be reading statuses from them,
- 26:25storing data in SQL, displaying values
- 26:27on an HMI, and things like that. Now,
- 26:30some of the most important components
- 26:32that we're not covering in this video
- 26:33are things like motor starters, VFDs or
- 26:36variable frequency drives, and HMIs or
- 26:39human-machine interfaces, which for the
- 26:41programmers out there can be thought of
- 26:43as the GUI or graphical user interface
- 26:46specifically for industrial controls and
- 26:48automation. But to speed recap what
- 26:50you've seen here, we've seen the main
- 26:52power supply come into a panel, which
- 26:54passes through a circuit breaker for
- 26:56overload protection, then goes into a
- 26:5824-V power supply, which then goes into
- 27:01terminal blocks for my power
- 27:03distribution, and then that powers my
- 27:05PLC. It also powers things like my
- 27:08relay, my switch, and it can be spread
- 27:10out using terminal blocks. Everything is
- 27:12mounted on DIN rail. When you need to
- 27:14convert signals from one type of voltage
- 27:17to another, you need to look for relays.
- 27:19And when you need to network lots of
- 27:21components together over Ethernet or
- 27:23other advanced protocols, you need
- 27:25something like a switch. Again, it's
- 27:27really hard to cover a lot of these
- 27:29advanced concepts without being able to
- 27:30show you them. So, let me know in the
- 27:33comments below if this was a useful
- 27:34format or if you have other suggestions
- 27:36for how I can make this better. As I go
- 27:39through this controls and automation
- 27:40tutorial series with you, I want to
- 27:42constantly be making it better. So feel
- 27:44free to leave any feedback in the
- 27:46comments below. I'll link to some of the
- 27:48key hardware that I used here because
- 27:50everything I used here can actually be
- 27:52found on Amazon. I'll say in terms of
- 27:54learning resources that can help you
- 27:56build some of these skills completely
- 27:57for free. Rockwell Allen-Bradley makes a
- 28:00tool called Connected Components
- 28:01Workbench. Beckhoff has their TwinCAT
- 28:04programming studio. Arduino now has a
- 28:06PLC IDE or integrated development
- 28:09environment. And Ignition is one of the
- 28:12top SCADA HMI providers, and you can get
- 28:15their core software for free to use on
- 28:18your home laptop or desktop. All right,
- 28:20so that is going to do it for today's
- 28:21video. Don't forget to leave a like if
- 28:22you enjoyed it. Subscribe to the channel
- 28:24for tons more great content. Thanks for
- 28:26watching. We'll see you next time. Bye.
- 28:34Today, I'm going to talk to you about
- 28:36the top five tools I use as a controls
- 28:38and automation engineer. Video is going
- 28:40to be a continuation on the controls and
- 28:42automation series that I started up in
- 28:44the recent months on the channel. But
- 28:46today's video is going to focus on the
- 28:48tools that you would use as a controls
- 28:51and automation engineer. Now, without
- 28:52any further ado, let's dive in. So the
- 28:55first tool I'm going to talk about is
- 28:56the digital multimeter. And in terms of
- 29:00basic electrical troubleshooting, it
- 29:02really doesn't get any better than one
- 29:04of these. They start as low as like $20.
- 29:07You can get one from Walmart or Amazon
- 29:09that does the basic functionality pretty
- 29:12well for you. Before you start working
- 29:14on high voltage or dangerous electrical
- 29:16systems, you should be far more
- 29:18qualified than just saying, "Hey, I've
- 29:20got a multimeter." But these can do
- 29:22things like detect whether or not
- 29:24there's voltage at a source, tell how
- 29:26much voltage there is relative to
- 29:28ground, check for AC and DC voltage. You
- 29:31can even lift a wire and you can
- 29:33calculate amperage through current. You
- 29:35can detect point-to-point if you have
- 29:37continuity, which helps you when you're
- 29:39trying to trace wires in a jumbled old
- 29:42electrical panel. And you can also do
- 29:44resistance checks, which help you detect
- 29:46for like partially blown fuses and
- 29:48things like that. But digital multimeter
- 29:50is a great tool to have around, not just
- 29:52if you're a controls and automation
- 29:53engineer. If you do any sort of hobby
- 29:55work or tinkering or electrical work
- 29:57around your house, which you should also
- 29:59be very careful with, then a digital
- 30:01multimeter is a great call. This one
- 30:03came in a soldering kit that I bought
- 30:05from Amazon and I think the whole kit
- 30:07was like 40 bucks and it works great.
- 30:09It's very reliable. Kind of the more
- 30:11robust industrial version you'll
- 30:13probably see a lot come from the company
- 30:15Fluke. And the only reason I have one
- 30:17for personal use is cuz I renovated a
- 30:19house and I was doing a lot of home
- 30:21electrical. So, I decided to go out and
- 30:23get a more industrially hardened one.
- 30:26It's not necessarily normal that you
- 30:28would have a Fluke for home use. Your
- 30:30company might just have two or three to
- 30:32loan out because they're more on the
- 30:34expensive side, but every engineer who
- 30:36is doing significant work in a control
- 30:38panel should have a Fluke or digital
- 30:41multimeter cuz it tells you so much
- 30:43about the status of your electrical
- 30:45signals. This isn't moving on to item
- 30:46two yet. This is item 1.5, but in the
- 30:49same kind of vein of testing and
- 30:51validating electrical signals in a
- 30:53panel, I think a voltage pen is
- 30:55something for anyone who is doing
- 30:58anything near any electrical circuits.
- 31:00It's something valuable for them to go
- 31:02out and get. They make these in AC and
- 31:05DC in one pen, so you can check if a
- 31:07circuit is live whether you're working
- 31:09on DC or AC circuits. They make some
- 31:12more advanced ones that can tell you
- 31:14additional feedback, but the main
- 31:16purpose of a voltage pen is that when
- 31:18it's on, it will start blinking rapidly
- 31:21like an LED will flash red if there's
- 31:24voltage present and it'll start beeping
- 31:26at you if there's voltage present. So,
- 31:27you can hold this up to a wire that
- 31:30you're about to take off of a terminal
- 31:32that you don't think should have
- 31:33electricity flowing through it and if it
- 31:35starts beeping with a voltage pen,
- 31:37that's a really good first check that
- 31:39you were about to do something pretty
- 31:41unsafe. So, with voltage pens and
- 31:43multimeters, we've covered electrical
- 31:45troubleshooting and the most common tool
- 31:47used for that. So, the second tool I'm
- 31:49going to talk about and this one should
- 31:51be kind of obvious if you're familiar
- 31:53with what controls and automation
- 31:55engineering is, but it is the wire
- 31:57strippers. So, a pair of wire strippers
- 32:00are typically capable of cutting a piece
- 32:03of wire and removing the shielding from
- 32:05it, so you get the bare copper on it.
- 32:07And it might seem really obvious that if
- 32:09you're doing any work in a control
- 32:11panel, you need a pair of these on hand,
- 32:13but I can't tell you the number of times
- 32:15I've gone to a project, I've had a young
- 32:17engineer with me and they haven't had a
- 32:19pair of wire strippers, they didn't
- 32:21realize that they needed them. It's just
- 32:23useful to know you will need your wire
- 32:25strippers pretty much constantly. There
- 32:28are super high-tech versions of these.
- 32:30There are also cable strippers, which
- 32:32when you have a cable that has four or
- 32:35five core of wire inside of it, it can
- 32:37grab the sleeve and pull it off of all
- 32:40of your five wires that are inside. So,
- 32:42this can get way more complicated and
- 32:45I'm kind of lumping like sets for
- 32:48crimping ferrules, which are nice like
- 32:50metal tube ends that clamp onto the
- 32:53copper on the end of your wire. I'm kind
- 32:56of roping all of the wire prep tools
- 32:58into you can get by with a pair of wire
- 33:01strippers and sometimes you might want
- 33:03like a box cutter type knife.
- 33:07If you do have a cable or if you're
- 33:08doing Profinet cable, which is really
- 33:11shielded and has a thicker edge to it
- 33:14and you don't have the specific tools
- 33:15meant for crimping that style of cable,
- 33:18you can usually get by with cutting a
- 33:20slit in the edge of the shielding,
- 33:22peeling it back, taking the individual
- 33:24wires out and then you can just strip
- 33:26them if need be with your wire
- 33:29strippers. So, in my opinion, wire
- 33:31strippers and a box cutter can get
- 33:34almost any electrical work done that you
- 33:35have to get done, but just know the
- 33:38world of wire prep is actually way
- 33:41deeper than that and we could go on for
- 33:43a very long time about the right type of
- 33:45ferrules, how when to use splicing and
- 33:48heat shrink, the different types of wire
- 33:50nuts or terminal mounts and things like
- 33:52that, but we're going to keep it simple.
- 33:54You absolutely will want a good pair of
- 33:57wire strippers. Now, item number three
- 33:59is something that might catch you a
- 34:01little by surprise if you haven't done
- 34:03significant work in automation and
- 34:05controls engineering, but I would
- 34:07recommend any engineer who's spending
- 34:09significant time in the field or bench
- 34:11testing stuff in the office get
- 34:13themselves a 120 to 24 V
- 34:16power supply. If you're in the UK or
- 34:18internationally, you might want to get
- 34:20yourself a 230 to 24 V DC power supply.
- 34:25Um
- 34:26But the important point here is you're
- 34:28taking single phase voltage, you're
- 34:30taking the most common type of wall
- 34:32outlet voltage and you're turning it
- 34:34into the most standard DC type of
- 34:38control voltage, which is 24 V DC. You
- 34:41are going to be stunned by the number of
- 34:43times having one of these on hand or in
- 34:46your bag is super useful. Some of the
- 34:48most common reasons you might need one
- 34:50of these power supplies is there could
- 34:52be a lot of scenarios where a control
- 34:54panel was designed with high voltage
- 34:57three phase 480 or higher electricity in
- 35:00the same cabinet as switches and PLCs
- 35:03and HMIs. And strictly speaking, if
- 35:06you're going to be working on anything
- 35:08with that 480 voltage live, you should
- 35:11be in full arc flash gear every time
- 35:13even if you're not touching the 480 side
- 35:16of your cabinet. But it's not always
- 35:18conducive, it's not always realistic to
- 35:20say that you're going to be arc flashed
- 35:22up. So, sometimes it's better to just
- 35:24kill the power to the cabinet. But then
- 35:27you run into the problem where if you
- 35:28kill the power to the cabinet and you're
- 35:30using that infeed power to power the
- 35:33lower voltage things as well with a 480
- 35:36to 24 V or 120 transformer, now you need
- 35:39some way of powering on the PLC,
- 35:42powering on the switch, powering on the
- 35:44HMI so that you can do troubleshooting
- 35:46and service with a power supply that is
- 35:49fed from somewhere else. So, one of the
- 35:52more common, more scrappy things that
- 35:54you might do as an automation engineer
- 35:56is get a really long extension cord,
- 35:58find a nearby outlet, power up a power
- 36:00supply, and then you can have all of
- 36:03those lower voltage things like the PLC
- 36:05and the switch online, you can do your
- 36:07software-based troubleshooting, you can
- 36:10even do wire validation with the high
- 36:12voltage components powered down. Some
- 36:14other formats that you might see power
- 36:15supplies in and again, like your company
- 36:18might already have one on hand, your
- 36:19customer might already have one on hand.
- 36:21These are kind of common, although not
- 36:23super frequently used in the US as far
- 36:26as I know.
- 36:27They're just like a metal box that has
- 36:29the circuitry for transforming the
- 36:31voltage on the inside and then little
- 36:34terminals with a plastic shield. They do
- 36:36exactly the same, it's just a different
- 36:38way of looking at it, but it's nice to
- 36:40know what you're looking at. And it's
- 36:41also worth noting some of these can take
- 36:44multiple input voltages. So, this one
- 36:46for example can work with 120 or 230,
- 36:49but you have to adjust a dip switch to
- 36:51tell it which one it's getting. And they
- 36:53also make these that output 5 V DC, 12 V
- 36:57DC, 24 V DC. So, make sure when you're
- 36:59specifying it, you get the right one. If
- 37:02the majority of the work that you're
- 37:03doing is bench testing or in like a
- 37:05garage environment like here where I
- 37:07want to make sure something works the
- 37:08way I'm expecting it to work before I
- 37:11power it up permanently and buy a power
- 37:13supply just for that circuit,
- 37:15uh an adjustable DC power supply is a
- 37:18really tremendous tool. I don't think
- 37:20you would throw this in your book bag
- 37:21and keep it on hand as an automation
- 37:23engineer doing a lot of work in the
- 37:24field. You absolutely could. There's no
- 37:27reason not to. This would be able to do
- 37:29exactly the same thing that would be
- 37:31able to do as long as you get one that's
- 37:33able to output
- 37:3524 V DC. Most common thing you would
- 37:37want is 120 V in or single phase
- 37:40household voltage in and then 24 V DC
- 37:45out. That will let you do a ton of great
- 37:47troubleshooting and give you a lot of
- 37:49flexibility and the ability to make
- 37:51working on systems way safer. Now, item
- 37:54four I thought about roping in with item
- 37:56two, which was all of the wire prep
- 37:58stuff, but I decided it's important
- 38:00enough and different enough that I'm
- 38:02going to make it its own topic. And that
- 38:04is the terminal screwdrivers. So,
- 38:07when you're wiring up stuff in a control
- 38:10panel, the most common thing you'll see
- 38:12is a screw clamp terminal base. Some
- 38:16uh plants, some people trust the spring
- 38:19clamp terminal bases as well, which is
- 38:21basically you push down a lever,
- 38:24you put the wire in and you release the
- 38:26lever and now you have a spring clamp on
- 38:28it.
- 38:30Um but the more common one to see
- 38:32honestly, especially in older plants,
- 38:35is screw clamp terminal bases where you
- 38:37have to tighten down a screw to clamp
- 38:39onto the copper. This is sort of the
- 38:41most common way to land anything
- 38:43electrically. And what's surprising and
- 38:45annoying is just how tiny the terminals
- 38:48can be on those. You might think that
- 38:50you have a very fine screwdriver, but if
- 38:52all you've ever done is around the house
- 38:54home projects and home electricity, I
- 38:57promise the smallest screwdriver you
- 38:59have will be way too big for the
- 39:02terminals used in an industrial setting.
- 39:05So, what's nice is when you can find a
- 39:07thin screwdriver that's rated, this one
- 39:10for example is up to 1,000 V um
- 39:14and they're incredibly thin. They have
- 39:16very thin, typically flat heads. So, a
- 39:18terminal screwdriver is not expensive,
- 39:20it's incredibly important. And you would
- 39:22not believe, this is an example of
- 39:24terminal blocks. These aren't even close
- 39:26to as small as they come and this
- 39:28terminal screwdriver is already almost
- 39:31too large to fit in these terminals. So,
- 39:33having a set of very fine electronic
- 39:36screwdrivers is super important. Now,
- 39:38it's time to talk about number five, the
- 39:42final most common tool that you will
- 39:45need as a controls and automation
- 39:47engineer. And I saved it for last
- 39:48because it's a little bit of a tough one
- 39:51to show, a little bit of a tough one to
- 39:52talk about and explain, but I'm going to
- 39:55do my best and I figured if you made it
- 39:57to this point in the video, you probably
- 39:59don't hate me enough to click away as I
- 40:01try to explain this rather complicated
- 40:03concept. But tool number five that you
- 40:05will absolutely need as an automation
- 40:07and controls engineer is an engineering
- 40:10laptop. And the reason I specify
- 40:12engineering laptop is because your work
- 40:16will probably give you a laptop that has
- 40:19a whole bunch of IT settings on it. They
- 40:21might not let you change your IP
- 40:23address. They might not let you download
- 40:25software from the internet. They might
- 40:27not let you have admin access to your
- 40:29laptop. That is going to be a huge deal
- 40:32breaker for an automation and controls
- 40:34engineer. So it's very important that
- 40:36you have a lot of RAM. 16 GB is probably
- 40:39the bare minimum. 32 or definitely 64
- 40:43would absolutely be preferable because
- 40:45one of the most common things that you
- 40:47would do as an automation and controls
- 40:48engineer is you might have virtual
- 40:50machines, which are basically
- 40:52virtualized sessions of a computer that
- 40:55has certain engineering software loaded
- 40:57onto it that you open using the brains
- 41:00of your computer. So if you're running a
- 41:02laptop that has 16 gigs of RAM and you
- 41:05want to open a virtual machine that
- 41:07needs 8 gigs of RAM for it to be able to
- 41:09run, you've just reduced the actual
- 41:12memory your laptop is capable of using
- 41:14to do other things to 8 gigs right away
- 41:17cuz now half of it's been dedicated to
- 41:19opening a virtual machine. If the
- 41:20virtual machine concept confuses you a
- 41:23little bit, don't worry about that too
- 41:24much for now, but just know that there
- 41:26are engineering softwares like TIA
- 41:28Portal for Siemens or Studio 5000 for
- 41:31Rockwell where depending on the task
- 41:33that you're doing, if you're online with
- 41:35equipment, if you're trying to make live
- 41:37edits to programming, you could easily
- 41:39be using 8 gigs of RAM just running
- 41:42certain projects. TwinCAT for Beckhoff
- 41:45will just gobble up your system
- 41:46resources. So if you only have a laptop
- 41:49that has 16 gigs of RAM or is super
- 41:52locked down by company permissions,
- 41:54you're going to have a very hard and
- 41:56annoying time as a controls and
- 41:58automation engineer. If you're at a
- 41:59company that only has a few automation
- 42:01and controls engineers, it might be hard
- 42:03to properly articulate to them how badly
- 42:06you need a really open laptop, but it's
- 42:10super important that you be able to put
- 42:13any required software to support
- 42:15bringing up your system on that laptop.
- 42:18Of course, you should still follow info
- 42:20security protocols. You should still
- 42:23have IT vet software and make sure it's
- 42:25not coming from malicious parties, but
- 42:27if you're not able to change your IP
- 42:29address, download BootP, which is
- 42:31capable of just setting IP addresses. In
- 42:34theory, it never works. But then if
- 42:36you're not able to go and grab the
- 42:38software you need to program a drive or
- 42:42a a VFD or any smart component in your
- 42:45system where there's a little package or
- 42:47plug-in on the vendor's machine website
- 42:50and you're not able to quickly get it,
- 42:52it is going to slow you down. You'll
- 42:53have to open a ticket. You'll have to
- 42:55cuss out the IT department every time
- 42:57and nobody wants that. So just make sure
- 43:00that if you're an automation and
- 43:01controls engineer and you are expending
- 43:04a lot of time in this field, you go
- 43:06through whatever steps are required to
- 43:08get yourself an engineering laptop,
- 43:10admin access where you can quickly
- 43:12change your IP address and network
- 43:13settings, be able to download software
- 43:16that you deem is necessary to do your
- 43:19job, and make sure that it has a lot of
- 43:21system RAM. So make sure it has a lot of
- 43:24memory. And in addition to a lot of RAM,
- 43:26preferably at least 500 GB or maybe a
- 43:29terabyte of actual disk memory because
- 43:32some of those software that you need to
- 43:35program PLCs take up a ton of install
- 43:38space as well. So I know it might seem
- 43:40silly in 2024 to say that a laptop is
- 43:43one of the most important tools that
- 43:45you'll need as an automation engineer.
- 43:46Like of course you have a laptop, but
- 43:49this very specific type of like an
- 43:51automation and controls engineering
- 43:53laptop, to go out and get a beefy
- 43:56laptop.
- 43:58And make your company pay for it. That
- 44:00is going to do it for the list. That is
- 44:01going to do it for today's video. I hope
- 44:03you found it useful. As always, good
- 44:05luck with your work. Good luck with your
- 44:06projects and I'll see you next time.
- 44:08Thanks for watching. Bye.
- 44:18In today's video, we're going to talk
- 44:20about the IEC 61131 programming
- 44:23languages. These are the five standard
- 44:25programming languages you're likely to
- 44:27see as an automation or controls
- 44:29engineer. So hopefully this video can
- 44:31answer some of the most common questions
- 44:33around what these are, what programming
- 44:35languages automation and controls
- 44:37engineers need to be ready to see in the
- 44:39field, and then also how likely you are
- 44:41to see them in what different
- 44:42applications you might use different
- 44:44ones for. I know just the name IEC 61131
- 44:49can be a little bit confusing, but IEC
- 44:51is just International Electrotechnical
- 44:54Committee. They are sort of regulators
- 44:56and moderators of a lot of specifics and
- 44:59standards in the world of industrial
- 45:02electronics and controls and automation.
- 45:04You don't really have to worry too much
- 45:06about the numbers or the letters. You
- 45:08just need to know what these different
- 45:10programming languages are and when
- 45:12you're most likely to encounter them in
- 45:13the field. So let's start with my
- 45:14personal favorite and potentially the
- 45:16most common one, which is ladder. So
- 45:19ladder diagram, ladder logic, or just
- 45:21sometimes abbreviated LD is essentially
- 45:25the first PLC programming language that
- 45:27ever came up sort of organically because
- 45:31it looks a lot like
- 45:33electronic relay schematics. So in the
- 45:37old days before we had PLCs dedicated to
- 45:39running automation,
- 45:41you would read sort of primitive
- 45:43controls maps as schematics of different
- 45:46relays. So you could, for example, have
- 45:49a relay that would check to see if a
- 45:50button was pressed and if maybe some
- 45:54some thing in the field like a high
- 45:55pressure switch was met. And if those
- 45:57were both true, the relay would pull in
- 45:59and then something else would happen
- 46:01downstream of it. And so a standard
- 46:03programmer might think of this as like a
- 46:04series of and or gates to do like binary
- 46:07logic. In ladder logic, it's almost like
- 46:10you could trace a flow of electricity
- 46:13through your program. So this is why
- 46:14ladder logic looks sort of like a ladder
- 46:18when you stare at it. It's rung after
- 46:19rung after rung. And the individual
- 46:21modules all sort of spawned from the
- 46:24idea that you had relays. So the two
- 46:26most common ones are like examine if
- 46:28close and examine if open, which is
- 46:31basically a if or an if not. So it's
- 46:34basically if condition is a one or if
- 46:36condition is a zero. And that's 90% of
- 46:39how you do
- 46:41Boolean checking, just series of ifs and
- 46:43if nots. And then to turn on Boolean
- 46:46conditions, you really just need to know
- 46:47the difference between like an OTE,
- 46:50which is a energize the whole time this
- 46:52rung is true, versus like an OTL and an
- 46:55OTU pair, which is latching and
- 46:57unlatching a binary condition when
- 46:59something is true. Now obviously
- 47:01processes are a lot more complicated
- 47:03than binary logic in a lot of scenarios.
- 47:06So essentially what that means is you
- 47:09also have things like greater than, less
- 47:11than, limits where you check between
- 47:13values. And then you can also move
- 47:16numerical values into numerical
- 47:19variables. So you don't just have binary
- 47:21logic in ladder. You have all the sort
- 47:23of standard formats that you'd have in
- 47:25any other programming language. If you
- 47:27understand general programming types,
- 47:29you'll be able to pick up what these
- 47:31separate variable types mean pretty
- 47:33quickly and pretty easily. But ladder
- 47:35logic is extremely common. It's also
- 47:37super powerful and it's pretty easy for
- 47:39people who don't have a computer science
- 47:41background, but maybe are more familiar
- 47:43with the electronics side, or frankly
- 47:46they don't have a programming background
- 47:48at all. Ladder logic is super logical. I
- 47:50really like it. Almost every major PLC
- 47:53manufacturer supports some form of
- 47:56ladder logic using these same basic
- 47:58building blocks. So as a controls and
- 48:00automation engineer, you are super
- 48:02likely to need to become pretty familiar
- 48:04with ladder logic. Now for the one I
- 48:06consider second most common, some people
- 48:08might debate with me here, but I think
- 48:10the function block diagram. It's
- 48:13essentially more free form than like
- 48:16traditional ladder logic. You just
- 48:18basically have a blank page of workspace
- 48:21and you drop blocks in there that you
- 48:23want to do different functions. And
- 48:25typically you tie their inputs and
- 48:27outputs to different process conditions.
- 48:29Some of the more common ones for this
- 48:31would be like totalizers. A lot of the
- 48:33time a totalizer block that would
- 48:35monitor flow over a period of time and
- 48:38continually add to see how much total
- 48:40flow you had in that time. You would
- 48:42maybe have this floating function block
- 48:45diagram for a totalizer. You would tie a
- 48:48start command, a stop command, a reset
- 48:50command, as well as potentially like
- 48:53your input signal, so your actual raw
- 48:55flow meter signal. You could pass it
- 48:58through some sort of like time scale or
- 49:00multiplier, but it's just where having
- 49:03all of the conditions that control the
- 49:05totalizer and all of the outputs that
- 49:07you could do using the totalizer in one
- 49:10spot is just super powerful. I'm only
- 49:13using totalizer as one example. Function
- 49:15block diagram, its advantages are you
- 49:17can see all of the components that will
- 49:20control a block, a complicated block
- 49:22like a totalizer, in one location. You
- 49:25can also map out common programming
- 49:27things like and gates, or gates, XOR
- 49:30gates, nots, whatever Boolean
- 49:33control in these as well. The
- 49:35disadvantages are it starts to get very
- 49:38hard to read a logical sequence of
- 49:41things happening if you get too far down
- 49:43and too long into one function block
- 49:46diagram. So, you need to start
- 49:48partitioning it off and making a
- 49:49separate FBD for each major function
- 49:53that happens. But, I have seen systems
- 49:55where the entire thing is done in a
- 49:57function block. I've seen things where
- 49:59the entire system is done in ladder.
- 50:01But, it's important to understand what
- 50:03this looks like, how you can control it,
- 50:05what it's used for, and also it's an
- 50:07important one to familiarize yourself
- 50:09with. The next language, SFC or
- 50:11sequential function chart, is absolutely
- 50:14the most common language you'll see if
- 50:16you run batch processes. So,
- 50:19GE's like FT Batch and Rockwell's batch
- 50:23as well as I think
- 50:25just a lot of batch processes. The way
- 50:28you see a recipe is with a sequential
- 50:31function chart. And this one's really
- 50:33nice to kind of get an overarching view
- 50:35of your process because typically you'll
- 50:37have layers where you can look at one
- 50:40SFC and you'll see like start phase,
- 50:44validate parameters phase, manual
- 50:46additions phase, mix phase, automated
- 50:49additions phase, sample phase. And so,
- 50:52you can look at a high-level SFC and you
- 50:55can see the overall state of your
- 50:57project really quickly as it relates to
- 50:59your whole process. And then if you have
- 51:01questions about what's going on in one
- 51:03phase of that SFC, typically most
- 51:07software supports you drilling in and
- 51:09inside one phase at your high-level
- 51:11model, you could have a number of
- 51:13phases. And inside each of those phases
- 51:15you could have a number of phases in
- 51:17there. It's definitely most commonly
- 51:20used in batch. Most PLCs themselves
- 51:23don't support a really robust like SFC
- 51:27without a software that you run and
- 51:29configure on an actual computer. So,
- 51:32PLCs typically host mainly like ladder
- 51:36and FBD and even some of what we'll talk
- 51:39about next, which is structured text.
- 51:41But, to do an SFC-based control
- 51:43schematic, you're usually in like more
- 51:45of a distributed control system like DCS
- 51:47platform and you usually have to put
- 51:50your SFC software recipe editor,
- 51:53whatever, on a computer other than your
- 51:55PLC. Again, most common place you'll see
- 51:58it is batch applications. Batch just
- 52:00means that you separate all of your
- 52:02devices at the plant and your series of
- 52:05instructions that control devices into
- 52:08phases. Phases still typically have to
- 52:10get represented as ladder in your PLCs.
- 52:14So, an SFC is almost always accompanied
- 52:17by some form of ladder logic or
- 52:19structured text inside of a PLC. Not
- 52:22always, I'm trying to generalize and
- 52:24give you guys a quick summary. But,
- 52:25that's a summary of SFC. So, the next
- 52:28one, structured text, is
- 52:30probably the one that would look the
- 52:32most familiar to someone coming in with
- 52:34a programming background but not a
- 52:35controls background. Structured text
- 52:38really is what all programming languages
- 52:40are. I mean, it's a certain syntax of
- 52:43words and commands that will execute
- 52:45certain things in your code. Structured
- 52:47text is typically straightforward like
- 52:49saying set IO point status to digital
- 52:53output,
- 52:54set Boolean command equal to one when
- 52:58condition is met. Like, the actual text
- 53:00I'm not going to spend too much time
- 53:02digging into because it varies from
- 53:05manufacturer to manufacturer, controller
- 53:07to controller. So, if I were to tell you
- 53:09a bunch of specific structured text,
- 53:11there's a solid chance it wouldn't apply
- 53:13to your specific manufacturer. But, the
- 53:16documentation for what your manufacturer
- 53:18supports, what whatever your site
- 53:21standard is, if you're doing a lot of
- 53:23structured text, then the controls at
- 53:25your plant probably got started by a
- 53:28group of people who are more comfortable
- 53:30with software and programming. So, in
- 53:32general, PLC programmers, controls and
- 53:34automation engineers aren't going to
- 53:36need to see a ton of structured text,
- 53:38but it is supported and it is one of the
- 53:41IEC 61131
- 53:43languages. So, it's important to know
- 53:45what it is. If you see it in an
- 53:47application, don't be blindsided by it.
- 53:50Not super common. If it's super common
- 53:52at your site, you prove me wrong. Let me
- 53:54know I was wrong in the comments below,
- 53:55but most of the time the three we talked
- 53:58about before are going to show up a lot
- 54:00more in your applications. Okay, and the
- 54:02fifth one is kind of neat here. It's
- 54:04instruction list, typically abbreviated
- 54:06IL.
- 54:08And this one is going to be really
- 54:10familiar for people who have done a lot
- 54:12of work with like six-axis robots or if
- 54:15you've done a lot of work with like CNC
- 54:17machines or 3D printers. Instruction
- 54:20list is not too far off from structured
- 54:23text in that it's really just words
- 54:27that kind of have some numbers mixed in
- 54:29to command your variables to different
- 54:31stuff, whereas the first three languages
- 54:33we talked about were a lot more visual.
- 54:35But, instruction list is basically like
- 54:38machine code. So, for like a robot or a
- 54:42CNC machine, it's often called G-code.
- 54:45But, it usually is a series of commands
- 54:48that run one after another. It's always
- 54:50going to typically happen in sequence,
- 54:53but a lot of the time you can have like,
- 54:55oh, if this condition, then do this and
- 54:58jump to this rung, but if other
- 55:00condition, do this other thing, jump to
- 55:02this other rung. So, it doesn't have to
- 55:04be linear. But, typically it's in an
- 55:06order that makes sense that you would
- 55:08typically see it sequentially. And the
- 55:09most common applications are for things
- 55:11where you need position control in 3D
- 55:14space. So, you're controlling three or
- 55:16more
- 55:17axes and you would typically say, "Okay,
- 55:20go to certain position. All right, turn
- 55:22on your tool, whether it's cutting or
- 55:24drilling or welding or whatever." And
- 55:26then your tool's on. "Okay, move from
- 55:28point A down to your thing that you're
- 55:31operating on. Okay, now move over to
- 55:33point B with your tool on. Okay, now
- 55:35turn your tool off and lift up. Okay,
- 55:37now go back to your home spot. A
- 55:39conveyor will turn on, move the next
- 55:42piece in." So, it's pretty common on
- 55:43like assembly line where you have a lot
- 55:46of advanced like robotics or motion
- 55:48control. It's normal to see instruction
- 55:51list. But, again, this is sort of more
- 55:54common in robotics even than you would
- 55:56see it in controls and automation. So,
- 55:59it is one of the IEC 61131 languages.
- 56:03That's why we're talking about it. And
- 56:04in general, the more well-rounded you
- 56:06are as an engineer, the better you're
- 56:08going to do in your field. Good luck
- 56:09with your jobs. Good luck with your
- 56:10projects. Thanks for watching. Bye.
- 56:20This is the Arduino Opta PLC. PLCs are
- 56:24pretty well known for being hundreds or
- 56:26sometimes thousands of dollars because
- 56:28of their industrial ratings. And often
- 56:30the software and the licensing
- 56:31accompanied with them is hundreds or
- 56:33thousands of dollars as well. Arduino
- 56:35has created a compact microcontroller
- 56:38that has relay outputs and digital
- 56:40inputs on board as well as programmable
- 56:42buttons and LEDs so that you can learn
- 56:45the basics of controls and automation or
- 56:47build IoT and industrial automation
- 56:49solutions for just a couple hundred
- 56:51dollars. And for myself as a creator and
- 56:53the person who runs Le Master Tech, I'm
- 56:55really excited about this product
- 56:57because it gives me a way to teach the
- 56:59basics of controls and automation
- 57:01engineering, which is the field I work
- 57:02in professionally and something I feel
- 57:04quite passionately about. At a price
- 57:06point finally that's pretty accessible
- 57:08for anyone who's looking to break into
- 57:10this field. So, in today's video I'm
- 57:11going to walk you through downloading
- 57:13the PLC IDE from Arduino, getting online
- 57:16with it, and creating your very first
- 57:18project because in the coming videos on
- 57:20Le Master Tech, we're going to be doing
- 57:22progressively more advanced controls and
- 57:24automation tutorials. And being able to
- 57:26get started with the Arduino PLC is
- 57:29going to be very important if you want
- 57:30to follow along with all of those
- 57:32tutorials. So, let's get right into it.
- 57:34All right, let's go ahead and just pop
- 57:36the Arduino PLC IDE into Google. And the
- 57:40Arduino software link to the PLC IDE,
- 57:43the big button that says download the
- 57:45PLC IDE.
- 57:47I'm going to download the Windows
- 57:49version and I encourage you to
- 57:52contribute and download. Arduino's
- 57:53pretty awesome company. I'm going to
- 57:55just download cuz this is like the fifth
- 57:57time I've done this. Arduino's pretty
- 57:59awesome and they give their stuff away
- 58:01for free, their software stuff.
- 58:03But, let's go ahead and install the PLC
- 58:06IDE together.
- 58:11I'm going to check yes to launch it once
- 58:13it's done and I'm going to hit finish.
- 58:15Okay.
- 58:17All ready. So, it looks even though I
- 58:19just downloaded it can remember that I
- 58:21did some programs here before, which is
- 58:24fine.
- 58:25I'm just going to hit new project
- 58:27anyways and I'm going to name it my
- 58:30first PLC.
- 58:32And make sure your target is the Opta
- 58:34unless you're using the Portenta Machine
- 58:36Control.
- 58:37Um, but I'm going to use the Opta. I'll
- 58:39just put it in documents is fine and
- 58:41I'll hit okay. It's going to take a
- 58:43minute to generate the project.
- 58:46All right, then the device shows up
- 58:48here.
- 58:49First thing you want to do with the new
- 58:51Arduino PLC that you have plugged in,
- 58:53you want to go to device manager on your
- 58:55computer. Make sure you know what port
- 58:59your PLC is plugged into. I'm almost
- 59:01sure mine's USB 13, but I'm going to go
- 59:04ahead and unplug it and I see 13 goes
- 59:06away.
- 59:08Plug it back in and
- 59:10thir-
- 59:1212 and 14 come back. Interesting.
- 59:14Okay.
- 59:16So, this one might be in a weird state
- 59:18of limbo. That's like it got half booted
- 59:20before. So, I'm going to double click
- 59:22the reset button. That puts it in
- 59:24firmware reboot mode. So, if your USB is
- 59:28if your PLC is brand new out of the box,
- 59:30you should only have one USB serial
- 59:32device port here.
- 59:34Um so, COM 13.
- 59:36We're going to come in here and select
- 59:39that. And the first thing you want to
- 59:41do, uh regardless of the fact that you
- 59:43haven't written any code yet, is just on
- 59:45port uh COM port 13.
- 59:48You just want to hit download. It's for
- 59:50initial setup and and reinitialization.
- 59:53It tells you on on a new board, file
- 59:55system formatting can take some minutes.
- 59:57It takes some minutes, so just get it
- 59:59started. Uh really all you're looking
- 1:00:01for, you want this bottom left window to
- 1:00:03keep doing stuff. You don't want it to
- 1:00:05freeze and hang up. Um but it does take
- 1:00:08a couple minutes, so I'll probably fast
- 1:00:09forward much of this.
- 1:00:12Or play games on my phone.
- 1:00:23Okay, and you want file downloaded
- 1:00:26successfully. That's good. Um anything
- 1:00:29that's like, "Hey, DFU invalid suffix."
- 1:00:31Stuff like that. Your Arduino PLC IDE
- 1:00:34might have gotten uh incorrectly
- 1:00:36downloaded. You might want to go to the
- 1:00:38Arduino IDE and install the Opta
- 1:00:40libraries. Uh you might want to try
- 1:00:43double pressing reset on the Arduino
- 1:00:46Opta to get it to go back into
- 1:00:48bootloader mode and try again.
- 1:00:50Double-check your COM ports are correct
- 1:00:53with device manager. Those are all the
- 1:00:55troubleshooting steps that uh I know of
- 1:00:57because I've gone through very similar
- 1:00:59things.
- 1:01:00Um but ideally, if that works and you go
- 1:01:03to device manager
- 1:01:06and
- 1:01:08ports, you now have two ports because
- 1:01:10this is a dual-core PLC, so there are
- 1:01:13two USB uh ports in use to communicate
- 1:01:16with it. Uh you want so you have 12 and
- 1:01:1914.
- 1:01:20You want to go into online and set up
- 1:01:22communication and go to Modbus and
- 1:01:25properties. And you want to grab the
- 1:01:26higher of those two ports. The rest of
- 1:01:29the defaults should be fine. The baud
- 1:01:30rate, the frame, all that stuff.
- 1:01:32Hit okay. Hit okay. And now, you want to
- 1:01:36uh connect to the target.
- 1:01:39So, I'm actually just going to unlo- uh
- 1:01:42unplug and plug back in the PLC for my
- 1:01:44little
- 1:01:46you know, "Hey, I'm IT. This is how I do
- 1:01:48things." Um I don't think you have to do
- 1:01:50that. But go back to un- unload uh
- 1:01:54online setup communication Modbus COM
- 1:01:5614. That all looks good. Okay. And now,
- 1:01:59uh there's nothing in main except count
- 1:02:02equals count plus one. That's the
- 1:02:03default program Arduino gives you.
- 1:02:06But when you are in resources on this
- 1:02:08header page, you want to connect to the
- 1:02:10PLC even before downloading anything to
- 1:02:13it. You're just connecting to make sure
- 1:02:14that uh all the setup stuff worked okay.
- 1:02:18It'll take a second.
- 1:02:20Okay. Now, I've previously licensed
- 1:02:22this. Um but initially, yours will
- 1:02:24probably tell you that uh you need to um
- 1:02:27ref-
- 1:02:29disconnect it and connect it back um for
- 1:02:31the permanent license to take effect.
- 1:02:34One really cool thing that Arduino does
- 1:02:36that most industrial PLC uh IDE
- 1:02:39providers do not do is they include a
- 1:02:41permanent license for your PLC um with
- 1:02:44the purchase of the hardware. So, for
- 1:02:46about $200, which is not nothing, um you
- 1:02:49get a micro PLC that has relay outputs
- 1:02:52as well as programmable inputs that can
- 1:02:54be analog or digital inputs or more
- 1:02:56outputs if you need them to work that
- 1:02:58way. It can also be clipped into
- 1:03:00expansion IO modules, which makes it a
- 1:03:02lot more useful and flexible.
- 1:03:04And then a permanent license because the
- 1:03:06even the more affordable hardware
- 1:03:08providers, Beckhoff, Wago, uh Siemens
- 1:03:11have some more affordable PLC lines,
- 1:03:13they get you with licensing their
- 1:03:14software as well.
- 1:03:16So, really for getting into the world of
- 1:03:18industrial automation and controls, uh
- 1:03:20this is a pretty crazy affordable um
- 1:03:24pretty crazy affordable option. So, uh
- 1:03:26you should have all green. Not every
- 1:03:28Opta has Wi-Fi and Ethernet, so
- 1:03:30depending on the version you bought,
- 1:03:31these might not all be green. Um but
- 1:03:34mine does, so let's go to main, which is
- 1:03:36just the default program. Okay. Now, I'm
- 1:03:39just going to go uh in the to talk about
- 1:03:42the two tabs that they kind of give you
- 1:03:44um by default. They give you project and
- 1:03:46resources. In resources, you can see the
- 1:03:49Opta that we added. And in later
- 1:03:51tutorials, I have some IO expansion
- 1:03:53modules. You'll see where we add those
- 1:03:55as well. So, we have even more inputs
- 1:03:57and outputs we can play around with. But
- 1:03:59the Opta right on the body of the main
- 1:04:00PLC, it has a channel of inputs on the
- 1:04:03top. Uh it has relay outputs on the
- 1:04:05bottom. And then it has four status
- 1:04:08lights uh for L1, L2, L3, and L4 at the
- 1:04:10bottom. And then it has a red, green,
- 1:04:12and blue LED
- 1:04:17uh all all here. And then it also has
- 1:04:19button inputs.
- 1:04:21for now, the only thing I'm going to do
- 1:04:22is I'm going to go to LED outputs and
- 1:04:25I'm going to give LG, which is the green
- 1:04:27light, a variable name called green. So
- 1:04:30that then we can go over here to
- 1:04:31projects uh and in my first PLC project,
- 1:04:35I'm going to add a new program. I'm
- 1:04:37going to make it structured text.
- 1:04:39And I'm just going to call it green
- 1:04:41light. Okay? And I messed up because you
- 1:04:44need to assign it to a task. So, I'm
- 1:04:47going to delete that real quick and show
- 1:04:49you what I mean. Add new program.
- 1:04:53We'll just call it green
- 1:04:55light. We'll make it in structured text
- 1:04:58and I'm going to assign it to fast.
- 1:05:00Okay? So now, it doesn't have a question
- 1:05:02mark over here. And all I'm going to do
- 1:05:04is say green and then colon equal sign
- 1:05:08true all caps and then a semicolon.
- 1:05:10Okay? And you can see right now there's
- 1:05:12nothing on my PLC. I'm going to hit
- 1:05:14download and compile.
- 1:05:16And the green light turns on. Okay? So,
- 1:05:20this was not a PLC programming tutorial.
- 1:05:23This was getting started with the
- 1:05:24Arduino Opta PLC tutorial because we are
- 1:05:26about to do a whole bunch of ladder
- 1:05:28diagram structured text, hooking up
- 1:05:30inputs, hooking up outputs, building
- 1:05:32HMIs. All the stuff that turns you into
- 1:05:35a controls and automation engineer. We
- 1:05:36are going to do that and we are going to
- 1:05:38use the Arduino PLC IDE and the Arduino
- 1:05:41PLC itself. So, super important to go
- 1:05:43through the basics together.
- 1:05:45If you're running into problems with
- 1:05:47this, uh
- 1:05:48do not skip this and go forward to the
- 1:05:50next uh few videos. If you're trying to
- 1:05:52truly follow along with this tutorial,
- 1:05:54you really need to be able to get online
- 1:05:56with your PLC and at least make sure
- 1:05:58that you can turn that green light on
- 1:06:00and off. Um otherwise, you're going to
- 1:06:02be trying to follow follow along with
- 1:06:04tutorials in this series that will show
- 1:06:06you useful information and useful
- 1:06:07concepts. But if you're not online with
- 1:06:09the PLC right now, the rest of the
- 1:06:11tutorials will mainly just be for your
- 1:06:13information, but they won't be practical
- 1:06:15exercises together. So so. Thank you so
- 1:06:18much for watching. Uh the tutorials are
- 1:06:20really going to take off from here, so I
- 1:06:22hope this basic setup was useful for
- 1:06:23you. Let me know in the comments with
- 1:06:25any questions. We'll see you next time
- 1:06:26and thanks for watching. Bye.
- 1:06:36Okay. In uh this chapter, we are going
- 1:06:39to make a new project and we're going to
- 1:06:41call it first
- 1:06:44structured
- 1:06:45struct-
- 1:06:47structured text. Okay? So, we're going
- 1:06:49to go new project. Make sure you have
- 1:06:51the Opta selected if you're using the
- 1:06:53same controller as me. And we're going
- 1:06:55to say okay. It's going to generate a
- 1:06:57new project. Um now, I have previously
- 1:07:00loaded the firmware onto my uh Arduino,
- 1:07:03so everything else here should be fine.
- 1:07:05We'll go to online setup communication
- 1:07:08Modbus and properties and just make sure
- 1:07:10COM 10 is still selected. That looks
- 1:07:12good and we are going to hit connect
- 1:07:15just to make sure the connections look
- 1:07:16good and the all PLC Arduino Opta still
- 1:07:20looks good. All the available interfaces
- 1:07:22should show green lights. So, this is
- 1:07:25all good. Hopefully, uh in a previous
- 1:07:27video and previous chapter, watching a
- 1:07:30long-form uh tutorial, uh I covered all
- 1:07:33of this stuff in some greater detail.
- 1:07:35So, if you haven't gotten to this step
- 1:07:37and you're not able to get online with
- 1:07:38your Arduino Opta PLC, I suggest you go
- 1:07:41back on the channel and you watch the
- 1:07:43getting set up or getting started with
- 1:07:45your Arduino PLC video. Um so, uh
- 1:07:49assuming you can get to this step and
- 1:07:51you have a new project just like I have.
- 1:07:53And if you were to go into the project
- 1:07:54tab over here on the left and hit main,
- 1:07:57you just have this default program it
- 1:07:59gives us that is count equal to count
- 1:08:01plus one.
- 1:08:03Um but if you're able to get this far,
- 1:08:04then we're in the same spot and the rest
- 1:08:06of this video is going to go so
- 1:08:08smoothly.
- 1:08:10So, let's go to resources because for
- 1:08:12today's video, I'm going to use the uh
- 1:08:14LEDs that are built into the Arduino
- 1:08:17Opta and I'm going to use the user
- 1:08:18button, which is on the front of the
- 1:08:20PLC. Uh so, you could see there actually
- 1:08:23when I was pushing that button, it was
- 1:08:24doing stuff. That's cuz I have different
- 1:08:26code on there as shown by this diff code
- 1:08:29thing uh in the bottom left of my window
- 1:08:31right there.
- 1:08:32Um
- 1:08:33so, maybe I'll hang out right there so
- 1:08:34you can see my tab.
- 1:08:36Um but right now, I'm going to go ahead
- 1:08:39and just download this empty uh
- 1:08:41PLC program to it so that there's
- 1:08:43nothing on my PLC. Uh
- 1:08:46and then we'll be in exactly the same
- 1:08:48spot. So, compiling sketch. Please wait.
- 1:08:52I will wait for you, Arduino.
- 1:09:00Okay. So, once you get source okay, or
- 1:09:03you might have had nothing. Um but in
- 1:09:05this case, now we have PLC that has
- 1:09:08nothing on it. Uh pushing the button
- 1:09:10does nothing. The lights are not there.
- 1:09:12The green light isn't even on. You would
- 1:09:14not know anything was working on this.
- 1:09:16Um so, let's go to the resources and
- 1:09:20click on the Opta. Um this should still
- 1:09:22look good. But since we're using the
- 1:09:24button and the LEDs that are on the
- 1:09:27Opta, we're going to add variables here.
- 1:09:29So, the name of them is just kind of how
- 1:09:32you identify what the button is. There's
- 1:09:34one push button on the front of the Opta
- 1:09:37that is programmable. The other one is
- 1:09:39the reset button, which is used for like
- 1:09:42factory resetting. So, there's only one
- 1:09:44button on the front of the Opta we can
- 1:09:45use.
- 1:09:47It's the user push button. So, I'm going
- 1:09:49to assign it a variable name that is
- 1:09:51just going to be user, all caps like
- 1:09:53that. Now, I'm going to go to LED
- 1:09:55outputs and I'm going to do basically
- 1:09:56the same thing. L1, L2, L3, L4.
- 1:10:02LR, LG, LB.
- 1:10:06And so, this is my
- 1:10:08exist is not automatic, that's fine.
- 1:10:11LR.
- 1:10:13Okay, it's really unhappy.
- 1:10:17Oh, mercy. Okay, I'm going to call this
- 1:10:20red,
- 1:10:22green,
- 1:10:23and blue.
- 1:10:25Uh basically, you need to assign
- 1:10:27variable names to these uh
- 1:10:29hard-coded inputs and outputs so that we
- 1:10:32can use them in our program. So, we have
- 1:10:34L1 through L4 refers to the four status
- 1:10:37lights at the bottom of the Opta and
- 1:10:39then red and green show up in the same
- 1:10:41spot above the reset button and blue
- 1:10:43shows up right above uh the user button.
- 1:10:46So, we're assigning all those variable
- 1:10:48names so that when we go to write our
- 1:10:50program here in main, we have user and
- 1:10:54uh all seven of those lights that we can
- 1:10:56play around with.
- 1:10:58So, let's write functionally
- 1:11:01what can be considered uh the hello
- 1:11:04world, the intro to programming for
- 1:11:07structured text. Let's say green equals
- 1:11:10true. And a couple important syntax
- 1:11:12things here is green colon equals is how
- 1:11:16you set a value equal to true, all caps,
- 1:11:20and then a semicolon. So, for structured
- 1:11:22text, it's variable that you want to
- 1:11:25change the value of and then setting a
- 1:11:27value is colon equals and then the value
- 1:11:30you want to set it to and then a
- 1:11:32semicolon. And this should compile and
- 1:11:35download, so I'll hit this little button
- 1:11:36for download PLC code. It'll ask me if I
- 1:11:39want to compile it. Say yes.
- 1:11:42And now, if I hold up the PLC, the green
- 1:11:45light is on, okay? So, that's my hello
- 1:11:48world right there. That's the green
- 1:11:50light is on. I am talking to the PLC and
- 1:11:52it is listening.
- 1:11:54Now, let's go ahead and go a little bit
- 1:11:56further. Let's say that red will be
- 1:11:58equal to false. By default, it'll be
- 1:12:00off, but
- 1:12:01um let's go ahead and say blue is equal
- 1:12:04to user, okay? So, uh you'll notice the
- 1:12:08colon equal sign for all of those and
- 1:12:10the semicolon at the end for all of
- 1:12:12those. And all I'm doing is making sure
- 1:12:14the red light is off, but the blue
- 1:12:16light, I'm doing something a little more
- 1:12:18interesting here. I'm saying it's equal
- 1:12:19to the value of user. And I'm going to
- 1:12:22do something here. I'm going to add all
- 1:12:24of these values to watch uh just by
- 1:12:27right-clicking on the variables that I
- 1:12:28want to watch. I'm going to add them to
- 1:12:30watch and I have this window over here
- 1:12:33that's the watch window and it shows the
- 1:12:35current value of them. The current value
- 1:12:37of green is true because my original
- 1:12:39code was just green equals true. So, now
- 1:12:42if I download and compile this
- 1:12:45and then hold the PLC up, you'll see
- 1:12:47green is still true, red is still off,
- 1:12:50and that's all good. But, if I go ahead
- 1:12:51and push this button, you'll see the
- 1:12:53blue light turns on. And if you're
- 1:12:55watching the watch window here, you'll
- 1:12:56see user and blue change when I push the
- 1:12:59button.
- 1:13:00Okay? So, uh that's actually it's pretty
- 1:13:04cool how fast we're able to advance
- 1:13:06through this uh PLC programming
- 1:13:07tutorial. We're now controlling the
- 1:13:09state of an output from an input. So,
- 1:13:13the input being that user push button,
- 1:13:15blue being the output light. Um but,
- 1:13:18you're not really learning too much
- 1:13:19structured text with this. We're just
- 1:13:21directly setting values based on uh
- 1:13:23other values. So, let's go ahead and
- 1:13:25take a look at an if else if statement.
- 1:13:28Uh let's say if the user push button is
- 1:13:32pressed,
- 1:13:34so if user semicolon, actually if user
- 1:13:38then and no semicolon, I get my uh
- 1:13:41Python, my C++, and my structured text
- 1:13:44syntaxes messed up. But, here we're
- 1:13:46checking if a Boolean value is true. So,
- 1:13:49it's just if user, so if the user push
- 1:13:52button is pressed, then let's go ahead
- 1:13:55and set L1
- 1:13:56equal to true.
- 1:13:58And let's go ahead and do L2 also equal
- 1:14:01to true. And let's just make sure that
- 1:14:04L3 is off when the push button is
- 1:14:07pressed and that L4
- 1:14:09is off when I push the push button in.
- 1:14:12Now, I'm going to do else if
- 1:14:15not user. So, this is about the same
- 1:14:18thing as an else statement um but, I
- 1:14:21think it's important to call out that
- 1:14:23else if in structured text looks a
- 1:14:25little different than most programming
- 1:14:26languages. So, it's this E L S I F and
- 1:14:30then not user.
- 1:14:32Then,
- 1:14:33and you'll notice if user then and else
- 1:14:36if user then don't have semicolons, but
- 1:14:38all these command lines do. So, I'll
- 1:14:41copy these four instructions here
- 1:14:43and I'll
- 1:14:46shift tab, there we go. I'll change L3
- 1:14:50and L4 to the ones that should be on and
- 1:14:52L1 and L2 to the two that should be off.
- 1:14:55And then, super important in structured
- 1:14:57text, you need end underscore if and
- 1:15:00then a semicolon, okay? So, unless I
- 1:15:02missed something important, which is
- 1:15:04perfectly possible, this should make uh
- 1:15:07the the bottom four status lights
- 1:15:09flip-flop once it's downloaded.
- 1:15:12Okay? So, actually good sign, you can
- 1:15:15see that three and four turn on with the
- 1:15:17button button not pressed. So, I'll go
- 1:15:19ahead and press the button and there you
- 1:15:21go. You can see all four of the status
- 1:15:24lights on the bottom of the PLC as well
- 1:15:26as the blue light are changing.
- 1:15:29Okay, so that's cool. That's if and else
- 1:15:31if and an end if statement. Um but,
- 1:15:33again, it's all pretty uh straight-up
- 1:15:36Boolean binary comparisons.
- 1:15:40So, let's add one more thing here uh for
- 1:15:42this introduction to structured text.
- 1:15:44Let's add a variable and do a little bit
- 1:15:46of sequencing, okay?
- 1:15:49So, let's go into uh project and global
- 1:15:52variables, double-click, and I'm going
- 1:15:55to insert two variables here. I'm going
- 1:15:57to call one last underscore user. And
- 1:16:01this is going to be a Boolean that I'm
- 1:16:03going to use to track the last state of
- 1:16:06the user push button. So, similarly, if
- 1:16:09you've done anything in Arduino or other
- 1:16:11programming languages, sometimes you
- 1:16:13want a condition that only happens on
- 1:16:15the rising edge of a value. And to do
- 1:16:17that, you want some sort of variable to
- 1:16:20track the last state of it. Uh and then
- 1:16:22at the end of your routine, you'll set
- 1:16:24last user equal to user. Uh and then
- 1:16:27this second variable, I will just call
- 1:16:29position and I'm actually going to make
- 1:16:31this an integer.
- 1:16:33And I'm going to say initially I want it
- 1:16:35to be zero. Initially, I'll have this be
- 1:16:37false.
- 1:16:39False. So, those are just initial
- 1:16:41values. Come on. There we go. Oh, I have
- 1:16:44caps lock on.
- 1:16:46Okay. Uh and I'm going to use position
- 1:16:48to track where in the sequence we are.
- 1:16:53And here I'm going to give it an
- 1:16:55attribute called retain, which means on
- 1:16:58uh downloads and power cycles, it's
- 1:17:00going to keep its value. Uh so, that's a
- 1:17:03useful thing when you have some sort of
- 1:17:05PLC program that you want to hold values
- 1:17:08even when you download new iterations of
- 1:17:10the code, you want it to be set to
- 1:17:12retain, okay? So, we made a few new
- 1:17:15global variables that we can use in our
- 1:17:16code. Let's go back to main and we're
- 1:17:19going to scrap most of this, all of this
- 1:17:21really.
- 1:17:23And let's go ahead and start by setting
- 1:17:25L1 through L4 all equal to false here in
- 1:17:29the beginning. Um and a little way that
- 1:17:32structured text programming works is
- 1:17:34this code is going to go through and set
- 1:17:37all four of these lights equal to false
- 1:17:40uh at the beginning of each scan, but
- 1:17:43it's only going to matter what the value
- 1:17:45of it is at the end of the scan. So, if
- 1:17:47you had code here that said green equals
- 1:17:50true and then you added a line here that
- 1:17:52said green equals false within your code
- 1:17:56right here, you're changing the value of
- 1:17:59green to true and then to false, but
- 1:18:01what's going to happen, the only thing
- 1:18:03that would actually happen if you ran
- 1:18:04this code, so let's just do it,
- 1:18:07is whoops, there we go. Is the green
- 1:18:10light will be false. All the lights will
- 1:18:12be false. It doesn't show green turning
- 1:18:14on and then green turning off because
- 1:18:17the only thing that executes is the
- 1:18:19value of the variables at the end of the
- 1:18:21routine. So, by setting L1 through L4
- 1:18:24false at the beginning, we have the rest
- 1:18:26of this code to decide if we want to
- 1:18:29turn uh L1 through L4 off
- 1:18:32or on.
- 1:18:34So, what we're going to do is we're
- 1:18:35going to say if position
- 1:18:38is equal to one, then I want L1 equal to
- 1:18:43true, okay? And uh a couple things to
- 1:18:46call out here in structured text, the
- 1:18:48comparison is just single equal sign.
- 1:18:52Most programming languages that you've
- 1:18:54probably seen before, two equal signs is
- 1:18:56how you check for equality. Um it's
- 1:18:59definitely how Python works and that's
- 1:19:01my favorite, so uh then we're going to
- 1:19:03say else if position is equal to two, L2
- 1:19:06is equal to true.
- 1:19:08And then we'll say else if position
- 1:19:11three, L3, else if position four, L4.
- 1:19:15And then we'll say else if one more
- 1:19:17thing and then I'm going to end if.
- 1:19:20Okay? So, let's just get this all lined
- 1:19:23up. Position three, three. Position
- 1:19:26four, four. And now, let's say else if
- 1:19:29position is greater than four,
- 1:19:33then what I want to do here, dang, then
- 1:19:36what I want to do here is say, "Okay,
- 1:19:38position has been has exceeded my max
- 1:19:41step, so I'm going to set back to zero.
- 1:19:43I'm going to put back to the beginning."
- 1:19:45And notice that the if thens don't have
- 1:19:47semicolons at the end, uh but end if
- 1:19:50does and all of the action lines in each
- 1:19:53if condition do have semicolons.
- 1:19:56Okay, so this is great, but nothing's
- 1:19:58actually changing the state of position
- 1:20:00yet.
- 1:20:01So, let's move this down a little bit
- 1:20:03and let's say if the user button gets
- 1:20:06pressed
- 1:20:07and it's a rising edge. So, not me
- 1:20:09holding down the user button. Let me say
- 1:20:12this is just when user first gets
- 1:20:14pressed. So, if user and not last user,
- 1:20:19then I want position to be equal to
- 1:20:21position plus one
- 1:20:23and then end my if statement. And I
- 1:20:25missed a semicolon there.
- 1:20:27Then at the very end, like we talked
- 1:20:29about, we're going to say last user, set
- 1:20:33it equal to the value of user. Okay? So,
- 1:20:36this should be all we need. This is
- 1:20:39setting the initial values of all of our
- 1:20:41lights.
- 1:20:43And just to make sure this new program
- 1:20:45really took, let's go ahead and say we
- 1:20:46actually want red to be on now and we're
- 1:20:50going to turn green off. So, when this
- 1:20:52boots up, if it's working properly,
- 1:20:54we'll know right away from red being on
- 1:20:56and green being off. Let's see if we
- 1:20:58made any errors.
- 1:20:59Looks good cuz I'm a professional. And
- 1:21:02the red light's on, nothing else is on,
- 1:21:04which makes sense based on the code that
- 1:21:06we wrote. And let me try to get this
- 1:21:08framed properly. I'm going to push the
- 1:21:10button and the blue light turns on and
- 1:21:12position one turns on. Push it again,
- 1:21:15position two turns on, three, four,
- 1:21:18zero. One, two, three, four, zero. Okay?
- 1:21:22And you can add position to your watch
- 1:21:24window, add to watch, as well as last
- 1:21:27user, if you really want to, as well as
- 1:21:29L1 through L4. Um and now, as you're
- 1:21:32cycling through pressing the button, you
- 1:21:34can see the value of position change
- 1:21:36every time you push the button. As and
- 1:21:38blue, user, and last user all change
- 1:21:41almost exactly together. Um
- 1:21:45but so that's really fun. That's basic
- 1:21:47sequencing. Um a very common way to
- 1:21:50write uh controls sequencing is in step
- 1:21:54one, do a series of things, and then,
- 1:21:56once you've checked some condition, like
- 1:21:58pressure, flow, temperature, move to
- 1:22:00step two, and then do a series of things
- 1:22:03in step two. So, this sort of sequential
- 1:22:05move through a position value uh is
- 1:22:08actually a really great introduction to
- 1:22:10PLC programming. So, that's some basic
- 1:22:12structured text, I think. Uh up next,
- 1:22:14we'll sort of recreate this program in
- 1:22:17ladder logic, so you get to see both of
- 1:22:19the main sort of two uh PLC programming
- 1:22:22languages that sort of duke it out for
- 1:22:23ultimate control.
- 1:22:25Um but I hope you found this uh
- 1:22:26introduction to structured text
- 1:22:28programming useful. The Arduino Opta is
- 1:22:30a really cool, affordable way to get
- 1:22:32into PLC programming. Thank you to
- 1:22:34Arduino for providing the hardware for
- 1:22:35this video. I hope you learned something
- 1:22:37with this structured text uh tutorial.
- 1:22:39Let me know what you want to see next on
- 1:22:41the channel. Thank you for watching and
- 1:22:42we'll see you next time. Thanks. Bye.
- 1:22:52Hello and welcome back to the channel.
- 1:22:53In today's video, I'm going to show you
- 1:22:55how to make your first PLC program in
- 1:22:57ladder diagram. Uh this is a super
- 1:23:00popular, super common PLC programming
- 1:23:02language. And to show you how ladder
- 1:23:05diagram works, I'm actually going to
- 1:23:07show you the structured text program
- 1:23:09that I built in the last tutorial. Um
- 1:23:11and I'm going to convert that exact
- 1:23:13program from structured text into ladder
- 1:23:16line by line with you. But I wanted to
- 1:23:17show you what the program does first
- 1:23:20because ladder is a very visual
- 1:23:21programming language.
- 1:23:23And it's pretty different from C or
- 1:23:25Python or C#. Uh so so if you're getting
- 1:23:28into programming for the first time,
- 1:23:30that's not a big deal. But if you've
- 1:23:32been a programmer for a while and you're
- 1:23:33getting into controls, this is a more
- 1:23:36useful way to learn it in my opinion.
- 1:23:38So, the code that you can see on screen
- 1:23:40right now does the following to the PLC.
- 1:23:42The red light is always on. I have a
- 1:23:45green status light up here that is
- 1:23:47always off. And then the blue light
- 1:23:49turns on when I push the button that's
- 1:23:51under my index finger. So, when I push
- 1:23:53the button, the blue light turns on with
- 1:23:55the button. Then down here, the four
- 1:23:57green status lights over here, I have
- 1:23:59them go in sequence from zero, position
- 1:24:03zero, to position one, two, three, and
- 1:24:05four. Okay? So, the whole routine that
- 1:24:08you see here
- 1:24:10sets the initial values of all seven of
- 1:24:12those lights that I just mentioned. And
- 1:24:14then it says, "Hey, if the user button
- 1:24:16was just pressed and the last state of
- 1:24:19the user button was that it wasn't
- 1:24:20pressed, add one to this position
- 1:24:22variable and then end the if statement."
- 1:24:25Uh and then it checks if we're in
- 1:24:27position one, turn L1 on. If we're in
- 1:24:29position two, turn L2 on. If we're in
- 1:24:31position three, turn L3 on. Four, L4 on.
- 1:24:35And then if position exceeds four,
- 1:24:36meaning I pushed it a fifth time, set it
- 1:24:39back equal to zero. And then lastly, set
- 1:24:42the last user variable equal to user.
- 1:24:45Okay? So, if you have a PLC uh an
- 1:24:48Arduino PLC in your programming along,
- 1:24:51make sure that um from your overview
- 1:24:53screen, you're it kind of looks like
- 1:24:55this. Uh I should have started if I did
- 1:24:58this the right order, I should have
- 1:24:59started with a video on how to get set
- 1:25:01up with your Arduino Opta PLC. Um so,
- 1:25:04make sure you watch that if you're not
- 1:25:06at this step and you're trying to code
- 1:25:08along exactly with this tutorial. Get to
- 1:25:10this step um where the license looks
- 1:25:13okay and all the available interfaces
- 1:25:15look okay and it says connected in the
- 1:25:17bottom right. Um
- 1:25:19again, I should have done a tutorial on
- 1:25:21how to get here, so just check my
- 1:25:22channel. Or if you're watching all these
- 1:25:24videos smashed together, check the first
- 1:25:26section of this video for that. Um
- 1:25:29now, two other things we did uh in the
- 1:25:31structured text video to set ourselves
- 1:25:33up that you want double-check are in
- 1:25:34there. We went to button inputs and the
- 1:25:37user that is on the front of the PLC,
- 1:25:40the user button,
- 1:25:42we added the variable uh so that we
- 1:25:44could call it user in our program. So,
- 1:25:45make sure you have user or something
- 1:25:47easy to remember there. And then for LED
- 1:25:50outputs, I added the variable names L1
- 1:25:52through L4, red, green, and blue
- 1:25:56to all seven of these lights so that I
- 1:25:58could call these lights from the PLC as
- 1:25:59well. So, make sure you have all those
- 1:26:02variable names or you'll be like,
- 1:26:04"Hey, my version that I'm trying to
- 1:26:06follow along with uh doesn't compile and
- 1:26:09says that like those variable names
- 1:26:10don't exist or something like that."
- 1:26:12Okay? So, uh with that basic setup, with
- 1:26:15these variable names, with these button
- 1:26:17inputs, uh let's go ahead and go to
- 1:26:20project and let's go to add and new
- 1:26:24program. And we'll call this name we'll
- 1:26:27call this ladder one cuz I might do more
- 1:26:30ladder. And make sure you have LD,
- 1:26:33ladder diagram, selected. Structured
- 1:26:35text was what we did in the last video.
- 1:26:38And we're going to assign it to fast.
- 1:26:40So, these are different scan rates,
- 1:26:42fast, slow, backward background, and
- 1:26:44init. We might get more into it later or
- 1:26:46just let me know if you have questions
- 1:26:48about when to assign what to where.
- 1:26:50Uh but we're going to assign it to fast.
- 1:26:52No reason not to go fast. Um and let's
- 1:26:55just go line by line of what's happening
- 1:26:57in this main PLC and talk about how to
- 1:27:00recreate that in ladder.
- 1:27:02Okay? So, the first line is green equals
- 1:27:04false. So, how do we make a line of code
- 1:27:08in ladder diagram to set an output equal
- 1:27:10to false all the time? Well, we're going
- 1:27:13to use this output coil, which is what
- 1:27:14this object looks like. We're going to
- 1:27:16put the variable green in it. And
- 1:27:20currently, what it reads as is actually
- 1:27:22green is always true. So, I'm going to
- 1:27:24double-click on that coil and I'm going
- 1:27:26to negate it. And this strike through,
- 1:27:30this uh open parentheses, let hash line
- 1:27:33slash line, and then close parentheses
- 1:27:35reads as not. So, it's basically green
- 1:27:39is not on. If I copy this whole ladder
- 1:27:42one
- 1:27:43and I change this to normal and I change
- 1:27:46this name to red,
- 1:27:48this line of code reads as red is always
- 1:27:51on. So, we have green always false, red
- 1:27:55always true. That's what line one and
- 1:27:57line two here are doing. And it looks
- 1:28:00like this in structured text. Green is
- 1:28:02false, red is true. Okay? So, you can
- 1:28:05see right away just with this basic
- 1:28:06comparison that ladder is a super visual
- 1:28:09language. There's nothing that
- 1:28:10explicitly tells you it's true or false.
- 1:28:13It's telling you based on what sort of
- 1:28:15relays in electrical schematics look
- 1:28:16like that green will not be true and red
- 1:28:19will not be false.
- 1:28:21Uh green will not be true and red will
- 1:28:23always be true. So, let's look at the
- 1:28:25next line of code, which if you
- 1:28:27remember, was that blue, the blue light,
- 1:28:29will be exactly equal to the input of
- 1:28:32the user push button. So, I click on
- 1:28:34that coil again and I say, "Hey, we're
- 1:28:36going to control the blue light." But
- 1:28:38we're going to control it based on an
- 1:28:40input now. So, this is called a contact.
- 1:28:43These on the right that are controlling
- 1:28:44outputs are called coils. This on the
- 1:28:47left is called a contact. And we're
- 1:28:49going to say
- 1:28:50equal to
- 1:28:52the user input. So, the way this line of
- 1:28:54code reads as if user push button is
- 1:28:58pressed, then blue light is on. But
- 1:29:00there's a second thing going on here,
- 1:29:02which is if user push button is not
- 1:29:05pressed, blue light is off. And that's
- 1:29:07because this output is a momentary
- 1:29:10output, which means the blue light will
- 1:29:13be on as long as the conditions on the
- 1:29:15left of this rung are true. but by
- 1:29:17default, the blue light will then go off
- 1:29:20when the conditions on the left side are
- 1:29:22false. So, this sort of has if user,
- 1:29:25then blue light, and if not user, then
- 1:29:28not blue light baked into one line of
- 1:29:31code.
- 1:29:32So, it really is the same way this says
- 1:29:34blue is equal to user, whether it's
- 1:29:36true, whether it's false, set blue equal
- 1:29:38to user. That is basically exactly what
- 1:29:41this line of code is doing. So, so far
- 1:29:43we have three for three recreated from
- 1:29:45structured text. Now, this is us setting
- 1:29:48the initial value of all four of those
- 1:29:50lights equal to false. So, we're going
- 1:29:51to copy this green line, which is
- 1:29:54this whole rung, which is setting green
- 1:29:57equal to false. And let's see, can I
- 1:30:00move that down? I really want it in
- 1:30:01exactly the same
- 1:30:04I really want it in exactly the same
- 1:30:05spot. There we go. So, I'm going to
- 1:30:07change this to L1.
- 1:30:09And now, rather than make four rungs of
- 1:30:12code to do the exact same thing for
- 1:30:14these lights, I'm going to just control
- 1:30:16C and then control V right here.
- 1:30:19And you can see it sort of puts this
- 1:30:21branch in, which is saying, "Hey, the
- 1:30:23same input conditions are true for all
- 1:30:26of the outputs on this rung." So, the
- 1:30:28four outputs are just L1 through L4. Set
- 1:30:31them equal to not true.
- 1:30:34Um but, the input is shared by all four
- 1:30:36of them.
- 1:30:37All right. So, this is how we say L1,
- 1:30:40L2, L3, L4 equals false. That's what
- 1:30:43rung four through seven here are doing.
- 1:30:46Let's just keep going. Let's take a look
- 1:30:48at saying if user and not last user,
- 1:30:52then position equals position plus one.
- 1:30:55Okay? That's the line of code that
- 1:30:57checks when the user button is first
- 1:30:59pressed uh and adds one to the position
- 1:31:02incrementer. So, to do that, we'll say
- 1:31:04right click, new network after.
- 1:31:07And now, we're going to check two
- 1:31:09conditions. We're going to check if
- 1:31:10user, and then I'm just going to control
- 1:31:13C, control V this.
- 1:31:15And we're going to check if not user so
- 1:31:18last user.
- 1:31:20So, last user, but this one needs to be
- 1:31:22negated. And this is saying if the user
- 1:31:25push button is pressed and the last user
- 1:31:28Boolean is not true, then but we can't
- 1:31:32use a coil anymore. A coil is
- 1:31:34specifically just for Boolean
- 1:31:35conditions. It's for true false things.
- 1:31:38We need to adjust an integer value,
- 1:31:40which is called position. Ah, and I
- 1:31:42forgot to say this in the setup, but if
- 1:31:44you go to global variables, these two
- 1:31:46were made for the structured text
- 1:31:48tutorial. The variable last user, which
- 1:31:51is a Boolean, and I have the initial
- 1:31:53value set to false, which will be how we
- 1:31:55track the last state of the user push
- 1:31:57button. And then position, which is an
- 1:31:59integer, which will start out as zero.
- 1:32:02And I have retain on, which means it
- 1:32:03will
- 1:32:04keep its value on new iterations of the
- 1:32:07code being pushed. So, if position is
- 1:32:09set to three, when I update the code, it
- 1:32:11will stay as a three.
- 1:32:13Um
- 1:32:14and that will track where in the
- 1:32:15sequence we currently are. So, let's go
- 1:32:17back to our ladder. Just make sure you
- 1:32:19have these global variables set if
- 1:32:20you're following along exactly.
- 1:32:22Um and we'll say if user and not last
- 1:32:25user. And now, we need a new block. And
- 1:32:28if you're if you don't have this toolbar
- 1:32:30in here, go to project. No, go to view,
- 1:32:33toolbars.
- 1:32:35View, toolbars, and make sure FBD is on.
- 1:32:37Uh if you have a decent size monitor,
- 1:32:39you can have all of these toolbars on.
- 1:32:41It doesn't really hurt to have SFC.
- 1:32:44Um it's just it's not something we need
- 1:32:46right now.
- 1:32:47Um so, but you do need FBD because new
- 1:32:50block exists in FBD.
- 1:32:53And then, when you add a new block, uh
- 1:32:56this object browser lets you type in
- 1:32:58text and search for things, but you need
- 1:32:59to have most of the objects checked and
- 1:33:01selected. So, you could have them all
- 1:33:03checked and selected. That's not going
- 1:33:05to hurt you. It's just going to give you
- 1:33:06the most options. And the first thing we
- 1:33:09want to check for is an add function.
- 1:33:11Okay? So, ADD because what we want to do
- 1:33:15is say if user and not last user, then
- 1:33:19add one
- 1:33:21to
- 1:33:22position.
- 1:33:24And store that value in the position
- 1:33:26variable, and then we don't need a coil
- 1:33:28on this rung. Okay? So, this line of
- 1:33:31code, if user and not user, add one to
- 1:33:34position, looks very visually different
- 1:33:37from this if user and not last user,
- 1:33:40then position equals position plus one
- 1:33:42and if, but those are clones. Those are
- 1:33:44functionally equivalent. Okay?
- 1:33:47And just so I don't forget cuz it comes
- 1:33:49at the very end, but we might as well
- 1:33:51set it right now.
- 1:33:52Um we want the last network, so the
- 1:33:55bottom network in this to be set
- 1:33:58last user
- 1:34:00equal to user because uh ladder logic
- 1:34:04reads top to bottom and left to right.
- 1:34:07So, every scan of the PLC will start
- 1:34:09from one and go down to however however
- 1:34:12many rungs we have in our code. And then
- 1:34:14at the end, it will set last user equal
- 1:34:17to user. So, this line of code will only
- 1:34:20ever be true once at a time per button
- 1:34:23press, and then last user will
- 1:34:24immediately get set to the same value as
- 1:34:26user.
- 1:34:28Hopefully, that makes sense.
- 1:34:29Uh now, let's add a new rung here
- 1:34:33to do these steps here, which is if
- 1:34:35position one, then L1. If position two,
- 1:34:38then L2. And then, all the way through
- 1:34:40to if four, uh then four. And so, let's
- 1:34:43just go ahead. We need a new block here.
- 1:34:45We actually don't need either of these
- 1:34:47coils, but we need a new block, which
- 1:34:49will be checking for equality. So,
- 1:34:51that's EQ.
- 1:34:53And uh you grab the EQ block and you say
- 1:34:56if the position value
- 1:34:59is equal to one,
- 1:35:02then
- 1:35:03L1.
- 1:35:04And this rung of code is the exact same
- 1:35:07thing as if position one,
- 1:35:09uh then L1 from structured text right
- 1:35:12here. So, this is if position one, then
- 1:35:14L1 equals true.
- 1:35:16So, we just need to copy that 1 2 3 4 so
- 1:35:21that we can say, "Okay, now if two, then
- 1:35:26L2.
- 1:35:28If
- 1:35:29three,
- 1:35:31L3.
- 1:35:33And I somehow got them out of order.
- 1:35:36Okay, 1 2
- 1:35:383
- 1:35:39L3.
- 1:35:42And then, if four,
- 1:35:45L4. And now, we need just one more rung
- 1:35:49of code because if you remember from our
- 1:35:51structured text, we had if position is
- 1:35:53greater than four, then we need to set
- 1:35:56position back equal to four. So, we'll
- 1:35:58put in a new network after this. And we
- 1:36:00need two new blocks. We need to check uh
- 1:36:03for greater than. So, we'll go to block
- 1:36:05and we'll check uh GT is the code for
- 1:36:09greater than. If you ever can't find it
- 1:36:11uh because they're not all named super
- 1:36:14intuitively, you can just put a star in
- 1:36:16there and all of them will show up. And
- 1:36:18a little bit of scrolling, you'll see GE
- 1:36:20is greater than or equal to. GE GT is
- 1:36:23just regular old greater than.
- 1:36:26And we'll say, "Okay, if the position
- 1:36:29variable is greater than four."
- 1:36:32Now, the difference here is we don't
- 1:36:33want to change a output based on this.
- 1:36:36We actually want the next uh block in
- 1:36:39the rung to be controlled by this. Cuz
- 1:36:41if we just hit another block and we grab
- 1:36:43MOVE, which is how you move a value into
- 1:36:47a variable,
- 1:36:48and we say this is when we're going to
- 1:36:50want to move zero into the position
- 1:36:53value like that. Problem is we need this
- 1:36:56tied to this. We can't use enable
- 1:36:58output. This is always going to be true.
- 1:37:01We need this output to be tied into
- 1:37:03that. So, to do that, you delete this
- 1:37:05little tag. You right click on the body
- 1:37:07of the object and you say new con Nope,
- 1:37:11it's set output line.
- 1:37:14There we go. Set output line. Okay? So,
- 1:37:17this is what you want it to look like to
- 1:37:18actually say if position greater than
- 1:37:21four, go move zero into position.
- 1:37:24But, these 11 lines of ladder, and you
- 1:37:27can see it's quite a bit more scrolling
- 1:37:29than this little view of structured
- 1:37:31text, but functionally identical.
- 1:37:33Setting the same preliminary values and
- 1:37:35then sequencing through the PLC. And
- 1:37:38just so you can see that it's
- 1:37:39functionally identical, I'm going to go
- 1:37:40ahead and delete this out of this uh out
- 1:37:43of this structured text. And then, I'm
- 1:37:45just going to delete Actually, I'm going
- 1:37:47to just going to delete main out of the
- 1:37:48routine so that the only thing on here
- 1:37:51is this ladder routine. And now, I'm
- 1:37:53going to download it to my PLC. I will
- 1:37:56compile it.
- 1:37:58And I've got it up here. Make sure you
- 1:38:02got a good view. Okay? Push the button.
- 1:38:04Blue turns on.
- 1:38:06And we're cycling through it exactly
- 1:38:08like the structured text that we had at
- 1:38:10the start of the video. Okay? So, I know
- 1:38:13it might seem a little odd to rather
- 1:38:15than build something from scratch,
- 1:38:17compare it to structured text, but I
- 1:38:19really think if you're a PLC programmer,
- 1:38:21it's really important to understand how
- 1:38:24ladder logic correlates to structured
- 1:38:26text. Those are by far the two most
- 1:38:29common PLC programming languages that
- 1:38:31drive entire factories. So, knowing both
- 1:38:33of them is a really good idea. I hope
- 1:38:36you found this introductory tutorial
- 1:38:38useful. Be sure to let me know in the
- 1:38:39comments below what you want to see next
- 1:38:41on the channel. Um that's going to do it
- 1:38:43for today's starter video on ladder
- 1:38:45logic. Thank you to Arduino for
- 1:38:47providing the hardware used in this
- 1:38:48video. So, Arduino once again is making
- 1:38:52uh things more accessible for hobbyists
- 1:38:54and makers. So, thank you very much to
- 1:38:56Arduino. I'll see you next time. Thank
- 1:38:58you so much for watching. Thanks. Bye.
- 1:39:06Hello and welcome back to LeMasterTech.
- 1:39:08And today's video is going to be a
- 1:39:10continuation in the introduction to
- 1:39:12controls and automation tutorial series
- 1:39:14we've been doing in the channel
- 1:39:16recently. Today's video specifically,
- 1:39:18we're going to take an introduction to
- 1:39:20the world of wiring and electrical
- 1:39:22schematics for controls and automation.
- 1:39:25So, this is a super important concept
- 1:39:28and aspect of controls and automation
- 1:39:29engineering. It's also kind of a tricky
- 1:39:32one to figure out a good intro video.
- 1:39:35So, I want to start by briefly telling
- 1:39:36you how we're going to attack this sort
- 1:39:38of concept. So, there's way more just
- 1:39:41like all these concepts, there's way
- 1:39:42more than you could possibly cover in
- 1:39:44just one short introduction video for
- 1:39:47the world of electrical
- 1:39:49controls and automation. And so, what
- 1:39:51we're going to do is we're going to take
- 1:39:53a look at some example control
- 1:39:54schematics, not of panels that I
- 1:39:56physically have here in front of me, but
- 1:39:58then we're going to take a look at some
- 1:40:00very basic schematics, create them from
- 1:40:02scratch together, and then we'll also
- 1:40:04take a look at the hands-on what that
- 1:40:06actually means in the physical world.
- 1:40:07So, how every wire that you add to a
- 1:40:10control schematic actually communicates
- 1:40:12and translates into the real world.
- 1:40:14We're going to do a few hands-on
- 1:40:15examples together. So, that's sort of
- 1:40:17the format here. If you have basic
- 1:40:19understanding of hobby electronics, like
- 1:40:22you've played around with Arduinos or
- 1:40:23Raspberry Pis, then this will be a cool
- 1:40:25way to see how it translates into the
- 1:40:27world of industrial automation and
- 1:40:29controls. And then if you've been an
- 1:40:30electrician or a maintenance technician
- 1:40:32or anything like that, this will be a
- 1:40:34really good way for you to see the
- 1:40:36controls and software piece of it, but
- 1:40:38you're probably pretty familiar with the
- 1:40:39hands-on piece already. So, let's just
- 1:40:41dive right in. In terms of visual aids,
- 1:40:44it's going to be a little all over the
- 1:40:45place cuz I have some like very
- 1:40:47high-level bullet points in a
- 1:40:48PowerPoint. Then we're going to take a
- 1:40:50look super briefly at the code we write,
- 1:40:52but then we're going to cut over to a
- 1:40:53physical wiring as well. And again, the
- 1:40:56reason wiring is kind of a broad topic
- 1:40:58and a hard one to cover is because in
- 1:41:00the world of industrial automation and
- 1:41:02controls, a control panel schematic and
- 1:41:04a drawing package could be things that
- 1:41:06call out your devices and your actual
- 1:41:08sensor level connections to a control
- 1:41:11panel, and then all the PLC controller
- 1:41:14level connections. So, from your PLC to
- 1:41:16IO modules, input and output blocks,
- 1:41:19relays, terminal blocks and
- 1:41:20distribution, as well as connections to
- 1:41:23the devices and the sensors, and then
- 1:41:24your power distribution, usually a
- 1:41:26high-power AC power feed into a control
- 1:41:30panel, and how it translates into DC or
- 1:41:32step-down transformers to be used inside
- 1:41:35the control panel,
- 1:41:36as well as power feed to motors and VFDs
- 1:41:39and things like that. And then often
- 1:41:41your networking would be encompassed in
- 1:41:42that as well. So, your Profinet or
- 1:41:44EtherCAT or Ethernet connections as
- 1:41:46well. So, obviously it's a super broad
- 1:41:48concept, but the drawing package for a
- 1:41:51control panel is maybe the most
- 1:41:53important thing
- 1:41:54to correlate the physical world to the
- 1:41:57software side that are both so important
- 1:41:59for controls and automation. So, super
- 1:42:02quickly, in an industrial control
- 1:42:05package, a really good drawing package,
- 1:42:07you'll usually have a view that looks
- 1:42:09like both of these. So, this is kind of
- 1:42:10two different views.
- 1:42:12I'll try to drop myself in the middle
- 1:42:14here. This is kind of two different
- 1:42:17views most of the time. And what you've
- 1:42:19got is a physical rendering of the panel
- 1:42:22on the left here. So, this has these
- 1:42:24green covers are usually plastic
- 1:42:27wireways called Panduit or whatever sort
- 1:42:30of wireway that you have. It's just an
- 1:42:33industrial way of keeping your wires
- 1:42:35organized. As you will see when we get
- 1:42:37to my hands-on examples,
- 1:42:39physical wiring in the field looks
- 1:42:41really messy if you're not zip tying or
- 1:42:44using cable glands and conduit and stuff
- 1:42:46to keep your cords really clean. So,
- 1:42:48most of the time these like gray or
- 1:42:50light green rectangles will be in a
- 1:42:52materials like Panduit and it'll be a
- 1:42:55wireway. But then it this physically
- 1:42:58will look almost identical to the
- 1:43:00control cabinet when you swing the door
- 1:43:02open. So, you have circuit breakers and
- 1:43:04power distribution and VFDs and PLC
- 1:43:07components in a very physical realistic
- 1:43:10rendering. And then on the right you
- 1:43:12have what's kind of called the
- 1:43:13wireframe, which is usually a slightly
- 1:43:16less, but still precise, but slightly
- 1:43:19less precise physical rendering of the
- 1:43:21panel, but everything would be labeled
- 1:43:23with however it's getting called out in
- 1:43:24the drawing. So, if you see these are
- 1:43:26basically the same
- 1:43:28control cabinet, but on the right there
- 1:43:30are a lot of blue small text that's kind
- 1:43:33of hard to read, but there's a lot of
- 1:43:35blue labels calling these VFDs out as
- 1:43:37VFD 1070, 2070, 2190.
- 1:43:41Your switch in the middle row, terminal
- 1:43:43blocks, PLC components. And so, this is
- 1:43:46a labeled one that still has all of the
- 1:43:48physical components in their correct
- 1:43:50physical locations, but this one is
- 1:43:53correlating
- 1:43:54a wiring label like VFD 1070 or
- 1:43:57whatever, some way that it's going to
- 1:43:59get referred to in this control package,
- 1:44:02and it's it's correlating that physical
- 1:44:05component to a drawing package page that
- 1:44:08we'll find. So, if we look in this next
- 1:44:10page at an example page of an industrial
- 1:44:12wiring package,
- 1:44:14this is actually a great example of the
- 1:44:17whole drawing package once you get into
- 1:44:19the line level schematics, which we'll
- 1:44:21talk more about during this video.
- 1:44:24But to highlight a few things here, it's
- 1:44:26very common to have two columns side by
- 1:44:28side that have these wire numbers.
- 1:44:31That's kind of hard to see, but these
- 1:44:33line numbers from like 200 to 222.
- 1:44:36And often the wires will get physically
- 1:44:39labeled with whatever wire with whatever
- 1:44:42row they're on in their drawing package.
- 1:44:45So, it's very normal to see wire label
- 1:44:48physically on a wire in a panel that
- 1:44:50says 205 or 225.
- 1:44:54It's also very normal to see their tag
- 1:44:56name. So, if you have like a solenoid
- 1:44:57valve, it could say SV500
- 1:45:00whatever.
- 1:45:01But often the label will be a
- 1:45:04combination of where it physically is in
- 1:45:06the field and where it is in your
- 1:45:08drawing package.
- 1:45:10But anyways, you'll get these two
- 1:45:11columns side by side kind of drawings
- 1:45:13just because most wires don't merit a
- 1:45:16full page. Most schematics don't need a
- 1:45:19full landscape page. So, they'll split
- 1:45:21into two columns. And then the footer is
- 1:45:24actually where I want to spend some time
- 1:45:25here because the
- 1:45:27because the footer of the drawing
- 1:45:30package contains an enormous amount of
- 1:45:32information. Usually on the left side
- 1:45:34you have revision notes, which would be
- 1:45:36the person who approved a revision, the
- 1:45:38date it got changed, which revision
- 1:45:40number or letter it is, and then usually
- 1:45:43a brief note or comment about the
- 1:45:46revision itself. Like what are you
- 1:45:47adding, what are you deleting, what are
- 1:45:48you changing? It's very normal to see
- 1:45:51the latest revision or the newest
- 1:45:53revision have all the changes in like a
- 1:45:55cloud or a bubble format on your
- 1:45:57drawing. And then there's usually some
- 1:45:59footer information about the company
- 1:46:01that the drawings are for. Like, "Hey,
- 1:46:04this was for, you know, this chemical
- 1:46:06plant prepared by this person, this
- 1:46:08address, whatever." So, some physical
- 1:46:10information about the drawing package.
- 1:46:12And then over here is usually who
- 1:46:14prepared it. So, you'll have like the
- 1:46:16engineer's name of who prepared it, who
- 1:46:18installed it, who
- 1:46:20you know, engineer or designer that was
- 1:46:22kind of behind that. More information
- 1:46:24about the customer. And then usually in
- 1:46:26the footer you also have stuff on every
- 1:46:28single page that tells you the name of
- 1:46:30that page and then where within the
- 1:46:32broader drawing package you are. So, on
- 1:46:34a huge control panel that has individual
- 1:46:38motor and sensor and device schematics
- 1:46:40called out, you could be on page like 12
- 1:46:43of 158. So, the numbering and the
- 1:46:46information in the footer is very
- 1:46:47important. To talk super briefly about
- 1:46:51some of the most common software out
- 1:46:53there, you have like DWG like AutoCAD,
- 1:46:56Autodesk are some of the more common CAD
- 1:47:00software, and then EPLAN is one of the
- 1:47:02more like software-intensive
- 1:47:04CAD packages as well. But there's also
- 1:47:07some free ones online.
- 1:47:09You can use things like KiCad, which is
- 1:47:11best known as an electrical package for
- 1:47:14like designing PCBs, but you can do free
- 1:47:16schematics as well. There's a lot of
- 1:47:19online tools that are kind of free, but
- 1:47:22have less power. So, I think AutoCAD
- 1:47:26and basically EPLAN are like probably
- 1:47:28the two biggest competitors in this
- 1:47:30space. But there's plenty of companies
- 1:47:33that do this just like any other piece
- 1:47:35of the industrial automation and
- 1:47:36controls world. Okay? Where do you
- 1:47:38begin? If this is a beginner intro to
- 1:47:41control panels and schematics, knowing
- 1:47:43that the footer has great information,
- 1:47:45knowing that there's usually a title
- 1:47:46page, knowing what software to download,
- 1:47:49that's all great.
- 1:47:51But briefly, some some talking points.
- 1:47:53So, to remind you, this is an
- 1:47:55introduction and not a comprehensive
- 1:47:57lesson. And then if you Google just
- 1:48:00control package like electrical panel
- 1:48:02wiring examples, there are some really
- 1:48:05good ones out there that actually show
- 1:48:07you physical ones in the field, and they
- 1:48:09talk you through what you're physically
- 1:48:11looking at and everything else like
- 1:48:12that. So, if this in particular is the
- 1:48:14aspect of controls and automation that
- 1:48:16you really want to become super
- 1:48:18proficient at, I suggest you just do
- 1:48:20some Googling. This Solis PLC, another
- 1:48:23great online company, RealPars, has some
- 1:48:26other good examples, and they actually
- 1:48:28talk about individual components and
- 1:48:30schematics that you'll see in the field.
- 1:48:31So, that's not a cop-out. This is meant
- 1:48:34to get you familiar with the basics, but
- 1:48:36it's also just not a deep dive. So, if
- 1:48:39you want to spend a lot more time
- 1:48:40studying on this, I absolutely recommend
- 1:48:43just spend some time Googling. Solis PLC
- 1:48:45and RealPars have some great examples as
- 1:48:47well as some others out there. Okay?
- 1:48:50But then I do think one thing that's
- 1:48:52really important to talk about as part
- 1:48:53of this video is who has standards in
- 1:48:56this field. So, if you're a drawing
- 1:48:58designer or an instrumentation
- 1:49:01and controls engineer, it's very
- 1:49:03important to be familiar with NFPA 70,
- 1:49:06NFPA 79, and UL 508A.
- 1:49:10Also sometimes called NEC 70, but
- 1:49:13basically these are industrial guides on
- 1:49:16power requirements, power distribution
- 1:49:18requirements, best practices for
- 1:49:20installing and creating and developing
- 1:49:22control cabinets. UL or Underwriters
- 1:49:24Laboratory is a listing that like panel
- 1:49:27fabrication shops and places that
- 1:49:29develop controls equipment, they want to
- 1:49:31stamp their panel with a UL listing
- 1:49:33because that means they've they've
- 1:49:35adhered to a certain high standard that
- 1:49:37gets validated by this company, by the
- 1:49:39UL organization. Those are like
- 1:49:42thousand-page
- 1:49:43guidelines and books, and usually I
- 1:49:45think you have to pay for a whole copy
- 1:49:47of them. Practices of those are found
- 1:49:50online. They talk about wire gauges,
- 1:49:52power distribution concerns, and a lot
- 1:49:54of other really great things to keep in
- 1:49:56mind while you're developing control
- 1:49:57panels, but not really what we're going
- 1:50:00for in today's video. So those three
- 1:50:02standards are great for looking into.
- 1:50:04Um, but let's talk more practically. If
- 1:50:07you're a hobbyist or an a field engineer
- 1:50:09who just needs to know when I need
- 1:50:11information, where can I go to get said
- 1:50:14information? And it it's really
- 1:50:17the internet. But anytime you buy a
- 1:50:19sensor or a switch or a button or a
- 1:50:21motor, the manufacturer of that
- 1:50:23component should be providing the wiring
- 1:50:25schematic and information to you
- 1:50:28via internet manuals, downloadable
- 1:50:30manuals. Ideally it would be included
- 1:50:32with the component when you buy it, but
- 1:50:34just a quick Google or if you're buying
- 1:50:36components from Amazon like I do for my
- 1:50:38garage all the time, the Amazon listing
- 1:50:40itself often times has the wiring called
- 1:50:43out as well.
- 1:50:45Um,
- 1:50:45and then control components, these are
- 1:50:47actually a lot more standard. So if
- 1:50:49you're buying Allen-Bradley or Siemens
- 1:50:51or Beckhoff or even, you know, Arduino
- 1:50:53PLC like we're using in this tutorial
- 1:50:55series, they have really good pinouts
- 1:50:58and wiring schematics. They can take a
- 1:51:00variety of forms, so they won't always
- 1:51:02look like something you can easily drop
- 1:51:04into a wiring diagram, and they won't
- 1:51:07always have a 3D model that you can
- 1:51:09include in your panel. Sometimes you
- 1:51:11just need to make a little rectangle and
- 1:51:13say, "Hey, this is, you know, this
- 1:51:14device." or anything like that. But the
- 1:51:16actual wiring of how to wire a component
- 1:51:19comes from the manufacturer you buy the
- 1:51:21component from. So you don't have to do
- 1:51:23any guessing of how these things work.
- 1:51:25And then why it's so important and why
- 1:51:28it's worth a whole video during this
- 1:51:29tutorial series just to talk about this
- 1:51:32component is because in the world of
- 1:51:33industrial automation and controls, and
- 1:51:35honestly in the tutorials that we're
- 1:51:37doing just in this series, control
- 1:51:39panels and control systems get very
- 1:51:41large very quickly. And so manually
- 1:51:44tracking down every wire and cable,
- 1:51:46where it came from in the field and
- 1:51:48where it landed in the panel, it's not
- 1:51:50always safe, it's not always feasible if
- 1:51:52you've tucked things into conduit runs,
- 1:51:54or they're in, you know, an
- 1:51:56explosion-proof building but your
- 1:51:57control cabinet's on the outside,
- 1:52:00or even wireways inside of Panduit tends
- 1:52:02to get so full that you can't just trace
- 1:52:05your wire accurately.
- 1:52:07And it's also just faster. If you're the
- 1:52:10person trying to hook up a system and
- 1:52:11you're in the field and it's 2:00 in the
- 1:52:13morning and you've been on site for 48
- 1:52:15hours straight, you want an accurate,
- 1:52:17well-documented control panel schematic
- 1:52:20rather than guessing, trying to find a
- 1:52:22spare channel on your PLC, trying to
- 1:52:24look into the code and see if there's a
- 1:52:25spare channel by like reverse
- 1:52:28engineering the code. So understanding
- 1:52:30the electrical schematic importance of
- 1:52:33industrial automation and controls is
- 1:52:35super pivotal. Okay, so that was a lot
- 1:52:37of Pete talking, which is my least
- 1:52:39favorite kind of video. I really like to
- 1:52:41show you guys things and do engineering
- 1:52:43together. So let's get into a practical
- 1:52:45example, and let's just start because I
- 1:52:48really want this to be a tutorial series
- 1:52:49that's low to no barrier to entry,
- 1:52:52right? I'm going to make all of the
- 1:52:53electrical schematics today in this
- 1:52:55example for you in PowerPoint. I don't
- 1:52:58want this to be like, "Oh, as long as
- 1:52:59you have EPLAN or as long as you have
- 1:53:01AutoCAD, you can follow along." So for
- 1:53:04an example, let's take a look at a
- 1:53:06system that has a power supply, a PLC,
- 1:53:09and one input, which is just going to be
- 1:53:11a hand switch, okay? So a, you know,
- 1:53:13on-off hand switch, and then a PLC and a
- 1:53:17power supply.
- 1:53:19And I think I also, when I prepared
- 1:53:21these schematics, I had 12-V power
- 1:53:23supply called out. I think I've got a
- 1:53:2524-V power supply on my DIN rail right
- 1:53:28now. That part doesn't matter too much
- 1:53:30because the pinout's the same and the
- 1:53:32Arduino PLC can take between 12 and 24-V
- 1:53:35power supply, but nobody yell at me in
- 1:53:37the comments if the schematic says 12-V
- 1:53:39DC and the actual power supply says 24
- 1:53:42V.
- 1:53:42I will ignore your yelling. I want to
- 1:53:44talk about what I have on on the screen
- 1:53:47right now because like I said, I'm
- 1:53:48making this in PowerPoint. These are
- 1:53:50not, you know, shapes that you download
- 1:53:53from the manufacturer, anything else
- 1:53:54like this. This is literally just I have
- 1:53:57a power supply that takes wall outlet
- 1:53:59voltage. And then this power supply
- 1:54:01gives me two plus and two minus, so two
- 1:54:04zero VDC and two 12-V DC channels. I
- 1:54:08need the Arduino PLC to receive power,
- 1:54:11so it has two positive terminals and two
- 1:54:13negative terminals as well. And then it
- 1:54:15has eight input channels, and then it
- 1:54:17has four relay output channels. So if
- 1:54:19you've been following along with the
- 1:54:20tutorial series, you've seen the the
- 1:54:22body of the Arduino already. I'll have
- 1:54:25some pictures of it on screen now as
- 1:54:27well, but this is a simple rectangular
- 1:54:31representation of the component that
- 1:54:33we're dealing with. And then my hand
- 1:54:35switch has two different sets of
- 1:54:37terminals on the back labeled 11, 12,
- 1:54:4023, and 24, and it's just two different
- 1:54:42strips that are made when it's in the
- 1:54:44two different positions. So that's my
- 1:54:46hand switch.
- 1:54:48Let's take a look at what a not
- 1:54:50industrial control cabinet schematic for
- 1:54:52this system might be, okay? So this,
- 1:54:55again, just in PowerPoint, no fancy
- 1:54:57software or anything. I'm using a solid
- 1:55:00blue line to show my DC positive power,
- 1:55:04and then I'm using a kind of a white and
- 1:55:06blue, white with blue stripe is very
- 1:55:08common in the world of electrical
- 1:55:10controls for 0-V DC,
- 1:55:13or just solid white is also very common.
- 1:55:17But basically I have black, white, and
- 1:55:19green from the wall outlet into my power
- 1:55:22supply, and then I'm providing power and
- 1:55:250 V.
- 1:55:26So these two wires make up a power loop
- 1:55:28to the Arduino PLC.
- 1:55:31And then I'm using another positive lead
- 1:55:33off the power supply to go into the hand
- 1:55:35switch, and then when I turn the hand
- 1:55:37switch into position one,
- 1:55:39or which is basically connecting
- 1:55:41terminal 11 and 12, then power will flow
- 1:55:44through this hand switch and go to input
- 1:55:46eight on my Arduino PLC. Okay? So it's a
- 1:55:50very simple electrical schematic, and
- 1:55:52I'm going to tie it to this structured
- 1:55:54text program right here, which is just
- 1:55:57going to turn the blue light on when the
- 1:56:00switch is on, but then I'm going to use
- 1:56:03switching logic. So rather than just a
- 1:56:05boring like, "Hey, turn the green light
- 1:56:08on the body of this PLC on when the
- 1:56:10switch is on." I'm going to actually do
- 1:56:12a little bit of switching logic. So
- 1:56:14every time I turn the switch to the on
- 1:56:16position, that's going to switch my
- 1:56:18internal on-off variable, and then I'll
- 1:56:21switch an output and a little green
- 1:56:22light based on that.
- 1:56:25That was probably a poor brief example,
- 1:56:27but the structured text tutorial was two
- 1:56:30videos ago. This is about wiring.
- 1:56:34So let's go ahead and take a look
- 1:56:36physically at the wiring for this
- 1:56:38system, and you can see the exact wires
- 1:56:41that are called out in our schematic
- 1:56:42show up on here. We have the black,
- 1:56:44white, and green wires coming out of the
- 1:56:46outlet, and then we have two blue wires
- 1:56:48going into the power feed of the Arduino
- 1:56:50PLC, and onto terminal 11 of the hand
- 1:56:54switch. And then on the outlet terminal
- 1:56:5712 of the hand switch, it goes into
- 1:56:59input eight on the Arduino PLC. And then
- 1:57:02the last wire we need is a V- or 0-V DC
- 1:57:06return wire to the power supply from the
- 1:57:08Arduino PLC. Every wire that we have on
- 1:57:10the schematic shows up physically in the
- 1:57:13world exactly as it's drawn here. And
- 1:57:15let's take a look at a more industrial
- 1:57:17example of this. So this kind of looks
- 1:57:19more like you should expect to see
- 1:57:23in an industrial control cabinet, okay?
- 1:57:25I'll try to drop myself in the middle
- 1:57:27where I don't block anything. But this
- 1:57:29is sort of how you would expect to see
- 1:57:30that show up in an industrial control
- 1:57:33cabinet. You have on the left you have
- 1:57:35your AC voltage in, you have line one,
- 1:57:37neutral, and ground, and then they go
- 1:57:39into a power supply, and you can see
- 1:57:41here like I put the actual part number
- 1:57:44of the power supply that I got from
- 1:57:45Amazon.
- 1:57:46That's very common, too. So you'd see
- 1:57:48maybe PSU1, like power supply unit one,
- 1:57:52and then a part number for it, and then
- 1:57:54the pinout has ground, neutral, L1, and
- 1:57:57then plus, plus, minus, minus. Typically
- 1:58:00these are grayscale control panel
- 1:58:02drawings as well. They don't have to be,
- 1:58:04but you saw on this example a lot of
- 1:58:06color
- 1:58:07where I was kind of color coordinating,
- 1:58:09matching what's in the field with what's
- 1:58:11on the schematic. I do actually really
- 1:58:13like doing these sorts of schematics for
- 1:58:15hobby circuits
- 1:58:17because I just think it's clear, but
- 1:58:19when you're in an industrial setting,
- 1:58:20this is what you'll be dealing with more
- 1:58:22frequently. So
- 1:58:24you have the same Arduino PLC here.
- 1:58:26Again, I dropped the power supply or the
- 1:58:28part number on it.
- 1:58:30And then you have the DC outlet power
- 1:58:33feed of 0-V
- 1:58:35kind of becomes your new power rail on
- 1:58:37the left edge of the right half of my
- 1:58:39screen. And here you can see the power
- 1:58:41coming into the PLC, and then going
- 1:58:44through a hand switch, which is
- 1:58:46represented again by the part number,
- 1:58:48and into input eight. Okay? So actually
- 1:58:50what's important to know is that what
- 1:58:52you're looking at here is very
- 1:58:54industrial, and what you're looking at
- 1:58:55here is sort of hobby,
- 1:58:58but you'll see schematics that look a
- 1:59:00lot like both of these depending on your
- 1:59:02setting and the size of your
- 1:59:03application. That's our first practical
- 1:59:05example. We have one more slightly more
- 1:59:08complicated practical example and then
- 1:59:09we're going to wrap this video up. Okay,
- 1:59:12so we have our industrial hobby example.
- 1:59:16Let's add an output. So we have a
- 1:59:18digital input in this previous example
- 1:59:20and that's our hand switch. Let's go
- 1:59:22ahead and say we want to add an an
- 1:59:24output and it'll be an outlet. So we
- 1:59:28could hook any common household
- 1:59:30appliance we want up to a standard
- 1:59:32outlet. And to do that, we need L1,
- 1:59:36neutral, and ground. So we need that
- 1:59:38same three wires that kind of come into
- 1:59:40our power supply. We need those hooked
- 1:59:43up to an outlet, but L1 needs to pass
- 1:59:46through a relay and a relay is a super
- 1:59:48important controls component which
- 1:59:51allows us to switch a wire between
- 1:59:53multiple contacts. So you use low
- 1:59:56voltage DC power to change the state of
- 1:59:59a relay and then a separate electrical
- 2:00:02connection is made on the other side of
- 2:00:04the relay. So I think we'll probably get
- 2:00:06more into relays as we continue doing
- 2:00:08the tutorials in this series, but
- 2:00:11it's arguably the most important
- 2:00:13component in the world of industrial
- 2:00:15automation and controls. So let's take a
- 2:00:17look at the hobby version of this
- 2:00:19circuit now, okay? And let's walk
- 2:00:21through all the wires that have been
- 2:00:23added. I also put in one new sort of
- 2:00:25color convention which is a wire that
- 2:00:28ties directly into the PLC. I've changed
- 2:00:31to orange where in the previous example
- 2:00:33I just left it as blue. So basically the
- 2:00:36final PLC signal wire is orange. L1 on
- 2:00:40this schematic is represented in black,
- 2:00:43so that's going to be your 120 V hot.
- 2:00:46Neutral is going to be kind of this
- 2:00:48light gray because white didn't really
- 2:00:50look good on a white background. Ground
- 2:00:52is green and then everywhere that's 0 V
- 2:00:55DC is represented by this like light
- 2:00:57blue white and blue striped wire. And
- 2:01:00then dark blue represents your 12 V
- 2:01:03which in my physical setup is actually
- 2:01:0424 V. Um
- 2:01:07but what you can see here what's
- 2:01:08actually changed, nothing to do with the
- 2:01:10hand switch or powering up the Arduino
- 2:01:12PLC. But what we've done is we've added
- 2:01:15a hot wire, so a 12 or 24 V DC wire from
- 2:01:19the second terminal of the Arduino PLC
- 2:01:22out feed to side one of the relay output
- 2:01:25on the Arduino PLC. And if it seems
- 2:01:27silly to go from a relay to a relay to
- 2:01:30control something, it is a little bit
- 2:01:32silly, but actually I wanted to show you
- 2:01:34guys a DIN rail a DIN rail mounted relay
- 2:01:37rather than just a relay PLC
- 2:01:40output. Technically there's an extra
- 2:01:41component in here cuz I have a relay
- 2:01:43output and then I go to a relay. Let's
- 2:01:45just take a look at this practical
- 2:01:47example, okay? So So when the PLC
- 2:01:49energizes that wire, this relay connects
- 2:01:52the common to the normally open channel.
- 2:01:55And then when the coil releases, the
- 2:01:57common is connected to the normally
- 2:01:59closed channel. That's a super important
- 2:02:01concept not just for relays, but for
- 2:02:03sort of all of electronics. So if you
- 2:02:05look up relays and common normally open
- 2:02:08and normally closed, you'll learn a lot
- 2:02:10about sort of switching voltages. But
- 2:02:12for now, just know that to control the
- 2:02:15state of the outlet from our PLC, we
- 2:02:17bring 120 V hot into the common channel
- 2:02:21of our relay. And then normally open
- 2:02:24means it is the one that's not going to
- 2:02:26be connected until we pull that coil in.
- 2:02:28So you could technically program the
- 2:02:30circuit to work in normally open or
- 2:02:32normally closed. We're going to use
- 2:02:34normally open meaning the only time that
- 2:02:36outlet will be energized is when the
- 2:02:38relay is energized which is when the PLC
- 2:02:41tells that output it's true. Okay, so
- 2:02:44that's the schematic. Let's take a look
- 2:02:46real quick at what this physically means
- 2:02:48on our bench setup and you can see just
- 2:02:51like I said, it's the exact same wiring
- 2:02:53as before, but now we've introduced this
- 2:02:56new relay and we have the additional
- 2:02:59power feed from the Arduino coming into
- 2:03:01channel zero of the output and then we
- 2:03:03have the channel one of the output going
- 2:03:05to the A1 and A2 coil side of the relay.
- 2:03:09And then the other side of the relay
- 2:03:11goes back to 0 V DC. And then we have
- 2:03:14the downstream power feed of our
- 2:03:17relay switching the common wire between
- 2:03:20normally open and normally closed and
- 2:03:21the normally open signal goes to the
- 2:03:23outlet. So we actually didn't have to
- 2:03:25modify our PLC program at all for this
- 2:03:28one. All we did is we just said in
- 2:03:30addition to having L1 which is the light
- 2:03:33on the body of the PLC, we now also want
- 2:03:36the outlet to turn on and off. And we
- 2:03:39just tie our outlet, if we look at relay
- 2:03:41outputs, we just tie our outlet to the
- 2:03:43first output channel in the PLC. So if
- 2:03:46you've been following along with the
- 2:03:47tutorial series, that whole PLC side of
- 2:03:50it should look pretty trivial. Don't
- 2:03:51worry too much because the this purpose
- 2:03:54is to be hands-on and physical and
- 2:03:56electrical
- 2:03:57rather than just
- 2:03:59rather than software heavy, but feel
- 2:04:01free to ask any questions you have about
- 2:04:02it in the comments below. Now, same as
- 2:04:04before, let's take a look at how this
- 2:04:06would get represented in like a physical
- 2:04:10in a more industrial controls package
- 2:04:12drawing. So let's take a look at what's
- 2:04:15changed. We still have the power feed on
- 2:04:17the left going through our 24 V power
- 2:04:19supply which I know I called out as 12 V
- 2:04:24in in here, but it's 24 V on my bench
- 2:04:26setup, sue me. Anyways,
- 2:04:29and then I did something interesting
- 2:04:31that I think is useful to call out on
- 2:04:33this channel
- 2:04:35on this tutorial is I labeled two wires
- 2:04:38with numbers O1 and O2. And this is a
- 2:04:41massive simplification from how like a
- 2:04:44large control panel would do it, but
- 2:04:46it's not always feasible to show every
- 2:04:49physical connection in your drawing in a
- 2:04:51continuous one nice clean view sort of
- 2:04:55way. And if you look at the relay which
- 2:04:57we've added to the top right, you can
- 2:04:59see output channel one wire zero and
- 2:05:03wire one are pulling in the A1 A2 coil
- 2:05:06side of the relay just like we saw
- 2:05:08before, but O1 and O2 which are linked
- 2:05:12to these
- 2:05:14are actually being physically
- 2:05:16represented by a number that says, "Hey,
- 2:05:18there's this disconnect between over
- 2:05:20here and over here." And sometimes you
- 2:05:22would want to link it with some
- 2:05:24additional letters as well or anything
- 2:05:26like that. But this is just a way of
- 2:05:28calling out that the other side of this
- 2:05:30wire shows up somewhere else in your
- 2:05:32drawing package and it's a way for you
- 2:05:34to correlate and track down those wires.
- 2:05:37Again, this is sort of a non-sustainable
- 2:05:40way as you get into bigger and bigger
- 2:05:42and bigger systems. You can't just keep
- 2:05:44drawing this like function block diagram
- 2:05:47of all the crazy wiring schematics and
- 2:05:49the coloring conventions can get out of
- 2:05:51hand and they're sort of arbitrary. So
- 2:05:53you start to see as systems get bigger
- 2:05:55and bigger and bigger how essential
- 2:05:57having like a standard format drawing
- 2:05:59is. So this industrial example which
- 2:06:02honestly I've already sort of deviated
- 2:06:04cuz I'm building it in PowerPoint from
- 2:06:07like some common design choices, but I
- 2:06:09hope the basics are clicking for you
- 2:06:12here of what you're looking at, how the
- 2:06:14physical world maps onto this sort of
- 2:06:17electrical schematic software world, and
- 2:06:19then what you're actually looking at in
- 2:06:20the field and how that ought to be
- 2:06:22documented when you go and grab a
- 2:06:24control cabinet. Okay, so I know by far
- 2:06:27in this tutorial series this is the most
- 2:06:29talking that I've done and the least
- 2:06:31showing you things that I've done, but
- 2:06:33it is really hard to demonstrate the
- 2:06:35world of electrical controls
- 2:06:38drawings and schematics and control
- 2:06:40panels without like going into the field
- 2:06:42and walking through one with you. And
- 2:06:44frankly my company would not be okay
- 2:06:46with me like walking around the plant
- 2:06:48floor showing you our control cabinets.
- 2:06:50So you're going to have to do with what
- 2:06:51I can show you in the garage.
- 2:06:53I hope it was useful. As always, let me
- 2:06:55know with any comments or questions on
- 2:06:58this one. I also have a pretty deep
- 2:07:00library of me talking about controls and
- 2:07:02automation concepts including wiring and
- 2:07:04hardware and things like that on the
- 2:07:06channel. So be sure to check out
- 2:07:07LeMaster Tech for more. Drop me a
- 2:07:09comment with any questions that you had,
- 2:07:11anything that I can try to clarify for
- 2:07:13you, and let me know what you want to
- 2:07:15see more of on the channel next time.
- 2:07:16Thank you so much for watching and we'll
- 2:07:18see you next time. Thanks. Bye.
- 2:07:26Hello and welcome back to LeMaster Tech.
- 2:07:28And in today's video, I'm going to show
- 2:07:30you how to get started with the SCADA
- 2:07:32software called Ignition. And we're
- 2:07:34going to show how to use it for free for
- 2:07:37hobbyists and makers. So we're going to
- 2:07:39use the Ignition Maker Edition. To get
- 2:07:41started, just go to Bing or Chrome or
- 2:07:44Google, your favorite browser, and type
- 2:07:46in Ignition for Makers. The company that
- 2:07:48makes the SCADA software called Ignition
- 2:07:51is Inductive Automation. So you'll see
- 2:07:53Inductive, you'll see Ignition, and
- 2:07:55occasionally you'll hear it referred to
- 2:07:57as a SCADA.
- 2:07:58SCADA means Supervisory Control and Data
- 2:08:01Acquisition. It's just a layer of
- 2:08:04control software, but Ignition in
- 2:08:06particular has a ton of cool
- 2:08:07applications even for things that
- 2:08:09hobbyists and makers can get behind,
- 2:08:11which is why they have a Maker Edition.
- 2:08:14Ordinarily this is thousands of dollars
- 2:08:16to for a corporate company to get a
- 2:08:18full-blown version of a SCADA software,
- 2:08:20but Ignition has released a lightweight
- 2:08:22version of it
- 2:08:24for free, which is super exciting cuz a
- 2:08:26YouTube channel like mine can give a
- 2:08:28bunch of tutorials on how to do things
- 2:08:30in Ignition without needing to shell out
- 2:08:32thousands of dollars to get like a full
- 2:08:33license. So that's pretty cool of
- 2:08:35Inductive Automation.
- 2:08:37To get started, I'm already logged in.
- 2:08:39All you have to do is make a personal
- 2:08:42account. It'll ask you to verify an
- 2:08:43email,
- 2:08:44and then you'll be able to sign in to
- 2:08:46the link that is generated when you just
- 2:08:48type when you just click this button,
- 2:08:51get Ignition Maker Edition. And then the
- 2:08:54first thing, I have generated a license
- 2:08:56key. I'm not going to show you guys cuz
- 2:08:58it's mine.
- 2:08:59Um but when you generate a license,
- 2:09:02there's just a big button here that says
- 2:09:04no licenses and then you hit get license
- 2:09:07and then it'll take like 30 seconds,
- 2:09:09generate a unique code, and you'll get
- 2:09:11two things. The license key, which is
- 2:09:13this number and it's okay that you guys
- 2:09:14can see it because the other thing you
- 2:09:16get is a super long string of text,
- 2:09:18which is your unique license key.
- 2:09:21Um and then you want to download the
- 2:09:22installer for whatever platform you're
- 2:09:24on. I am on Windows, so I'll go ahead
- 2:09:26and download the Windows installer. This
- 2:09:29video's kind of geared at getting you
- 2:09:30started with uh a SCADA software. I
- 2:09:33think in the coming videos and on this
- 2:09:35series, we'll get into how to do lots of
- 2:09:38things with the SCADA and I'll kind of
- 2:09:40talk through why you might want this.
- 2:09:42One, if you're in the world of controls
- 2:09:43and automation, and two, if you're a
- 2:09:45hobbyist or a maker, um kind of show you
- 2:09:48why it's sort of cool to have access to
- 2:09:50a SCADA software even in a home setting.
- 2:09:52So,
- 2:09:53um I'm looking forward to this series. a
- 2:09:55lot of interest in controls and
- 2:09:57automation on the channel. Uh and
- 2:09:59additionally, I have also had um a lot
- 2:10:03of interest in um Python programming on
- 2:10:06the channel and even like Arduino and
- 2:10:08hobby builds and making things. And a
- 2:10:11SCADA software is a really interesting
- 2:10:12spot to bring SQL, Python, Java,
- 2:10:16uh
- 2:10:17in and automation and controls obviously
- 2:10:19all together. So, I'm looking forward to
- 2:10:21this series.
- 2:10:22Um I'm just going to go ahead and do
- 2:10:23typical installation because you can do
- 2:10:26custom here and you can uh choose
- 2:10:28modules to install or not install. Um
- 2:10:31but you can also add modules at any time
- 2:10:33down the road. So, you don't have to
- 2:10:34feel like if you don't customize your
- 2:10:35install in the beginning, you're stuck
- 2:10:37with features or without features that
- 2:10:39you might want later. That's no big
- 2:10:41deal. Um so, let's just go ahead and run
- 2:10:43the installer. And something super cool
- 2:10:45about Ignition, it has two uh types of
- 2:10:48visuals. It has perspective um and I
- 2:10:51think the other one's called Vision. I
- 2:10:53don't use Vision really. Perspective is
- 2:10:55a web-based one. So, uh any if you had a
- 2:10:58system of networked computers, it could
- 2:10:59be your house or it could be a company,
- 2:11:02um you could uh have hundreds of
- 2:11:05computers on the same network and
- 2:11:06they're all able to pull up the views,
- 2:11:08the displays that you build in Ignition
- 2:11:11from uh anywhere. So, Perspective is
- 2:11:13pretty cool.
- 2:11:14Um yeah, so let's go ahead and get the
- 2:11:17Maker Edition. This standard edition is
- 2:11:19pretty awesome, but you do have to pay
- 2:11:21for it. So, let's just uh get the
- 2:11:23personal use.
- 2:11:25I do.
- 2:11:26I do not agree. I do agree.
- 2:11:29And here's where I'm going to pause the
- 2:11:31recording cuz I need to put my license
- 2:11:32key and activation token in and I don't
- 2:11:34want you guys to see my activation
- 2:11:35token.
- 2:11:37Okay, so you punch in your activation
- 2:11:39key and your license and uh then it asks
- 2:11:42you to make a username and a password. I
- 2:11:44make really strong passwords, so don't
- 2:11:46even try to hack me. Um these we're
- 2:11:49going to leave uh for now. We might mess
- 2:11:51around with some gateway port HTTP and
- 2:11:54HTTPS
- 2:11:56but really leaving them as the
- 2:11:57uh default ports will not be a problem.
- 2:12:00Um so, start and launch the gateway now?
- 2:12:02Sure, shoot. Who cares?
- 2:12:05Um the uh Ignition gateway is sort of a
- 2:12:09hub, so you could have multiple projects
- 2:12:12that do different things, have different
- 2:12:14views, different scripts and tags
- 2:12:15underneath them, and the gateway is what
- 2:12:18brings them all together. So, there's
- 2:12:19really typically only one gateway per
- 2:12:22installation.
- 2:12:24Enable quick start and for new users?
- 2:12:27No, I'm like so good at Ignition
- 2:12:29already. Uh I'm going to start from
- 2:12:31scratch. So, but uh when you download
- 2:12:34the designer and you uh put that um
- 2:12:37software on your computer, that is like
- 2:12:40a desktop-based tool that you use to
- 2:12:42build HMI displays in. And uh I'll
- 2:12:46install for all users.
- 2:12:49Install for all users. It's just me
- 2:12:50using the computer.
- 2:12:52Um and you can create a desktop shortcut
- 2:12:54here, so this is nice. It lets you
- 2:12:56um
- 2:12:57access the designer from your desktop.
- 2:12:59And uh real quick to look through the
- 2:13:01gateway.
- 2:13:03Oh, but I have to log in. Okay.
- 2:13:07So, if we look at the gateway real quick
- 2:13:09after logging in, just a few things to
- 2:13:11highlight here. This is just your hub to
- 2:13:13tell you how many devices you have
- 2:13:15connected, what they can do for you, and
- 2:13:18uh tell you some statistics about your
- 2:13:20performance. So, by default, the gateway
- 2:13:22has access to 2 GB of your RAM um when
- 2:13:26you download it, and I have a computer
- 2:13:28running basically nothing other than um
- 2:13:31Ignition and my video capture software,
- 2:13:33so the CPU is really not working
- 2:13:34particularly hard. Um but you can also
- 2:13:38up this number. My computer doesn't have
- 2:13:402 gigs of RAM, it's given Ignition 2
- 2:13:42gigs of RAM. So, we'll do uh how to
- 2:13:45increase RAM on Ignition in a future
- 2:13:47video.
- 2:13:48Um for this video, I think the most
- 2:13:50useful thing to do would be uh create
- 2:13:52our first view in designer and uh maybe
- 2:13:55add a couple tags and just show how to
- 2:13:58display them on a view, and we'll call
- 2:14:00that for the introductory video. I do do
- 2:14:03quite a bit of work with Ignition, so if
- 2:14:05you do have um questions, be sure to
- 2:14:07drop them in the comments below and I'll
- 2:14:09try to get back to you as soon as I can.
- 2:14:11When you open up the designer, there's
- 2:14:13going to be nothing configured and
- 2:14:15initially you can just hit add designer.
- 2:14:17Assuming you're doing all of this on
- 2:14:18your
- 2:14:19um same computer, the designer should
- 2:14:21already be discoverable. You might uh
- 2:14:24have to do like discover um gateways on
- 2:14:27your network if you're using a different
- 2:14:29computer on the same network. Uh but
- 2:14:32again, that's kind of like more advanced
- 2:14:34and I start questioning, are you really
- 2:14:35doing this for makers? Um but I guess
- 2:14:38also these videos could be super helpful
- 2:14:40for people who do have a corporate
- 2:14:42license. So,
- 2:14:44um now uh when it shows up there and you
- 2:14:46hit open designer, it's going to give
- 2:14:49you a view um that is a little bit
- 2:14:52daunting at first. There's it's hard to
- 2:14:54make anything simple. Um let's go ahead
- 2:14:57and log in, so I'm going to pause again.
- 2:15:00Okay, so after logging in, uh if you
- 2:15:02have been working on projects in the
- 2:15:04past, they'll be here. If not, then you
- 2:15:06can just hit new project. Let's call
- 2:15:08this one LeMaster Tech and then we'll
- 2:15:12say underscore tutorials, okay? Uh
- 2:15:15project name, project title. I don't
- 2:15:17know, that seemed like a good title.
- 2:15:20I think
- 2:15:23uh project project template parent
- 2:15:25project. We'll get into that in the
- 2:15:26future. You really don't need one right
- 2:15:27now. Um connection settings, default is
- 2:15:30fine. OPC UA module for anyone using
- 2:15:33like PLCs, they're going to probably
- 2:15:35want the OPC module as user source, but
- 2:15:38you can also
- 2:15:39um change all of this stuff later. So,
- 2:15:41don't worry too much about those.
- 2:15:43Leaving them as the default is just
- 2:15:44fine. Um stuff we're going to get into
- 2:15:47in future videos, tags and type of tags
- 2:15:50and how to use them, how to use SQL with
- 2:15:52Ignition, how to add PLCs and devices to
- 2:15:55Ignition, different types of displays,
- 2:15:57things like that. So, if you have
- 2:15:58questions about anything specific with
- 2:16:01Ignition, be sure to drop them in the
- 2:16:02comments below. Uh and now let's take a
- 2:16:05look at making a first view, okay? So,
- 2:16:08let's go ahead and hit the plus on this
- 2:16:10first view that pops up. We are in
- 2:16:12Perspective. So again, I talked a little
- 2:16:14bit earlier. Ignition has two HMI uh
- 2:16:18tools. One is called Vision and it's a
- 2:16:20like conventional-based
- 2:16:22on a computer software. The other one is
- 2:16:25Perspective and it looks to me like
- 2:16:26Perspective is the only one that's
- 2:16:28included
- 2:16:29with the For Makers Edition, which is
- 2:16:31totally fine. Um
- 2:16:34but when you the cool thing about
- 2:16:35Perspective is it's web-based and so
- 2:16:38that means that you can give URLs to
- 2:16:40every page. So, let's just make one and
- 2:16:43we'll call it {slash} homepage. And it
- 2:16:45asks you what primary view you want, but
- 2:16:47because we haven't created any views
- 2:16:49yet, there's no views. So, we'll expand
- 2:16:52uh in the project browser, we'll expand
- 2:16:54the Perspective section and you'll see
- 2:16:56there's an area for views, but it's just
- 2:16:59an empty folder right now. If you
- 2:17:01right-click, then you can hit new view
- 2:17:03and we'll call it homepage. Homepage.
- 2:17:06Homepage. There we go. Root container
- 2:17:09type, column container, breakpoint
- 2:17:11container, blah blah blah blah.
- 2:17:12Coordinate is going to be your default.
- 2:17:14Go ahead and keep that. And when you
- 2:17:16make uh check page URL, it's doing this
- 2:17:19page for you uh this part for you in the
- 2:17:22background. So, we'll actually hit
- 2:17:24create view. Um and real quick, if you
- 2:17:27click back on views, you're going to see
- 2:17:30ones that are linked and ones that
- 2:17:32aren't. So, this is the one I was
- 2:17:33working on. I'm going to delete this.
- 2:17:35Yes. What you're doing is you're telling
- 2:17:37Ignition a series of pages that can be
- 2:17:39navigated directly to from a web browser
- 2:17:42as long as you're on the gateway, which
- 2:17:44is super interesting. Um and we'll get
- 2:17:47into how to access it and what that
- 2:17:48actually means one video at a time right
- 2:17:51now. But so, we have created a view
- 2:17:53called homepage and it is linked to the
- 2:17:56URL {slash} homepage. So, simplest thing
- 2:18:00I can do uh to show you guys like um
- 2:18:04what Ignition is is make a tag. Uh so, I
- 2:18:07think what I want to do here is I want
- 2:18:09to make a folder and I'll call this
- 2:18:11folder tutorial tags. Um and SCADAs and
- 2:18:15PLCs and basically anything automation
- 2:18:17and controls really live off of the tag
- 2:18:20structure, um which is just having in
- 2:18:23conventional programming, you'd think of
- 2:18:24it as a variable. Um in automation and
- 2:18:28SCADA software, it's a tag. It
- 2:18:30warehouses a tiny bit of data. It can be
- 2:18:33used for reading, writing, and logic. Um
- 2:18:35so, let's go ahead and make a memory
- 2:18:37tag, which means it just lives on
- 2:18:39Ignition. It lives on this computer. And
- 2:18:42we will call it um
- 2:18:43my first tag, okay? And let's make this
- 2:18:47a string and let's give it an initial
- 2:18:50value of why not hello world. Okay.
- 2:18:54And let's go ahead and drag my first tag
- 2:18:57onto the screen and all we do is click
- 2:19:00on that tag and drag it onto the screen
- 2:19:02and it's going to give us its top
- 2:19:04recommendations for what that data
- 2:19:06format might be. And so we'll hit label.
- 2:19:09And there you can see we have a tag that
- 2:19:11says hello world. Nothing crazy, nothing
- 2:19:14fancy going on here.
- 2:19:16Um
- 2:19:17and if we hit save, so control S or the
- 2:19:19save button up here, we should now have
- 2:19:21a view called hello world. And so if we
- 2:19:24go back to my my robot heard me say
- 2:19:28hello.
- 2:19:29Um if we go back to the web, we can see
- 2:19:31how we can access this now.
- 2:19:33And actually one thing we're going to do
- 2:19:34before we uh access it from the web is
- 2:19:37we're going to make a URL um for just
- 2:19:40the homepage and we're going to address
- 2:19:42it to that same page, too. So what's
- 2:19:44interesting here is I've made a second
- 2:19:46address that will access the same page.
- 2:19:48If you've done a little bit of web
- 2:19:49development, you've probably seen that
- 2:19:51sort of thing. If not, no big deal, but
- 2:19:53this basically means that uh this page
- 2:19:56should act as your homepage as well. Um
- 2:19:59so let's go ahead and see how you can
- 2:20:01actually view and access this thing. If
- 2:20:03I go back to uh Edge and I just go to
- 2:20:07localhost 8088,
- 2:20:10so this here, localhost 8088, is going
- 2:20:14to be um how you access it from the
- 2:20:16computer when you're on it, but you can
- 2:20:19also usually get to it. If you just
- 2:20:21start typing in Ignition, you'll see
- 2:20:23here it'll remember like Ignition L the
- 2:20:26Master Tech Engineering 1 Ignition
- 2:20:28Gateway.
- 2:20:29Um and anything that has this orange dot
- 2:20:32is usually going to take you to
- 2:20:33somewhere on the gateway. It might have
- 2:20:35you log in, that's okay. Um but uh
- 2:20:39anyways, when you want to view a project
- 2:20:41online, this homepage has download the
- 2:20:44designer, we've already done that, and
- 2:20:46it has view projects. And if you do
- 2:20:48that, the projects that you're making
- 2:20:50should be here. And if you hit launch
- 2:20:51project and agree that it is for
- 2:20:54hobbyist students and individuals,
- 2:20:56um then what you can see is we have a
- 2:20:59page that says hello world and that's
- 2:21:01super cool. Um and if you had a forward
- 2:21:05slash homepage,
- 2:21:07it would still be this page because we
- 2:21:09gave it two different addresses. Um but
- 2:21:12we're basically building a website that
- 2:21:15is uh only for people who have access to
- 2:21:17your gateway and that is something super
- 2:21:20cool and kind of unique about the
- 2:21:21Ignition SCADA software. You uh have
- 2:21:24here is the first tag, the first
- 2:21:28display, how to get started with
- 2:21:29Ignition for makers. What we'll be doing
- 2:21:32in this series is a lot of the basic
- 2:21:33stuff that you might need to know about
- 2:21:36um
- 2:21:37to build various features in Ignition.
- 2:21:39I'll definitely focus mostly on the core
- 2:21:42functionality of how to do things with
- 2:21:44Ignition and then I'll probably start um
- 2:21:47showing how to do a lot of things for
- 2:21:50makers specifically. So I have a pretty
- 2:21:52cool garage workshop. I'll probably do a
- 2:21:54lot of automation projects in the
- 2:21:56garage, show how I use SCADA to do that.
- 2:21:58So if you have ideas of what we should
- 2:22:01do with Ignition or things that would be
- 2:22:03useful for you to see, be sure to let me
- 2:22:05know about in the comments below. Thank
- 2:22:07you guys so much for checking out uh the
- 2:22:09channel and if you have any questions,
- 2:22:11let me know. If you have any ideas for
- 2:22:13future videos, let me know. And um as
- 2:22:16always, good luck with your projects.
- 2:22:17Thanks for watching and we'll see you
- 2:22:18next time. Thanks. Bye.
- 2:22:27Hello and welcome back to the channel.
- 2:22:29In today's video, I'm going to walk you
- 2:22:31through how to use expression tags in
- 2:22:34Ignition. All right, so this is
- 2:22:36obviously a continuation in the Ignition
- 2:22:38tutorial series uh we've recently
- 2:22:40started on the channel. If you do have
- 2:22:41any questions about how to download
- 2:22:43Ignition for makers, what Ignition is,
- 2:22:46why you need it, what an expression tag
- 2:22:48is, be sure to check out the playlist on
- 2:22:50the channel. I will be adding all
- 2:22:51Ignition tutorials to that playlist and
- 2:22:54hopefully building a pretty deep uh
- 2:22:56backlog of how to get started and how to
- 2:22:58use Ignition and eventually doing some
- 2:22:59pretty cool and in-depth automation
- 2:23:02slash makers uh projects with it. So um
- 2:23:05as always, if you have any questions,
- 2:23:06feel free to drop them in the comments
- 2:23:08below, but I'll be assuming for this
- 2:23:09video that you at least have downloaded
- 2:23:11Ignition, know how to get into the
- 2:23:13designer, and want to know how to use
- 2:23:15expression tags. So I've already built
- 2:23:18out a little bit of a framework here
- 2:23:19that has a Boolean, meaning a bit,
- 2:23:22meaning on or off, true or false, and
- 2:23:24you can see I have a toggle checkbox for
- 2:23:26it on the screen that I've built, and
- 2:23:28you can see the tag value itself in this
- 2:23:30browser on the lower left also changing
- 2:23:33when I change the bit. Then I built out
- 2:23:35a little just plus uh minus two buttons
- 2:23:38on either side of a counter.
- 2:23:40And these are just letting me change the
- 2:23:41value of my integer tag. And then I have
- 2:23:44a text entry box here
- 2:23:47uh just where I can enter values and
- 2:23:49change the value of a string tag. So the
- 2:23:51reason I built out these three different
- 2:23:53types of tag is because I want to
- 2:23:55obviously new tag um new standard tag
- 2:23:58expression tag.
- 2:24:00I want to show you how to use expression
- 2:24:01tags and I want to show you how to
- 2:24:03interact with three different types of
- 2:24:05tags in your expression, so that's why I
- 2:24:07did that. And let's just call this
- 2:24:10expression tag one. So nice descriptive
- 2:24:13name. We'll make it an expression and we
- 2:24:15will make it a Boolean because what this
- 2:24:17expression is going to be doing is
- 2:24:19evaluating multiple other tags and
- 2:24:22making a decision whether those
- 2:24:23conditions are true or whether those
- 2:24:25conditions are false. So we'll come down
- 2:24:27to expression and we'll hit the pencil.
- 2:24:29So now we are in the expression editor.
- 2:24:32Uh if you ever get like super duper lost
- 2:24:34and confused, um these uh fields in the
- 2:24:38top right, there's a little plus and an
- 2:24:40equal sign and these are some of the
- 2:24:41most common fields that you'll be using
- 2:24:43in expression tags, so I find them
- 2:24:45pretty useful. If you ever forget that
- 2:24:47like or or and or less than uh or equal
- 2:24:51to is uh is this specific symbol, it's
- 2:24:54nice to have a little refresh available
- 2:24:55to you right there. But to be honest, uh
- 2:24:58expression tags fill a pretty tight
- 2:25:00niche in Ignition because when things
- 2:25:02get really complicated, you don't
- 2:25:04necessarily want to be using expression
- 2:25:06tags, you want to be using like Python
- 2:25:08scripting, which we'll talk about in
- 2:25:10future videos. But the purpose of
- 2:25:11expression tags is to sort of evaluate a
- 2:25:14few things in a field. Uh you could
- 2:25:16think of a tank, right? That could have
- 2:25:18multiple alarm issues. It could be at
- 2:25:20high high level. It could be at high
- 2:25:22high pressure. It could be at uh high
- 2:25:24high temperature. And if any of those
- 2:25:26things are true, you want to turn an
- 2:25:28alarm on. Uh maybe it's a strobe light,
- 2:25:31maybe it's an alert, maybe it's an email
- 2:25:33that gets sent out to like maintenance
- 2:25:34or something.
- 2:25:35So that is kind of the perfect time to
- 2:25:38use an expression tag. And uh to use an
- 2:25:40expression tag, we're basically saying
- 2:25:42we want to look at the value of other
- 2:25:44tags and let that determine the outcome
- 2:25:47of this tag. Uh it's basically
- 2:25:51like let me read values about other tags
- 2:25:53and make decisions uh what about what I
- 2:25:56should do. I said that already. All
- 2:25:57right, so let's copy the path of our
- 2:26:00Boolean tag. And I went kind of fast
- 2:26:02there, but if you want to look at the
- 2:26:04value of another tag inside of your
- 2:26:07expression, one easy way to do that is
- 2:26:09go to the tag that you want to look at
- 2:26:11the value of and right click and go down
- 2:26:13to copy path. That will give you uh text
- 2:26:16which when if you paste it into curly
- 2:26:18brackets, will look like this and this
- 2:26:20is going to give you uh that tag and
- 2:26:23it's telling this expression tag
- 2:26:25explicitly where to go and look at the
- 2:26:27value. So first thing, let's say we want
- 2:26:29the outcome of this tag to be determined
- 2:26:32uh by whether or not that Boolean tag is
- 2:26:34true. So when this thing is checked,
- 2:26:37it'll say enabled and that means it's
- 2:26:39true and so this will become true. Now
- 2:26:42we're going to use the expression and
- 2:26:44which is two ampersands. And now we're
- 2:26:47going to look at the integer tag. So I
- 2:26:49could do it exactly the same uh way. I
- 2:26:52could copy the path just like I just did
- 2:26:54and I could paste it in here, but uh one
- 2:26:57additional pretty cool little thing you
- 2:26:59can do inside the expression browser is
- 2:27:01this insert tag button which is a little
- 2:27:04tag icon over on the right. You hit
- 2:27:06insert tag and uh it'll open up a tag
- 2:27:09browser. So I can go to my folder for
- 2:27:12tutorial tags, my expression tag
- 2:27:14tutorial, and I can click on that
- 2:27:16integer tag and I can hit okay.
- 2:27:19And I can say uh so now integer tag and
- 2:27:23I want it greater than two. And what you
- 2:27:25guys notice is kind of interesting is
- 2:27:27rather than all this first gobbledygook,
- 2:27:30what I get is square bracket period
- 2:27:33square bracket and that is because it's
- 2:27:35telling this expression you don't have
- 2:27:37to go look through the entire tag
- 2:27:40browser to find this tag. It's in the
- 2:27:41same host folder and location as you
- 2:27:44are. So this dot is just a way to get uh
- 2:27:47your expression optimized to look at a
- 2:27:50closer location. So really we could go
- 2:27:53back and we could control C this into
- 2:27:55here because the Boolean tag is
- 2:27:57obviously in the same location as well.
- 2:28:00But for now, let's do just those two
- 2:28:02things. Let's say if the Boolean tag is
- 2:28:05true and if the integer tag is greater
- 2:28:07than two, then we want uh that to
- 2:28:09determine the outcome of our expression
- 2:28:11tag, okay? And I'm intentionally not
- 2:28:13using the string yet because there's one
- 2:28:15thing we're going to talk about when we
- 2:28:16get to that. But let's go ahead and make
- 2:28:18the expression tag and uh just so it's a
- 2:28:21little bit more useful for us, let's go
- 2:28:23ahead and change our uh
- 2:28:25yeah, I left it in run mode. Let's go
- 2:28:27ahead and change the text on this
- 2:28:30uh to look at the expression tag. So
- 2:28:33it's still looking at my first tag.
- 2:28:35Let's look at the expression tag, which
- 2:28:37is just going to say true or false, and
- 2:28:39let's real quick, let's just transform
- 2:28:41it to tell us explicitly that false will
- 2:28:45mean
- 2:28:46conditions
- 2:28:48not met. And I'm not really focusing on
- 2:28:51stuff like how to transform
- 2:28:54in what I'm doing right now. Conditions
- 2:28:57all met, okay? All I'm doing is taking
- 2:29:00the true false outcome of the expression
- 2:29:02tag we just made and saying whether or
- 2:29:04not the conditions are met in a little
- 2:29:07label up top, okay? So, if you remember,
- 2:29:09we said the integer has to be greater
- 2:29:11than two and we said this bit has to be
- 2:29:14enabled. So, the bit is enabled but the
- 2:29:17integer is exactly two. Let's go ahead
- 2:29:18and add one to the integer. And now it
- 2:29:21says three and now the expression tag
- 2:29:23says conditions all met. Now, if I were
- 2:29:25to disable the bit, it says conditions
- 2:29:28not met again. And what's really
- 2:29:29interesting is we didn't set up our
- 2:29:32expression tag to be like cyclical or
- 2:29:34anything. We left it on the default
- 2:29:36which was event-driven. And event-driven
- 2:29:38is really interesting because
- 2:29:39event-driven means it's looking at
- 2:29:41changes of any of the tags that it is
- 2:29:44addressing in its expression. So, it
- 2:29:46knows that when this bit changes, it
- 2:29:48needs to do a new evaluation because the
- 2:29:50values that it's comparing to are
- 2:29:53changing underneath it. So, it's a
- 2:29:55really cool function of Ignition
- 2:29:56expression tags. If we were to take this
- 2:29:59integer back down under two, we would
- 2:30:01get an issue
- 2:30:02um
- 2:30:03Oh, it would just say conditions not
- 2:30:05met, not an issue. Now, let's take a
- 2:30:07look at how to incorporate a string cuz
- 2:30:08it's a little bit tricky and I left one
- 2:30:11thing out of this expression on purpose
- 2:30:13to show you the difference. I think now
- 2:30:15is a perfect time to take a quick pause
- 2:30:17and talk to you about the sponsor of
- 2:30:18today's video, PCBWay. PCBWay is a
- 2:30:21long-term supporter of the Le Master
- 2:30:23Tech channel and I love working with
- 2:30:25them because their products and services
- 2:30:27are all about empowering makers. As
- 2:30:29their name suggests, the core of their
- 2:30:31business is manufacturing PCBs or
- 2:30:33printed circuit boards. This is such a
- 2:30:35cool way for hobbyists and makers to
- 2:30:37turn their electronic designs into super
- 2:30:39high-quality and professional-grade
- 2:30:41circuit boards. Beyond that, they also
- 2:30:43have the ability to support all of your
- 2:30:45prototyping with high-quality 3D
- 2:30:47printing and metal fabrication as well.
- 2:30:49Be sure to check them out at the
- 2:30:50description below this video and thank
- 2:30:52you so much to PCBWay for sponsoring the
- 2:30:54video. All right, now let's get right
- 2:30:56back to the tutorial. Okay, now let's
- 2:30:58take a look at how to take that
- 2:30:59expression tag one step further and
- 2:31:02incorporate our string tag here. All
- 2:31:04right, so let's go ahead and say we also
- 2:31:06want to keep an eye on the string and
- 2:31:08make sure that it doesn't equal a
- 2:31:11certain code, right? Like you might have
- 2:31:13a status for a tank and it says like
- 2:31:16filling, heating, mixing, idle. Um and
- 2:31:19you want to make sure that tag is not
- 2:31:21idle. So, we could say uh and we want to
- 2:31:24make sure the string tag is not equal to
- 2:31:27and not equal to is {exclamation mark}
- 2:31:29{equal sign}. And let's just pick uh
- 2:31:32Pete because that's my name and that's
- 2:31:34something that is easy for me to
- 2:31:36remember while I type it.
- 2:31:39All right, and let's go hit apply and
- 2:31:40let's hit save and now I'm going to say
- 2:31:44all right, this is greater than three
- 2:31:46and my string tag is not equal to Pete,
- 2:31:49which is great. Um but if I hit enter,
- 2:31:52you'll see conditions not met. So, it's
- 2:31:54still working like that, which is really
- 2:31:56cool.
- 2:31:57Um but one weird nuance that you just
- 2:32:00should be aware of is if you want to do
- 2:32:03something different like and
- 2:32:05uh length of the string tag is not equal
- 2:32:10to zero. So, you're just basically
- 2:32:12saying I don't want to have an empty
- 2:32:15string. If we hit apply and we hit apply
- 2:32:18and we hit okay, um it says conditions
- 2:32:21all met right now and when we hit uh
- 2:32:24delete it out, it seems to be working
- 2:32:28properly because the string goes to
- 2:32:30nothing. It might seem like an
- 2:32:32unnecessary step because everything was
- 2:32:34working fine without it, but just to
- 2:32:36show you kind of how it's
- 2:32:38interchangeable
- 2:32:39but still important to know about, I'm
- 2:32:41going to add {dot} value to the end of
- 2:32:43all of them. And what you'll see is they
- 2:32:45still all individually work. Like I can
- 2:32:47still turn off uh enable disabled. I can
- 2:32:50still make the integer go below three
- 2:32:53and I can still make this uh go empty. I
- 2:32:56hope the outcome of this video is
- 2:32:58crystal clear. This is a really neat,
- 2:33:00powerful way that you can get one tag
- 2:33:03that tells you the status of multiple
- 2:33:05things in your process and you can use
- 2:33:07that to do all sorts of useful stuff
- 2:33:09downstream. So, it's like doing
- 2:33:12programming uh it inside of Ignition,
- 2:33:15which is nice because a lot of old SCADA
- 2:33:17software, you mainly wanted to do as
- 2:33:19much programming as you could inside
- 2:33:21like the PLC or the devices that were
- 2:33:23coming into your SCADA and you want to
- 2:33:26minimize developing like code and uh
- 2:33:29different formulas and stuff inside of
- 2:33:31the SCADA, inside of the HMI itself. But
- 2:33:34Ignition really changes that in my
- 2:33:35opinion. Bringing raw tags in and doing
- 2:33:38math and calculations on them inside of
- 2:33:40a project absolutely makes logical sense
- 2:33:43uh using Ignition. So, I think this is a
- 2:33:45super cool topic and I use these tags
- 2:33:48all the time. So, be sure to let me know
- 2:33:50in the comments below if you have any
- 2:33:51questions. If you have any questions
- 2:33:53about the stuff I kind of did on the
- 2:33:54side to set up this example, let me know
- 2:33:56as well. And be sure to let me know what
- 2:33:58you want to see next on the channel. I
- 2:34:00do a lot of development in in Ignition,
- 2:34:02so if you have questions about how to do
- 2:34:03any sort of specifics with that, just
- 2:34:06let me know. As always, thank you so
- 2:34:08much for watching and we'll see you next
- 2:34:10time.
- 2:34:16Hello and welcome back to the channel.
- 2:34:18In today's video, I'm going to show you
- 2:34:21how to write Python scripting inside of
- 2:34:24the SCADA platform Ignition. I'm going
- 2:34:26to show you how to do it in three
- 2:34:28different places and we are going to
- 2:34:29cover a lot of material. So, let's get
- 2:34:31right into it. Today, we're going to
- 2:34:32talk about one of the things that makes
- 2:34:34Ignition so incredibly powerful and
- 2:34:37super easy for traditional programmers
- 2:34:40to break into the world of industrial
- 2:34:41controls and automation, but also for
- 2:34:43controls and automation engineers to
- 2:34:45learn a little bit more of the
- 2:34:47conventional programming skills, so to
- 2:34:49speak. And part of the reason for that
- 2:34:51is you can write code in Python. And so,
- 2:34:56to do this, I'm going to actually save
- 2:34:58us a little bit of trouble watching me
- 2:35:00scrap together a piece of Python code,
- 2:35:03but I'm going to propose a scenario for
- 2:35:05you guys.
- 2:35:06And hopefully you can see in the bottom
- 2:35:08left here, I have a tag that I've
- 2:35:09created called input array, okay? And it
- 2:35:13is just an integer array. So, there are
- 2:35:1510 integers inside of this array and
- 2:35:19that is all that's in there. And we can,
- 2:35:21you know, just manually remove rows if
- 2:35:24we want to. It's It's just a memory tag.
- 2:35:26It's a block of integers. But let's say
- 2:35:28I want to write a script that's going to
- 2:35:31dynamically read through that integer
- 2:35:34array, look at how many elements are
- 2:35:36inside of that integer array, and create
- 2:35:39a tag for each of those elements
- 2:35:41individually. This could be useful for
- 2:35:43trending like creating historical graphs
- 2:35:45of temperatures and flows and things
- 2:35:47like that or a variety of purposes. So,
- 2:35:49there's a lot There are a lot of reasons
- 2:35:52you might want to do this inside of
- 2:35:54Python rather than break it out when
- 2:35:57you're like reading a block of data from
- 2:35:59a PLC, for example, you might read that
- 2:36:01in
- 2:36:02as an array. So, let's take a look now.
- 2:36:05I'm assuming you have a reason you want
- 2:36:07to write Python Ignition. So, let's take
- 2:36:09a look at first example of just how to
- 2:36:12test a script while writing it in
- 2:36:14Python. So, your best friend as a
- 2:36:16developer when you're inside of Ignition
- 2:36:19designer and you want to test some
- 2:36:20Python script is the script console. So,
- 2:36:23if you go to tools at the top and then
- 2:36:25script console, it's going to open a
- 2:36:27window that
- 2:36:29looks kind of like a very bare-bones IDE
- 2:36:33in a conventional like programming
- 2:36:35setting like a Jupyter notebooks or
- 2:36:37something.
- 2:36:38None of the bells and whistles of like a
- 2:36:40PyCharm or VS Code, but the idea is you
- 2:36:43write code on the left and it gives you
- 2:36:45output on the right. So, I'll talk you
- 2:36:48through the code that I've written
- 2:36:49already and hopefully you can tell if
- 2:36:51you're somewhat familiar with the Python
- 2:36:53syntax that other than knowing some
- 2:36:55specific Ignition syntax in here, the
- 2:36:58code really reads like Python. It's a
- 2:37:00variable set equal to a value. It's for
- 2:37:04I in range whatever, try except for I in
- 2:37:08range, right? Like this is Python code
- 2:37:10with some Ignition specific syntax.
- 2:37:13You'll just have to refer to Ignition
- 2:37:15forums, ask a friend, ask the internet,
- 2:37:17ask Ignition support if you don't know
- 2:37:20the specific syntax of the thing that
- 2:37:22you're trying to do. But basically, this
- 2:37:25is a script to take elements of
- 2:37:30an array and break them into child tags,
- 2:37:36okay? Um so, there are a lot of ways to
- 2:37:38do this. This script is in no way the
- 2:37:41only way you could do this sort of
- 2:37:42functionality, but I start by reading
- 2:37:45the raw data from the input array tag
- 2:37:48and then I define the path where I'm
- 2:37:51going to store and delete any child
- 2:37:53tags. So, the first thing I do, and I'm
- 2:37:55kind of using a fudge factor here of 20,
- 2:37:59but first thing I'm going to do is clear
- 2:38:00out any tags that might already be in
- 2:38:03there. So, if I've already
- 2:38:06done this script previously and there
- 2:38:08were let's say six array elements
- 2:38:10already sitting in there, this code will
- 2:38:12go through and it will delete those all
- 2:38:14out. And then what it's going to do is
- 2:38:17for I in range length of the data. So,
- 2:38:20in the length of the array, it's going
- 2:38:22to define a new tag that will be called
- 2:38:26array element 0 1 2 3 4 5 to whatever
- 2:38:29length we have. And then it's going to
- 2:38:32configure the tag, meaning create the
- 2:38:34tag and then it will write a value to
- 2:38:37that tag of whatever's in that array.
- 2:38:39So, is this a somewhat confusing
- 2:38:42example? I hope not.
- 2:38:44But, remember I have an array here that
- 2:38:46has the values in it of 10 20 30 40 50
- 2:38:51and 60. So, our goal is to create a and
- 2:38:54you can see there's no drop down in the
- 2:38:56child tags folder currently. Our goal is
- 2:38:58to write a Python script that is going
- 2:39:01to read the data from that tag and then
- 2:39:04it's going to create six children tags
- 2:39:07that say 10 20 30 40 50 60. That should
- 2:39:11be what this code does. And so, if I
- 2:39:13execute it, you'll see I actually get
- 2:39:16bad not found, which is completely fine
- 2:39:18because that's the delete code not
- 2:39:20finding the tags. And then all of the
- 2:39:22goods are the configuration and the
- 2:39:24right blocking working. So, if we click
- 2:39:26on child tags over on the left, now
- 2:39:28you'll see we've dynamically created
- 2:39:30array element 0 1 2 3 4 5 6 just 0
- 2:39:35through 5,
- 2:39:36which is cool and their values are 10
- 2:39:38through 60, which makes intuitive sense.
- 2:39:40But, now let's pop into our array and
- 2:39:42let's say between 10 and
- 2:39:45between 30 and 40 we have 35, right? And
- 2:39:49after 60 we have 70. Okay? So, let's say
- 2:39:52that the array has just been updated and
- 2:39:55now there's eight values. And what
- 2:39:57you'll see is the script in the script
- 2:39:58console isn't going to
- 2:40:01automatically update it. We have to hit
- 2:40:03execute again. But, when we hit execute
- 2:40:05again, the same code works and it gives
- 2:40:08us 10 20 30 35 40 50 60 and 70. Okay?
- 2:40:13So, this is some very basic code to
- 2:40:15generate tags as you rip them out of an
- 2:40:17array dynamically as well as clear out
- 2:40:20children tags that may have already been
- 2:40:21in there.
- 2:40:22This is pretty cool. But, I think what
- 2:40:25you guys are probably noticing already
- 2:40:27and it's no big deal if not,
- 2:40:29but is it's not super convenient to have
- 2:40:32to manually execute a script every time
- 2:40:34an array updates. And so, what we want
- 2:40:36to do is explore how to get that code
- 2:40:39firing on tag change. And that's what
- 2:40:42we're going to talk about now because
- 2:40:43there are a lot of places that you can
- 2:40:45embed this script that we've just
- 2:40:47written
- 2:40:48into a different location that will do
- 2:40:51some of that functionality for you
- 2:40:53automatically. So, let's take a look at
- 2:40:55the first one and I'm not going to lie,
- 2:40:56we are pretty much immediately going to
- 2:40:58look at better places to store this
- 2:41:00scripting. But, if you have simple
- 2:41:02Python functionality that you want to
- 2:41:04do, you can double click on a tag or
- 2:41:06right click and hit edit tags. And then
- 2:41:08there's an option on the left for
- 2:41:10scripting and for every tag value change
- 2:41:13and quality change are going to be two
- 2:41:15of your options as well as alarm events,
- 2:41:17but we're not going to talk about alarms
- 2:41:18in today's video. And quality change
- 2:41:21means like if you're reading values off
- 2:41:22of a PLC and the quality goes from good
- 2:41:25healthy I can see this tag to oh bad oh
- 2:41:28crap I can't see the tag, you could do
- 2:41:31something here. But, what we're going to
- 2:41:32do is value change.
- 2:41:34And when the value of an array changes,
- 2:41:37that means two things. Either we've
- 2:41:39changed one of the integers inside of
- 2:41:41the array or we've changed something
- 2:41:43about the array itself like the overall
- 2:41:45dimensions.
- 2:41:46So, we're going to drop the code that we
- 2:41:48just wrote inside of this value change
- 2:41:51location.
- 2:41:53And what you can probably see
- 2:41:56just by looking at kind of what's
- 2:41:57available to you here, they give you
- 2:41:59some values available to you just by the
- 2:42:02nature of it being a value change
- 2:42:04script. So, you could use the tag path
- 2:42:06of this tag
- 2:42:08the tag itself, the previous value or
- 2:42:11the current value in this tag change
- 2:42:13script. So, theoretically rather than
- 2:42:15reading the value of this tag, we could
- 2:42:17just use current value. That's a little
- 2:42:19bit of Ignition specific syntax. If you
- 2:42:22have questions about that, let me know
- 2:42:23in the comments below and we can talk
- 2:42:25about it more. But, I'm actually going
- 2:42:27to leave the code exactly as is just to
- 2:42:29illustrate that it works exactly as is.
- 2:42:33And then one thing I'm going to add here
- 2:42:36is I'm going to add a logger. And this
- 2:42:38is basically Ignition's version of like
- 2:42:41a web hosted hosted by their gateway
- 2:42:44console window. So, think of the print
- 2:42:47statement in a conventional Python
- 2:42:50script. Logger is like Ignition's way of
- 2:42:53giving you that same functionality.
- 2:42:55So, if you do logger equals and then the
- 2:42:57specific syntax is system.util.get
- 2:43:01logger just like that. And then you get
- 2:43:03to define a name. So, we will call ours
- 2:43:07um
- 2:43:07Python tutorial. Okay? I love Python
- 2:43:12tutorials.
- 2:43:13All right. And then what we're going to
- 2:43:15do is logger.info and there are a few
- 2:43:17classes of logger. You could do
- 2:43:20logger.warn debug info. There might be
- 2:43:24more, but trace I think is one. But,
- 2:43:27basically I'm just going to do
- 2:43:28logger.info, which is the easiest one
- 2:43:31and we'll just say this came from a tag
- 2:43:35change script. Okay? With an exclamation
- 2:43:37mark. We'll drop it right there. And all
- 2:43:40this should do is when we update this if
- 2:43:43the script works, this should appear in
- 2:43:45the logs on the gateway. And I'll show
- 2:43:47you how to get there in just a second.
- 2:43:49But, for now let's hit okay and let's
- 2:43:52hit save on our project and nothing
- 2:43:55happens because the array still has the
- 2:43:57value it already had. But, let's pop in
- 2:43:59here and let's add
- 2:44:0380 90 and just to mess with the people
- 2:44:07with OCD, let's make this one 1,000.
- 2:44:10Okay? And let's hit apply and okay. And
- 2:44:13you can see the array elements are
- 2:44:14already there and they're there in the
- 2:44:16order that we defined in the previous
- 2:44:18scripting and they're already populated
- 2:44:200 to 10 with all 11 elements. So, now if
- 2:44:23I pop back into the array
- 2:44:26and I delete let's say 1,000 all the way
- 2:44:28up to 30. So, there's just these two
- 2:44:31rows in there 10 and 20 and I hit apply
- 2:44:33again and I hit okay. All right. So,
- 2:44:35just by putting in a value change
- 2:44:37script, this code is working. And now if
- 2:44:40I go to my gateway, right? If I go to my
- 2:44:42host here
- 2:44:44and disregard everything before like
- 2:44:4723:14
- 2:44:48cuz that was me testing and setting up
- 2:44:50for this tutorial. But, what you can see
- 2:44:52is Python tutorial, right? The logger
- 2:44:54name that I just gave
- 2:44:57to this logger is saying hey this
- 2:44:59message came from a tag script. This
- 2:45:01came from a tag script. This came from a
- 2:45:03tag script. So, that represents the
- 2:45:05three times the script ran. It's logging
- 2:45:07it each time and you get a timestamp of
- 2:45:09when it happened. You get here when
- 2:45:12you're on the gateway and you're at
- 2:45:13home, you go to status and then you go
- 2:45:15to logs. And this is absolutely going to
- 2:45:17be an Ignition developer's best friend,
- 2:45:19especially if you're trying to set up
- 2:45:21Python scripting and you're getting
- 2:45:23weird errors and you're not sure how to
- 2:45:25track it down,
- 2:45:26you're going to want to rely on logging
- 2:45:29a lot of information. Okay? So, I think
- 2:45:31I kind of alluded to already
- 2:45:34not allude to I directly said it. We're
- 2:45:36going to move this. This is not
- 2:45:38necessarily the best spot to have this
- 2:45:41kind of scripting live. It is absolutely
- 2:45:43acceptable and if you have smaller
- 2:45:45applications or you're the sole
- 2:45:46developer for a plant, put the code
- 2:45:48where you want to put the code. But, in
- 2:45:50the instance of wanting to store the
- 2:45:53code somewhere where it's maybe easier
- 2:45:55to share, easier to immediately see all
- 2:45:57of the scripts that are executing in a
- 2:45:59project you want to keep it elsewhere.
- 2:46:01Think now is a perfect time to take a
- 2:46:03quick pause and talk to you about the
- 2:46:05sponsor of today's video PCBWay. PCBWay
- 2:46:08is a long-term supporter of Inductive
- 2:46:10Automation Tech Channel and I love
- 2:46:11working with them because their products
- 2:46:13and services are all about empowering
- 2:46:15makers. As their name suggests, the core
- 2:46:17of their business is manufacturing PCBs
- 2:46:20or printed circuit boards. This is such
- 2:46:22a cool way for hobbyists and makers to
- 2:46:24turn their electronic designs into super
- 2:46:26high-quality and professional grade
- 2:46:28circuit boards. Beyond that, they also
- 2:46:30have the ability to support all your
- 2:46:31prototyping needs with high-quality 3D
- 2:46:34printing and metal fabrication as well.
- 2:46:36Be sure to check them out at the
- 2:46:37description below this video and thank
- 2:46:39you so much to PCBWay for sponsoring the
- 2:46:41video. So, what I'm going to do, I'm not
- 2:46:43going to delete this right now cuz you
- 2:46:45never know, maybe you want to turn it
- 2:46:46back on. I'm just going to uncheck this
- 2:46:49enabled box. And so, now what you'll see
- 2:46:51if I update my array, okay? So, let's
- 2:46:55just add
- 2:46:5630 and 40 back in here. 30 40
- 2:47:01Okay? And I hit apply and I hit apply
- 2:47:02and I hit okay and I hit save, you'll
- 2:47:04see the array elements do not update and
- 2:47:07that's because we disabled the script
- 2:47:08that is on there. So, if you go to the
- 2:47:10scripting, you go to value change, it is
- 2:47:11not enabled, okay? So, let's look at the
- 2:47:15better place to put it and I already
- 2:47:17have it highlighted actually. But, in
- 2:47:19the project browser in the top left, if
- 2:47:21you go to scripting, there is gateway
- 2:47:23events as well as project library. Let's
- 2:47:26start with gateway events, okay?
- 2:47:28And you can see these ones over on the
- 2:47:30left, they all have utility. We'll
- 2:47:32probably get to a tutorial on almost all
- 2:47:34of them eventually. But, for now let's
- 2:47:36click on tag change, okay? And what
- 2:47:38we're going to do is we're going to call
- 2:47:40this array breakout. All right? That's
- 2:47:43what we'll call this script. And change
- 2:47:46triggers, I almost always turn off
- 2:47:49quality and timestamp because I want to
- 2:47:51trigger on the value changing of this
- 2:47:53tag. So, I'm going to grab the path of
- 2:47:56this input array tag by right clicking
- 2:47:58and going down to copy path. And then in
- 2:48:01my gateway events here, I'm just going
- 2:48:03to drop the tag path here. Now, you
- 2:48:05don't need to copy path like that, you
- 2:48:07can just hit your tag and if you have a
- 2:48:09small system, you're probably able to
- 2:48:12just go right to it and find it pretty
- 2:48:15quick just like that. But, you can see
- 2:48:16that's just the same way a second way of
- 2:48:19getting the same data, okay? So, we have
- 2:48:22the code in here and now we need to put
- 2:48:24our script in here. So, I'm going to go
- 2:48:27in here and copy the entire script,
- 2:48:29okay? And then back to my gateway events
- 2:48:32and I'm going to drop that code in. It
- 2:48:34always does this funky indentation
- 2:48:36stuff, but don't worry about it. It's
- 2:48:38the exact same code. The only thing I'm
- 2:48:40going to do is I'm going to change from
- 2:48:42logger.info, I'm going to change it to
- 2:48:44this came from a
- 2:48:47gateway script, okay? So, a gateway
- 2:48:50event script. Now, I'm going to hit
- 2:48:52apply and I'm going to hit okay and I'm
- 2:48:54going to hit save, which sends it live.
- 2:48:56And you can see it updated immediately,
- 2:48:58right? There's 10 20 30 40. We'll go
- 2:49:00back in, we'll add 50 just so you guys
- 2:49:03can see I'm not crazy.
- 2:49:05Um well, I'm crazy, but not that way.
- 2:49:08Okay? So, we already have tag 50, which
- 2:49:10is awesome. And if we go back to the la
- 2:49:12la la la la logs, you'll see this came
- 2:49:15from a gateway event script, okay? So,
- 2:49:17we had those tag change scripts. Now, we
- 2:49:19have our gateway event scripts. So, that
- 2:49:21is a super useful
- 2:49:24uh thing to know, a thing to store. And
- 2:49:26then also useful to know
- 2:49:28excuse me.
- 2:49:30Tag value change scripts are obviously
- 2:49:32living on the tag themselves. So, that's
- 2:49:34on the tag provider in the tag browser.
- 2:49:38This gateway event is going to be
- 2:49:40executed at the gateway level, meaning
- 2:49:42it's using gateway resources uh and is
- 2:49:45not project specific. So, something that
- 2:49:47we can do is we can make a project
- 2:49:51library. And this is just another place
- 2:49:53to store script. Um honestly, I'm not
- 2:49:55here to tell you which one of these is
- 2:49:57best and worst. Like, if you prefer
- 2:50:00the code living on the tag that's firing
- 2:50:02it, that's honestly fine. Um as you get
- 2:50:05to larger systems and you maybe have
- 2:50:07hundreds of tag change scripts, it might
- 2:50:10be very useful for you to see all of
- 2:50:12those in one spot. Um but as long as
- 2:50:14you're documenting where everything
- 2:50:16lives, it it's totally fine to just mix
- 2:50:18and match, try a little bit of
- 2:50:20everything.
- 2:50:21Um but let's go ahead and copy this
- 2:50:22script. And what I'm going to do is I'm
- 2:50:24going to put it in a new location. And
- 2:50:26so, I'm going to go into Now, I'm in
- 2:50:28scripting and I am in project library.
- 2:50:31And I'm going to create a new script and
- 2:50:33I will call this array breakout, okay?
- 2:50:36And in here, just like in a conventional
- 2:50:39uh Python IDE, I'm going to create a
- 2:50:41function. I'll call it run and I'll put
- 2:50:44all of this code inside of it. But now,
- 2:50:47I'm going to have in the logger, I'm
- 2:50:49going to say this came from a project
- 2:50:52stored script, okay? So, I'm going to
- 2:50:55save this file, array breakout. Um and
- 2:50:58first thing, easiest thing is if I go
- 2:51:01back into gateway events and I
- 2:51:04uh tags tags and I disable this one so
- 2:51:07that it's not firing for now. First
- 2:51:09thing you'll be able to see
- 2:51:11is if I go in here and I add uh let's
- 2:51:15say now that this is 60, okay?
- 2:51:19Then uh you'll see the thing doesn't
- 2:51:21update automatically, right? But if I
- 2:51:23were to go back to the script console, I
- 2:51:25actually don't know if this will work,
- 2:51:27so let's just see. If I were to import
- 2:51:30array breakout, which is the file that
- 2:51:33those work in,
- 2:51:34uh and let's say as AB, so I don't have
- 2:51:36to type that. And now, I just do AB.run
- 2:51:39like that. And if I hit execute on this,
- 2:51:42execute. Okay, it actually worked. We
- 2:51:45got 60.
- 2:51:46Um and so, the script console is able to
- 2:51:49take that command that we just stored in
- 2:51:51a file and execute it. And I think if we
- 2:51:54go to the logs, you can see that
- 2:51:57actually that one
- 2:51:59uh
- 2:52:00didn't store. This came from a gateway
- 2:52:02event script. Did it?
- 2:52:05This came from a project. Yeah. Um which
- 2:52:07is actually a feature of the script
- 2:52:09console. If you're um
- 2:52:11sort of new to scope in uh Ignition,
- 2:52:15just know that script console is a local
- 2:52:18thing and it's not hitting the gateway.
- 2:52:20And so, when you are messing around in
- 2:52:22here, you can't use the logger, but you
- 2:52:25could use uh this interactive
- 2:52:27interpreter on the right side. So, you
- 2:52:29could swap out logger statements for
- 2:52:31print statements and they would show up
- 2:52:33on the right, but they would not appear
- 2:52:35in your uh gateway logs, okay? But let's
- 2:52:39go one step further, basically the final
- 2:52:41step, and show how you might want to use
- 2:52:43this. Rather than as this code gets
- 2:52:46longer and longer and more convoluted,
- 2:52:48rather than having all that code live
- 2:52:50here, you could do this. You could call
- 2:52:52the script that lives in the array
- 2:52:54breakout folder and you could just tell
- 2:52:57it to run when this tag value changes.
- 2:53:00So, I'm going to enable that. I'm going
- 2:53:02to say okay and say all right. And now,
- 2:53:05I'm going to save everything and I'm
- 2:53:06going to go into the array.
- 2:53:08And I am going to add a bunch more tags.
- 2:53:12And we'll say this is 63, 66, 70, 75,
- 2:53:1880, okay? So, I add a bunch more tags. I
- 2:53:21hit okay. And what you'll see is we get
- 2:53:24all those tags. We get 63, 66, 70, 75,
- 2:53:2780. Um and what just happened is this
- 2:53:31root tag input array changed. We
- 2:53:34triggered a gateway way event for tag
- 2:53:36change script that then called a script
- 2:53:39that we stored in array breakout and it
- 2:53:42ran this file. Is that convoluted? You
- 2:53:45bet. Was that the best way I could think
- 2:53:47of showing you all the different places
- 2:53:49and ways that you could write Python?
- 2:53:51Also, yes. Okay? And so, if you look at
- 2:53:54uh the logs after a test like that,
- 2:53:57you'll see now we have this came from a
- 2:53:59project stored script. This came from a
- 2:54:01project stored script. Um
- 2:54:04because it did. Because now, this one is
- 2:54:07firing. And if you'd like to see
- 2:54:09evidence that both the gateway event and
- 2:54:13uh the stored script are firing, we can
- 2:54:15do this. We can say both a logger for
- 2:54:18this came from a
- 2:54:20gateway script and uh then underneath
- 2:54:23it, this came from a stored script. And
- 2:54:25if we save it and delete one of our
- 2:54:27tags,
- 2:54:29delete, okay, apply, okay, and hit save.
- 2:54:33All right, so 80 drops off, but more
- 2:54:35importantly, both of those just ran. And
- 2:54:37so, if you look at the script, you'll
- 2:54:39see this came from a project stored
- 2:54:41script fires this way came from a
- 2:54:44gateway script, this came from a project
- 2:54:46stored script, this came from a gateway
- 2:54:48script, okay?
- 2:54:50So, you see them firing one after
- 2:54:51another
- 2:54:52um because also every time you save in a
- 2:54:55project, your tag change uh gateway
- 2:54:58events are going to fire to cover their
- 2:55:00butts because they don't necessarily
- 2:55:02know if the tag changed during that
- 2:55:04saving instance. So, just know that as
- 2:55:07well. If you're seeing weird behavior in
- 2:55:08logs of like multiple multiple
- 2:55:10instances, odds are you're doing control
- 2:55:13S a whole lot, which I do fairly
- 2:55:15frequently.
- 2:55:16Um but okay. Anyways, uh things we
- 2:55:19covered, super speed, we covered how to
- 2:55:22use the script console for basic code uh
- 2:55:25um compilation. We covered how to put
- 2:55:28put scripting directly on a tag with
- 2:55:30value changed. Uh we even covered how to
- 2:55:33generate and delete tags a little bit uh
- 2:55:36using Ignition scripting in Python,
- 2:55:38which is useful. And then, we covered
- 2:55:39gateway tag change events as well as
- 2:55:42storing scripting. So, this is a lot to
- 2:55:44cram into one tutorial. I know this was
- 2:55:46pretty dense and I know I moved pretty
- 2:55:48fast, but there was a lot to cover, so I
- 2:55:50hope you found it useful. I hope you've
- 2:55:52been enjoying the Ignition tutorial
- 2:55:54series. Uh if so, please leave a like on
- 2:55:57the video, subscribe to the channel. Let
- 2:55:59me know in the comments below what you'd
- 2:56:00like to see next on the channel. Don't
- 2:56:02forget to check out the uh sponsor link
- 2:56:05in the description of the video as well.
- 2:56:07And if you would like to consider
- 2:56:08becoming a super supporter of the
- 2:56:10channel, my Patreon link is down there
- 2:56:12below. Uh I appreciate the heck out of
- 2:56:14everyone who likes and supports
- 2:56:16LeMasterTech YouTube in any way.
- 2:56:18Um so, as always, thank you for
- 2:56:20watching. We'll see you next time.
- 2:56:21Thanks. Bye.
- 2:56:28Hello and welcome back to LeMasterTech.
- 2:56:30And in today's video, I'm going to walk
- 2:56:32you through animations in the SCADA
- 2:56:34software called Ignition. We're going to
- 2:56:36cover several types of animations you
- 2:56:38can do, including Boolean, color, and
- 2:56:41visibility transforms, text transforms
- 2:56:44including color, text strings, and
- 2:56:46integers, and then enumeration as well,
- 2:56:48where you can take integer values and do
- 2:56:50text-based transforms with it. So, this
- 2:56:53is many of the most common types of
- 2:56:54animations you'd need to do in Ignition.
- 2:56:57And then more importantly, it'll show
- 2:56:58you how tag bindings and animations work
- 2:57:01so that you can go and build whatever
- 2:57:03sorts of animations you need into your
- 2:57:05projects. All right, so we're going to
- 2:57:07try to cover a lot of content in this
- 2:57:08video. So, let's dive right into it. To
- 2:57:11start, let's go ahead and make a new tag
- 2:57:15called a memory tag because I don't have
- 2:57:17a PLC hooked up right now. I'm doing
- 2:57:19that just to show you that this doesn't
- 2:57:21really matter what platform you're
- 2:57:23using. As soon as you get a tag to
- 2:57:26Ignition, they're all kind of the same.
- 2:57:28So, I'm just going to make a Boolean tag
- 2:57:30and call it color bool to start, all
- 2:57:32right? Now, I'm going to go to the
- 2:57:34perspective components window and I'm
- 2:57:36going to grab an icon.
- 2:57:38Um this is just something Ignition
- 2:57:40includes. They have a number of icons uh
- 2:57:43that you can kind of select and play
- 2:57:45around with. And actually, I'm going to
- 2:57:47make two. One to act sort of as a button
- 2:57:50for us. So, I'm going to go to the path
- 2:57:51and I'm going to type in button. And I'm
- 2:57:53just going to grab this one that looks
- 2:57:55like a button. And then, the second one
- 2:57:56is what we're actually going to animate,
- 2:57:58okay? So, I'm going to write a very
- 2:58:00basic script here with you um that is
- 2:58:03going to uh I'm going to go to the icon
- 2:58:06that's our button. I'm going to go to
- 2:58:08configure events, mouse events, on
- 2:58:10click, plus, add a script. And what I'm
- 2:58:13going to do is I'm going to read the
- 2:58:15tag, system.tag.readBlocking.
- 2:58:21And then, I'm going to read the value
- 2:58:23of that tag. dot value, there we go. And
- 2:58:27then, if my value is high, I'm going to
- 2:58:29basically write uh to that tag. So,
- 2:58:32system.tag.
- 2:58:36write blocking. There we go. And then
- 2:58:39the same tag path
- 2:58:41Control C.
- 2:58:42And what we're checking here is if it's
- 2:58:44high, we want to write false. And then
- 2:58:48else would be it's low. So, in that
- 2:58:50case, we will write true.
- 2:58:53All right. And honestly, that tag path
- 2:58:56had to be typed out three times. Should
- 2:58:58probably put that in a variable. But,
- 2:59:00we're not here to optimize my scripting
- 2:59:02abilities. We're here to make sure that
- 2:59:04this tag
- 2:59:05[Music]
- 2:59:06works for toggling. So, I'm going to go
- 2:59:08ahead and quickly just go into this run
- 2:59:11mode and I can see that's toggling in
- 2:59:13the lower window.
- 2:59:14All right. Now, let's talk about the
- 2:59:16actual animation that is the subject of
- 2:59:18the video. I'm going to copy that tag
- 2:59:21path preemptively cuz I know we want it.
- 2:59:23And I'm going to go to the perspective
- 2:59:26property editor window. By default, it's
- 2:59:29usually tabbed in the right when you
- 2:59:30open up the designer.
- 2:59:32But, if you go to views and panels and
- 2:59:35toolbars, you have a lot of
- 2:59:36configurability over that. And you just
- 2:59:38need the perspective property editor
- 2:59:41toolbar active. Okay?
- 2:59:43So, in props, you can see color is
- 2:59:46already there. But, if it wasn't there,
- 2:59:48you're always able to add a property.
- 2:59:50And then you can add in color if you
- 2:59:53need to. In this case, it won't let me
- 2:59:55because it would be a duplicate.
- 2:59:58But, you should have color already if
- 2:59:59you're using the icons. And then for
- 3:00:01binding type, we're going to go to tag.
- 3:00:03We're going to paste in that color
- 3:00:05boolean. And now, if we were to do just
- 3:00:07this right now, it's going to give us an
- 3:00:09error because it can't convert true and
- 3:00:13false to a different color. So, what we
- 3:00:15need to do is hit this add transform
- 3:00:17button. And we're going to do a map. And
- 3:00:19it should open up this window for you.
- 3:00:21And we're just going to hit two pluses.
- 3:00:23The input type is going to be a value.
- 3:00:25And specifically, it's going to either
- 3:00:28read true or false. And you can see in
- 3:00:30the bottom, it's also telling you what
- 3:00:33the tag is currently reading, which is
- 3:00:35nice. And then the output type we want,
- 3:00:37you can see they have a number of
- 3:00:39options. But, value and color are by far
- 3:00:42the two most common ones. And so, when
- 3:00:44it's true, let's go ahead and make it
- 3:00:46green. And when it's false, let's make
- 3:00:48it red. And then fallback would be like,
- 3:00:50"Hey, we're having error." Like, this is
- 3:00:52a boolean tag and we don't have true or
- 3:00:54false. So, fallback will make this
- 3:00:56yellow just in case there's an error.
- 3:00:59Okay? And as soon as I hit apply, you
- 3:01:00can see that it goes green. Now, if I
- 3:01:03hit run and I click this button, you can
- 3:01:05see it turns red. So, the button is
- 3:01:07changing color bool between zero and
- 3:01:09one. But, then the animation on the tag
- 3:01:13is reading that back and determining
- 3:01:15which color it should go to.
- 3:01:17All right. So, color is one of the most
- 3:01:20common animations you're going to want
- 3:01:22to do if you're in a factory setting or
- 3:01:24in a home setting. It's a really easy
- 3:01:26way to quickly tell you the status of
- 3:01:27something as either okay or not okay.
- 3:01:31So, let's go ahead and delete color and
- 3:01:33take a look at what I think is kind of
- 3:01:35the next most common one,
- 3:01:37which would be let's take that same tag
- 3:01:39color boolean and we already have a
- 3:01:41button set up for it. And let's take a
- 3:01:43look at doing a visibility animation.
- 3:01:45So, I'm going to use the I'm going to
- 3:01:47use the same tag, which is color bool.
- 3:01:50Copy path. I'm going to use the same
- 3:01:52tag. But, what's nice is because
- 3:01:54visibility is a true or false, you don't
- 3:01:56actually need any expression or any
- 3:01:59transform here if you want it to change
- 3:02:01true and false with the tag. So, if I go
- 3:02:04into run mode
- 3:02:07and I toggle the bit, you can see that
- 3:02:09second smiley face appearing and
- 3:02:11disappearing on the boolean.
- 3:02:14Again, I know I went through that one
- 3:02:15pretty quick. But, down in meta, there's
- 3:02:17this visible option. You can toggle it
- 3:02:20true or false just from the designer.
- 3:02:22But, if you want it to be tied to a tag,
- 3:02:24you do it just like this.
- 3:02:27Now, I know in the beginning I had like
- 3:02:29a sun and a moon
- 3:02:31toggling back and forth. So, it also
- 3:02:33kind of makes it look like it's doing a
- 3:02:36transform if you have two icons and that
- 3:02:39their visibility toggles inversely of
- 3:02:42each other. So, let's do that pretty
- 3:02:43quick.
- 3:02:44Um
- 3:02:46I
- 3:02:47don't want to spend too much of the
- 3:02:48tutorial looking for the moon icon, but
- 3:02:52I found it quick last time.
- 3:02:54Typing in moon didn't work. So,
- 3:02:56um
- 3:02:58Yeah, there we go. There's one. Um so,
- 3:03:00if I have these copies and I have them
- 3:03:02both set to visible, then you do need a
- 3:03:05you do need a transform to get you the
- 3:03:08opposite. And the easiest one is just
- 3:03:10add a script transform and return not
- 3:03:13value. That way, the output is going to
- 3:03:15be the opposite of whatever boolean
- 3:03:17you're reading. So, if I hit apply now
- 3:03:19and I save and I enter runtime, you can
- 3:03:21see my sun and my moon are toggling as
- 3:03:24the color here toggles. So, that's a
- 3:03:26basic animation
- 3:03:28for visibility and for color based on a
- 3:03:31boolean tag. Now, let's go ahead and
- 3:03:33take a look at two cool things, which is
- 3:03:35dynamically changing color and text
- 3:03:38based on a non-boolean condition. So, an
- 3:03:40integer or a float.
- 3:03:42Heck, a string if you really wanted to,
- 3:03:44but I don't. So, memory tag. I'm going
- 3:03:46to call this one
- 3:03:48color integer. And then I'll start it
- 3:03:51out as a zero and it'll be a memory tag.
- 3:03:54Um now, I'm going to go back to
- 3:03:55perspective components and I'm going to
- 3:03:57grab a label for this one. Uh I'm going
- 3:04:00to just drop in a label here in the
- 3:04:03middle. And so that it's a little easier
- 3:04:05to see on the tutorial
- 3:04:08Whoop. Come on.
- 3:04:10That was weird. Okay. So, it's a little
- 3:04:12easier to see on the tutorial, I am
- 3:04:14going to just preemptively make the font
- 3:04:16size
- 3:04:17uh
- 3:04:18pretty big. And then we're actually
- 3:04:20going to mess with the font size in a
- 3:04:22second. But, I'll make it what's big?
- 3:04:2432? Yeah, we'll start there.
- 3:04:27Okay?
- 3:04:28So, it is basically just what we already
- 3:04:31saw at a very basic point. If I copy the
- 3:04:33path of my integer and I go to text now,
- 3:04:36the text property of a label, and I go
- 3:04:38to tag for binding, and then I just drop
- 3:04:41in the color integer, then I hit okay.
- 3:04:43It is that value. And if I go into this
- 3:04:45value and I write it to a 10 instead, it
- 3:04:48immediately changes to a 10. So, that is
- 3:04:51actually a basic style of animation.
- 3:04:54It's animating the text. But, all you're
- 3:04:57really doing is uh
- 3:04:59you know, changing the text on a label.
- 3:05:01You probably found that one out with
- 3:05:02just forms. So, let's look at something
- 3:05:05a little more interesting, which would
- 3:05:06be like the color of the text changing
- 3:05:10with that value as well. Right? So,
- 3:05:13let's say we have the label and the
- 3:05:15color and I don't know, we'll make it
- 3:05:18red initially.
- 3:05:19If we go into the same spot before that
- 3:05:22we had that color animation and tag and
- 3:05:25we drop in the same tag and we add a
- 3:05:27transform and we go to map, uh now,
- 3:05:30what's going to be kind of annoying is
- 3:05:32if you go in here and you do value and
- 3:05:35you just add a bunch and you make your
- 3:05:36output color, what's annoying is if you
- 3:05:39just do mapping value to color, then you
- 3:05:42would have to go integer by integer or
- 3:05:44value by value that that integer could
- 3:05:46be and you have to choose what color you
- 3:05:48want it to be. So, what's easier is this
- 3:05:51numeric range option where we say,
- 3:05:53"Okay, between zero and 50,
- 3:05:57the level is good, let's say." So,
- 3:06:00level's going to be green. Between 50
- 3:06:03and 75, let's say we're talking about
- 3:06:06percentages on on a tank. It's getting
- 3:06:10too high. So, we maybe want to make it
- 3:06:12yellow. And then between 75
- 3:06:16and 100, we are at high level. So, we're
- 3:06:19going to make it red to warn people. And
- 3:06:22then the fallback will be like yeah,
- 3:06:24fallback will be black
- 3:06:26to basically say like, "Hey, we're
- 3:06:28getting unexpected values here." Okay?
- 3:06:30So, with this numeric range to color
- 3:06:32mapping, I'm going to hit okay. And what
- 3:06:34you can see is it's green right now
- 3:06:36because we're at that zero to 50 range.
- 3:06:38If I go to 60, it turns yellow, which is
- 3:06:41actually not super easy to see because
- 3:06:44the
- 3:06:45background color is white. I spelled
- 3:06:49background wrong.
- 3:06:50Background color is white. But, if we
- 3:06:52make it a
- 3:06:54dark gray, I think all of these colors
- 3:06:56will show up. So, 10, it's green, it's
- 3:06:59healthy. Yellow,
- 3:07:02it's it's you know, "Hey, you're getting
- 3:07:04up there." And then 80, there's red. And
- 3:07:06let's say this went to 105, it turns
- 3:07:09black because the value is out of range.
- 3:07:12So,
- 3:07:13that's kind of a cool way to take a look
- 3:07:15at doing
- 3:07:16um
- 3:07:17dynamic animation. So, I'm going to go
- 3:07:19back. I had pre-written a gateway script
- 3:07:21that was going to take that color
- 3:07:23integer and just keep sending it up
- 3:07:26until it hits 100 so that we can do some
- 3:07:29testing and I don't have to like
- 3:07:30manually
- 3:07:32um I don't have to manually go in and
- 3:07:34toggle
- 3:07:35uh
- 3:07:36Come on, Pete. Talking right at the same
- 3:07:38time. So, I don't have to manually go in
- 3:07:40and toggle that value. I can just
- 3:07:44I can just automate it away. But, that
- 3:07:46only works if you keep consistent naming
- 3:07:50standards. So, I called it color tag
- 3:07:52before. All right. So, with that script,
- 3:07:54you can now see every 100 milliseconds I
- 3:07:56have the gateway going through and
- 3:07:58adding one to that value. It's just so
- 3:08:00that we can kind of see our animation
- 3:08:02working and I don't have to keep typing
- 3:08:04in a value. And just before we get to
- 3:08:06the last section, I think now is a great
- 3:08:08time to tell you about the sponsor of
- 3:08:10today's video, PCBWay. PCBWay is an
- 3:08:12incredibly cool company that
- 3:08:14manufactures printed circuit boards and
- 3:08:16printed circuit board assemblies for
- 3:08:17hobbyists and makers. On top of that,
- 3:08:19they have high-quality 3D printing and
- 3:08:21metal prototyping services. They have
- 3:08:24super helpful and friendly staff,
- 3:08:25including an engineering team that
- 3:08:27reviews every order before sending it to
- 3:08:29production, fair pricing, and great
- 3:08:30turnaround times. So, thank you to
- 3:08:32PCBWay for sponsoring the video. Be sure
- 3:08:34to check them out in the link in the
- 3:08:35description below. Now, back to the
- 3:08:37tutorial. The next thing I want to do is
- 3:08:39show, let's say you also wanted to
- 3:08:41animate uh something else. Now, we have
- 3:08:44two animations based on the same tag
- 3:08:47already. So, if I wanted to go in and
- 3:08:49also have the font size change based on
- 3:08:51the same tag, um
- 3:08:53one, that's a pretty enormous changing
- 3:08:56value, and it starts pretty small. So,
- 3:08:58let's also add a transform
- 3:09:01um and a little script here to say
- 3:09:05um return let's just return the value
- 3:09:09divided by 2 + 10. So, it'll change a
- 3:09:11little bit slower like this. Um
- 3:09:15now, what I wanted to show you is you
- 3:09:18can animate multiple properties by using
- 3:09:20a custom property that you pass in once.
- 3:09:22So, obviously, we now have three
- 3:09:24animations based on this one color
- 3:09:27integer tag. If I were to go into custom
- 3:09:29and add a tag property and put in the
- 3:09:32mapping of that tag, this gets way
- 3:09:35easier because I can come into each of
- 3:09:36these spots, and rather than this being
- 3:09:40um
- 3:09:41uh directly linked to a tag, whoops.
- 3:09:45Uh you can go to indirect tag binding,
- 3:09:47and you can give it the property of this
- 3:09:50thing, and then custom parameters, and
- 3:09:52then we called the tag this custom tag.
- 3:09:55So,
- 3:09:56you can go and do this for all three,
- 3:09:58and you may be saying it doesn't
- 3:10:00actually save you time cuz you have to
- 3:10:02go back and uh do this part uh three
- 3:10:05times, which is true, but what I'm going
- 3:10:07to show next is this is what you really
- 3:10:10want to do if there is any chance that
- 3:10:12you're going to use this thing again for
- 3:10:15similar animations for a different tag.
- 3:10:18So, um what do I mean by that? Just give
- 3:10:20me a second to finish tying all three of
- 3:10:23these to
- 3:10:24the tag indirect property.
- 3:10:28Um
- 3:10:29and let's hit okay and apply. Now,
- 3:10:33that took just as long as manually tying
- 3:10:36it uh in all three places, but let's say
- 3:10:39I have a second one of the same object,
- 3:10:41and I want to make sure that all of the
- 3:10:44animations that it was doing for this
- 3:10:46first integer, it does again for what
- 3:10:49I'll call color integer whoop
- 3:10:51color int two. Uh I'm going to call it
- 3:10:55slow cuz I'm going to have it change
- 3:10:56slower than the first one.
- 3:10:59Alrighty. So, what I'm going to do then
- 3:11:02is I'm going to say everywhere that I
- 3:11:04was using color int for that first one,
- 3:11:06I want to use color int slow for that
- 3:11:08second one. And initially, cuz we don't
- 3:11:10have the value changing, it's just
- 3:11:12looking at 29. But if I go into gateway
- 3:11:15events, and I make a same
- 3:11:18I make another script color int
- 3:11:21slow
- 3:11:22color int slow, and this one runs once
- 3:11:26per second rather than uh every 100
- 3:11:29milliseconds. Okay, apply, okay. And
- 3:11:32then we go back to our home screen. You
- 3:11:34can see I have this on the right
- 3:11:36changing much slower than the first one,
- 3:11:38but the font size is updating, the color
- 3:11:40is updating, and the text is updating
- 3:11:43just by changing that custom tag
- 3:11:44property. So, that's a cool little thing
- 3:11:47to make it replicatable. Even with
- 3:11:49buttons and things like this, if you're
- 3:11:50going to generate a lot of toggle
- 3:11:52buttons, you want to write that script
- 3:11:55to look at custom tag parameters so that
- 3:11:58all you have to do is pass in what tag
- 3:12:00you're looking at, and all of the rest
- 3:12:02of it is extrapolated away by using
- 3:12:03those shared parameters. So, that's kind
- 3:12:06of one step past an animation tutorial,
- 3:12:09but I think we have the time to make
- 3:12:11this useful.
- 3:12:12So, let's go ahead and do one additional
- 3:12:15thing, which is going to be transforming
- 3:12:17text based on an integer. Uh and I think
- 3:12:21this is super useful because it's kind
- 3:12:23of the basis of like enumeration, which
- 3:12:25is why I'm going to call it an enum tag.
- 3:12:29And it's going to be an integer, and I'm
- 3:12:30going to initially set it to zero. And
- 3:12:33the thing about enumeration is it's
- 3:12:35embedding detailed text status or some
- 3:12:39meaningful thing in an integer value
- 3:12:41because PLCs don't always want to store
- 3:12:45long strings of text when they could
- 3:12:49just store it as an integer. So, the
- 3:12:51most common thing I'm thinking of is for
- 3:12:53a sequence or a vessel like a tank in a
- 3:12:55tank farm
- 3:12:57is tank status would just tell you 0 1 2
- 3:13:013 4 or 5, but to make that useful to an
- 3:13:04operator, you would want to transform
- 3:13:06that to say running, idle, starting,
- 3:13:09stopped, whatever status the tank is in.
- 3:13:12Um so, let's go ahead and go to
- 3:13:13perspective components, and let's grab a
- 3:13:15new label,
- 3:13:17and I'll show you in a little more
- 3:13:18detail what I'm talking about. I
- 3:13:20accidentally made a second label, that's
- 3:13:22okay.
- 3:13:24I'm going to grab this enum tag, and I'm
- 3:13:26going to uh have the tag
- 3:13:29tied to the enumeration tag, and now I'm
- 3:13:32going to add another transform just like
- 3:13:34before. And we're going to take input
- 3:13:36values and output values. You don't have
- 3:13:40to change this to string or anything
- 3:13:41like that. It'll know you want a string
- 3:13:44by default. So, I'm going to say, let's
- 3:13:46say 0 1 2 3 and 4 are our statuses that
- 3:13:52we could get. And let's say zero means
- 3:13:54idle for a tank, one means it's
- 3:13:57starting, two means it's running, three
- 3:14:02means it's
- 3:14:04paused, and four means it is aborting or
- 3:14:08stopping. Let's just say stopping.
- 3:14:11Aborting always means like something's
- 3:14:13wrong. Okay. Fallback will be error
- 3:14:17uh error bad status, okay? That's what
- 3:14:21it'll say.
- 3:14:23Now, because the value's initially set
- 3:14:25to zero, oh, let me make it a bigger
- 3:14:27font size, too.
- 3:14:29Font size 40, heck yeah. Um because it's
- 3:14:32initially zero, uh it says idle.
- 3:14:36Let's go ahead and make a new button,
- 3:14:39and let's change the script on this one
- 3:14:41to uh
- 3:14:43I'm eating my earlier words. I should
- 3:14:44have just made it look at a tag. Let's
- 3:14:47look at the enumeration tag in this
- 3:14:49script.
- 3:14:51And let's say the tag path is equal to
- 3:14:54this, and then let's read the tag here
- 3:14:58in the beginning,
- 3:15:00and then whoop
- 3:15:01I caps lock. It is case sensitive. And
- 3:15:04then we'll say if value is less than
- 3:15:06four, let's just go ahead and
- 3:15:10add one to the tag, which will be value
- 3:15:14plus one, and then we'll say else, let's
- 3:15:16write to the tag and have it be equal to
- 3:15:20zero, okay? So, this is just giving me a
- 3:15:23button that is going to let me increment
- 3:15:26the status. So, there you go. It goes to
- 3:15:28one, it says starting, two, it says
- 3:15:30running, three, it says paused, four, it
- 3:15:32says stopping, and then zero, it says
- 3:15:35idle. And if I were to go in and
- 3:15:37manually make it a five, you can see it
- 3:15:38says error bad status. If you don't like
- 3:15:41it on multiple lines like that, just
- 3:15:42make your object a little wider. All
- 3:15:44right? And then what's cool is you can
- 3:15:46also transform these values, and then
- 3:15:48you can add another transform if you
- 3:15:50want. And so, you can give a little
- 3:15:51clarity around what this is. Like if
- 3:15:53this is tank status, you can say tank
- 3:15:57status, and then the value, all in one
- 3:16:00tag and one object, and you can say,
- 3:16:03okay, the tank status is idle. Now, if
- 3:16:06you have a bunch of text strings on a
- 3:16:08screen, you're able to show a lot of
- 3:16:10information just by adding a label to
- 3:16:13this, and you could also go in that same
- 3:16:16expression, and if it was, you know, a a
- 3:16:19pressure reading, let's say, you could
- 3:16:21then add units to the end. So, if it
- 3:16:23wasn't tank status, if it was tank
- 3:16:25pressure, you could all in one
- 3:16:27expression, you could say tank pressure,
- 3:16:30then the value, and then the units, all
- 3:16:32in one string, and you would get this
- 3:16:35object that is just one cohesive object.
- 3:16:37You don't have to deal with formatting
- 3:16:39like three different strings all in one.
- 3:16:42Um and I actually think that that's
- 3:16:44pretty darn cool and pretty darn uh
- 3:16:46easy. So, obviously, the tank status uh
- 3:16:49being PSI doesn't make much sense, so
- 3:16:51I'll delete that PSI part cuz that's my
- 3:16:54OCD acting up.
- 3:16:57Apply, okay.
- 3:16:58All right, but right there, we have
- 3:16:59covered so many of the basic animations
- 3:17:02that you can use in Ignition in a fairly
- 3:17:04short period of time. If you have
- 3:17:06specifics about how to do more advanced
- 3:17:09uh animations, or if I missed an obvious
- 3:17:11one, and you guys let me know about in
- 3:17:13the comments below, I will make sure to
- 3:17:15do a follow-up video uh to address the
- 3:17:17most sought-after tutorials in Ignition
- 3:17:21that people have. So, be sure to let me
- 3:17:23know in the comments below what you want
- 3:17:24to see more of. Thank you so much for
- 3:17:26checking out the channel. I appreciate
- 3:17:28your time. I hope this video was useful
- 3:17:30for you. Please consider leaving a a
- 3:17:32like on the video, subscribing to the
- 3:17:33channel. It helps me out a ton. And if
- 3:17:36you want to become a super supporter of
- 3:17:37the channel, consider checking out my
- 3:17:39Patreon link at uh the description of
- 3:17:41this video as well. It helps me out so
- 3:17:43much, and I could not have gotten the
- 3:17:45channel to where it was without my
- 3:17:46Patreon supporters. So, thank you all
- 3:17:48for watching, and we'll see you next
- 3:17:50time. Thanks. Bye.
- 3:17:58Hello, and welcome back to The Master
- 3:18:00Tech. In today's video, we're going to
- 3:18:02continue our introduction to the basics
- 3:18:04of controls and automation uh through
- 3:18:07practical tutorials. Today, we are going
- 3:18:09to take a look at tying a PLC into an
- 3:18:12HMI service and building your first HMI,
- 3:18:15or human-machine interface. Our specific
- 3:18:18setup is going to be the Arduino Opta
- 3:18:20PLC using the Arduino IDE, the PLC IDE,
- 3:18:25and we're going to talk to Ignition for
- 3:18:27Makers.
- 3:18:28Um so, we've previously done a setup
- 3:18:30video on how to get started with the
- 3:18:32Opta PLC
- 3:18:33um
- 3:18:34as well as your first structured text
- 3:18:36and ladder logic languages. We'll
- 3:18:38continue building on those skills in
- 3:18:40this video. And then, we've previously
- 3:18:42done how to set up Ignition for Makers.
- 3:18:45So, the basics, if you want to start
- 3:18:47from the same point that I'm starting
- 3:18:48this tutorial from, would be have
- 3:18:50Ignition for Makers. It can run on any
- 3:18:52computer. It can run on your laptop. Um
- 3:18:55Ignition for Makers and the Arduino PLC
- 3:18:58and PLC IDE hooked up. And we'll be in
- 3:19:01the exact same spots when we start this
- 3:19:03video. So, today we're going to look at
- 3:19:06setting the IP address of the Arduino
- 3:19:08Opta PLC, setting up variables to talk
- 3:19:11over Modbus TCP, tying a Modbus TCP
- 3:19:14device into Ignition,
- 3:19:17adding tags from that device, and
- 3:19:20building an HMI or a human machine
- 3:19:22interface, a graphical screen that looks
- 3:19:25at the PLC. You don't need any project
- 3:19:28built in either of these already. So,
- 3:19:30what we'll be starting from is an
- 3:19:32Ignition project that has no HMI. So,
- 3:19:35we'll build a brand new project
- 3:19:36together. And an Arduino PLC that has
- 3:19:39nothing running on it other than the
- 3:19:40base code that is on there when uh you
- 3:19:43load a new project on there. So, I have
- 3:19:45this count uh equals count plus one,
- 3:19:48which if we watch it live, you can see
- 3:19:50that is the only thing running on the
- 3:19:51PLC is the default main code. So,
- 3:19:54without any further ado, without me
- 3:19:56explaining to you where we're starting
- 3:19:57and what we're doing, let's just get
- 3:19:59into some of the basics together. So, up
- 3:20:02to this point, we've seen a little
- 3:20:03structured text. We've seen a little
- 3:20:05ladder diagram. Um
- 3:20:07but we haven't tied the PLC into
- 3:20:09anything. So, what we want to do is we
- 3:20:12want to uh give this Arduino Opta PLC an
- 3:20:17IP address because Modbus TCP uses uh
- 3:20:21RJ45 connection. It uses an Ethernet
- 3:20:23connection uh to talk and send data over
- 3:20:26Modbus. And what's interesting is if you
- 3:20:29go to the resources tab of your Opta
- 3:20:31project, and then you go to sketch,
- 3:20:33there will already be a commented out
- 3:20:36section for configure IP address, which
- 3:20:38is really nice, super useful.
- 3:20:41Um
- 3:20:42So, all we're going to do actually is
- 3:20:43remove the comments. And this is
- 3:20:46actually just giving us what we need for
- 3:20:47it to talk over the network. The only
- 3:20:49difference is we don't want to keep this
- 3:20:51IP address. 192168.1's
- 3:20:54kind of fine for home use, but usually
- 3:20:57it and if you're in any kind of
- 3:20:59industrial setting, they'll have a a
- 3:21:01different block of IPs they want you to
- 3:21:03adhere to. Super easy to adjust that.
- 3:21:06You just type in what you want the IP to
- 3:21:08be here. So, I'll use 42069169.
- 3:21:11That's nice and secure. And then uh in
- 3:21:14the gateway, I'll say 42
- 3:21:17069.1.
- 3:21:20That would be pretty normal
- 3:21:22um for a gateway on any sort of like
- 3:21:24corporate network to be the same first
- 3:21:27three blocks as your as your uh device
- 3:21:30IP, but then dot one for the gateway.
- 3:21:32So, that's all we're going to do uh to
- 3:21:34set the IP address on on the machine,
- 3:21:37and that's really simple. We don't have
- 3:21:39to do anything additional beyond that.
- 3:21:41Um but what we do want to do so that
- 3:21:43this actually does something when we tie
- 3:21:45it into Ignition is we want to come into
- 3:21:47parameters, and we want to just add a
- 3:21:49few variables here that we'll actually
- 3:21:52be able to monitor from Ignition. So, if
- 3:21:54you go to parameters, um this is going
- 3:21:56to be your Modbus addresses. So, if we
- 3:21:58just add four things here real quick,
- 3:22:01um we could add let's say we want to add
- 3:22:04some tags for monitoring the
- 3:22:07user push button. So, if you remember
- 3:22:09the Arduino Opta PLC from previous
- 3:22:11videos, we have a push button on the
- 3:22:14front, and then we have some LEDs as
- 3:22:16well. We have the uh red light. We'll
- 3:22:18just call it red. We have the blue
- 3:22:20light, and we have the green light. And
- 3:22:22it's important to note that we are not
- 3:22:24tying these currently to the red light,
- 3:22:26blue light, green light, or user push
- 3:22:28button. We're creating new variables,
- 3:22:31and we want to change them all to
- 3:22:32booleans.
- 3:22:34But what we're doing is we're assigning
- 3:22:35those variables to Modbus addresses
- 3:22:38where they'll actually populate when
- 3:22:40something that can read data over Modbus
- 3:22:42TCP connects to these addresses. So,
- 3:22:45this addressing is important when we get
- 3:22:47to the Ignition piece.
- 3:22:49And we'll take a look at it. But right
- 3:22:51now, they're not going to do anything
- 3:22:52cuz we haven't tied them to anything
- 3:22:54yet. So, let's take user push button,
- 3:22:56red, blue, and green, and let's tie them
- 3:22:58to the actual values that uh they need
- 3:23:01to be tied to. And to do that, we also
- 3:23:03want to come to uh LED outputs. And here
- 3:23:06we have LR. Uh and so, we'll call that
- 3:23:10LR, LG, and LB. And if you've been
- 3:23:13following along with the tutorial
- 3:23:14series, you know why we're doing this
- 3:23:16piece. Um and if you aren't following
- 3:23:19along with the tutorial series, maybe
- 3:23:21consider doing that. Um but basically,
- 3:23:24we are assigning the actual red, green,
- 3:23:26and blue lights on the front of the uh
- 3:23:29Arduino Opta, as well as the user push
- 3:23:32button, to variables that we can use in
- 3:23:34our main uh PLC program now.
- 3:23:37So, if in here, we just come in and we
- 3:23:39say like first thing we want to do is
- 3:23:42set the red light to be equal to true,
- 3:23:44the green light to be equal to false,
- 3:23:48and then the blue light to be equal to
- 3:23:51the state of the user push button. So,
- 3:23:53the blue light will change as we press
- 3:23:56and release the user push button. Uh
- 3:23:58then that would give us sort of those
- 3:24:01four variables populated. And then, what
- 3:24:03we need to come down here and do is we
- 3:24:05need to say blue should be equal to L
- 3:24:08LB. Whoop.
- 3:24:11So, now we're taking our Modbus
- 3:24:13variables, and we're setting them equal
- 3:24:15to the status
- 3:24:17of the variables we're controlling in
- 3:24:18the program. So, the first lines were to
- 3:24:21actually set the state of our outputs.
- 3:24:23Whoop. I'm trying to talk and type, and
- 3:24:25that never goes well.
- 3:24:28And then, user_pb
- 3:24:31is equal to user.
- 3:24:34So, to recap what we're doing here,
- 3:24:35we're just telling the red light to be
- 3:24:37true, the green light to be false, the
- 3:24:39blue light to turn on and off with the
- 3:24:41user push button, and then we're telling
- 3:24:44the blue, red, green, and user push
- 3:24:46button Modbus variables that they should
- 3:24:48be equal to these variables that we're
- 3:24:51using in the code. So, if we uh download
- 3:24:54this to the PLC, and we hit yes and
- 3:24:57compile,
- 3:24:58it should compile without error. I don't
- 3:25:00always write perfect code, but I'm not
- 3:25:02that bad at it.
- 3:25:05It'll want us to restart, and that's
- 3:25:07okay. And then, we'll initialize, and
- 3:25:09that's okay.
- 3:25:11Okay, so it looks like it completed.
- 3:25:14If we connect to the PLC,
- 3:25:21we can also enter this cool mode that I
- 3:25:23don't think I explicitly called out
- 3:25:24before called live debug mode. Um and
- 3:25:27this actually lets us see the value of
- 3:25:30all of those variables. And what's cool
- 3:25:32is my PLC, which is on some DIN rail and
- 3:25:35connected to a power supply, so it's a
- 3:25:37little harder to show on camera than
- 3:25:40before. Um but what's cool is you can
- 3:25:43see the red light is on, the green light
- 3:25:45is off, and if I push the push button,
- 3:25:47the blue light turns on uh and off with
- 3:25:50the push button. So, that's cool. Um
- 3:25:52that means that the PLC program took,
- 3:25:55and we should be all set now to actually
- 3:25:58tie it into Ignition.
- 3:26:02Okay, so let's go ahead now. We have an
- 3:26:04IP address set on this. We have a few
- 3:26:06variables that we can address here in
- 3:26:08our Modbus addresses. So, let's jump
- 3:26:10over to the Ignition gateway. So, you go
- 3:26:13to your
- 3:26:15web page.
- 3:26:17I have a lot of security on mine, very
- 3:26:19secure.
- 3:26:21All right. So, for a Modbus device, it's
- 3:26:23a little different than adding most like
- 3:26:25um tier one PLC manufacturers. Most
- 3:26:29Allen-Bradley, Siemens, Beckhoff
- 3:26:31devices, like major PLC manufacturers
- 3:26:34that you'd talk to, you may go to OPC
- 3:26:36connections and create a new OPC
- 3:26:38connection. But if you have a um
- 3:26:42device using a slightly older or
- 3:26:43slightly less common communication
- 3:26:45protocol, a lot of that times you're
- 3:26:47just going to go to config, and then
- 3:26:49you're going to go to device connections
- 3:26:51instead.
- 3:26:52Uh and for us, we'll create a new
- 3:26:54device. You can see a lot of their
- 3:26:56default browser
- 3:26:57um default uh data types that they have
- 3:27:00in here. And we are just looking for
- 3:27:02Modbus TCP, okay?
- 3:27:04And it's cool. It just needs a name, and
- 3:27:07then a description. It can be first Opta
- 3:27:11PLC to Ignition for description. That
- 3:27:15part's optional. And then here, you can
- 3:27:17enter your IP address. That's all you
- 3:27:19need to enter. And then, port 502 is by
- 3:27:22default. You can leave that be, and that
- 3:27:23should work. And just go ahead and
- 3:27:26create new device. You don't have to
- 3:27:27look at any of the advanced options or
- 3:27:29anything like that. Uh if you hit create
- 3:27:31device, and it says connected, you're
- 3:27:34money. If it says failure to connect, it
- 3:27:36may give you a reason why here. It may
- 3:27:38give you information. Um you can try to
- 3:27:41open the command window, and you can try
- 3:27:43to just ping uh you can try to just ping
- 3:27:47your IP address.
- 3:27:49Um and you should be able to get a reply
- 3:27:53from it. If you haven't, I didn't
- 3:27:54explicitly call this out, make sure your
- 3:27:56network adapter is on the same uh
- 3:27:59subnet. So, make sure your laptop that
- 3:28:02is plugged into your Arduino, or
- 3:28:04whatever computer is plugged into your
- 3:28:06PLC, make sure that Ethernet port is on
- 3:28:09the same 420.69
- 3:28:11or whatever you're using. Make sure it's
- 3:28:13on the same subnet cuz Ignition can't
- 3:28:15see devices on different subnets unless
- 3:28:18you open them up and configure your
- 3:28:19network that way.
- 3:28:21Uh the industrial networking side of
- 3:28:23controls and automation might be the
- 3:28:25least fun part of the job.
- 3:28:27But important thing while we're here on
- 3:28:30the device, it says connected and that's
- 3:28:31awesome. But if we were to like for
- 3:28:34example use the OPC quick client um
- 3:28:37to try to browse
- 3:28:39uh the Opta for tags, we have basically
- 3:28:42nothing. We have diagnostics which is
- 3:28:44nice and it's proof that the device
- 3:28:46connected, but we have no useful data.
- 3:28:48We can't find those four tags that we
- 3:28:50added because they don't exist yet
- 3:28:52because after you add a Modbus device
- 3:28:55you have to hit more and you have to go
- 3:28:57to addresses and then uh you need to add
- 3:29:01a row of uh the tags that you want to
- 3:29:03read from. So if for us specifically
- 3:29:08Let me find my notes. Good. We want to
- 3:29:10go add row
- 3:29:12and then if we look back at the Arduino
- 3:29:14PLC, we started at 16384
- 3:29:18which means back in Ignition
- 3:29:23minimize this.
- 3:29:24We can go to prefix and here's where you
- 3:29:27just call it something you want to
- 3:29:29reference this. So we'll call we'll just
- 3:29:30call it um
- 3:29:33Opta tags is fine. Uh we'll start from
- 3:29:36one and we'll go to four cuz we only
- 3:29:38have four tags and then you give it a
- 3:29:40unit ID. Um this part doesn't matter so
- 3:29:44much. Uh I've used 255 multiple times.
- 3:29:48Um it it really doesn't matter. You can
- 3:29:50put any unit ID number you want here. Uh
- 3:29:53you just need to remember what that is
- 3:29:55when you're looking at the tags. This is
- 3:29:56the part that matters. 16384 is where it
- 3:29:59starts. So now it knows to grab 16384
- 3:30:03and then go four uh bytes or words or
- 3:30:06addresses registers is what they're
- 3:30:08called um from the first 16 384. So if
- 3:30:13we hit save, uh disconnected should turn
- 3:30:16to connected pretty quick. And now the
- 3:30:18difference is if we go to OPC quick
- 3:30:21client
- 3:30:22and we go to devices and the Opta and
- 3:30:25now we have unit ID 255 which we just
- 3:30:28added. Opta tags one through Opta tags
- 3:30:30four. And now if I subscribe by hitting
- 3:30:33this little S on all four of those, down
- 3:30:36here in the bottom window it shows me
- 3:30:37the value of all four of those tags.
- 3:30:40It'll take a second to update cuz this
- 3:30:41is not the fastest tool. This isn't like
- 3:30:44scanning the tags live. But you can see
- 3:30:46we have 0100.
- 3:30:49Um if we were back in the Arduino PLC,
- 3:30:51we know that correlates to the user push
- 3:30:53button, the red light, the blue light,
- 3:30:55and the green light. So if I were to go
- 3:30:58ahead and hold down the user push button
- 3:31:01you can see that zero the first tag and
- 3:31:04the third tag both turn to one because
- 3:31:06that's me pushing the user push button
- 3:31:08and the blue light turning on. So that's
- 3:31:10cool. Now we have tags that live in the
- 3:31:13PLC that are reading through Ignition.
- 3:31:15We haven't built an HMI yet, but we've
- 3:31:18verified that we can get tags
- 3:31:20uh into Ignition. So that's half the
- 3:31:22battle.
- 3:31:24It's actually over half the battle. So
- 3:31:26let's go to the designer launcher now
- 3:31:28which is for Ignition. That's where you
- 3:31:30you know build your visualization.
- 3:31:33And let's go ahead to our Ignition
- 3:31:36session. Let's open the designer and
- 3:31:38we're going to make a new project
- 3:31:40together so that we can do every step of
- 3:31:42this together. Username will be
- 3:31:45LaMasterTech cuz it's cool.
- 3:31:48And then this is top secret and
- 3:31:52definitely totally different. Okay, so
- 3:31:55rather than open Arduino PLC tutorial,
- 3:31:57but I promise you there's nothing in
- 3:31:59there. We'll do Arduino Opta HMI.
- 3:32:04Project must start with a letter or
- 3:32:06underscore and contain only Okay, so
- 3:32:08it'll be Arduino Opta HMI all like that
- 3:32:10smooshed together. We'll copy that three
- 3:32:12times. I don't need to inherit anything.
- 3:32:14Leave all these as defaults. Let's just
- 3:32:16create a project. Okay, so
- 3:32:19should be pretty similar to the default
- 3:32:21window you get uh when you open this up.
- 3:32:23Let's just go to perspective
- 3:32:26and uh let's go to views and let's right
- 3:32:29click and hit new view and we will just
- 3:32:31call this homepage. Okay? So it's going
- 3:32:35to give you a default window. I'm going
- 3:32:37to hit save real quick. Force of habit.
- 3:32:39Like every 3 seconds I impulsively do
- 3:32:42control S and hit save. You don't have
- 3:32:45to. Perspective components. Let's go
- 3:32:48over on the right. You should have a
- 3:32:50little palette here. If you ever want to
- 3:32:51play around with the tools and toolbars
- 3:32:54in Ignition, feel free to. There's lots
- 3:32:56of panels and toolbars.
- 3:32:59Um
- 3:32:59Inductive Automation is always adding
- 3:33:01new features to this stuff. So it's not
- 3:33:03a bad idea to comb through toolbars and
- 3:33:06check for updates and whatnot. But I use
- 3:33:09labels for a lot of stuff. So for this
- 3:33:13label, let's just call this our Arduino
- 3:33:15Opta PLC and let's take 3 seconds real
- 3:33:19quick to uh make this label kind of look
- 3:33:22like our PLC, okay? I'm going to go to
- 3:33:24style over here on the right. I'm going
- 3:33:26to hit plus and I'm going to go to
- 3:33:28background color
- 3:33:30and I'm going to make it dark gray.
- 3:33:34And I guess actually before we get too
- 3:33:36deep into this or while I'm building
- 3:33:38this, uh we'll also go to style. We'll
- 3:33:41go to color.
- 3:33:42Just just color.
- 3:33:45And we'll make the text color white. And
- 3:33:48now I'm going to make it a little bit
- 3:33:50bigger cuz I'm going to drop a bunch of
- 3:33:52images and icons on it. And then I'm
- 3:33:54going to align vertical top. So now I
- 3:33:57have this rectangle. I'm going to drop
- 3:33:59inputs and outputs and lights and
- 3:34:01statuses on this HMI so that it looks
- 3:34:03like the PLC. I'm going to hit save and
- 3:34:06I'm going to pause for just a second
- 3:34:07about what an HMI is meant to be and
- 3:34:10what you want to put on an HMI.
- 3:34:13So HMI human machine interface is what a
- 3:34:16conventional software programmer would
- 3:34:18refer to as their GUI or graphical user
- 3:34:20interface. It is where the person
- 3:34:23interacts with a virtual system so that
- 3:34:26they can control the outputs and monitor
- 3:34:28the inputs and interact with the
- 3:34:30physical system from an easy to use and
- 3:34:32easy under to understand screen.
- 3:34:36So while it may look like I'm kind of
- 3:34:37rapidly building a thing and it's sort
- 3:34:40of like PowerPoint, the important extra
- 3:34:43piece to know is that you're linking
- 3:34:45tags and you're creating animations of
- 3:34:48objects based on those tags and the
- 3:34:51animations of those objects as well as
- 3:34:53the output actions from clicking on
- 3:34:55buttons and things like that should go
- 3:34:57back and affect your PLC. So in addition
- 3:35:01to reading things like the statuses of
- 3:35:03lights and the status of your push
- 3:35:05button, you can also click buttons from
- 3:35:08an HMI that go and activate sequences in
- 3:35:11the PLC. So for basic first step let's
- 3:35:13tie those three
- 3:35:15uh lights and the push button in so that
- 3:35:17we can get an HMI just working and then
- 3:35:20we'll start building sequences that
- 3:35:21really show how powerful this is.
- 3:35:24So let's go into icon and let's look for
- 3:35:28uh a light.
- 3:35:29Um I went into perspective components. I
- 3:35:32know some of these tabs are a little
- 3:35:34small and I'm going kind of fast. I went
- 3:35:36to perspective components and I grabbed
- 3:35:38an icon.
- 3:35:39Um
- 3:35:40There's symbol factories, drawings, you
- 3:35:42can import SVGs. You can do a lot of
- 3:35:45different ways in a lot of different
- 3:35:47HMIs. There's also different syntax and
- 3:35:49all these different icons and whatever.
- 3:35:52But icons are kind of nice in Ignition
- 3:35:54because they're all simple objects uh
- 3:35:56just like circles or smiley faces or
- 3:35:59light bulbs and they're pretty easy to
- 3:36:01animate. So like if I want this to be
- 3:36:03tied to the user push button, I can grab
- 3:36:06it and I can say that I want the uh I
- 3:36:09want to add a custom property that I'll
- 3:36:12call tag and I'll put a tag path in here
- 3:36:15in just a second cuz I haven't added my
- 3:36:17Ignition tags yet. But what I want is
- 3:36:20the color of this button to change with
- 3:36:24the tag. And to do that, I'll go to
- 3:36:26indirect which means I'm calling a
- 3:36:27parameter on this tag. Again, I do
- 3:36:31several Ignition tutorial uh
- 3:36:33introductions videos on uh my channel.
- 3:36:36It would take a lot of time to do all of
- 3:36:39the basics of Ignition
- 3:36:42and then a practical example together.
- 3:36:45Um so to keep this tutorial moving, I'm
- 3:36:47not going to deep dive every concept
- 3:36:49that we're doing, but I will try to
- 3:36:51still gear this at beginners. But
- 3:36:53basically we're going to do an indirect
- 3:36:55tag binding. Click the sort of hamburger
- 3:36:57menu over on the right and go to view
- 3:37:01uh root icon zero. Icon zero is actually
- 3:37:05what we're working on. You can see that
- 3:37:06highlight on the left. Um and then
- 3:37:09custom per like custom parameters and
- 3:37:12then tag. But what it really shakes out
- 3:37:14to is the tag path is curly brackets
- 3:37:17around tag and then the property is
- 3:37:20this.custom.tag.
- 3:37:22All I'm saying is I'm going to grab a
- 3:37:24tag that I just want to pass in that
- 3:37:26text field and I'm going to add one
- 3:37:28transform which is just going to be map
- 3:37:31the true false boolean of whether or not
- 3:37:34the button is pressed to a color. So the
- 3:37:36output will be the color and the input
- 3:37:38will be the value. And what I'll do is
- 3:37:41I'll say if it's true
- 3:37:44then I want it to be it's a push button
- 3:37:47so color
- 3:37:49doesn't actually change. Let's say if
- 3:37:51it's true, then I want it to be black.
- 3:37:53If it's false, I want it to be light
- 3:37:55gray. And if I don't have any reading, I
- 3:37:58want it to be white. Okay? So it's white
- 3:38:01right now because there's no tag
- 3:38:03which is a great opportunity for us to
- 3:38:05go and add our first tag. So I'm going
- 3:38:08to hit the little plus in the tag
- 3:38:10browser menu on the left side of
- 3:38:11ignition and I'm going to say
- 3:38:14Arduino tags and I'm going to make a new
- 3:38:16folder. Now, I'm going to browse
- 3:38:19devices. I'm going to expand out my
- 3:38:21devices, go to the Opta, go to unit 255
- 3:38:25and I'm going to add Opta tags 1 through
- 3:38:274 to my Arduino tags folder.
- 3:38:30Okay? And what you probably can see so
- 3:38:33that a little arrow populates and all
- 3:38:35these zeros and ones populate. Modbus by
- 3:38:37default is going to call pretty much
- 3:38:39everything a short when you add it, but
- 3:38:42these are all booleans. They're lights
- 3:38:44and push buttons. So, I can I can select
- 3:38:46all the tags, right click, go to edit
- 3:38:49tags and at the same time I can make
- 3:38:51them all booleans. So, I can bulk edit
- 3:38:55all of these tags. I could change them
- 3:38:56all to arrays or strings or whatever at
- 3:38:59same time. I can make them all booleans
- 3:39:01and hit okay or apply and they'll all
- 3:39:04update to be booleans.
- 3:39:07Now, Opta tags 1 through 4 isn't that
- 3:39:10useful and if we go back to our PLC, you
- 3:39:12can see that it's user push button and
- 3:39:15then red, blue, and green. So, what I'm
- 3:39:17going to do is I'm going to rename these
- 3:39:19user underscore push button as the name
- 3:39:23and then
- 3:39:26red
- 3:39:29and then green
- 3:39:35and then
- 3:39:37blue.
- 3:39:39Okay?
- 3:39:41Cool. So, now close. Now, I can right
- 3:39:44click on user push button and I can go
- 3:39:46to copy path
- 3:39:48and I can paste that path right here
- 3:39:50control V into tag
- 3:39:53and now you can see hopefully you can
- 3:39:56see that went from gray to uh or that
- 3:39:58went from white to gray because now the
- 3:40:00tag exists. Now, I'm going to push the
- 3:40:03button now on my HMI or on my PLC and
- 3:40:07you can see it changes to black. That's
- 3:40:09really cool.
- 3:40:10Um I think it's really cool. If you
- 3:40:12don't,
- 3:40:13I don't care.
- 3:40:15Uh now, let's get rid of this smiley
- 3:40:16face cuz we're not using it and let's
- 3:40:18add in some additional stuff. So, this
- 3:40:20is the push button which is cool. Let's
- 3:40:22go ahead and just add the three lights
- 3:40:24as well. So, the blue light on the PLC
- 3:40:27is kind of physically
- 3:40:28uh right above it. So, let's say if that
- 3:40:30one's true, we want it to be blue.
- 3:40:34And then let's copy this over here
- 3:40:39and the green and red lights are
- 3:40:40actually in the same spot. So, I'll just
- 3:40:43put them right next to each other so
- 3:40:44that we can see two different lights.
- 3:40:46And let's say that this one should be
- 3:40:49green.
- 3:40:50Okay? And this one should be red. So,
- 3:40:55all I'm going to all I'm doing is I'm
- 3:40:58changing the linking, the color
- 3:41:00animation on these circles
- 3:41:02uh to be different colors, but now I
- 3:41:05have to go and I have to copy that tag
- 3:41:07path. So, I copy the path for blue and
- 3:41:10I'm going to replace user push button
- 3:41:12with blue. But what's cool is the way we
- 3:41:14did that custom tag pathing, this will
- 3:41:17now update uh just when I click the blue
- 3:41:21button. But what you'll see is right now
- 3:41:23I've only updated the blue light and not
- 3:41:26red or green. So, when I push the
- 3:41:27button,
- 3:41:30okay, all of them except blue updated.
- 3:41:32So, my blue light tag is not actually
- 3:41:35working. Let's check that out in the
- 3:41:37code.
- 3:41:39Little live debugging together.
- 3:41:41Oh, yeah. I called the green light blue
- 3:41:44and the blue light green.
- 3:41:46That can get you in trouble if you're
- 3:41:48not very careful about the order that
- 3:41:50you do things in. So, we'll correct this
- 3:41:52to blue. We'll move this to green.
- 3:41:56So,
- 3:41:58basically what happened there is because
- 3:42:00the Opta tags got added as Opta tags 1
- 3:42:03through 3, I misnamed uh I got blue and
- 3:42:07green backwards. So,
- 3:42:09now if we go in here and we correct this
- 3:42:12tag path to be just tied to red.
- 3:42:17Okay? And then this tag path to be just
- 3:42:20tied
- 3:42:21to green.
- 3:42:25Okay?
- 3:42:27We have
- 3:42:29Now, if I push the button, you can see
- 3:42:31the black button getting pushed in and
- 3:42:33the blue light turning on at the same
- 3:42:35time.
- 3:42:36Uh if we were to go back in the Arduino
- 3:42:38PLC, let's say and uh just change from
- 3:42:41LR being equal to true to setting LR
- 3:42:46equal to we got to go offline.
- 3:42:50Let's say we want LR to be false now and
- 3:42:54we want LG to be true and we want to
- 3:42:56compile that and say yes and send the
- 3:43:00new code.
- 3:43:02Now, we should be able to go to
- 3:43:06Yep, we can go to our PLC. I can push
- 3:43:08the button in and I can have blue and
- 3:43:11the blue light turns on and then the
- 3:43:12green light turns on
- 3:43:14uh and red never turns on uh because of
- 3:43:17the code that we have running on it. So,
- 3:43:19this is really cool. We have an Arduino
- 3:43:21PLC connected to ignition and uh we
- 3:43:24built our first HMI actually looking at
- 3:43:27tags off of the ignition PLC. So, in the
- 3:43:30next video, I think what we'll do is
- 3:43:32we'll build multiple sequences in ladder
- 3:43:35logic and structured text that actually
- 3:43:37interact back and forth with the HMI.
- 3:43:39So, we'll take a look at controlling
- 3:43:41sequences uh from the HMI, reporting
- 3:43:44statuses, doing enumeration,
- 3:43:47and a lot more interesting SCADA HMI
- 3:43:50plus PLC development together. So,
- 3:43:53today's video was a great way to get you
- 3:43:55connected,
- 3:43:57get tags reading back and forth. If
- 3:43:59you're a somewhat competent programmer,
- 3:44:01this can be a fun spot to play around
- 3:44:03and explore with animations and things
- 3:44:05like that. Um but this is really also
- 3:44:08the legwork so that the next uh chunk of
- 3:44:10this tutorial series can move along
- 3:44:12really well and we can focus on
- 3:44:14programming and we can focus on HMI
- 3:44:16development and we don't have to get all
- 3:44:18of the basic interconnections done. So,
- 3:44:20I hope you found this video useful. I
- 3:44:22hope you've been finding this tutorial
- 3:44:23series useful. I have really been
- 3:44:25enjoying using Ignition for Makers and
- 3:44:28the Arduino Opta PLC. All right, so I'll
- 3:44:30leave you with that. I'm looking forward
- 3:44:31to the next video. Please leave comments
- 3:44:34with any questions on what you saw here
- 3:44:36today or things you want to make sure we
- 3:44:38cover on future videos on the channel. I
- 3:44:40appreciate all the support and as always
- 3:44:43good luck with your projects and thanks
- 3:44:44for watching. We'll see you next time.
- 3:44:46Thanks. Bye.
- 3:44:53Hello and welcome back to The Master
- 3:44:54Tech and today's video is going to be a
- 3:44:56continuation in our introduction to
- 3:44:58controls and automation tutorial series.
- 3:45:01And in today's video, we're going to
- 3:45:02write some uh pretty specific form of
- 3:45:05PLC logic called sequences. So, one of
- 3:45:08the most common ways that long
- 3:45:11complicated routines get controlled to
- 3:45:13do things in order in factories is with
- 3:45:16sequential programming and sequences
- 3:45:19often involve interaction from the
- 3:45:21operators at specific points in the
- 3:45:23sequence. So, we're going to take a look
- 3:45:25at how to create a step and then a
- 3:45:27function where you step through it in
- 3:45:29order and then we'll also add some
- 3:45:31features to the HMI so that uh you can
- 3:45:33see how the HMI could interplay with the
- 3:45:36sequence. And most important thing is
- 3:45:38because this is kind of a continuation
- 3:45:40in a tutorial series, the concepts in
- 3:45:42this video stand alone. So, if you just
- 3:45:44want to see an example of sequential
- 3:45:47logic being programmed in ladder logic
- 3:45:49on a PLC, you're in the right place.
- 3:45:51Keep watching. But if you want to follow
- 3:45:53along line by line and build the same
- 3:45:55sort of things as we go, make sure that
- 3:45:57you have uh Ignition connected to an
- 3:46:00Arduino Opta PLC. You've already set up
- 3:46:03the Modbus connections. So, I have it so
- 3:46:06that the red, green, and blue buttons as
- 3:46:08well as the user push button are already
- 3:46:10tied to my PLC and then I have a PLC
- 3:46:13program where I've already set the IP
- 3:46:16address, set it up with Modbus
- 3:46:17connections, and created some very basic
- 3:46:20logic
- 3:46:21So, if you haven't been following along
- 3:46:23with the tutorial series, but you really
- 3:46:25want to do this piece together, all you
- 3:46:27really need to do is watch the previous
- 3:46:29video on the channel. I'll try to
- 3:46:30remember to leave a link to it below, a
- 3:46:32card to it somewhere in the top of the
- 3:46:34screen now. But I don't want a ton of
- 3:46:36comments on this video that are like,
- 3:46:39"Oh, you jumped right into it with no
- 3:46:40context or background." So, um please
- 3:46:43get yourself in the same spot as me if
- 3:46:45you would like to follow along exactly.
- 3:46:50Otherwise, let's dive into the tutorial
- 3:46:52and the concepts in this video. Okay?
- 3:46:54Now, I've prepared uh a pretty simple
- 3:46:56prompt that is going to step out a
- 3:46:59five-step sequence and it's basically
- 3:47:01going to tell us what we should be
- 3:47:02trying to program because a really
- 3:47:04important thing about controls and
- 3:47:06automation is if you just sit down to
- 3:47:08write PLC code and you have no idea what
- 3:47:11you're trying to code, it gets really
- 3:47:13hard uh in terms of inputs, outputs,
- 3:47:16variables, what you need to put on an
- 3:47:17HMI. So, anytime in controls and
- 3:47:19automation when you go to write new PLC
- 3:47:22code, you should have a basic vision of
- 3:47:24what you are trying to accomplish. Bit
- 3:47:26of a tangent, but basically step zero of
- 3:47:28our sequence will be considered idle and
- 3:47:30it'll just be waiting for an operator to
- 3:47:32press the start button on the screen.
- 3:47:34Then step one, we're going to be
- 3:47:36activated and then I still have the hand
- 3:47:38switch connected to my PLC uh from the
- 3:47:41wiring examples that we did a few videos
- 3:47:43back. But instead of the hand switch,
- 3:47:45you could use the user push button on
- 3:47:47the front of the Opta like we've been
- 3:47:49doing lately. It's up to you. But in
- 3:47:51sequence step two, we're going to wait
- 3:47:53for a timer to complete so I can show
- 3:47:55you guys the timer function block. And
- 3:47:56then in sequence step three, we're going
- 3:47:58to click a button on the HMI until we
- 3:48:00get up to a set point. So, I'm going to
- 3:48:02show you how to create a set point on
- 3:48:04the HMI screen that operators can change
- 3:48:07and interact with, and then we will use
- 3:48:09that in our sequence. And then step four
- 3:48:10will be sequence completed, and it'll be
- 3:48:12sitting there waiting for us to send it
- 3:48:14to idle by pressing a stop button. Uh
- 3:48:16let's dive right back in. I'll let's
- 3:48:18dive into the programming. I'll probably
- 3:48:20pull up this notepad if we forget what
- 3:48:22the next step is supposed to be. I'll
- 3:48:23try to go slow. I'll try to explain
- 3:48:25everything as I do it. Hopefully a lot
- 3:48:27of this is familiar if you've been
- 3:48:28following the series along. So, let's go
- 3:48:30ahead and go to our program. Let's go to
- 3:48:33project, and then uh we're going to
- 3:48:35right-click, and we're going to add a
- 3:48:36new program in LD, ladder diagram, and
- 3:48:40we will call this ladder underscore
- 3:48:43sequence,
- 3:48:44and let's assign it to fast task and hit
- 3:48:47okay.
- 3:48:48All right. So, sequence step zero equals
- 3:48:52idle, and we're going to wait for the
- 3:48:53HMI start button to be pressed. So, the
- 3:48:56first thing we need to do is we need to
- 3:48:58check with an equals block.
- 3:49:01So, EQ.
- 3:49:04We need to check if sequence step is
- 3:49:06equal to
- 3:49:08zero.
- 3:49:09So, we're going to
- 3:49:10need a variable that we'll call sequence
- 3:49:14underscore step.
- 3:49:16And if it does equal zero, then we just
- 3:49:19want to tie this into the output line.
- 3:49:24So, uh this should look familiar from
- 3:49:25the first ladder uh tutorial that we
- 3:49:28did. Okay. Now, we're also not going to
- 3:49:30worry about making all of these
- 3:49:31variables right now. I'm going to write
- 3:49:33the sequence, and then I'm going to go
- 3:49:35and look at what variables I used and
- 3:49:37kind of add them all at once.
- 3:49:39Uh if that feels a little backwards, if
- 3:49:41you're more of a person who wants to
- 3:49:43define all of your variables and then
- 3:49:44use them or define them as you go, um
- 3:49:48you know, dealer's choice. But, uh
- 3:49:50basically, we have sequence step equals
- 3:49:52zero. We're going to listen then for a
- 3:49:56uh push button from a tag that we'll
- 3:49:59just call HMI
- 3:50:01start.
- 3:50:02Okay. And when the HMI start button gets
- 3:50:05pressed, that'll be something that we
- 3:50:07click on the ignition screen. So, then
- 3:50:10we'll go ahead and start by resetting
- 3:50:13the HMI start push button. Okay. So,
- 3:50:16you're going to turn it on from the HMI
- 3:50:19screen, and then the code will turn it
- 3:50:21off. But, when it turns it off, we will
- 3:50:24also add one to the sequence. You could
- 3:50:27add one to sequence step at this step,
- 3:50:30or you could say move one to sequence
- 3:50:32step. It doesn't really matter. Just
- 3:50:34like any form of programming, there's a
- 3:50:36few different ways that you could write
- 3:50:37it. Um what's nice about this rung that
- 3:50:40we've built is it's sort of good for
- 3:50:42reusability. So, we can copy it, and now
- 3:50:45we can say, "All right. Now sequence
- 3:50:47step equals one." And I'm not looking
- 3:50:50for HMI start anymore. Now I'm probably
- 3:50:53looking for input eight, right? So, I
- 3:50:55have a hand switch. If you don't have
- 3:50:57the hand switch still hooked up from a
- 3:50:59few tutorials ago, you could put
- 3:51:02the user push button right here. Um but
- 3:51:05instead, I'm going to put
- 3:51:07an HMI tag in that uh is monitoring
- 3:51:10input eight. Uh actually, I'll just
- 3:51:12Yeah. That's fine.
- 3:51:15And then when it's made, we'll go to
- 3:51:17step two.
- 3:51:18Um and then we could do the same reset,
- 3:51:21but that doesn't make a lot of sense
- 3:51:23because this is actually going to be
- 3:51:24looking at the hand switch. Um now, the
- 3:51:27hand switch has on position and off
- 3:51:30position. And I specifically want to
- 3:51:33listen for the rising edge of the hand
- 3:51:36switch. So, let's say you had left this
- 3:51:38on, I don't want it to automatically
- 3:51:41blast through this step. I want it to
- 3:51:43listen for a person to intentionally
- 3:51:45turn the hand switch on. So, to do that,
- 3:51:48I'm not just going to use a regular
- 3:51:50examine if closed block, uh this regular
- 3:51:53normal contact. I'm going to use
- 3:51:56positive edge of the contact. So, this
- 3:51:58is rising edge. This is as you detect
- 3:52:02that that Boolean variable transitions
- 3:52:04to a one pulse. So, it's basically a
- 3:52:06one-shot on transition high.
- 3:52:09So, this step is just going to listen
- 3:52:12when we're in sequence step one and only
- 3:52:15when we're in sequence step one for the
- 3:52:17hand switch to turn on, and then it'll
- 3:52:19move a two into sequence step.
- 3:52:22So, if we're tracking our little notepad
- 3:52:25of instructions,
- 3:52:27we have step zero, we're in idle, and
- 3:52:30we're waiting for the HMI start button
- 3:52:31to be pressed. And then we have step
- 3:52:33one, we've activated the sequence, and
- 3:52:36we're waiting for the hand switch uh to
- 3:52:38move us to step three.
- 3:52:39Uh step two. Now, in step two, we're
- 3:52:42going to wait for a timer to complete.
- 3:52:44So, we haven't talked about timers yet.
- 3:52:46There's a timer on delay where when the
- 3:52:49conditions that make the timer uh start
- 3:52:52begin, the output is false until a set
- 3:52:55point is met. Then there's a timer off
- 3:52:58delay, which is kind of the opposite,
- 3:53:00which is where uh when the conditions go
- 3:53:04when the conditions to start the timer
- 3:53:06begin, the output is immediately true,
- 3:53:09but then when the conditions that make
- 3:53:10the timer true go away, the timer will
- 3:53:13then start counting and stay true for a
- 3:53:16period of time after that. That's a lot
- 3:53:18of gobbledygook and stuff to try to
- 3:53:22explain what ought to be a simple
- 3:53:24concept, but um with PLC programming,
- 3:53:26there is just a little game within the
- 3:53:28game of knowing the nuances going on
- 3:53:30here.
- 3:53:31Um so, let's go ahead and drop a new
- 3:53:33block that we haven't seen before, but
- 3:53:35it's TON, timer on delay. And just to
- 3:53:37show you real quick, there's timer off
- 3:53:39delay. So, when you make function blocks
- 3:53:41like timers that have a few parameters
- 3:53:44to them, you have to give them an
- 3:53:45instance name. So, for this one, we can
- 3:53:47just call it the step two uh TON, the
- 3:53:50step two TON.
- 3:53:52Um but the reason you need to do that is
- 3:53:54because there's an output tag, an input
- 3:53:57tag, a set time, and then an elapsed
- 3:54:00time. All of these uh four parameters,
- 3:54:03and they need to be stored in a variable
- 3:54:05or instance. Okay. So, for this timer,
- 3:54:08we're going to go down to PT, and you
- 3:54:10can add constants. So, if you know you
- 3:54:12always want it to be 5 seconds or
- 3:54:14something like that, um you can put a
- 3:54:16constant here. I'm going to want to tie
- 3:54:18it to a variable, which I will call um
- 3:54:21I will just call step two time. That's
- 3:54:25what I'll call the variable. Um and
- 3:54:27that'll be my uh
- 3:54:29my time that uh is set for the timer.
- 3:54:33So, that's how long I want the timer to
- 3:54:34count up for, which will be something
- 3:54:36we'll let the user set from the HMI
- 3:54:38screen we're about to build.
- 3:54:40Um and then we will make on the output
- 3:54:43of this timer completing, we will make
- 3:54:45it move to sequence step three.
- 3:54:49Okay. Now, there's a few things Oh, I
- 3:54:51have two moves here.
- 3:54:53Okay. Um there's a few things we're
- 3:54:54going to change now. We don't want the
- 3:54:56input of uh eight anymore. We don't need
- 3:54:59that. But, there is one thing about PLC
- 3:55:02timers that we haven't included yet. Um
- 3:55:05and that's that the default time for
- 3:55:07almost every PLC is in milliseconds.
- 3:55:12I don't want the operator, I don't want
- 3:55:13the user on the HMI entering a time in
- 3:55:16milliseconds. It's not that intuitive.
- 3:55:18It's not how people think. So, I'm going
- 3:55:20to add uh a multiply block in here, MUL,
- 3:55:25and I'm going to drag it before the
- 3:55:27timer, if it'll let me. There we go. Um
- 3:55:30and I'm going to take the HMI time
- 3:55:35SP, so set point, HMI time set point. If
- 3:55:38you don't like my uh tag naming
- 3:55:40conventions, I don't know what to tell
- 3:55:42you.
- 3:55:44You know, that's okay. And then I'm
- 3:55:46going to multiply it by 1,000, and I'm
- 3:55:48going to store that in
- 3:55:50step two time, which is the name of the
- 3:55:53variable that we just defined. Okay. So,
- 3:55:56what this line is doing now is saying
- 3:55:58when I get to this step, I'm going to
- 3:56:00take the set point that's on the HMI,
- 3:56:03and I'm going to multiply it by 1,000,
- 3:56:05and then we're going to use that value
- 3:56:08in the timer. So, we'll enter a time in
- 3:56:10seconds on the HMI.
- 3:56:12This will convert it to milliseconds for
- 3:56:14us, and then once the timer finishes,
- 3:56:17it'll move us to step three.
- 3:56:19Okay. And then, if we remember step
- 3:56:22three,
- 3:56:23we're going to have a counter. So, we're
- 3:56:25going to have a target number of times a
- 3:56:26button has to get clicked, and we're
- 3:56:28going to keep track of how many times
- 3:56:30it's been clicked, and then once we hit
- 3:56:32our set point, we'll move to step four.
- 3:56:35So, this one's a little bit different,
- 3:56:36and it'll probably make more sense once
- 3:56:39we get to uh the HMI where you can see
- 3:56:42the interaction part. Um but I'm just
- 3:56:45choosing to sort of start in the PLC
- 3:56:47code, and then we'll move into uh the
- 3:56:49HMI all at once. So, it's still not too
- 3:56:52bad. We're going to say now if we equal
- 3:56:55three, and then we want to move to four
- 3:56:57when this step finishes. In the middle,
- 3:57:00what we're actually checking for,
- 3:57:01because we'll do most of the hard work
- 3:57:04uh on the HMI for this step, so what
- 3:57:06we're going to check for here is that
- 3:57:08we're greater than or equals. So, GE, a
- 3:57:11new block. Um and we can delete the
- 3:57:13multiplication that was for the previous
- 3:57:15step.
- 3:57:16And we're going to want to check that
- 3:57:18HMI counter
- 3:57:21Oop. So, let's go ahead and make a new
- 3:57:23tag called HMI counter in here.
- 3:57:27Um and we want to check that the live
- 3:57:29counter gets greater than the uh HMI
- 3:57:33count, and we'll say set point, SP,
- 3:57:35right there. Okay. And uh now we need to
- 3:57:38delete this block because what we want
- 3:57:41the output to be is just set the output
- 3:57:44line.
- 3:57:45Okay. So, very simply, this line means
- 3:57:49when we get to step three,
- 3:57:51wait until the HMI counter gets above
- 3:57:54the HMI count set point, and then move
- 3:57:57uh to step four after that. But, one
- 3:58:00thing that we want to keep in mind is
- 3:58:02that if you were to restart the PLC or
- 3:58:05you didn't properly clear the sequence
- 3:58:07or anything like that, how do we
- 3:58:09guarantee that the HMI counter has been
- 3:58:11reset to zero by the time we get to this
- 3:58:14step? One of the easiest ways is
- 3:58:16actually just go to the step before it
- 3:58:18and add some branching logic add some
- 3:58:21branching logic around your output
- 3:58:23conditions. Okay? And we're going to
- 3:58:25come down here
- 3:58:27and we're going to add a new block to
- 3:58:28just move a zero, so come over here. And
- 3:58:32here we're going to move a zero into
- 3:58:35HMI counter. So, this is just my way of
- 3:58:38saying I really don't care what's
- 3:58:39happened to that variable up until now.
- 3:58:42I haven't needed my sequence up until
- 3:58:44now, but I'm about to enter step three
- 3:58:46and I know I want that to be a zero when
- 3:58:48I get there. So, I'm going uh to set it
- 3:58:51equal to zero before I get into step
- 3:58:52three. So, that's all we're doing there.
- 3:58:55And then that's really it for our
- 3:58:57sequence. So, step four is sequence
- 3:59:00completed, press HMI stop to send to
- 3:59:03idle. That is basically exactly what we
- 3:59:06did with line one. Since that's exactly
- 3:59:08like the first line, we have a really
- 3:59:10good thing to reference here already.
- 3:59:11And we'll just go ahead and uh say,
- 3:59:14"Okay, that was a coil." And we are
- 3:59:16going to say, "All right, when I get to
- 3:59:17step four then I want to move to step
- 3:59:20zero when HMI stop gets pressed." HMI
- 3:59:25stop. And if you remember from that
- 3:59:28first line, we also went ahead and we
- 3:59:30reset the uh output as part of that. So,
- 3:59:33if we go over here
- 3:59:36we also want to put HMI stop
- 3:59:41in a reset. That's going to say you
- 3:59:43wrote a one to it from the HMI, we're
- 3:59:45going to write a zero to it from the
- 3:59:47PLC.
- 3:59:49All right, we did a lot of ladder here
- 3:59:52without looking at the HMI. We need to
- 3:59:54add a lot of variables, so let's try to
- 3:59:56do this carefully and methodically now.
- 3:59:59Um if we go into the uh resources tab
- 4:00:03and then parameters, I'm basically going
- 4:00:05to default to wanting every one of these
- 4:00:07tags uh in parameters because I want to
- 4:00:10give the HMI
- 4:00:13as much information as we can. So, we're
- 4:00:15going to have sequence step, that's
- 4:00:17going to be an integer. We're going to
- 4:00:18have HMI start.
- 4:00:21That's going to be a Boolean. We're
- 4:00:23going to have HMI input eight, that'll
- 4:00:26be a Boolean and we'll tie it to my hand
- 4:00:28switch. We're going to have
- 4:00:31HMI I spelled HMI wrong. Uh we're going
- 4:00:35to have HMI time set point.
- 4:00:39I'm struggling to type today.
- 4:00:42Time set point, that'll be an integer
- 4:00:43where the operator enters something in
- 4:00:45seconds. We'll have step two time,
- 4:00:48that'll also be an integer, it'll just
- 4:00:51be uh multiplied by a thousand.
- 4:00:54And then we're going to have HMI
- 4:00:58counter.
- 4:00:59That's going to be an integer as well.
- 4:01:03And then we'll have
- 4:01:06You know, we could also put the elapsed
- 4:01:08time from that timer in a variable, so
- 4:01:10we could call that HMI
- 4:01:12elapsed and we could make
- 4:01:16Yeah, that could be an integer as well,
- 4:01:18that's fine.
- 4:01:19Uh so, we can put how much time has
- 4:01:21progressed in another variable. So, on
- 4:01:24the HMI we could also show how far the
- 4:01:26timer has progressed. Um I just decided
- 4:01:29that was a good idea right now.
- 4:01:31Then we're also going to have the HMI
- 4:01:33count set point, so that'll be what you
- 4:01:36need to press the button up to.
- 4:01:38And then we want
- 4:01:40HMI
- 4:01:42stop.
- 4:01:43Uh and I may have missed some things,
- 4:01:45but that's what we're going to start by
- 4:01:47making. So, let's go into parameters.
- 4:01:49And we have the user push button red,
- 4:01:51blue, and green from before. No reason
- 4:01:53to delete those, let's just go ahead and
- 4:01:55add. Um
- 4:01:57and we'll add sequence step and that can
- 4:02:00be an integer.
- 4:02:02And then we'll add
- 4:02:04HMI start.
- 4:02:07Careful on spelling, that'll be a
- 4:02:09Boolean.
- 4:02:12And then we'll add
- 4:02:14HMI I8 and that'll be a Boolean.
- 4:02:21Now we will add
- 4:02:24HMI
- 4:02:26time set point integer.
- 4:02:29Add
- 4:02:31step
- 4:02:32step two time.
- 4:02:35That'll be an integer.
- 4:02:40We'll add HMI counter.
- 4:02:43Also an integer.
- 4:02:47We have HMI elapsed.
- 4:02:50You guessed it, that's an integer.
- 4:02:53We have HMI count set point. Integer.
- 4:02:59And then we have
- 4:03:01HMI stop. And that's a Boolean.
- 4:03:06Okay, one thing that we need to do
- 4:03:08because it's the thing that interacts
- 4:03:10with the physical world is we need to go
- 4:03:13in here
- 4:03:15and we need to set HMI
- 4:03:18I8 here being, sorry, I should have
- 4:03:20clarified, here being the main routine
- 4:03:23that we set up uh in the previous video
- 4:03:25where we just mapped our lights and uh
- 4:03:29push button to the we mapped our Modbus
- 4:03:32tags to the physical tags that actually
- 4:03:34represent them. So, here we want to set
- 4:03:36HMI I8 equal to input eight and we want
- 4:03:41to go to our um programmable inputs and
- 4:03:44make sure that I8 or whatever. I have my
- 4:03:47hand switch wired up to I8 on my
- 4:03:49Arduino.
- 4:03:50Um
- 4:03:51so, I'm just going to make a variable
- 4:03:53called I8 that physically represents the
- 4:03:56state of the hand switch. And then in
- 4:03:58main, I am mapping the HMI tag that we
- 4:04:01just made to share with Ignition and I
- 4:04:04am mapping that to the physical hand
- 4:04:06switch.
- 4:04:08All right, so I am
- 4:04:10naively optimistic that this is going to
- 4:04:12compile. Let's just go ahead and compile
- 4:04:15and see what we missed. And it appears
- 4:04:17that it works, so let's go ahead and try
- 4:04:19to download it. A warm restart's
- 4:04:21required, that's fine.
- 4:04:23Initialize the database with default
- 4:04:25values, that's fine.
- 4:04:26Warm reboot, it says source code okay.
- 4:04:29So,
- 4:04:30uh if you were to throw on the little
- 4:04:32live debug mode, which is a a cool
- 4:04:34feature of ladder
- 4:04:36um and most PLC IDEs, you can see the
- 4:04:39live value of all of these tags come in.
- 4:04:42And so, sequence step zero is active
- 4:04:44right now.
- 4:04:45And if I were to uh click the HMI start
- 4:04:49button
- 4:04:50um or just within the code by double uh
- 4:04:53clicking, I can set it equal to true.
- 4:04:56What you can't see is that the HMI start
- 4:04:59went true and it immediately reset
- 4:05:01itself, but what you can see is that the
- 4:05:03sequence step is now one.
- 4:05:06So, now we're waiting for HMI uh I8 to
- 4:05:09go true.
- 4:05:10If I set equal to a one, that one
- 4:05:13actually won't let me force it through
- 4:05:15because it's being overridden in the
- 4:05:16main PLC routine, but what I can do is
- 4:05:19boot up my 24-V power supply real quick
- 4:05:21and I can actually trigger the hand
- 4:05:23switch. And if I go in here and I watch
- 4:05:26HMI I8, if I make the hand switch it
- 4:05:29goes true.
- 4:05:31Okay? And actually, predictably,
- 4:05:34um it went straight to sequence step
- 4:05:36four because our time set point is equal
- 4:05:39to zero. So, the timer finished
- 4:05:41immediately and went to step three. And
- 4:05:43then our counter is equal to zero, so it
- 4:05:46went immediately to four. It's waiting
- 4:05:48for someone to press uh HMI stop.
- 4:05:51So, if I go ahead and I write a true to
- 4:05:54that Boolean, it'll go back to step
- 4:05:56zero.
- 4:05:58So, that's kind of as fast as you can
- 4:05:59walk through it just on the PLC to make
- 4:06:01sure it's working. So, we added a total
- 4:06:04of 1 2 3 4 5 6 7 8 nine new tags. We
- 4:06:08need to go into Ignition. And first
- 4:06:11thing from the gateway, if you were
- 4:06:12following along last tutorial, we need
- 4:06:14to expand our addresses to include those
- 4:06:17new um nine tags. So, before we went
- 4:06:20from one to four, this is super easy.
- 4:06:22Now we just go from one to 13
- 4:06:25and hit save. Uh the status is
- 4:06:27connected, which is great. The live
- 4:06:30screen won't change, so we open up
- 4:06:31designer launcher and we open our
- 4:06:34gateway uh designer.
- 4:06:40Open the designer.
- 4:06:41All right, so we've got our home page.
- 4:06:43I'm going to I'm going to leave the Opta
- 4:06:45up there exactly like it was from last
- 4:06:47time. I don't have a problem with that.
- 4:06:49Um but I'm going to add to my tags. I'm
- 4:06:51going to add a new folder and call these
- 4:06:54sequence tags. And then I'm going to
- 4:06:57browse devices
- 4:06:59and go to my
- 4:07:01Opta.
- 4:07:02And I'm going to go to my unit ID. And I
- 4:07:04just added tags
- 4:07:07uh 1 2 3 4. I just added tags five
- 4:07:11through 13. So, I'm going to store those
- 4:07:15in sequence tags. Okay? So, I am adding
- 4:07:18all of the new tags that we just added
- 4:07:19in the PLC to uh a the HMI. They're all
- 4:07:23zeros. They also all came in as shorts.
- 4:07:27Um but if we look back at our PLC real
- 4:07:29quick, we have sequence step, HMI start.
- 4:07:32We have the exact order we actually
- 4:07:34wrote on this notepad for easy
- 4:07:35reference. Um we have 1 2
- 4:07:39three bools. And so, we need to change
- 4:07:41those tag types to bools. Modbus uh
- 4:07:44holding registers always look like
- 4:07:4616-bit signed ints to Ignition if you
- 4:07:49don't tell it otherwise. So, um Opta tag
- 4:07:52five was the
- 4:07:55sequence step.
- 4:07:58Okay.
- 4:07:59Opto tag six
- 4:08:02was the HMI start. And you don't
- 4:08:05actually have to call them exact and
- 4:08:07this one was a Boolean. You don't have
- 4:08:09to call them exactly what they're called
- 4:08:11in the PLC. It's just an easier way to
- 4:08:13keep them straight.
- 4:08:15HMI input eight was also a Boolean and
- 4:08:18was the next tag.
- 4:08:21And then
- 4:08:24HMI
- 4:08:26time set point was an integer.
- 4:08:30And the next tag was
- 4:08:33step
- 4:08:34two
- 4:08:36time integer. Okay.
- 4:08:39The next tag HMI counter.
- 4:08:43Counter.
- 4:08:45And that's an integer. Okay. Step 11.
- 4:08:51The next one HMI elapsed and that is how
- 4:08:55much time has passed. That can be an
- 4:08:57integer.
- 4:08:58The next tag is
- 4:09:01HMI
- 4:09:03count set point integer. Okay. And the
- 4:09:08last tag will be HMI stop and that's a
- 4:09:13Boolean.
- 4:09:15Go to the PLC. Uh okay, HMI start
- 4:09:19needs to be
- 4:09:23Oh, well, it is case-sensitive. So, this
- 4:09:25needs to be a capital S for HMI start.
- 4:09:28Do you want to reassign this variable
- 4:09:30and use it as parameter? Yes.
- 4:09:32Um okay, so that should be a Boolean.
- 4:09:34That should work. Uh this should also be
- 4:09:37a Boolean.
- 4:09:39And then this should also be Boolean.
- 4:09:42That should work.
- 4:09:44Uh all right, all the addressing should
- 4:09:46still be fine. And then I guess since we
- 4:09:47have to download anyways,
- 4:09:50um we can go back to our ladder sequence
- 4:09:52really quickly and we can add that
- 4:09:54elapsed time that I forgot to put in
- 4:09:56here. So,
- 4:09:58um if we go back to resources, we just
- 4:10:00called it HMI {underscore} elapsed.
- 4:10:02Let's go to our timer block and let's
- 4:10:04add a variable to the ET. And we called
- 4:10:07it HMI {underscore} elapsed.
- 4:10:11Okay.
- 4:10:12Okay. And uh one thing to call out here
- 4:10:15that you could kind of see which is also
- 4:10:17kind of nice and maybe I did this in the
- 4:10:20bad order. If you define all your
- 4:10:21variables that you're going to need for
- 4:10:23your routine before writing your
- 4:10:26program, then they're available when you
- 4:10:28go to add variables and you can see that
- 4:10:30they exist and what data type they are.
- 4:10:32So, maybe I did a little bit backwards.
- 4:10:35Uh
- 4:10:35I'm not perfect. Let's compile and
- 4:10:38download and restart the PLC.
- 4:10:41Initialize the database again.
- 4:10:43Okay, so with all of our tags added, we
- 4:10:45can finally do the fun part. Depends who
- 4:10:48you are. I enjoy the graphical user
- 4:10:50interface, the HMI development portion
- 4:10:53of the job. Um let's go ahead and add
- 4:10:55that sequence step, right? So, to the
- 4:10:57visuals and Ignition's kind of nice. You
- 4:10:59can just grab a device and or a tag and
- 4:11:02drag it onto the screen and based on
- 4:11:05what type of tag it is, it'll show you
- 4:11:06all the recommendations for it. So, like
- 4:11:08an integer, by default they have gauges,
- 4:11:11one-shot buttons, cylindrical tanks, uh
- 4:11:13labels, things like that. So, we'll just
- 4:11:15do a label for the sequence step and
- 4:11:17then we'll build some more cool features
- 4:11:19into it. Um but let's go ahead and do
- 4:11:21little checkbox uh buttons for um start
- 4:11:24and stop and the text will say start for
- 4:11:28the start button. That seems like a good
- 4:11:30thing to say. And then we'll say stop
- 4:11:33for the stop button.
- 4:11:35So, uh text stop. Cool.
- 4:11:40And then we'll throw What do we want to
- 4:11:43throw? We want to throw our set points
- 4:11:45on the screen as um
- 4:11:48as a numerical entry. So, if we click
- 4:11:50the little palette over on the right, uh
- 4:11:53perspective components toolbar, we'll
- 4:11:55type in numerical numeric entry field
- 4:12:00and drag it onto the screen. And the
- 4:12:02value will be what it's asking for.
- 4:12:05It'll be asking for a tag. So, let's
- 4:12:07make this one our count set point. And
- 4:12:10we'll say value tag path
- 4:12:12count set point and make sure to click
- 4:12:14bidirectional so that people can write
- 4:12:16to it. Okay, so this is our count set
- 4:12:19point. So, why don't we uh go back to
- 4:12:21perspective components and add another
- 4:12:24label that just says
- 4:12:27count set point. So, count set point.
- 4:12:32And that doesn't have to be linked to
- 4:12:34anything. It's just telling us what this
- 4:12:35numeric entry field is. And then we had
- 4:12:38one other thing that uh people could
- 4:12:40edit willy-nilly and that was uh time
- 4:12:44set point in seconds, right? And that
- 4:12:49has to go to a different tag. That one
- 4:12:51needs to go to HMI time SP. So, time SP.
- 4:12:57And I know some people are going to be
- 4:12:58furious at my lack of consistency with
- 4:13:02capitalization and camel case, snake
- 4:13:04case,
- 4:13:06made up case, you pick it. Um okay, but
- 4:13:09so that'll let us enter a time set
- 4:13:11point. That'll let us enter a number of
- 4:13:13times to be counted. Uh so, then the
- 4:13:16only other thing I want to add real
- 4:13:18quick is I want to add a button,
- 4:13:21perspective components, button that is
- 4:13:24going to button
- 4:13:28that is going to add one
- 4:13:30to the counter. So, if you remember, we
- 4:13:32get to a step where Ooh, I also want to
- 4:13:35add indication. Let's finish that
- 4:13:37counter first.
- 4:13:38Press to count up. Okay. So, we're going
- 4:13:42to make a little button and when you
- 4:13:44press it, the count goes up and then we
- 4:13:46will show the counter right next to it
- 4:13:48in a label.
- 4:13:50So, this is the HMI counter tag and then
- 4:13:53on click so, button, right click,
- 4:13:57configure events. We're going to do a
- 4:13:59little script here, a little Ignition
- 4:14:01script to add one to the value
- 4:14:04um
- 4:14:04when the button is pressed. So, we go to
- 4:14:06mouse events in configuration events, on
- 4:14:09click, press the plus button and we're
- 4:14:12going to do a quick little script that
- 4:14:14is going to be
- 4:14:16uh val equal to so, the current value of
- 4:14:21the counter is equal to system.tag
- 4:14:25.readBlocking
- 4:14:26and that's a little bit of just Ignition
- 4:14:28syntax for you. The tag path is going to
- 4:14:31be that counter variable. So, we're
- 4:14:34going to say read the value that the
- 4:14:37counter currently has.
- 4:14:39And then little Jython syntax fun that
- 4:14:43we get to play here is if we actually
- 4:14:45want the value, we say square brackets
- 4:14:48z- zero.value. So, this is how you get
- 4:14:51the actual value that is in the counter
- 4:14:54tag already.
- 4:14:56And then what we're going to say is
- 4:14:58value equals val plus one. Okay, so
- 4:15:02we're just saying you could just say val
- 4:15:04again is equal to val plus one. But now
- 4:15:07we're going to do system.tag.
- 4:15:09writeBlocking.
- 4:15:11And in that same tag path we're going to
- 4:15:14write value. So, we're just adding one
- 4:15:19to the value of the counter when that
- 4:15:21button gets pressed. And what's cool is
- 4:15:23it'll let you It'll let you click the
- 4:15:26button at any time, but what you'll see
- 4:15:28is when we get to step three, which is
- 4:15:30where it's actually checking it, you'll
- 4:15:31see it get reset to zero cuz we only
- 4:15:34care about it when we get there. So,
- 4:15:35you're starting to see how the HMI and
- 4:15:38the PLC work together to create a system
- 4:15:40that the operator has some control over,
- 4:15:42but the PLC can also be programmed
- 4:15:44intelligently to protect it.
- 4:15:48So, this is how we just make a button in
- 4:15:49Ignition to increment a value.
- 4:15:53And let's see. What am I missing? When
- 4:15:56we're in step zero, we're idle. We press
- 4:15:58start, we should go to step one. Yeah,
- 4:16:00we want to monitor
- 4:16:02input eight. And actually, to do that,
- 4:16:05I'll grab one of these buttons that we
- 4:16:06made in the previous step. This was the
- 4:16:08blue button. Uh and I'll just drag it up
- 4:16:11here. This is This is input eight up
- 4:16:13here cuz that's kind of physically where
- 4:16:14it is on the Arduino. And we'll have it
- 4:16:17uh when it's true, we'll have it go um
- 4:16:21pink. I don't care. Pick a color.
- 4:16:25All right, so then all I have to do is
- 4:16:26copy the path for that tag and I have to
- 4:16:28say, "Hey, here's the tag that you're
- 4:16:30animating off of." Again, I'm assuming
- 4:16:32you uh watched the previous video and
- 4:16:34you know that we set this tag parameter
- 4:16:36to tie into that color animation. Okay,
- 4:16:39so real quick we can check that color
- 4:16:40animation cuz I have the hand switch
- 4:16:42right here with me and we can see
- 4:16:44whether the hand switch is on or off.
- 4:16:46Okay? Very cool. So, obviously it looks
- 4:16:50like crap because we haven't formatted
- 4:16:52it. We haven't made it stylistically
- 4:16:55pleasant. Uh we don't animate things
- 4:16:57whenever, but let's go into read write
- 4:16:59mode real quick for the gateway. So,
- 4:17:01that's what these two little arrows are.
- 4:17:04And right here in the designer, we can
- 4:17:06toggle into uh preview mode. So, now we
- 4:17:08can interact with the things. Let's say
- 4:17:10when we get to the countdown step, we
- 4:17:12want 5-second countdown. And when we get
- 4:17:15to the count up step, we want to have to
- 4:17:17click the button three times. Okay, I'm
- 4:17:19going to enter those. You can see right
- 4:17:21here, I can start counting up just by
- 4:17:23clicking it and the counter is at eight.
- 4:17:26What's cool is when we get to the count
- 4:17:28up step, that should go back to zero and
- 4:17:30we should have to start over again. Um
- 4:17:32one thing we didn't add, but I want to
- 4:17:34put here is the elapsed time um and I'm
- 4:17:37going to put it in a label.
- 4:17:39But where did it go?
- 4:17:41Oh, there it is. Um
- 4:17:43But you guys are going to see something
- 4:17:45cool. Let me Let me go up here. You guys
- 4:17:47are going to see that this value is
- 4:17:48going to come in in milliseconds.
- 4:17:51Um so, I'm going to let it do that this
- 4:17:53first test through and then I'm going to
- 4:17:54show you how you can scale it in the
- 4:17:56HMI. You could scale it in the PLC, you
- 4:17:58can scale it in the HMI.
- 4:18:00Just kind of pick something and try to
- 4:18:02be consistent on your project.
- 4:18:04So, we're in step zero. I hit the start
- 4:18:06button. Now, we're in step one and we're
- 4:18:09waiting for HMI. We're waiting for input
- 4:18:12eight. So, I'm going to turn the hand
- 4:18:13switch.
- 4:18:15And now we're in step two and you can
- 4:18:16see the counter counting up and when it
- 4:18:18hits 5,000, we go to step three. Okay?
- 4:18:22Pretty cool. And now it's waiting for us
- 4:18:24to count up to three. So, you see this
- 4:18:25was eight, now it's just waiting at
- 4:18:27zero. So, we click once, twice, a third
- 4:18:31time.
- 4:18:32Now, we're in step four
- 4:18:35and we press stop and it goes back to
- 4:18:37zero. Okay? So, the sequence step is
- 4:18:40working and that's really cool. What's
- 4:18:42not great is it doesn't tell you
- 4:18:44anything useful. So, what we're going to
- 4:18:46do is we're going to add a transform and
- 4:18:48we're going to map it. Okay? So, this is
- 4:18:51very common when you have a numerical
- 4:18:54value that tells you something that you
- 4:18:57would prefer to explain with text. Some
- 4:19:01a common way to refer to this is
- 4:19:02enumeration.
- 4:19:04Enumeration just refers to taking a
- 4:19:07integer value or a numerical value and
- 4:19:10it telling you more than just a number.
- 4:19:12It's telling you a string of text, but
- 4:19:14it's easier for PLCs to pass a simple
- 4:19:17integer back and forth than long
- 4:19:19strings.
- 4:19:21So, in zero, we're in idle
- 4:19:24waiting to press start button
- 4:19:28on HMI. That's the text that we want to
- 4:19:31display in step zero. Oh, where'd my
- 4:19:34There we go.
- 4:19:37In step one, we're
- 4:19:39active
- 4:19:41waiting to see
- 4:19:43input eight transition high.
- 4:19:47In step two, we're
- 4:19:50active waiting for
- 4:19:54timer to complete based on time set
- 4:19:59point. Step three, we're active
- 4:20:05and we want to
- 4:20:07wait
- 4:20:08for
- 4:20:11pushes to reach
- 4:20:14push count
- 4:20:17up set point. You can call it whatever
- 4:20:21you want if you don't like my step
- 4:20:23names. And then step four, we can say
- 4:20:26complete. Press stop button
- 4:20:30on HMI to
- 4:20:33idle sequence. And what's nice about
- 4:20:36Ignition 2 is they have a feature called
- 4:20:38fallback, which is I don't know how I
- 4:20:40got here. And we can just basically say
- 4:20:43sequence
- 4:20:45step somehow
- 4:20:48out of normal
- 4:20:51boundaries.
- 4:20:55And that's just basically saying you
- 4:20:57should not have been able to get here.
- 4:20:59Here's an error message telling you that
- 4:21:00something bad is happening. That can
- 4:21:03come in handy a lot. So, we're going to
- 4:21:04make that label a lot wider cuz that
- 4:21:07text is a lot longer. And then other
- 4:21:10than that, I think the only other thing
- 4:21:12I want to do right off the bat is I want
- 4:21:14to take this thing on the screen and I
- 4:21:17want to make it in seconds. So, what
- 4:21:20we're going to do is we're actually
- 4:21:21going to make this scale mode linear and
- 4:21:26I'm going to say, "Okay, well, it's
- 4:21:27showing me milliseconds, but I want
- 4:21:30seconds. So, if the raw high is 1,000,
- 4:21:34that means the scaled high is one." And
- 4:21:37as long as you don't do clamp mode, then
- 4:21:39it will automatically say, "Okay, even
- 4:21:41if I'm more than zero or more than one,
- 4:21:44that's okay." And then we'll make the
- 4:21:46value a float since now we're dividing
- 4:21:48it by 1,000, we'd like to see decimal
- 4:21:50precision.
- 4:21:53Okay, so this is this should be a little
- 4:21:55bit better now when we test through it
- 4:21:57because it's giving us instructions and
- 4:21:59we'll actually open the web page now.
- 4:22:05And we'll actually open the web page now
- 4:22:06and we'll run it from here. So, I'm
- 4:22:08going to
- 4:22:09go ahead and hit start. I'm waiting to
- 4:22:12see input eight transition high and you
- 4:22:13can see it's already high, but we put in
- 4:22:16that positive transition bit.
- 4:22:19So, it needs to see it high again. And
- 4:22:22here you can see fractional seconds
- 4:22:24counting up, which is nice cuz we set
- 4:22:26the set point in seconds. Now, we need
- 4:22:28to count up to three. 2 3. And now we
- 4:22:31need to press stop on the HMI.
- 4:22:34Okay, we can pretty easily say, "Let's
- 4:22:36make the count set point 11. Let's make
- 4:22:39this time set point seven and let's do
- 4:22:42it again. Let's press start here. Let's
- 4:22:45flip the hand switch."
- 4:22:48We're going to get to seven seconds.
- 4:22:53We are going to count up to 11 clicks.
- 4:22:58And now we finished the sequence, we can
- 4:22:59hit stop and we're back to idle.
- 4:23:02Overall, this was a challenging tutorial
- 4:23:05to put together because where to start,
- 4:23:07how to make it useful, how to explain
- 4:23:09the concepts, but not get bogged down
- 4:23:10the details was all a little bit
- 4:23:12daunting. I do hope you found it useful.
- 4:23:15I think we're getting to the point where
- 4:23:16all of the basics have been covered and
- 4:23:18I think we want to build one complete
- 4:23:22automation and controls project
- 4:23:23together. So, I am looking forward to
- 4:23:25doing that. I am already sort of
- 4:23:28fleshing out what that's going to look
- 4:23:29like and entail. So, as always, be sure
- 4:23:32to ask any questions that you may have
- 4:23:33in the description below. Thank you so
- 4:23:35much for watching. Let me know what you
- 4:23:37want to see next time on the channel and
- 4:23:38keep an eye out for more controls and
- 4:23:40automation tutorials. Thanks. We'll see
- 4:23:42you next time. Bye.
- 4:23:49Hello and welcome back to The Master
- 4:23:51Tech and in today's video, we're going
- 4:23:52to continue our controls and automation
- 4:23:54tutorial series by introducing the
- 4:23:57concept of a historian or a continuous
- 4:24:00trending tool as well as SQL, which is
- 4:24:02kind of a more conventional database
- 4:24:04tool. So, by far, these are the two most
- 4:24:07common ways that data gets represented
- 4:24:09in the world of industrial automation
- 4:24:11and controls. SQL SQL stands for
- 4:24:13structured query language. There are
- 4:24:16ample tutorials on the internet on how
- 4:24:17to get started with SQL, but
- 4:24:19specifically how to embed it within like
- 4:24:21a controls and automation project is
- 4:24:24very much like an automation concept.
- 4:24:26And then historians are sort of the
- 4:24:29standard for continuous trending of
- 4:24:31automation data. So, if you are just
- 4:24:33watching this video on its own, it will
- 4:24:35stand alone as a tutorial on how to use
- 4:24:38both the historian tool and create a SQL
- 4:24:41query from Ignition, which I think is
- 4:24:43useful on its own. But if you've been
- 4:24:45following along with the tutorial
- 4:24:46series, you know that we physically have
- 4:24:48this Arduino Opto PLC. We have the
- 4:24:51button and the blue light and the green
- 4:24:53light and the red light all all tied to
- 4:24:57the HMI on Ignition and then as well as
- 4:24:59input eight there in the top right
- 4:25:01corner, which I have a physical hand
- 4:25:03switch for. So, when I make the hand
- 4:25:05switch, we can see that input eight goes
- 4:25:07on. So, in the last video, we kind of
- 4:25:09introduced sequential programming and we
- 4:25:12made this sequence where we could start,
- 4:25:15we could wait to see that hand switch go
- 4:25:17high and then we start a timer that's
- 4:25:20going to count to a set point that we
- 4:25:22can adjust and then we need to click
- 4:25:24this button until we get to a target
- 4:25:26value and then we press stop. Okay? So,
- 4:25:30I have a sequence. If you don't want to
- 4:25:32follow along exactly with my example,
- 4:25:34that's okay. But you should have
- 4:25:37something sequential that you want to
- 4:25:39track if you want to this to be like a
- 4:25:41practical hands-on example for you. So,
- 4:25:44we're using Ignition for Makers, which
- 4:25:46is very popular SCADA supervisory
- 4:25:49control and data acquisition software.
- 4:25:52We're using Ignition Maker Edition,
- 4:25:53which is which is an awesome free tool
- 4:25:57that Inductive Automation put out.
- 4:25:59We have a basic HMI project that shows
- 4:26:01some of our tags and then we have the
- 4:26:04Arduino Opto PLC sharing data with
- 4:26:06Modbus TCP data. So, we're going to go
- 4:26:09into the designer of Ignition and we're
- 4:26:11going to take a look first at a very
- 4:26:13simple continuous trend.
- 4:26:16So, one thing to note is when you start
- 4:26:18storing data, when you start looking at
- 4:26:21data history over time, you need some
- 4:26:24version of a database to store that in.
- 4:26:27One really nice feature of Ignition for
- 4:26:29Makers and the industrial version of it
- 4:26:32is it'll by default have a sample SQL
- 4:26:35light database enabled and it'll use
- 4:26:38some of the storage of your computer by
- 4:26:40default because SQL light is just a
- 4:26:43file. So, it's a way of storing data
- 4:26:45that looks like, you know, Microsoft SQL
- 4:26:48or any other sort of like table and
- 4:26:50columns and rows version of a SQL, but
- 4:26:53SQL light is just a file. So, by
- 4:26:56default, we don't have to do anything
- 4:26:57special in Ignition. We have one
- 4:27:00connection to a database and it's a
- 4:27:02sample SQL light database.
- 4:27:04That's really important because anytime
- 4:27:06you want to store data, you have to
- 4:27:07store it somewhere. Okay, now let's go
- 4:27:10ahead and just pull up the HMI that we
- 4:27:12were developing before. It's kind of
- 4:27:14just a little square here. And I had it
- 4:27:17mode fixed. So, what I'm going to do is
- 4:27:19zoom out a little bit and widen it to be
- 4:27:22a little closer to the width of the
- 4:27:23screen. I'm going to hit save and then
- 4:27:26I'm going to do one thing here. I'm
- 4:27:27going to change mode from fixed to
- 4:27:29percent. So, now it should scale with
- 4:27:31the screen. Before we did that, if we
- 4:27:34were zooming in and zooming out, all
- 4:27:36those objects would also be zooming in
- 4:27:38and out, but now it's scaled to always
- 4:27:40be full screen. So, it's just a little
- 4:27:42feature of Ignition in particular.
- 4:27:45But that also means if we want to add a
- 4:27:46trend over here, uh we can. So, if we
- 4:27:49hit the Perspective Components uh
- 4:27:51palette over on the right, um I'm just
- 4:27:53going to grab a
- 4:27:56power chart.
- 4:27:58And I'm going to drag it onto the
- 4:27:59screen. And what's really cool is you
- 4:28:01don't have to tell it what tag to look
- 4:28:03at or anything. You just drag this power
- 4:28:05chart onto the screen and Ignition has a
- 4:28:09pre-built object that will let you
- 4:28:10browse tags within that. So, just by
- 4:28:13hitting save and going back to the web
- 4:28:15page, you can see this chart is on
- 4:28:17screen. The only problem is there's only
- 4:28:19example data in here. So, I have uh I
- 4:28:22have tags that I added before for
- 4:28:24testing. And then they give you these
- 4:28:26sample tags of realistic values to show
- 4:28:28you what navigating it looks like. Um
- 4:28:31but since in the designer, we haven't
- 4:28:33added historical data to any tags,
- 4:28:36um
- 4:28:37we're not seeing anything, okay? So, if
- 4:28:40you've been following along with the
- 4:28:40tutorials, you should have the same
- 4:28:42tags. But if you don't, that's okay. Um
- 4:28:45I don't have data trending enabled on
- 4:28:47any of these tags. So, let's grab a few
- 4:28:50that we might want to historize. So,
- 4:28:52sequence step is a good one to start
- 4:28:55with as an example. If I want to see the
- 4:28:57sequence step over time, that would tell
- 4:28:59me where in the sequence it was over
- 4:29:01time.
- 4:29:02Um and all I have to do when I open the
- 4:29:04tag editor is go to history and then
- 4:29:08true, and I need to give it a storage
- 4:29:10provider, which in this case we'll make
- 4:29:11that sample SQLite database. And then
- 4:29:14there's a few important things here.
- 4:29:15There's uh dead bands, there's dead band
- 4:29:17styles. You can leave most of these on
- 4:29:20the default and it'll just start working
- 4:29:22if all you do is enable history and give
- 4:29:25it a storage provider and hit apply.
- 4:29:27Um
- 4:29:28it's important, I think, to call out on
- 4:29:30change versus periodic because on change
- 4:29:33by default will only store new values
- 4:29:36when the value changes. That's kind of
- 4:29:38like a memory optimization. But you can
- 4:29:40tell it no matter what, I want uh it to
- 4:29:43store at a certain periodic interval as
- 4:29:46well. So, we'll leave it as on change.
- 4:29:48I'm going to hit apply and okay. And so
- 4:29:51now it should have history enabled. And
- 4:29:53let's go to that web page and let's open
- 4:29:56the tag browser and let's browse through
- 4:29:58this uh to default and then sequence
- 4:30:01tags and then sequence step and let's
- 4:30:03add that selected tag here. So, if I
- 4:30:06collapse the tag browser, what you can
- 4:30:08hopefully see, although it might be hard
- 4:30:10on the recording,
- 4:30:12and we can click this X trace tool which
- 4:30:14tells us the value.
- 4:30:15We can see that sequence step is a
- 4:30:18constant zero. And if I change my
- 4:30:20real-time uh value to show the last 5
- 4:30:23minutes and hit apply,
- 4:30:26and you can always edit that here in the
- 4:30:27set date range.
- 4:30:29But if I show the last 5 minutes,
- 4:30:32uh now let's go ahead and start that
- 4:30:33sequence and I hit start and it should
- 4:30:36go to step one. And you can see this
- 4:30:38trend jumped right to one in real time.
- 4:30:41Now it's waiting to see input eight
- 4:30:42transition high. So, I'll go ahead and
- 4:30:44turn on that hand switch. And you can
- 4:30:46see it the value jumps up to two right
- 4:30:49away. Now it hits our 5-second timer and
- 4:30:52it jumps up to three. Now it's waiting
- 4:30:54for the pushes to reach the set point.
- 4:30:571 2 3 should jump up to five. And then
- 4:31:01if I hit the stop button,
- 4:31:04the sequence step goes back to zero. So,
- 4:31:06it's really cool. You can see just right
- 4:31:08there us stepping through the sequence.
- 4:31:10So, if I were to go to
- 4:31:12uh time set point 10 now and we did it
- 4:31:15one more time, kind of as fast as we can
- 4:31:18here, hit start, uh turn the set point
- 4:31:21on,
- 4:31:23and then it's going to take 10 seconds.
- 4:31:27And then we count up to three.
- 4:31:30And then we hit stop.
- 4:31:34But what's cool is you can see between
- 4:31:35those two runs, step two, which is the
- 4:31:38time-based step, was 5 seconds here and
- 4:31:40was 10 seconds here. And we can narrow
- 4:31:43that window as well. We can say last 2
- 4:31:45minutes and you get a more precise uh
- 4:31:47you get a more precise graph going.
- 4:31:49Okay, so that's going to do it for our
- 4:31:50very basic introduction to the historian
- 4:31:53because that is objectively the simpler
- 4:31:55of the data tracking tools that we're
- 4:31:57trying to cover today. Um kind of like I
- 4:32:00said in the outset, when you just want
- 4:32:02to see process data continuously over
- 4:32:04time, a historian tool is great for that
- 4:32:07and is plenty to do that. But when you
- 4:32:09want to create a more um
- 4:32:11a more, I guess, logical data story over
- 4:32:14time and you want to tie what time I
- 4:32:16started, what time I stopped with, you
- 4:32:18know, what were these settings at that
- 4:32:20time, who was doing that work, um that's
- 4:32:23usually when you want to go to something
- 4:32:24like a SQL database. And uh like I said,
- 4:32:28we have a um SQLite already here in
- 4:32:32Ignition. Again, if you're not using the
- 4:32:34Ignition platform, I guarantee your
- 4:32:36SCADA supports some way of interfacing
- 4:32:38with a database like a SQL tool. Um you
- 4:32:41just have to do a little reading on how
- 4:32:42to connect insert name of your SCADA or
- 4:32:45HMI platform to SQL and I guarantee
- 4:32:48someone's done it. All right, so from
- 4:32:50the Ignition designer, I'm going to go
- 4:32:51ahead and go to the database query
- 4:32:53browser. And I previously had um a
- 4:32:57sequence data table I was testing. I'm
- 4:33:00going to go ahead and delete that real
- 4:33:01quick with this drop table command so
- 4:33:03that we can rebuild it from scratch. So,
- 4:33:05I had sequence data. I just deleted it
- 4:33:07there. Um so you guys can follow the
- 4:33:10exact steps that I do. So, I'm going to
- 4:33:12kind of think about our sequence real
- 4:33:14quick and the things that I would want
- 4:33:16to add to capture how the sequence was
- 4:33:18running. So, I would want to capture the
- 4:33:21time it started. I'll call that start
- 4:33:22time. I would want to capture end time.
- 4:33:25I want to capture what the time delay
- 4:33:26set point was and the count set point
- 4:33:29were
- 4:33:29um and then
- 4:33:31potentially a username if someone was
- 4:33:33logged in. Um and then maybe like a run
- 4:33:36count, an ID that says, "Hey, this was
- 4:33:38run 1 2 3 4 5 6." And it just keeps
- 4:33:41incrementing up, okay? So, I don't have
- 4:33:44all of those variables defined yet, but
- 4:33:46I have many of them. We're not going to
- 4:33:47worry about the tags existing yet. We're
- 4:33:50going to make that table first. So,
- 4:33:52let's go back into our tools and let's
- 4:33:55go into our database query browser and
- 4:33:57let's create a table in the query
- 4:33:59browser that's going to have that data
- 4:34:01that we want. So, to do this, we're
- 4:34:02going to say create
- 4:34:04table. And at this point, you guys have
- 4:34:07probably seen Ignition can use Python in
- 4:34:09some places. It has specific Ignition
- 4:34:12syntax for certain things. This is SQL
- 4:34:15syntax and in particular SQLite, but all
- 4:34:18uh SQL is pretty similar if you know
- 4:34:21what you're looking at. So, we're going
- 4:34:22to create a table. We'll call it
- 4:34:24sequence data and we'll expand these
- 4:34:25parentheses out. And we'll have a field
- 4:34:28called run count and we'll make that an
- 4:34:30integer. And we'll make this the primary
- 4:34:32key. So, you don't have to know about
- 4:34:35keys and primary keys and stuff to build
- 4:34:37a simple table. You don't have to
- 4:34:39include that primary key bit. Um but if
- 4:34:41you want something that is like uh
- 4:34:44unique for a table, which would be a
- 4:34:46primary key, you're saying, "Hey, run
- 4:34:48can never repeat itself. If I already
- 4:34:51did run one or run two or run three, I
- 4:34:54can't have another run one or run two or
- 4:34:56run three. That's going to corrupt my
- 4:34:57data." So, you can make that a primary
- 4:34:59key.
- 4:35:01And then we'll have a username, which
- 4:35:03we'll make a varchar 50. If you haven't
- 4:35:05seen that format before, that's SQL's
- 4:35:07way of saying it could be a string.
- 4:35:09Varchar means variable character and you
- 4:35:12can basically pass anything in there.
- 4:35:15Okay. And then we'll say start date
- 4:35:18time. And the reason I'm putting null at
- 4:35:20the end is kind of SQL's format for
- 4:35:23saying, "Do you want that field to be
- 4:35:25able to be left empty or not?" Um and in
- 4:35:28my case, I'm actually okay if any of
- 4:35:31these fields get left empty except for
- 4:35:33uh the run count because I'm sort of
- 4:35:36just trying to prove out the function.
- 4:35:38Uh but a lot of the times you might say,
- 4:35:40"Hey, a row of data is going to be
- 4:35:42useless if I don't have start time or
- 4:35:44end time or a username." And in that
- 4:35:46case, you would say not null.
- 4:35:50Click count int null.
- 4:35:52Okay. So, what I am doing right here
- 4:35:54with this command is creating a table
- 4:35:56that has an integer for run count, a
- 4:35:59string variable character for username,
- 4:36:02a date time parameter for start time and
- 4:36:04end time, and then I'm going to store
- 4:36:05the set points for time delay and click
- 4:36:07count. And if I hit execute on this and
- 4:36:10then I refresh my little browser over
- 4:36:12here in the right, you can see sequence
- 4:36:15data has those six columns. And a
- 4:36:17statement that we'll use a few times is
- 4:36:20I'm going to select all by using the
- 4:36:21star from sequence data. Okay. And if I
- 4:36:26hit execute, you can see nothing exists
- 4:36:29in there. Um and that's actually what we
- 4:36:31expect. We expect nothing because we
- 4:36:33just made that table. So, we're going to
- 4:36:35go ahead and close this.
- 4:36:37Uh and what we're going to do next is
- 4:36:38take a look at from Ignition, from our
- 4:36:41sequence, how to uh store that data, how
- 4:36:44to trigger um events in our Ignition
- 4:36:47sequence that are going to write data to
- 4:36:49SQL. And that'll give you an example of
- 4:36:51how to store batch data out of a
- 4:36:54sequence that you might have written in
- 4:36:55the PLC and are monitoring from an HMI.
- 4:36:58So, very cool interconnected automation
- 4:37:00controls concepts going on here. And to
- 4:37:02do this, we're going to add a few new
- 4:37:04tags. So, we had our original Arduino
- 4:37:06tags from our first example of tying
- 4:37:08Arduino into Ignition. We had our
- 4:37:10sequence tags from our additional
- 4:37:11sequence. We're going to make a few new
- 4:37:14tags um just so we can keep track of
- 4:37:16when we added what. So, we're going to
- 4:37:18make a new folder called SQL tags. I
- 4:37:20accidentally added it inside that
- 4:37:22folder. Let's go ahead and liberate it.
- 4:37:25Um and we need to add a few new tags.
- 4:37:27One of the first tags is going to be a
- 4:37:30new standard tag. I'm going to make it a
- 4:37:32memory tag and I'm just going to call it
- 4:37:34run count.
- 4:37:36Okay. Uh and we're going to leave it in
- 4:37:38the default tag group. It's It's to be
- 4:37:40memory. It's going to be integer, and to
- 4:37:42start, it'll be a zero.
- 4:37:45Okay, so the run count is going to be
- 4:37:47that primary key that tells us how many
- 4:37:49times we've run through this sequence,
- 4:37:51and we're going to make a another new
- 4:37:53tag.
- 4:37:54Standard tag, memory tag, and this one
- 4:37:57we'll call username.
- 4:38:01Okay, so if you were going to log in,
- 4:38:03you could store that info in a string
- 4:38:05tag. Initially, we'll say it's Pete.
- 4:38:07That sounds like a cool guy.
- 4:38:11And then the last new tags that we have
- 4:38:13to create are start time and end time.
- 4:38:15So, I'm going to do new standard tag,
- 4:38:18memory tag. This format is going to be
- 4:38:21date time, and we'll call this start
- 4:38:24time. And actually, getting a little bit
- 4:38:27ahead of ourselves here, but I'm going
- 4:38:28to only make start time, and we're not
- 4:38:31going to need a tag for end time because
- 4:38:33we're going to use the trigger event
- 4:38:35that finishes the sequence as the time
- 4:38:38to go do end time. Um
- 4:38:41All right, so
- 4:38:43There's There's just me adding the tags
- 4:38:46that round out what we're going to write
- 4:38:48to SQL because everything else already
- 4:38:50existed. Let's capture the start time of
- 4:38:53our sequence. So, when we click this
- 4:38:55button
- 4:38:56for start and we're in step zero, that's
- 4:38:59when we go from step zero to step one.
- 4:39:02So, I'm going to click on the sequence
- 4:39:03step tag, and I'm going to go to
- 4:39:05scripting, and I'm going to go to value
- 4:39:07change, and I'm going to add a little if
- 4:39:10current value.value
- 4:39:14is equal to one and
- 4:39:18previous value.value
- 4:39:21was equal to zero. So, here I'm taking
- 4:39:24advantage of the tag change event, which
- 4:39:26has current value and previous value as
- 4:39:29parameters of the event. And
- 4:39:31technically, the sequence only ever goes
- 4:39:33to step one from step zero. So, this is
- 4:39:35kind of an over-engineered statement,
- 4:39:37but we're going to leave it, and I'm
- 4:39:39going to say okay. That means someone
- 4:39:41just started up the sequence. So, I'm
- 4:39:43going to do system.tag.write
- 4:39:47blocking
- 4:39:48which is the
- 4:39:50Ignition syntax for writing a value to a
- 4:39:52table.
- 4:39:53And I'm going to copy the path for that
- 4:39:55start time tag that I just made. Copy
- 4:39:57path. And I'm going to paste that path
- 4:40:00in here, and then I'm just going to say
- 4:40:03use system.date.now. Okay, so this is
- 4:40:05Ignition's like system-formatted.
- 4:40:07Go grab a timestamp
- 4:40:11of what my computer says it currently
- 4:40:13is, and store that in a tag. And I'm
- 4:40:15going to hit apply, and I'm going to hit
- 4:40:17okay, and I'm going to hit save. And
- 4:40:20now, we're going to go back here, and
- 4:40:22we're going to hit start real quick.
- 4:40:24And now, we're in step one. And if we go
- 4:40:27back into the designer, now we can see
- 4:40:30we have, you know, August 12th at 10:17
- 4:40:33p.m. stored in start time. So, that's
- 4:40:36cool. That tells us that our script
- 4:40:38worked. Now, we've got the time
- 4:40:39capturing into start time, which is very
- 4:40:42cool.
- 4:40:43But to actually write to SQL, we need to
- 4:40:45hit a database, which is technically a
- 4:40:47gateway
- 4:40:49scoped thing. So, we're going to go to
- 4:40:51gateway tag change events, and we're
- 4:40:53going to go to tag change, and we're
- 4:40:55going to create new event, and we're
- 4:40:56going to call it
- 4:40:58write to SQL. But basically, we're going
- 4:41:01to say when that sequence step tag
- 4:41:03changes, when the value specifically
- 4:41:06changes, so not the quality, not the
- 4:41:08timestamp, but the value of that tag
- 4:41:10changes, we're going to trigger this
- 4:41:11write to SQL script. But we don't want
- 4:41:15to trigger that script every time the
- 4:41:17value changes, only when it resets. So,
- 4:41:20we're going to start by doing
- 4:41:21system.tag.
- 4:41:24read
- 4:41:26blocking on that sequence step, and then
- 4:41:30square bracket zero.value. That's just a
- 4:41:33little Ignition-specific syntax for how
- 4:41:35to read the value out of a tag. And
- 4:41:37we're specifically going to say if value
- 4:41:39equals zero.
- 4:41:41Because value equaling zero means that
- 4:41:44the sequence has just reset. This is an
- 4:41:46on change on tag change event script.
- 4:41:50So, the tag is only changing to zero
- 4:41:53when someone hits stop because it was in
- 4:41:55sequence step five. So, that's when
- 4:41:57we're actually going to trigger write
- 4:41:59data to SQL. Now, all we really need to
- 4:42:02do is we need to go out and read all
- 4:42:06tags that have SQL data, and then we're
- 4:42:09going to do a section of define the SQL
- 4:42:14query and
- 4:42:17arguments.
- 4:42:19And then we're going to call
- 4:42:22the SQL query and increment the counter.
- 4:42:26So, if you remember, we have like a
- 4:42:27counter variable. It's currently at
- 4:42:29zero, and we're going to increment that
- 4:42:31every time we do a new run. Okay, so
- 4:42:33these are kind of the three sections we
- 4:42:35have to create in this script, and it's
- 4:42:37immediately hopefully sort of apparent
- 4:42:40why you don't want to do this just on a
- 4:42:42tag change script. It's a little bit
- 4:42:44easier with gateway events to keep
- 4:42:47revision control and sight on things
- 4:42:49like that. So, we're going to read all
- 4:42:51the tags that have SQL data. And if we
- 4:42:53remember our table, we want to start
- 4:42:55with start time, and I'm going to try to
- 4:42:57keep the convention. Going to try to
- 4:42:59keep the convention of first letter
- 4:43:03lower case, and then all following
- 4:43:05words. What is that called? Snake case,
- 4:43:07I think, or camel case. I get the two
- 4:43:09backwards. Okay, in any case, we need
- 4:43:11start time, we need end time, we need
- 4:43:13the username, we need the count set
- 4:43:16point, we need the time
- 4:43:19delay set point.
- 4:43:22And we need the
- 4:43:24run count, that unique parameter. So, we
- 4:43:27need to read all these tags. I'm going
- 4:43:29to steal this system.tag.readBlocking
- 4:43:32command here.
- 4:43:35And I'm going to just replace the tag.
- 4:43:37So, start time is going to be that start
- 4:43:40time tag. Copy path.
- 4:43:43And paste it in here instead. And then
- 4:43:46actually, that isn't what we want it to
- 4:43:49be for end time. We want
- 4:43:50system.date.now.
- 4:43:53No, system.time.now.
- 4:43:56Um No, system.date.now. Come on, Pete.
- 4:43:59Getting tired.
- 4:44:01So, we want system.date.now
- 4:44:03for end time, and then for the username,
- 4:44:06that's going to be
- 4:44:07We're going to copy this line and look
- 4:44:10at
- 4:44:11username instead of start time. So,
- 4:44:14we're just going to update this bit
- 4:44:16to username.
- 4:44:18And to write the Basically, all we're
- 4:44:21trying to do, just to be super clear, is
- 4:44:23that when we write a SQL query, we need
- 4:44:25to pass in all of the data we want
- 4:44:27stored in SQL. So, within our script, we
- 4:44:30have to go out and grab the data that we
- 4:44:31want to read. You can read all of these
- 4:44:34tags in one line of code. I think it's a
- 4:44:36little easier for beginners to see it
- 4:44:38broken out this way. So, let's go ahead
- 4:44:40and say
- 4:44:42run count is this just
- 4:44:45run count like that. And then time delay
- 4:44:48set point is actually copy path.
- 4:44:52And a little bit of a different
- 4:44:53location. So, we'll copy that one. And
- 4:44:57then count set point is right next to
- 4:44:59time delay set point, but it's called
- 4:45:02HMI_
- 4:45:05count SP. Okay.
- 4:45:08So, that should give us the six fields
- 4:45:10that we want to write into SQL.
- 4:45:13One thing that is worth calling out. So,
- 4:45:15we've got start time. We're actually
- 4:45:17going to format start time here. We're
- 4:45:19going to use a command called
- 4:45:20system.date.format
- 4:45:23because the Ignition date and what MySQL
- 4:45:27or SQLite uses are slightly different.
- 4:45:30So, we're going to take that start time,
- 4:45:33and we're going to explicitly tell it to
- 4:45:34be four-digit year with YYYY, two-digit
- 4:45:38month two-digit day, and then two-digit
- 4:45:42hour, two-digit minute, and then
- 4:45:45two-digit second. So, we're explicitly
- 4:45:48defining a date format because SQL will
- 4:45:50throw an alarm
- 4:45:52throw an error if it uses the exact
- 4:45:55Ignition format. So, we're going to make
- 4:45:56this new variable start and end instead
- 4:45:59of start time and end time, and they're
- 4:46:01just going to have the transform data.
- 4:46:03You can do system.date.format
- 4:46:06and system.tag.readBlocking on the same
- 4:46:08line. I think it's easier to split it
- 4:46:10out this way, especially for beginners.
- 4:46:12But if you look at this tag
- 4:46:15and if you were to see that printed,
- 4:46:17it's got p.m. on it, and it can also,
- 4:46:20depending on the Ignition statement, it
- 4:46:22can sometimes have the date, too. Like
- 4:46:24it'll say Monday, the whatever.
- 4:46:27So, this is just us explicitly calling
- 4:46:29out a format that we know SQL will
- 4:46:31support. Okay, so we've got all of the
- 4:46:35We've got all of the raw data we need.
- 4:46:37Now, we're going to define a query. And
- 4:46:40this is a cool thing about Ignition. You
- 4:46:41can just write simple queries in a
- 4:46:44string of text. This is true of Python
- 4:46:46as well, if you're if you're a bit of a
- 4:46:48Python programmer. We can just type in
- 4:46:51insert into
- 4:46:52sequence data, and we can say username
- 4:46:56username. Let's go real quick to the
- 4:46:59database browser, query browser, and
- 4:47:01make sure I get all these column names
- 4:47:03right. Oops. Where'd they go?
- 4:47:06Um Yeah, so we've got run count. I'm
- 4:47:10just going to take a snip of this real
- 4:47:12quick. Run count. No, I'm going to leave
- 4:47:13it up the whole time, even better.
- 4:47:15Gateway events. Okay.
- 4:47:17So, we want username
- 4:47:21like that. So, this is case-sensitive,
- 4:47:24which is the main reason I'm being extra
- 4:47:25careful about this. Oh, where'd my
- 4:47:27gateway event go?
- 4:47:30And we're going to insert using Now, the
- 4:47:31order also doesn't really matter. It's
- 4:47:34okay that we
- 4:47:35grabbed the
- 4:47:37grabbed the order in a different
- 4:47:40grabbed these raw tags in a different
- 4:47:42order than I'm defining them right here.
- 4:47:45Click count.
- 4:47:47What else did we have? Let's just finish
- 4:47:49typing these in so that then I can talk.
- 4:47:52Time delay.
- 4:47:53Start
- 4:47:55time and end time. Okay, what I was
- 4:47:58trying to say is it's okay that these
- 4:48:00are in different orders because then we
- 4:48:02say the values are going to be
- 4:48:06parameters that we pass in so that we do
- 4:48:08that with these question marks. So there
- 4:48:09should be six parameters that we're
- 4:48:11passing in.
- 4:48:13So our sequence our SQL statement is
- 4:48:16just saying we're going to insert values
- 4:48:18into those six columns
- 4:48:20and the values are things we're going to
- 4:48:22pass in. They're going to be arguments.
- 4:48:24So args is equal to and then a square
- 4:48:26bracket.
- 4:48:28And here I'm going to do a little type
- 4:48:30casting. I'm going to
- 4:48:31say okay string username. It's never a
- 4:48:35bad idea even if you're pretty sure it's
- 4:48:37already the right format to explicitly
- 4:48:40make sure that it gets defined as the
- 4:48:42right format. So like
- 4:48:44run count needs to be an integer for it
- 4:48:47to work.
- 4:48:49Click count same deal which what do we
- 4:48:51call click count? Count set point.
- 4:48:54Count set point
- 4:48:57and then we have the time delay set
- 4:48:59point. Same thing that needs to be an
- 4:49:01integer time delay SP.
- 4:49:05And then we have our start time and our
- 4:49:07end time. And actually for
- 4:49:10another just my SQL light thing that I'm
- 4:49:14sharing with you all is that casting it
- 4:49:16to a string in the correct format is the
- 4:49:20best way to ensure that it gets stored
- 4:49:22in SQL light appropriately. So there's a
- 4:49:24little bit of just knowing how to play
- 4:49:26the game here. But basically what we've
- 4:49:28done is we've said username run count
- 4:49:30click count time delay start time end
- 4:49:32time are going to be passed in as six
- 4:49:34parameters. That's what the question
- 4:49:35marks mean and then this order is very
- 4:49:38important. These need to correlate to
- 4:49:40the column order that you just did. So
- 4:49:42it needs to be username run count click
- 4:49:44count time delay start time end time.
- 4:49:48Um
- 4:49:48Now there's only two lines of code left
- 4:49:50and then we're done.
- 4:49:52We want to do system.db.
- 4:49:55run
- 4:49:57prep
- 4:49:58update and we're going to pass in the
- 4:50:00query and we're going to pass in the
- 4:50:02arguments.
- 4:50:03And then I'm going to delete out all the
- 4:50:05other auto-generated stuff.
- 4:50:06system.db.run prep update query and the
- 4:50:09arguments. And then the last thing I
- 4:50:11want to do which will also show us when
- 4:50:13we run it that it's working is I want to
- 4:50:15do system.tag.writeBlocking
- 4:50:18and I want to write to the
- 4:50:21uh
- 4:50:22count set point. No, run count. I want
- 4:50:25to write to this tag.
- 4:50:29Write to this tag
- 4:50:32a value of
- 4:50:34run count plus one. Okay, so this is me
- 4:50:39saying hey at the very end of logging
- 4:50:41data to SQL I want to increment the run
- 4:50:43count parameter by one. Okay? So we're
- 4:50:47going to go ahead and hit save and to
- 4:50:49see if it's working we're going to go
- 4:50:51ahead and run through the sequence. So
- 4:50:53all right, let's count up 1 2 3.
- 4:50:56Now it's in step four. Let's go ahead
- 4:50:59and hit stop. Okay? Now it's idle it's
- 4:51:03ready to go again. Let's go ahead and go
- 4:51:05back to the designer and you can see run
- 4:51:07count is one. So if you weren't looking
- 4:51:09before
- 4:51:10it was zero. To make sure that it
- 4:51:12actually got to SQL we'll go to tools
- 4:51:15we'll go to query browser and again
- 4:51:17we'll go ahead and select all from
- 4:51:19sequence data like we did before. Hit
- 4:51:21execute and that's pretty cool. Now we
- 4:51:23have run count username Pete start time
- 4:51:26end time look accurate. I had a pretty
- 4:51:29big break between when we started and
- 4:51:31now.
- 4:51:32The time delay set point and the click
- 4:51:34count. Okay? So let's go ahead and go
- 4:51:36back there one more time. Let's say now
- 4:51:38the count set point is only going to be
- 4:51:39two but our time delay is going to be
- 4:51:41five seconds and in the designer you
- 4:51:45could make it a label on the field but
- 4:51:47in the designer I'm just going to change
- 4:51:49the username from Pete to Peter.
- 4:51:52And let's go ahead and start this thing
- 4:51:54again. So start
- 4:51:56and waiting to see him put eight. There
- 4:51:58we go.
- 4:52:00Time set point count up to five.
- 4:52:03Count set point count up to two.
- 4:52:06And press stop.
- 4:52:08Okay? So back to designer we go.
- 4:52:12And now we can see run count is up to
- 4:52:14two. We go ahead and we go to the query
- 4:52:16browser and we search again. We have two
- 4:52:18entries. So one last thing because it's
- 4:52:21nice to tie it back into a visualization
- 4:52:23in SQL tags we're going to add a new tag
- 4:52:25and a new standard tag and a query tag
- 4:52:28and we're just going to say SQL results.
- 4:52:31I'm trying to go pretty fast now because
- 4:52:33I know how long this tutorial's gotten
- 4:52:35and we're going to make this a query
- 4:52:37tag. We're going to make it a data set.
- 4:52:41Data set I know you're in here.
- 4:52:44There it is.
- 4:52:45And we're going to just make it
- 4:52:48every let's say 10 seconds. No, five
- 4:52:51seconds. What the heck? It's
- 4:52:53not doing much.
- 4:52:55We're going to make a query that is just
- 4:52:57going to be select all from
- 4:53:01sequence data just like we've been
- 4:53:04running. And the data source is going to
- 4:53:06be our SQL light database. I'm going to
- 4:53:08hit apply.
- 4:53:09And now I'm going to drag that SQL
- 4:53:11results onto the screen and I'm going to
- 4:53:12make it a table.
- 4:53:14And one Ignition thing I've seen a lot
- 4:53:17of forums a lot of people are like why
- 4:53:18do my dates
- 4:53:20look jacked up? This is just a little
- 4:53:22bonus lesson for you. When you have a
- 4:53:24table
- 4:53:25you need to explicitly define the
- 4:53:27columns are date time to get the date
- 4:53:30and time to look correct. So if we go to
- 4:53:33columns in the table
- 4:53:35and we add
- 4:53:37array elements and we say 1 2 3 4 5 and
- 4:53:406 we can go to
- 4:53:43two and three which in this case are
- 4:53:45start time and end time and we can say
- 4:53:47start time
- 4:53:49and then you come down to date format
- 4:53:51date time and there you go start time
- 4:53:53looks good. We can do the same thing go
- 4:53:55to three
- 4:53:56end time. This very much is a tidbit of
- 4:54:00useful if you're working in Ignition. No
- 4:54:03other SCADA that I've seen has this like
- 4:54:05explicitly needing to define dates and
- 4:54:07times. We're not going to worry about
- 4:54:09that. We have a table on the screen.
- 4:54:11Let's go ahead and run it one more time
- 4:54:12so you you guys can see this power of
- 4:54:15live updating. So we're going to start
- 4:54:17it again. Let's change this to six and
- 4:54:20this to four
- 4:54:21and transition the hand switch.
- 4:54:24We've got to wait six seconds. So we
- 4:54:26should have one now that shows starting
- 4:54:28after this 2303. 1 2 3 4.
- 4:54:33And push stop.
- 4:54:35And within five seconds this table here
- 4:54:37should update. There it goes way less
- 4:54:39than five seconds. New start time new
- 4:54:41end time new time delay new click count.
- 4:54:43Okay, so we've seen just in a couple
- 4:54:46minutes we've seen how quick and easy it
- 4:54:48is with a good SCADA software to be able
- 4:54:51to monitor live data. This also this
- 4:54:54same tool can go back in history pretty
- 4:54:57far so you can look at days or weeks
- 4:54:59past as long as your computer's
- 4:55:01retaining it
- 4:55:02and you can look at continuous trending
- 4:55:04data like that. You can look at SQL data
- 4:55:06like that.
- 4:55:09Far and away historian and SQL are the
- 4:55:11two most powerful data analysis tools
- 4:55:14for automation and controls engineers to
- 4:55:16get familiar with.
- 4:55:17So I hope you found this to be a useful
- 4:55:19introduction. I hope you have found the
- 4:55:21introduction to the automation and
- 4:55:23controls tutorial series if you've been
- 4:55:25following the whole series to be super
- 4:55:27useful. We've covered the majority of
- 4:55:29the basics to the point where you should
- 4:55:31at least understand the major fields
- 4:55:34that we're addressing. So as always if
- 4:55:36you have any questions about what you
- 4:55:38saw in this video today or things you'd
- 4:55:40like to see in the future on the channel
- 4:55:42be sure to let me know about them in the
- 4:55:43comments below. Thank you so much for
- 4:55:45watching and we'll see you next time.
- 4:55:47Thanks. Bye.
- 4:55:54Welcome back to The Master Tech and in
- 4:55:55today's video we are going to continue
- 4:55:57our series on industrial automation and
- 4:56:00controls tutorials with a quick but
- 4:56:02super important and useful concept which
- 4:56:05is adding IO expansion modules. So with
- 4:56:07pretty much any PLC manufacturer
- 4:56:10Allen-Bradley Rockwell Siemens Arduino
- 4:56:14you're going to run out of input and
- 4:56:16output channels with whatever came on
- 4:56:19board the PLC module itself. In fact
- 4:56:21some of the high-end Siemens and
- 4:56:23Allen-Bradley PLCs are just CPU modules.
- 4:56:26They're just brains and they don't have
- 4:56:28any IO on board. So you design a project
- 4:56:31and automation system for a certain
- 4:56:33number of inputs and outputs and you
- 4:56:36need to be able to add IO modules to
- 4:56:38those PLCs.
- 4:56:40So the Arduino Opta line is a pretty new
- 4:56:43line. They only have three expansion
- 4:56:45modules that they offer right now but it
- 4:56:47covers all of the basics. They have two
- 4:56:49different versions of input and output
- 4:56:51digital input and output cards. One that
- 4:56:54has electromagnetic relays and one that
- 4:56:56has solid state relays. And then they
- 4:56:58have a little bit of a grab bag card
- 4:57:00that has pulse width modulation outputs
- 4:57:02analog inputs analog outputs as well as
- 4:57:04a few conventional input and output
- 4:57:06channels as well. But the important
- 4:57:09thing is you design an overall system.
- 4:57:11You make like an IO list of the total
- 4:57:13inputs and outputs that you're going to
- 4:57:15have and you need to be able to add
- 4:57:17these modules to your PLC. So we've been
- 4:57:19doing this tutorial series with the
- 4:57:21Arduino Opta PLC so we're going to
- 4:57:23continue using that in today's video.
- 4:57:25Whatever PLC and system you have just
- 4:57:28know that your manufacturer should
- 4:57:31provide all sorts of recommendations for
- 4:57:33cards that support digital inputs,
- 4:57:36digital outputs, analog in, analog out,
- 4:57:38IO-Link, Profinet, high-speed counter.
- 4:57:41There's so many different variations on
- 4:57:43inputs and outputs, RTDs and
- 4:57:45thermocouples. You just need to look up
- 4:57:47the card that's compatible with your
- 4:57:49PLC. Or you're following along with this
- 4:57:51Arduino Opta series,
- 4:57:53and I'll leave all of the cards that I'm
- 4:57:54using linked in the description below
- 4:57:56this video if you want to follow along
- 4:57:58exactly. So that we start from exactly
- 4:58:00the same spot, just make a new project
- 4:58:02for this tutorial and I'll call it IO
- 4:58:04add-ons,
- 4:58:06and I'll just make a brand new project.
- 4:58:09And then in terms of my physical setup
- 4:58:11right now, all I have is the Arduino
- 4:58:13Opta PLC plugged in via USB-C cable to
- 4:58:16my laptop and then plugged in to a 12-V
- 4:58:19power supply
- 4:58:21for DC power. So that is the total
- 4:58:23physical wiring. There's no cards
- 4:58:25clamped on there yet. I have them just
- 4:58:27sitting here waiting to be hooked up.
- 4:58:29But so we have a brand new project,
- 4:58:31nothing going on. I'm going to go ahead
- 4:58:33and onboard the file system just like
- 4:58:35you do first time with any PLC so we can
- 4:58:37really start from scratch together. I
- 4:58:39mean that takes a little time, but it
- 4:58:40looks like it works. So if we just go
- 4:58:43into our LED outputs real quick and we
- 4:58:45just give ourselves
- 4:58:47like L1, L2, L3, and L4 variables real
- 4:58:52quick as well as let's just say, you
- 4:58:55know, red,
- 4:58:56green, and blue. And then let's grab
- 4:58:58that user button input and let's call it
- 4:59:02user so we can program with those
- 4:59:04variables now. Hopefully you've been
- 4:59:05following this series and that's all
- 4:59:07pretty familiar to you.
- 4:59:09And we have this count program. Let's
- 4:59:11just go ahead and say that we want green
- 4:59:13to be on and we want blue to be equal to
- 4:59:16the user. This is just kind of like a
- 4:59:18great one-two line to make sure that PLC
- 4:59:22is actually working when you connect to
- 4:59:24it and then download to it. So we
- 4:59:26connect, it says no code, that's good
- 4:59:28cuz it's the first boot up, so there is
- 4:59:31no code running on there. And we're
- 4:59:33going to go ahead and just send this and
- 4:59:34hopefully it compiles okay, downloads
- 4:59:36okay, and then we'll get the green light
- 4:59:38turning on, and then the blue light will
- 4:59:40turn on and off as we push the user push
- 4:59:43button in. That means our PLC is all
- 4:59:45rocked and rolling and ready to go.
- 4:59:48It'll ask you to restart, go ahead and
- 4:59:49hit yes. Target reboot, shouldn't take
- 4:59:53too long.
- 4:59:54Okay, and it does look like it worked.
- 4:59:56The bottom right says source okay and
- 4:59:57connected. If I come in here and turn on
- 5:00:00live debug mode, I can see the count
- 5:00:02counting up, which is good. I'll grab a
- 5:00:04video real quick here of the front of
- 5:00:06the Opta. So the green light's on and as
- 5:00:09I push the user push button in, I get
- 5:00:11the blue light. So that's great. It's
- 5:00:13online and we're communicating with it.
- 5:00:16We've been in this point a few times
- 5:00:18before, that's not really the new
- 5:00:19content for the video. But this is where
- 5:00:22we're going to start from because now
- 5:00:23it's time to now it's time to add those
- 5:00:26IO expansion modules. And the wiring and
- 5:00:30the IDE, the PLC software side of things
- 5:00:33are both really simple, but it's easiest
- 5:00:35to just do them one at a time. So let's
- 5:00:37go ahead and take a look at the wiring
- 5:00:39really quickly and then we'll look at
- 5:00:41the IDE side really quickly. Now the
- 5:00:43wiring required to get one of these
- 5:00:46expansion modules, again there are three
- 5:00:48and they all look very similar to the
- 5:00:50body of the PLC because they all clip
- 5:00:53into the same chassis.
- 5:00:55It's very simple for wiring. They just
- 5:00:57need their own power feed, which you can
- 5:01:00daisy chain off of the PLC or the card
- 5:01:02right next to it, or you can give it
- 5:01:04dedicated 12-V power.
- 5:01:07But then they have these little slots in
- 5:01:09the side. The PLC has that same slot
- 5:01:11right there. And they need these little
- 5:01:1310-prong I squared C communicators.
- 5:01:16Whoop, I dropped that one. Okay, well
- 5:01:18there's one right here. They need these
- 5:01:20little communicators and they just clip
- 5:01:22in right next to each other, and that's
- 5:01:24how they communicate card to card. And
- 5:01:26we'll see in the IDE once we get these
- 5:01:28clipped in
- 5:01:30that the PLC actually knows what cards
- 5:01:32it's plugged into because of those
- 5:01:34little communication tabs. So that's all
- 5:01:36we have to do is get the power hooked up
- 5:01:38and then get these clipped in together.
- 5:01:39So I'll go ahead and do that now and
- 5:01:41we'll go back to the software side.
- 5:01:43Okay, so I've got them powered up. I've
- 5:01:46got them hooked up to power and I've got
- 5:01:48them communicating down the line, which
- 5:01:51is great. But you can see the lights are
- 5:01:53kind of doing their own thing. Green for
- 5:01:55power is good, definitely means they're
- 5:01:57connected, but the PLC is throwing an
- 5:01:59error because it doesn't know what to do
- 5:02:01with these cards cuz we haven't told it
- 5:02:03what to do from the software yet. So the
- 5:02:05physical wiring very simple to connect
- 5:02:07them. Now we have to look at what to do
- 5:02:09in the PLC IDE to connect them. So if we
- 5:02:12come back into the PLC IDE and we try to
- 5:02:14connect to it,
- 5:02:16well we'll see that because I unplugged
- 5:02:17it.
- 5:02:19Now that we're plugged in, if I just try
- 5:02:20to connect to it again, I'm going to get
- 5:02:22errors
- 5:02:23because it's not in a running state
- 5:02:25because the IO configuration has
- 5:02:27changed. So the PLC has thrown an error.
- 5:02:30If I go to IO expansions and I hit scan,
- 5:02:33this is really cool. It's going to say,
- 5:02:35"Hey, the configuration's not matching."
- 5:02:37And it's going to say, "Hey, I have
- 5:02:38these cards here. Do you want to add
- 5:02:40them?" And I can just hit apply detect
- 5:02:42config. If you hit scan and they're not
- 5:02:45detected, you should double-check your
- 5:02:47wiring because something is probably
- 5:02:49wrong with the physical wiring. But if
- 5:02:51you're sure the wiring is correct, or if
- 5:02:53you're trying to set one of these up
- 5:02:54ahead of time, you can always add a card
- 5:02:56just by right-clicking on IO expansions
- 5:02:59and hit add,
- 5:03:01and you can select the cards and you can
- 5:03:04add them to your project manually. But
- 5:03:06it's a lot easier to scan and then say,
- 5:03:08"Okay, apply the detected config." And
- 5:03:10then it adds the cards as well as all
- 5:03:12the programmable inputs and outputs that
- 5:03:14you can use for those cards. So if we
- 5:03:17take two of the LED channels
- 5:03:19on the first card and we just say
- 5:03:21that'll be light 11, that'll be light
- 5:03:2412. And then I take the relay outputs on
- 5:03:27the second card and I say that'll be
- 5:03:29output 21 and that'll be output 22.
- 5:03:32We'll use those two lights on those two
- 5:03:34cards to do a little bit of programming
- 5:03:37with, okay? So I'm going to go ahead and
- 5:03:39hit save and then I'm going to try to
- 5:03:41download this now that it has these
- 5:03:43cards on it.
- 5:03:44Well, first let's go to the program and
- 5:03:46let's do something.
- 5:03:49Let's say that we also want we just want
- 5:03:52light 11 to be on all of the time and we
- 5:03:57want light 12 to be on when the user
- 5:04:01push button is pressed as well. And then
- 5:04:03let's say the opposite
- 5:04:06for
- 5:04:07the second card. Let's say we want
- 5:04:09output two on all the time and then the
- 5:04:12light for one to come on when the user
- 5:04:14push button is pressed. Okay, so this
- 5:04:17should compile unless I missed
- 5:04:19something, which is possible.
- 5:04:22Build, looks fine. Now let's go ahead
- 5:04:24and download.
- 5:04:25Download, yes. It's okay that it's going
- 5:04:28to want to restart.
- 5:04:29Restarted pretty quick, but there's no
- 5:04:32lights on because the PLC is not
- 5:04:34running, that's an important clue. You
- 5:04:36can go ahead and hit cold restart here,
- 5:04:38the blue circle there, and hit yes. And
- 5:04:41that's cool. That's best-case scenario
- 5:04:44for sure. It's normal to need to power
- 5:04:46cycle at this point. Stuff goes goofy
- 5:04:48sometimes,
- 5:04:49but I have now
- 5:04:51one LED on both of the expansion
- 5:04:54modules. And if I push the push button
- 5:04:57in, you can see the other LED on both
- 5:05:00cards turns on with the blue LED on the
- 5:05:03Opta itself. So that is proof that the
- 5:05:05cards are talking to each other and that
- 5:05:07I can program any input or output
- 5:05:09channels for any of these cards from the
- 5:05:12PLC now and I've got all the
- 5:05:14communication. Okay, so at this point
- 5:05:17you should understand how to get
- 5:05:19expansion modules added to your PLC.
- 5:05:21Like I said in the beginning, they're
- 5:05:23not all this straightforward for all PLC
- 5:05:25manufacturers out there. But Arduino has
- 5:05:28made it really easy to add their
- 5:05:29expansion modules. And it is generally
- 5:05:32the same steps of set the network
- 5:05:34parameters, connect them to your
- 5:05:36network, and then discover them in your
- 5:05:38PLC IDE or related software. Like with
- 5:05:42Siemens, they have TIA Portal, but they
- 5:05:44also have a software called Proneto
- 5:05:46where you can discover and set up
- 5:05:48network parameters for Profinet devices.
- 5:05:51RSLogix, they have Studio 5000, which is
- 5:05:53this integrated software, but they've
- 5:05:55always had this RX RSLinks software
- 5:05:58where you can see network devices and
- 5:06:01you can see remote IO and things like
- 5:06:03that. So there's definitely some
- 5:06:05industry knowledge. It's hard to become
- 5:06:07an expert in every type of remote IO,
- 5:06:10but now you understand the basics of
- 5:06:12adding IO expansion modules to your
- 5:06:14projects, especially for the Arduino
- 5:06:16Opta PLC. I'll have all the hardware I
- 5:06:19used in this tutorial linked in the
- 5:06:21description below this video.
- 5:06:23Let me know of any questions or snags
- 5:06:25that you ran into
- 5:06:27on this video, and let me know what you
- 5:06:29want to see more of next on the channel.
- 5:06:31Thanks so much for watching and see you
- 5:06:33next time. Thanks, bye.
- 5:06:41Welcome back to The Master Tech, and in
- 5:06:42today's video, I'm going to show you how
- 5:06:44to use push buttons and switches for
- 5:06:47industrial controls and automation. I
- 5:06:49will probably skew the topics in this
- 5:06:52video towards applications that might
- 5:06:54involve controls and automation, but
- 5:06:57this also is applicable for anyone who
- 5:06:59wants to use push buttons or switches
- 5:07:01for hobby applications. And far and away
- 5:07:04the most common example of a digital
- 5:07:07on-off input that is used in controls
- 5:07:10and automation and hobby circuitry and
- 5:07:12electronics are the push button and the
- 5:07:15switch. With a push button,
- 5:07:17it's either pushed or it's not pushed.
- 5:07:20With a switch, it's either in position
- 5:07:22one or position two. So today we'll be
- 5:07:25looking at the most common wiring and
- 5:07:27talking about some of the uses and
- 5:07:28applications of push buttons and
- 5:07:30switches for controls, automation, and
- 5:07:33electronics. And a huge thank you to APL
- 5:07:36who provided the hardware we use in this
- 5:07:38video. More about them later in the
- 5:07:40video. Now, let's start with the most
- 5:07:43common type of push button you will see
- 5:07:45anywhere and everywhere, a momentary
- 5:07:48push button. This is a type of device
- 5:07:50that is only going to read a one or high
- 5:07:54or energized when it is actively being
- 5:07:57pushed in. At an absolute minimum, these
- 5:08:00buttons may only have two wires because
- 5:08:03that's all you need to get the effects
- 5:08:05of a push button. It's basically the
- 5:08:08power feed in and then it's broken by a
- 5:08:11strip of metal that is not made until
- 5:08:14you push the button in. When you push
- 5:08:16the button in, power flows into the
- 5:08:18second wire and goes downstream. When
- 5:08:21you have a slightly more advanced button
- 5:08:23that has things like a built-in LED or a
- 5:08:25normally opened and normally closed
- 5:08:27wire, you can do a lot more
- 5:08:29functionality with it. To understand the
- 5:08:31concept of normally open and normally
- 5:08:34closed, it's useful to start from the
- 5:08:36concept of common. On this momentary
- 5:08:39push button in particular, there are
- 5:08:41five wires total. Now, two of them are
- 5:08:43just the power circuit for the LED. So,
- 5:08:46to discuss the controls concept going on
- 5:08:48here, we actually just want to focus on
- 5:08:51the other three wires first. And those
- 5:08:53three wires are common, normally open,
- 5:08:56and normally closed. In our case, we'll
- 5:08:58put our positive power from the 9-V
- 5:09:01battery on the common wire, which is
- 5:09:04green for these buttons. When I'm not
- 5:09:06pushing in my momentary push button, one
- 5:09:09of the wires will read 9 V
- 5:09:12and the other wire will read 0 V.
- 5:09:15The wire that's going to read 9 V when
- 5:09:17it's not being acted upon is the
- 5:09:19normally closed wire, which in this case
- 5:09:22is yellow. The wire that is going to
- 5:09:24only read 9 V when we're pushing the
- 5:09:26button in is the normally open wire or
- 5:09:30blue in this case. So, when you have a
- 5:09:32device that offers you both normally
- 5:09:34open and normally closed feedback, what
- 5:09:37you're saying is there's a wire there
- 5:09:39that will be connected to common until
- 5:09:42you push the button in and then there's
- 5:09:43another wire there that won't be
- 5:09:45connected to common until you push the
- 5:09:48button in. So, for my application, I
- 5:09:50have the ground of the LED pin connected
- 5:09:53to the negative terminal of the battery.
- 5:09:56And then I have the positive terminal of
- 5:09:57the battery connected currently to my
- 5:10:00normally open contact, meaning the light
- 5:10:03will not turn on until I close this
- 5:10:05button. Then, I have the positive power
- 5:10:08from the battery coming into the common
- 5:10:09terminal and currently I don't need any
- 5:10:12purpose for my normally closed contact,
- 5:10:15so I'm just going to cap that off. It's
- 5:10:17not a good idea to leave live copper
- 5:10:19wires around even when you're only
- 5:10:21working with low volt DC. Now, what
- 5:10:24we'll see when I push the button in is
- 5:10:26I'm actually powering the normally open
- 5:10:29wire, which now becomes closed and
- 5:10:31because it's connected to the power of
- 5:10:33the LED, it turns the LED on. To
- 5:10:36understand the difference between the
- 5:10:37normally open wire and the normally
- 5:10:40closed wire, we can just flip which one
- 5:10:43our power LED is connected to. So, the
- 5:10:46red wire, which determines whether or
- 5:10:48not we have the LED powered on, is now
- 5:10:51going to get connected to my yellow
- 5:10:53wire, which correlates to normally
- 5:10:56closed on the button. Because it's
- 5:10:59normally closed, we can see that the LED
- 5:11:01turns on right away and it doesn't turn
- 5:11:03off until I push the button in. In my
- 5:11:06handy-dandy box where I have a whole
- 5:11:08bunch of these hooked up, that's how I
- 5:11:10have both of my momentary push buttons
- 5:11:12hooked up. Now, that's not just a deep
- 5:11:14dive into how momentary push buttons
- 5:11:16work. We also covered the fundamentals
- 5:11:19of how normally open and normally closed
- 5:11:21terminals work. For that reason, we'll
- 5:11:23really be able to fly as we talk through
- 5:11:26the next one, which is a latched push
- 5:11:28button. So, the biggest difference
- 5:11:30between a latching push button and a
- 5:11:32momentary push button is right there in
- 5:11:35the name. With a momentary push button,
- 5:11:37you have to be actively holding and
- 5:11:39affecting the button for it to change
- 5:11:42from a one to a zero. With a latching
- 5:11:45push button, there's an internal and
- 5:11:47rather interesting ratcheting mechanism,
- 5:11:49which will hold it in place until you
- 5:11:51press it again to release it. So,
- 5:11:53effectively, you're getting the
- 5:11:56switching between a one and a zero
- 5:11:58effect that you get with a momentary
- 5:12:00push button when you press it in and
- 5:12:02release it, but it holds its state. So,
- 5:12:05you can put it in one and leave it and
- 5:12:08come back later and put it to a zero.
- 5:12:10So, using the exact same wiring
- 5:12:12configuration that we just had with the
- 5:12:14momentary push button, where the LED was
- 5:12:17connected to the normally closed contact
- 5:12:20and when we push the button in, the LED
- 5:12:22goes off, you can now see that I get the
- 5:12:25same functionality that I was getting
- 5:12:27before by having to hold it, but now I
- 5:12:30can release it and leave it in place.
- 5:12:32So, now with the exact same normally
- 5:12:34open, normally closed configuration, now
- 5:12:36I have the LED connected to the normally
- 5:12:39open terminal. So, once I push the
- 5:12:41button in, the light comes on. When I
- 5:12:43push it again, the light turns off. Now,
- 5:12:46in my opinion, because we're looking at
- 5:12:48a latching push button, that's a good
- 5:12:50chance for us to take a look at pivoting
- 5:12:52into the latching switch. Now, I have a
- 5:12:55couple different types of latching
- 5:12:58switches here on my handy-dandy box. One
- 5:13:01that has no visual indication of whether
- 5:13:04or not it's passing power onward, but
- 5:13:06has two positions, and one that does
- 5:13:10have an LED to show you whether or not
- 5:13:12it's feeding power out of the load line.
- 5:13:15The limitation of these switches, as
- 5:13:16we'll see in a second, is there's only
- 5:13:18one way for you to feed power out. So,
- 5:13:20you don't have the normally open,
- 5:13:22normally closed connections that you do
- 5:13:25actually have with a two-position switch
- 5:13:27like this. So, it's important before
- 5:13:29selecting your hardware for any
- 5:13:31application to think through the use
- 5:13:33case. If you have a switch that is as
- 5:13:35simple as it needs to pass power on, so
- 5:13:40you just want to be able to flick a
- 5:13:41switch and feed power to a bunch of
- 5:13:43devices, flick it back the other way,
- 5:13:46and kill power to those devices,
- 5:13:48something that only has one signal wire
- 5:13:50coming off of it is probably perfectly
- 5:13:53fine. In the case of my switch here, I
- 5:13:55can turn it on and I get the visual
- 5:13:57indication that the LED is on. And in
- 5:13:59this case, I'm actually triggering
- 5:14:01another LED on this push button just as
- 5:14:04an example of how to use the switch. So,
- 5:14:07when I sit here flicking my switch, I'm
- 5:14:10turning not just the LED on this, but
- 5:14:12also the LED on this light on. However,
- 5:14:15a limitation is when I turn it off, the
- 5:14:18light has to turn off. There's no way
- 5:14:21for me to use this light
- 5:14:24to turn on this light in an inverse
- 5:14:27manner, where if I wanted the green
- 5:14:29light to be on while the switch was in a
- 5:14:31de-energized way. Because the switch
- 5:14:34only has one load wire and the other two
- 5:14:37are the power feed, there's no way for
- 5:14:39me to effectively do that. So, if I had
- 5:14:41an application where I needed a switch
- 5:14:43to do one thing in one position and a
- 5:14:45different thing in another position,
- 5:14:48this would not be the right switch to
- 5:14:49select.
- 5:14:50But it does give me visual indication of
- 5:14:53whether or not it's feeding power down
- 5:14:55the line. So, we move on to the selector
- 5:14:58switch that has four terminals on the
- 5:15:01back. And when it has four terminals,
- 5:15:03what it actually has is two sets of
- 5:15:06electrically independent contacts. So,
- 5:15:09when I am in position one on this
- 5:15:11switch, two terminals are being
- 5:15:13connected in the back and the other two
- 5:15:16terminals are not connected to each
- 5:15:18other.
- 5:15:20Then, when I flip the switch into its
- 5:15:22other position, the opposite two
- 5:15:24terminals get connected and the original
- 5:15:26two terminals that were connected are
- 5:15:27now broken. You can see that here by my
- 5:15:30blue and green LEDs that change
- 5:15:34Hopefully, you can see that. That change
- 5:15:36state every time I actuate the switch.
- 5:15:39So, here again, I have not so much
- 5:15:41normally open, normally closed
- 5:15:43configuration, but position one,
- 5:15:46position two. These are very often used
- 5:15:48not just for on-off like I have here,
- 5:15:51where I use my switch to kill power to
- 5:15:54the entire enclosure. I could use it
- 5:15:57where when it's in position one, it
- 5:15:58powers only this half of the box and in
- 5:16:01position two, it powers only this half
- 5:16:03of the box. That would be a normal
- 5:16:05application for it. They do make a
- 5:16:07three-position selector switch as well
- 5:16:09that has the same four terminals on the
- 5:16:11back, but it also has an off position
- 5:16:14where no terminals are being connected.
- 5:16:16The most common use for that would be
- 5:16:18like on a pump. You might see a
- 5:16:19hand-off-auto.
- 5:16:21In hand, the left two terminals might be
- 5:16:24made. In off, no terminals might be
- 5:16:26connected. And then in auto, it might be
- 5:16:29the right two terminals. There are
- 5:16:31definitely more selector switch options
- 5:16:33out there, some of which have eight
- 5:16:35terminals on the back, some have six
- 5:16:37terminals on the back, but far and away
- 5:16:39a two-position selector switch with two
- 5:16:42sets of isolated terminals is the most
- 5:16:45common type that you'll run into and the
- 5:16:47most common type you would need. So,
- 5:16:48just to show one cool variation on the
- 5:16:51two-position selector switch, I also
- 5:16:53wanted to talk about this cool keyed
- 5:16:55selector switch. It's effectively
- 5:16:57exactly the same device as this
- 5:17:00two-position selector switch, but rather
- 5:17:02than being able to be turned by a human
- 5:17:05hand, you have to turn it using the key
- 5:17:07that matches it. And this way, you're
- 5:17:10able to control access to who can power
- 5:17:12up a piece of equipment or machinery
- 5:17:14using a set of keys. In this case, too,
- 5:17:17the key is actually locked in the device
- 5:17:19while it's on. So, you can't turn
- 5:17:21something on and walk away with the
- 5:17:23keys. Anyone has the ability to turn it
- 5:17:26back off and then you can take the keys
- 5:17:28away. This is a safety measure to make
- 5:17:31sure that anybody is able to deactivate
- 5:17:33a piece of equipment if they feel it's
- 5:17:35unsafe. It's not incredibly common to
- 5:17:37see these, but it is an interesting and
- 5:17:40useful to know about variation on the
- 5:17:42selector switch. The last and most
- 5:17:44important maybe piece of equipment in
- 5:17:46industrial controls and automation that
- 5:17:48I want to talk about that is really just
- 5:17:50another form of a latching push button
- 5:17:53is the e-stop. And the purpose of an
- 5:17:56e-stop is really to kill power to an
- 5:17:58application. Some e-stops do have
- 5:18:01terminals and feedback to a PLC or a
- 5:18:04controller or a stack light to let you
- 5:18:06know that they have been pressed, but
- 5:18:09typically the main reason you hit an
- 5:18:11e-stop is something is wrong and you
- 5:18:14want to kill power to a device or at a
- 5:18:16minimum put it in a safe state. Wiring
- 5:18:19and functionality-wise, you everything
- 5:18:21we discussed about momentary push
- 5:18:23buttons still applies here, but
- 5:18:25typically there's an extra motion like a
- 5:18:27twisting motion or a hard pull to
- 5:18:30release an e-stop when it gets pressed.
- 5:18:33It's supposed to be easy to press in
- 5:18:36to put things back into a safe state and
- 5:18:38require effort and intentionality to
- 5:18:40release and put back into an operational
- 5:18:43state. But, it's a super useful piece of
- 5:18:46equipment to know about, especially if
- 5:18:47you're in the world of automation or
- 5:18:49controls. Well, I know at first glance
- 5:18:52how to use push buttons and switches can
- 5:18:54seem really intuitive or like a basic
- 5:18:56concept, but it's actually one of the
- 5:18:58most important fundamental things to get
- 5:19:00down if you want to be doing industrial
- 5:19:03controls and automation or hobby
- 5:19:05electronics and building with robotics
- 5:19:07at home. The topics and concepts covered
- 5:19:09here will serve you great not just as
- 5:19:12you build physical things, but it also
- 5:19:14helps you think through logic and how
- 5:19:16programming using normally open and
- 5:19:18normally closed conditions work as well.
- 5:19:20As always, good luck with your projects.
- 5:19:22Thank you for watching and we'll see you
- 5:19:24next time. Thanks. Bye.
About this transcript
This page contains the full transcript of Intro to Controls and Automation Engineering Full Course! by LeMaster Tech, generated from the public captions YouTube serves with the video. The transcript has 56,610 words across 8,222 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.