YouTube2Text

Intro to Controls and Automation Engineering Full Course! — Transcript

by LeMaster Tech · 56,610 words · 8,222 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hi, I'm Pete LeMaster, creator of the
  2. 0:02LeMaster Tech YouTube channel, and for
  3. 0:04the last 10 years, I've been working in
  4. 0:06industrial automation and controls
  5. 0:08engineering. This is a field I feel very
  6. 0:10passionately about. It's an often
  7. 0:12overlooked or seldom talked about in
  8. 0:14university field of engineering. It's
  9. 0:16adjacent to what some may call
  10. 0:18mechatronics or robotics, but in
  11. 0:21particular, it's in an industrial
  12. 0:23setting, and it's the hidden backbone
  13. 0:24driving all of manufacturing forward
  14. 0:27worldwide. Last 4 years since starting
  15. 0:30my YouTube channel, I've slowly been
  16. 0:31trickling certain videos and tutorials
  17. 0:34on this field out on the channel, but
  18. 0:36never really painted a comprehensive
  19. 0:38picture of a crash course start here how
  20. 0:41to become and how to learn about
  21. 0:43controls and automation engineering.
  22. 0:45Until now. In this tutorial series, we
  23. 0:47mix talking about concepts with actual
  24. 0:50practical hands-on exercises using free
  25. 0:53software and very affordable hardware,
  26. 0:56so that you can learn about PLC
  27. 0:58programming, SCADA and HMI development,
  28. 1:01SQL and historian, electrical
  29. 1:02schematics, in an approachable and
  30. 1:05affordable way. This video is a
  31. 1:0717-chapter video, and while I do believe
  32. 1:10they play logically back to back, you do
  33. 1:12not need to watch the entire 5-plus hour
  34. 1:15video in one sitting. You don't have to
  35. 1:18watch it in order if you find more value
  36. 1:20in certain concepts than others.
  37. 1:22There'll be timestamps and chapters
  38. 1:23breaking up everything as you go. The 17
  39. 1:26videos were recorded over the past 4
  40. 1:28years since I started my YouTube
  41. 1:30channel. While I do think they play in a
  42. 1:32logical order, not be always the
  43. 1:34smoothest flow between one video and the
  44. 1:36next. By the end of this video, you
  45. 1:38should have a really great comprehensive
  46. 1:41understanding of the basic concepts of
  47. 1:43what is controls and automation
  48. 1:45engineering, feel confident that you've
  49. 1:47been exposed to the basic concepts of
  50. 1:49the field, and feel empowered to go out
  51. 1:51and further your depth of knowledge in
  52. 1:53the field. It's an incredibly important
  53. 1:55field of engineering. I feel very
  54. 1:56passionately about it, and I'm very
  55. 1:58excited to bring you this series.
  56. 2:00useful, please consider leaving a like
  57. 2:02on the video, subscribe to LeMaster Tech
  58. 2:04on YouTube, and thank you so much for
  59. 2:06watching. Enjoy the series.
  60. 2:14By the end of this course, you should
  61. 2:16have an excellent understanding of what
  62. 2:18controls and automation is. You should
  63. 2:20also be pretty familiar with what
  64. 2:22industries and companies would be
  65. 2:23looking for these skills and trades, be
  66. 2:25equipped to know whether getting into a
  67. 2:27career in this field or an education in
  68. 2:29this field is something that would
  69. 2:30interest you. And lastly, you should
  70. 2:32feel very equipped to know the right
  71. 2:34ways to get more information if you're
  72. 2:36curious in pursuing this field further.
  73. 2:39So, for episode 1, introduction to
  74. 2:41controls and automation engineering
  75. 2:42today, what we're going to cover is what
  76. 2:44controls and automation engineering is,
  77. 2:46the tools and technologies as well as
  78. 2:48some lingo that you'll need to know, the
  79. 2:50biggest industries that need automation,
  80. 2:52average salary ranges you can expect.
  81. 2:54So, if you're completely new to the
  82. 2:55field, in just a few sentences, what is
  83. 2:58controls and automation engineering? In
  84. 3:00my words, it's the field of engineering
  85. 3:02pertaining to improvements to a process
  86. 3:04by increasing throughput and
  87. 3:06manufacturing speed, increasing safety
  88. 3:08and system reliability, or both.
  89. 3:12And this is most commonly achieved by
  90. 3:14writing code for a dedicated industrial
  91. 3:16computer known as a programmable logic
  92. 3:19controller or PLC that controls input
  93. 3:21and output devices referred to as IO,
  94. 3:24and often interfacing with the engineers
  95. 3:27and operators through a human-machine
  96. 3:29interface or HMI. There's a little bit
  97. 3:31of industry lingo in there, but the
  98. 3:33essence of it is we make things faster,
  99. 3:35higher quality, or safer. And ideally,
  100. 3:38we would do all three. So, bit of a
  101. 3:40funny meme here, um but I think it's
  102. 3:42actually super applicable. A controls
  103. 3:44and automation engineer most commonly is
  104. 3:46not something you go to school for, at
  105. 3:49least not specifically for. You have to
  106. 3:51have enough mechanical or chemical
  107. 3:53knowledge to be able to be helpful in
  108. 3:56the process that you're automating, but
  109. 3:58you also have to have enough electrical
  110. 3:59engineering knowledge that you'll know
  111. 4:00what you're doing with a panel design
  112. 4:02schematic. But you're also going to have
  113. 4:04to be enough of a software developer,
  114. 4:06computer science engineer to be able to
  115. 4:08write some functional, elegant, easy to
  116. 4:11read, and easy to debug PLC code. And on
  117. 4:13top of all of that, you're going to need
  118. 4:15to dip your toes in the IT field of
  119. 4:16knowing a little bit about industrial
  120. 4:18networking. And it's not that you have
  121. 4:20to enter the field with all of these
  122. 4:21skills, but you should enter the field
  123. 4:24with some of them and be ready to learn
  124. 4:26the rest of them. So, some of the key
  125. 4:27technologies and tools of the trade,
  126. 4:29words that you will absolutely need to
  127. 4:31be familiar with if you have any
  128. 4:32interest in getting into this field or
  129. 4:34knowing about the field. The
  130. 4:35programmable logic controller, the PLC.
  131. 4:38There are definitely some industries
  132. 4:40moving towards an industrial PC, which
  133. 4:42is just like a really robust computer
  134. 4:44running Windows sometimes, or even some
  135. 4:47smaller automation systems now relying
  136. 4:50on microcontrollers like a Raspberry Pi
  137. 4:52or an Arduino if it's a really simple
  138. 4:54application. But far and away, the
  139. 4:56industry standard for years and years,
  140. 4:58and likely continuing for years and
  141. 5:00years to come, is the programmable logic
  142. 5:02controller. There are so many
  143. 5:04manufacturers of PLCs. The biggest ones,
  144. 5:07and if you're in the US, the ones you'll
  145. 5:08almost certainly get exposed to at some
  146. 5:10point, Allen-Bradley, Rockwell, ABB.
  147. 5:13Those are kind of three of the giants,
  148. 5:15but there are so many companies that
  149. 5:17make PLCs as well. Mitsubishi,
  150. 5:19Panasonic, Wago, um to name a few.
  151. 5:23There's There's more. And so, a PLC is a
  152. 5:26specific type of computer optimized for
  153. 5:29high reliability, synchronous
  154. 5:31programming, meaning time-cycled code,
  155. 5:34and converting commands to electrical
  156. 5:36signals to control devices known as
  157. 5:38outputs, and read electrical signals
  158. 5:41back from devices known as inputs.
  159. 5:43Specific programming languages exist to
  160. 5:46write code for these PLCs. The most
  161. 5:48common two, and the two that you should
  162. 5:49have on your radar right off the bat,
  163. 5:51are ladder logic and structured text.
  164. 5:54Ladder logic looks a lot like relays and
  165. 5:57kind of an electrical-based programming
  166. 5:59language. It's very visual. It's like a
  167. 6:01flowchart, um that combines programming
  168. 6:04concepts with electrical concepts. And
  169. 6:06structured text is somewhere between
  170. 6:08like a C++ C# Python hybrid, more of a
  171. 6:12traditional programming language to
  172. 6:14where people with a software background
  173. 6:16often feel more comfortable writing in
  174. 6:17structured text. People with a
  175. 6:19mechanical or electrical background
  176. 6:21often pick up ladder logic. But to talk
  177. 6:23a little more about input and output
  178. 6:25devices, there are really only two types
  179. 6:27of input and output devices here, and
  180. 6:29I'm simplifying, but this is a crash
  181. 6:31course. Digital inputs and outputs are
  182. 6:33also known as discrete, Boolean, on-off,
  183. 6:38binary. Think just a simple light
  184. 6:41switch, an on-off light switch where the
  185. 6:43light bulb turns on or turns off. It's
  186. 6:46only two states, and examples of this in
  187. 6:49the field could be a start-stop pump or
  188. 6:51motor, a valve that is open or closed,
  189. 6:55and information back like a light that
  190. 6:58is either on or off, a push button that
  191. 7:00is either pressed or not pressed.
  192. 7:02Discrete, digital, on-off, or analog
  193. 7:06inputs and outputs, aka variable range,
  194. 7:090 to 100% position control. And for
  195. 7:12this, you can think of like a dimmer
  196. 7:14switch in your home where there's a 0 to
  197. 7:16100% setting, and the variable range is
  198. 7:20known as analog. So, in process, the
  199. 7:23most common ones you might see for
  200. 7:24inputs are like temperature sensors,
  201. 7:27flow sensors, pressure sensors. And the
  202. 7:29most common outputs you might see are
  203. 7:31like uh pumps that can ramp up in speed
  204. 7:34known as variable frequency drives, or
  205. 7:37motors that have adjustable speed
  206. 7:38parameters, or 0 to 100% open control
  207. 7:41valves. And a lot of devices now are
  208. 7:43smart enough to actually use an advanced
  209. 7:45communication protocol like Ethernet,
  210. 7:48EtherCAT, Profinet, Modbus TCP/IP, just
  211. 7:52to name a few. There are a lot of
  212. 7:53others, but even when you boil it down,
  213. 7:56if they are talking over those advanced
  214. 7:58communication protocols, the end devices
  215. 8:00you're interfacing with still typically
  216. 8:02fall into either digital or analog.
  217. 8:05Determining what type of IO you have and
  218. 8:07how many total points you have typically
  219. 8:09is one of the key drivers in a lot of
  220. 8:11the hardware decisions you'll make in a
  221. 8:13project. And one of the last huge things
  222. 8:16you need to be aware of is the
  223. 8:17human-machine interface or HMI. Some
  224. 8:20very simple systems might be
  225. 8:22controllable just from a few push
  226. 8:24buttons or indicator lights, and not
  227. 8:26actually require custom graphics to be
  228. 8:28made, but the vast majority of
  229. 8:30automation systems are going to require
  230. 8:33well-designed, simple, and easy to use
  231. 8:35HMI graphics. Software developers and
  232. 8:38people with a programming background
  233. 8:40might think of these as GUIs or
  234. 8:41graphical user interfaces, but in the
  235. 8:44industry world, because you're
  236. 8:45controlling machines, the phrase
  237. 8:47human-machine interface or HMI is
  238. 8:49typically used more often. And these can
  239. 8:51range from simple displays with a few
  240. 8:53buttons or device statuses to super
  241. 8:56complicated plant overviews with
  242. 8:58thousands of data points being pulled
  243. 8:59back in. A standalone HMI, a very simple
  244. 9:02display, could be used to control one
  245. 9:04piece of equipment, sometimes called a
  246. 9:06skid, but a complicated graphical
  247. 9:08display environment with embedded
  248. 9:10trending and alarms and security is
  249. 9:13typically going to fall more in the
  250. 9:15category of a SCADA or supervisory
  251. 9:18control and data acquisition system.
  252. 9:20Which brings us to the supervisory
  253. 9:22control and data acquisition system.
  254. 9:24Plus, we're going to talk about the
  255. 9:26whole automation pyramid thing. This is
  256. 9:27kind of a very important concept that's
  257. 9:30really a lot of jargon, but it does
  258. 9:32actually hold true for the industry.
  259. 9:35Supervisory control and data acquisition
  260. 9:37system, more commonly called a SCADA, is
  261. 9:39like a blend of the HMI that allows
  262. 9:42operators to interface and control with
  263. 9:44devices, but also like a corporate
  264. 9:46software tool that can pass data up to a
  265. 9:49data aggregation system. But what you
  266. 9:51need to know about the automation
  267. 9:52pyramid is basically every control
  268. 9:54system has the lowest two levels, the
  269. 9:56field level, meaning devices that are
  270. 9:59being controlled and giving you
  271. 10:00feedback, and the control level, which
  272. 10:02is like where your PLCs and smart
  273. 10:04devices and switches and networking
  274. 10:06live. And then very often a plant or a
  275. 10:08system will stop at the supervisory
  276. 10:10level. So a SCADA might be as high as a
  277. 10:13plant goes. Not everyone has an ERP
  278. 10:16controlling production, and not everyone
  279. 10:18has an MES for data aggregation, but
  280. 10:20that is technically the automation
  281. 10:22pyramid. That's enough about that for
  282. 10:24now. Let's move on. Other things to keep
  283. 10:27on your radar, we're not going to do a
  284. 10:28deep dive in episode one. Industrial
  285. 10:30networking standards and protocols are
  286. 10:32very important. Basics of servers,
  287. 10:34operating systems, and
  288. 10:36computer-to-computer communications are
  289. 10:38super important as well. Industrial
  290. 10:40control panel design and electrical
  291. 10:42schematics, we talked about this a
  292. 10:43little bit earlier, but that is
  293. 10:44guaranteed to come up in a career as an
  294. 10:47automation engineer. Data reporting and
  295. 10:49logging, historian, SQL database,
  296. 10:51creating Power BI reports and trends,
  297. 10:54these types of things are also super
  298. 10:56important, and there's so much more, but
  299. 10:58not for lesson one. So now you know a
  300. 11:00little bit about what it is, but is this
  301. 11:02in demand? Where could you work if you
  302. 11:04did this? And I honestly encourage you
  303. 11:06if you're curious about that, to spend a
  304. 11:07little time on LinkedIn or just Google
  305. 11:10poking around and seeing if your
  306. 11:11favorite companies need an automation
  307. 11:13engineer. Because if you just type in
  308. 11:15blank company automation and controls
  309. 11:18engineer, odds are something is going to
  310. 11:20pop up. They're very in demand, and
  311. 11:22because it's a slightly more niche field
  312. 11:24of engineering, if you have some of
  313. 11:26these skills, a lot of the time you can
  314. 11:29get an interview and get your foot in
  315. 11:30the door with some pretty big companies
  316. 11:32pretty quickly. While most of the time
  317. 11:34this job is not going to be fully
  318. 11:35remote, there are definitely a lot of
  319. 11:37hybrid opportunities out there in pretty
  320. 11:39much every city in the world and every
  321. 11:41company in the world to some extent that
  322. 11:43does manufacturing or anything
  323. 11:45industrial will need some automation and
  324. 11:47controls engineering. So if you're
  325. 11:49heading to school and you're thinking
  326. 11:51about getting this field or you're an
  327. 11:52undecided major of engineering, and
  328. 11:54you're thinking about going to this
  329. 11:56field, should you go specifically for
  330. 11:59controls and automation engineering? I
  331. 12:01would actually say not really. It's just
  332. 12:04my advice, and you do not have to take
  333. 12:06it, but I think getting a mechanical
  334. 12:08engineering degree, an electrical
  335. 12:10engineering degree, a computer science
  336. 12:12degree, a broad field of engineering
  337. 12:14degree, and focusing on electives,
  338. 12:17school projects, and internships or
  339. 12:19co-ops that help get you in this
  340. 12:21direction is actually probably going to
  341. 12:23be better for you in the long run, than
  342. 12:26looking for a hyper-focused degree like
  343. 12:28controls and automation engineering. I'm
  344. 12:30not saying you won't love the field of
  345. 12:31controls and automation engineering, but
  346. 12:33I am trying to say that a mechanical
  347. 12:35engineer who wants to get into controls
  348. 12:38can usually do it. A controls engineer
  349. 12:40who wants to go be a mechanical engineer
  350. 12:43can't usually just make that switch. And
  351. 12:45most places are looking for individuals
  352. 12:48with a four-year engineering degree for
  353. 12:49their automation and controls
  354. 12:51engineering roles, but they're usually
  355. 12:53very open as to what specific
  356. 12:55engineering discipline those people
  357. 12:57have. They're far more focused on
  358. 12:58finding driven and motivated individuals
  359. 13:01with some practical on-hand knowledge.
  360. 13:03So if you are an automation and controls
  361. 13:05engineer, what can you kind of expect
  362. 13:07your career path to look like? And the
  363. 13:09two most common types of controls and
  364. 13:11automation engineer are either an
  365. 13:13integrator or an internal resource to a
  366. 13:16company. And an integrator is
  367. 13:18essentially an engineering contractor.
  368. 13:20There are a lot of companies that don't
  369. 13:22have the internal resources to do
  370. 13:24large-scale automation upgrades and
  371. 13:26projects on their own. So companies like
  372. 13:28RoviSys, my first job, uh and other
  373. 13:31similar companies will be called into a
  374. 13:33big factory to do a large automation
  375. 13:36project. Integration can be very
  376. 13:38intense. It's project-driven, so a lot
  377. 13:40of the time there will be slower periods
  378. 13:42as you develop systems in the office,
  379. 13:45and then very intense periods of travel
  380. 13:47and long hours as you commission systems
  381. 13:50on site. But these organizations are
  382. 13:52often very focused on controls and
  383. 13:54automation, and they promote from
  384. 13:55within. So if your main goal is to rise
  385. 13:58to the top of a company, you might want
  386. 14:00to look for a company that is primarily
  387. 14:02engineers doing what you're doing,
  388. 14:04because your odds of making it to
  389. 14:05manager, director, senior levels are
  390. 14:08probably better at an integrator. But on
  391. 14:10the flip side, as an internal resource,
  392. 14:12there's often a much smaller team of
  393. 14:14automation and controls engineers. A lot
  394. 14:16of the time that comes with larger
  395. 14:18responsibility, or more people looking
  396. 14:21to you to take on whole system
  397. 14:23ownership. At my second company, I was
  398. 14:25one of two controls engineers and the
  399. 14:26only one on site, so anytime an
  400. 14:28opportunity for automation or controls
  401. 14:30arose, it was on my shoulders. This was
  402. 14:33a mix of awesome responsibility and
  403. 14:35quite a bit of stress. But these
  404. 14:37organizations could be larger and much
  405. 14:39broader than just an automation firm,
  406. 14:42and for that reason, you could get tied
  407. 14:44up in your career path in layers of
  408. 14:46bureaucracy, and find yourself kind of
  409. 14:48stalled as a senior engineer unable to
  410. 14:50move into management or break any
  411. 14:52higher, because you're at a company that
  412. 14:55does a lot of different things, not just
  413. 14:56automation. So now let's take a look at
  414. 14:58salaries and typical controls and
  415. 15:01automation engineering salaries. I want
  416. 15:03to caveat this with I am talking about
  417. 15:05US-based. I don't have a good
  418. 15:07understanding of the international
  419. 15:09salary ranges and how they vary. If
  420. 15:11you've had a wildly different
  421. 15:12experience, higher or lower, let me know
  422. 15:15about it in the comments below. So most
  423. 15:17interns and co-ops in this position are
  424. 15:20finding paid internships. They're kind
  425. 15:22of on the low end. The Midwest, maybe
  426. 15:24the lower markets for this field, might
  427. 15:27find 16, 17, the high teens per hour,
  428. 15:30but there are internships paying in the
  429. 15:32high 20s as well. Most new full-time
  430. 15:35hires right out of school with an
  431. 15:37engineering degree doing automation and
  432. 15:39controls engineering can expect to be
  433. 15:41around the $70,000 benchmark. There are
  434. 15:44definitely companies hiring higher than
  435. 15:46that, sort of right on par with the
  436. 15:48average of most engineering disciplines
  437. 15:50right now in the US. Once you're in the
  438. 15:51middle of your career and you've been
  439. 15:53technical for 5 to 10 years, you can
  440. 15:55kind of know you're at a decent spot
  441. 15:57right now if you're around the $90,000
  442. 16:00mark. Now as you get kind of beyond the
  443. 16:0210-plus years, there's kind of two paths
  444. 16:04at this point. You've entered management
  445. 16:07and you're like an engineering manager
  446. 16:08or director, or you're still technical
  447. 16:11like as a senior or lead engineer.
  448. 16:13Technical resources typically just make
  449. 16:16less money than management resources.
  450. 16:18That's the nature of industry. But even
  451. 16:20as a technical resource, once you're in
  452. 16:22kind of deep into your career, 10 or
  453. 16:24more years, you should be finding
  454. 16:26yourself into six figures in 2024. I
  455. 16:29consistently found that mid-career
  456. 16:32controls and automation engineers were
  457. 16:34averaging around $110,000.
  458. 16:36And this is where the ranges start to
  459. 16:39get really wide. And of course, if
  460. 16:40you're an engineering manager or
  461. 16:42director, you can expect to be outpacing
  462. 16:44that a little bit. Again, some things
  463. 16:46like stock incentives and bonuses cannot
  464. 16:48really be captured in these numbers, but
  465. 16:51if you're in management and automation
  466. 16:53controls engineer, you can expect that
  467. 16:55you'll be doing pretty well. But kind of
  468. 16:57a truth of engineering is that you'll do
  469. 17:00very well for yourself, and it's not a
  470. 17:02path to instant and immediate riches. So
  471. 17:05it's a great salary, it's a good field
  472. 17:07option, but it might not be the single
  473. 17:09highest-earning field that you could go
  474. 17:11into. And so that pretty much wraps up
  475. 17:13episode one, introduction to controls
  476. 17:15and automation engineering. And I wanted
  477. 17:17to finish some free and cheap ways to
  478. 17:20learn more about the field. I have to
  479. 17:22first plug the RealPars YouTube channel.
  480. 17:25It's kind of funny as a YouTube channel
  481. 17:26to tell you to go watch a different
  482. 17:28YouTube channel, but they have so many
  483. 17:30short videos on just individual concepts
  484. 17:34of controls and automation engineering.
  485. 17:36Almost their entire page is dedicated to
  486. 17:38controls. They have really compelling
  487. 17:41animations. They're not sponsoring the
  488. 17:43channel. I'm not being asked to plug
  489. 17:45them or anything. Um they're just a
  490. 17:47really good YouTube channel. If you
  491. 17:48search anything like what is a PLC,
  492. 17:51they're probably going to be the top or
  493. 17:52one of the top results. I really like
  494. 17:54the RealPars YouTube channel. We'll see
  495. 17:56you next time. Good luck with your
  496. 17:57projects. Thanks for watching. Bye.
  497. 18:05In today's video, I'm going to show you
  498. 18:07the basics of the most important
  499. 18:09components of controls and automation
  500. 18:11hardware. In this video, we're going to
  501. 18:13cover everything from main power coming
  502. 18:15into a panel to power supplies and
  503. 18:18transformers to terminal blocks. Then
  504. 18:20we'll look at the PLCs including inputs
  505. 18:22and outputs, as well as relays and
  506. 18:25networking components. There's no way to
  507. 18:27cover all of the intricacies you could
  508. 18:29see in controls and automation hardware
  509. 18:30in one video, but this video should
  510. 18:32hopefully give you a basic understanding
  511. 18:34of most of the core components you'll
  512. 18:37find everywhere in controls and
  513. 18:38automation engineering. So without any
  514. 18:40further ado, let's dive right into
  515. 18:42looking at a lot of these core
  516. 18:43components. First thing you'll probably
  517. 18:45notice is that every component I have is
  518. 18:47mounted to this specific bent piece of
  519. 18:50metal that's called DIN rail.
  520. 18:56Okay, and DIN rail, D I N rail, is a
  521. 18:59specific standardized type of metal that
  522. 19:02is bent at a specific angle for controls
  523. 19:05and automation components to be able to
  524. 19:06easily clip on and unclip from it.
  525. 19:09Anytime you're searching for a component
  526. 19:11and you want to mount it in a controls
  527. 19:13cabinet, it's a good idea to look up a
  528. 19:15DIN rail mountable power supply, DIN
  529. 19:18rail mountable PLC. And ordinarily, all
  530. 19:21of the components you see here would be
  531. 19:22inside an industrial control panel, but
  532. 19:25I want to showcase a lot of it to you,
  533. 19:27so it's easier to just have it on a
  534. 19:28backer plane. Now, let's take a look at
  535. 19:30the power into this cabinet.
  536. 19:37I have it on this specific small piece
  537. 19:39of DIN rail just so that I could zip tie
  538. 19:41it for some cable management, but
  539. 19:42basically I take a 120-V
  540. 19:45power into the cabinet. If you have
  541. 19:47larger components like motor starters
  542. 19:49that might require three-phase power
  543. 19:51like 480 volts, you would need something
  544. 19:54a little heavier duty than what I have.
  545. 19:56But since I'm just dealing with 120
  546. 19:58voltage or household outlet voltage,
  547. 20:00it's okay to just have it come in and
  548. 20:02land on our next components. Which
  549. 20:04brings us to the next component, which
  550. 20:06is the circuit breaker.
  551. 20:12Circuit breaker, which can sometimes be
  552. 20:14replaced with a fuse, is meant to be
  553. 20:16your panel's local protection against
  554. 20:19overcurrent. There's a lot more than we
  555. 20:20can cover in this video on properly
  556. 20:22protecting all of your components from
  557. 20:24short circuits. But you should
  558. 20:26definitely be aware that basically every
  559. 20:28industrial control cabinet is either
  560. 20:30going to have circuit breakers or fuse
  561. 20:32terminal blocks for the main power
  562. 20:34coming into your enclosure. Next
  563. 20:36component you see here is the 24-V DC
  564. 20:39power supply.
  565. 20:45This is a really critical component
  566. 20:47because in modern industrial controls
  567. 20:49and automation, you see less and less
  568. 20:51stuff getting powered off of AC voltage.
  569. 20:53Low voltage is inherently safer, so
  570. 20:55dealing with DC is safer than dealing
  571. 20:58with AC in almost every application. And
  572. 21:01since the industry is moving towards DC
  573. 21:03voltage applications, you need a power
  574. 21:05supply that can step down AC to DC.
  575. 21:08Next, hopefully you see these wires
  576. 21:10coming out of the power supply, and I
  577. 21:12have them landing on these blocks here,
  578. 21:14which are distributing the power to
  579. 21:16multiple zones. These are called
  580. 21:18terminal blocks.
  581. 21:24And I have a whole bunch of spares over
  582. 21:25here. And what you can kind of see is
  583. 21:28that there's ordinarily plain gray or
  584. 21:30white or black, like a plain color. And
  585. 21:32those are just meant to be somewhere
  586. 21:34that you can land wires on one side and
  587. 21:37a partner wire on the other side of the
  588. 21:39same terminal block. You can think of
  589. 21:41them like industrially rated wire nuts.
  590. 21:43It's a spot where two different wires,
  591. 21:46or sometimes more than two wires, meet
  592. 21:48up and it's best used for organization
  593. 21:51and keeping your cables manageable. It
  594. 21:53also can let you land inputs and outputs
  595. 21:56from a PLC on terminal strips in your
  596. 21:59panel, and then you have somewhere to
  597. 22:01land the wires that come from the actual
  598. 22:02devices in the field. So terminal blocks
  599. 22:05are super important. Green ones
  600. 22:07ordinarily correspond with a ground
  601. 22:09wire. Some variations on these, you can
  602. 22:11find some that you lift up and they have
  603. 22:13a fuse in them. These are known as
  604. 22:15fusible terminal blocks, which offer you
  605. 22:17an additional level of built-in
  606. 22:19overcurrent protection. You can also
  607. 22:20find two-tier terminal blocks, which
  608. 22:22have two completely independent circuits
  609. 22:24that you can use. These are great for
  610. 22:26very dense panels. And a lot of the
  611. 22:28times you can find terminal blocks with
  612. 22:29three or four multi-connections. These
  613. 22:32are really great for things like power
  614. 22:33disbursement or anywhere that you need
  615. 22:35one signal in a lot of places. Okay, the
  616. 22:37next thing we're going to zero in on
  617. 22:39real quick here are relays.
  618. 22:45In a time before PLCs, most of
  619. 22:48industrial controls was done using
  620. 22:50relays. They didn't always look exactly
  621. 22:52like this, but basically what a relay is
  622. 22:55something that can take an input
  623. 22:57electrical signal and transform that to
  624. 22:59an output of either normally open or
  625. 23:01normally closed wiring. And that output
  626. 23:03signal can be completely electrically
  627. 23:06isolated from the input. So for example,
  628. 23:08the relays I have on here can be turned
  629. 23:10on and off using a 24-V signal, but they
  630. 23:14can be used to control 120-V outputs.
  631. 23:17Now, in modern times, it's very unusual
  632. 23:19to see more than basic logic being done
  633. 23:22with relays. And the reason for that is
  634. 23:24the PLC.
  635. 23:30Programmable logic controller is able to
  636. 23:32read statuses into the device and
  637. 23:35control the status of field devices.
  638. 23:38When it reads something into it, it's
  639. 23:40known as an input. When it controls
  640. 23:43something going out from it, it's known
  641. 23:45as an output. If you're familiar with
  642. 23:47Arduinos or hobby electronics, you're
  643. 23:50probably familiar with this terminology.
  644. 23:51So PLCs are able to be programmed,
  645. 23:54typically using the five IEC 61131
  646. 23:58programming languages. That numbering
  647. 24:00and acronym and abbreviation is a little
  648. 24:02bit unnecessary. Basically, the two most
  649. 24:05prevalent PLC programming languages are
  650. 24:07ladder logic and structured text. Ladder
  651. 24:10logic looks a lot like reading an
  652. 24:11electrical schematic, while structured
  653. 24:13text looks a lot like a conventional
  654. 24:15programming language. I've done entire
  655. 24:17past videos on these programming
  656. 24:19languages and we'll be covering them
  657. 24:20more in coming videos. So for the
  658. 24:22specific example I have here, I just
  659. 24:25have one input and one output hooked up
  660. 24:27to my PLC. And so for my input, I just
  661. 24:30have a simple push button. And when I
  662. 24:31press it, my PLC receives 24 volts on
  663. 24:34that channel saying it's energized. And
  664. 24:37when I release it, my PLC receives zero
  665. 24:39volts saying it's de-energized. For my
  666. 24:41output, I have a conventional work
  667. 24:44light, just to kind of show you that
  668. 24:46anything can be used as an output. If
  669. 24:48it's controllable in some way from
  670. 24:50electricity, it can be a PLC output. For
  671. 24:53this specific application, to show using
  672. 24:56a few different pieces of electronics, I
  673. 24:58have the output signal from my PLC
  674. 25:00coming into a relay. So the PLC is
  675. 25:03outputting 24 volts, and then on the
  676. 25:06other side of the relay, when this turns
  677. 25:08on, you can see a little green LED right
  678. 25:10here. And that's when 120 volts makes
  679. 25:13connection with the wire going to the
  680. 25:14light. So, my input of a push button
  681. 25:18tells the PLC, "Hey, I see this input. I
  682. 25:21programmed it to turn on that output
  683. 25:24when it sees the push button." So, I
  684. 25:26press the button,
  685. 25:27it turns on the output channel from the
  686. 25:29PLC because of code that I wrote, which
  687. 25:32activates this relay because now it's
  688. 25:34getting 24 volts, which connects this
  689. 25:36120-V signal to the light. This specific
  690. 25:40application, it's obviously unnecessary
  691. 25:42to use the relay and the PLC in this
  692. 25:45circuit because a simple push button
  693. 25:47turning on and off a light on its own is
  694. 25:49not a great use case for a PLC and
  695. 25:52industrial automation. But the purpose
  696. 25:54of this video is to show you the
  697. 25:55hardware, not necessarily build an
  698. 25:57advanced automation and controls
  699. 25:59project. The last component I think it's
  700. 26:01important to cover today because it
  701. 26:02comes up in almost every industrial
  702. 26:04controls and automation scenario is the
  703. 26:06switch. In this case, I have an
  704. 26:08eight-port Ethernet-compatible switch,
  705. 26:11which would allow me to connect things
  706. 26:12like my PLC or smart hardware like a VFD
  707. 26:16or variable frequency drive or any other
  708. 26:18networked components back to a master
  709. 26:21controller or my main laptop, which
  710. 26:23could be reading statuses from them,
  711. 26:25storing data in SQL, displaying values
  712. 26:27on an HMI, and things like that. Now,
  713. 26:30some of the most important components
  714. 26:32that we're not covering in this video
  715. 26:33are things like motor starters, VFDs or
  716. 26:36variable frequency drives, and HMIs or
  717. 26:39human-machine interfaces, which for the
  718. 26:41programmers out there can be thought of
  719. 26:43as the GUI or graphical user interface
  720. 26:46specifically for industrial controls and
  721. 26:48automation. But to speed recap what
  722. 26:50you've seen here, we've seen the main
  723. 26:52power supply come into a panel, which
  724. 26:54passes through a circuit breaker for
  725. 26:56overload protection, then goes into a
  726. 26:5824-V power supply, which then goes into
  727. 27:01terminal blocks for my power
  728. 27:03distribution, and then that powers my
  729. 27:05PLC. It also powers things like my
  730. 27:08relay, my switch, and it can be spread
  731. 27:10out using terminal blocks. Everything is
  732. 27:12mounted on DIN rail. When you need to
  733. 27:14convert signals from one type of voltage
  734. 27:17to another, you need to look for relays.
  735. 27:19And when you need to network lots of
  736. 27:21components together over Ethernet or
  737. 27:23other advanced protocols, you need
  738. 27:25something like a switch. Again, it's
  739. 27:27really hard to cover a lot of these
  740. 27:29advanced concepts without being able to
  741. 27:30show you them. So, let me know in the
  742. 27:33comments below if this was a useful
  743. 27:34format or if you have other suggestions
  744. 27:36for how I can make this better. As I go
  745. 27:39through this controls and automation
  746. 27:40tutorial series with you, I want to
  747. 27:42constantly be making it better. So feel
  748. 27:44free to leave any feedback in the
  749. 27:46comments below. I'll link to some of the
  750. 27:48key hardware that I used here because
  751. 27:50everything I used here can actually be
  752. 27:52found on Amazon. I'll say in terms of
  753. 27:54learning resources that can help you
  754. 27:56build some of these skills completely
  755. 27:57for free. Rockwell Allen-Bradley makes a
  756. 28:00tool called Connected Components
  757. 28:01Workbench. Beckhoff has their TwinCAT
  758. 28:04programming studio. Arduino now has a
  759. 28:06PLC IDE or integrated development
  760. 28:09environment. And Ignition is one of the
  761. 28:12top SCADA HMI providers, and you can get
  762. 28:15their core software for free to use on
  763. 28:18your home laptop or desktop. All right,
  764. 28:20so that is going to do it for today's
  765. 28:21video. Don't forget to leave a like if
  766. 28:22you enjoyed it. Subscribe to the channel
  767. 28:24for tons more great content. Thanks for
  768. 28:26watching. We'll see you next time. Bye.
  769. 28:34Today, I'm going to talk to you about
  770. 28:36the top five tools I use as a controls
  771. 28:38and automation engineer. Video is going
  772. 28:40to be a continuation on the controls and
  773. 28:42automation series that I started up in
  774. 28:44the recent months on the channel. But
  775. 28:46today's video is going to focus on the
  776. 28:48tools that you would use as a controls
  777. 28:51and automation engineer. Now, without
  778. 28:52any further ado, let's dive in. So the
  779. 28:55first tool I'm going to talk about is
  780. 28:56the digital multimeter. And in terms of
  781. 29:00basic electrical troubleshooting, it
  782. 29:02really doesn't get any better than one
  783. 29:04of these. They start as low as like $20.
  784. 29:07You can get one from Walmart or Amazon
  785. 29:09that does the basic functionality pretty
  786. 29:12well for you. Before you start working
  787. 29:14on high voltage or dangerous electrical
  788. 29:16systems, you should be far more
  789. 29:18qualified than just saying, "Hey, I've
  790. 29:20got a multimeter." But these can do
  791. 29:22things like detect whether or not
  792. 29:24there's voltage at a source, tell how
  793. 29:26much voltage there is relative to
  794. 29:28ground, check for AC and DC voltage. You
  795. 29:31can even lift a wire and you can
  796. 29:33calculate amperage through current. You
  797. 29:35can detect point-to-point if you have
  798. 29:37continuity, which helps you when you're
  799. 29:39trying to trace wires in a jumbled old
  800. 29:42electrical panel. And you can also do
  801. 29:44resistance checks, which help you detect
  802. 29:46for like partially blown fuses and
  803. 29:48things like that. But digital multimeter
  804. 29:50is a great tool to have around, not just
  805. 29:52if you're a controls and automation
  806. 29:53engineer. If you do any sort of hobby
  807. 29:55work or tinkering or electrical work
  808. 29:57around your house, which you should also
  809. 29:59be very careful with, then a digital
  810. 30:01multimeter is a great call. This one
  811. 30:03came in a soldering kit that I bought
  812. 30:05from Amazon and I think the whole kit
  813. 30:07was like 40 bucks and it works great.
  814. 30:09It's very reliable. Kind of the more
  815. 30:11robust industrial version you'll
  816. 30:13probably see a lot come from the company
  817. 30:15Fluke. And the only reason I have one
  818. 30:17for personal use is cuz I renovated a
  819. 30:19house and I was doing a lot of home
  820. 30:21electrical. So, I decided to go out and
  821. 30:23get a more industrially hardened one.
  822. 30:26It's not necessarily normal that you
  823. 30:28would have a Fluke for home use. Your
  824. 30:30company might just have two or three to
  825. 30:32loan out because they're more on the
  826. 30:34expensive side, but every engineer who
  827. 30:36is doing significant work in a control
  828. 30:38panel should have a Fluke or digital
  829. 30:41multimeter cuz it tells you so much
  830. 30:43about the status of your electrical
  831. 30:45signals. This isn't moving on to item
  832. 30:46two yet. This is item 1.5, but in the
  833. 30:49same kind of vein of testing and
  834. 30:51validating electrical signals in a
  835. 30:53panel, I think a voltage pen is
  836. 30:55something for anyone who is doing
  837. 30:58anything near any electrical circuits.
  838. 31:00It's something valuable for them to go
  839. 31:02out and get. They make these in AC and
  840. 31:05DC in one pen, so you can check if a
  841. 31:07circuit is live whether you're working
  842. 31:09on DC or AC circuits. They make some
  843. 31:12more advanced ones that can tell you
  844. 31:14additional feedback, but the main
  845. 31:16purpose of a voltage pen is that when
  846. 31:18it's on, it will start blinking rapidly
  847. 31:21like an LED will flash red if there's
  848. 31:24voltage present and it'll start beeping
  849. 31:26at you if there's voltage present. So,
  850. 31:27you can hold this up to a wire that
  851. 31:30you're about to take off of a terminal
  852. 31:32that you don't think should have
  853. 31:33electricity flowing through it and if it
  854. 31:35starts beeping with a voltage pen,
  855. 31:37that's a really good first check that
  856. 31:39you were about to do something pretty
  857. 31:41unsafe. So, with voltage pens and
  858. 31:43multimeters, we've covered electrical
  859. 31:45troubleshooting and the most common tool
  860. 31:47used for that. So, the second tool I'm
  861. 31:49going to talk about and this one should
  862. 31:51be kind of obvious if you're familiar
  863. 31:53with what controls and automation
  864. 31:55engineering is, but it is the wire
  865. 31:57strippers. So, a pair of wire strippers
  866. 32:00are typically capable of cutting a piece
  867. 32:03of wire and removing the shielding from
  868. 32:05it, so you get the bare copper on it.
  869. 32:07And it might seem really obvious that if
  870. 32:09you're doing any work in a control
  871. 32:11panel, you need a pair of these on hand,
  872. 32:13but I can't tell you the number of times
  873. 32:15I've gone to a project, I've had a young
  874. 32:17engineer with me and they haven't had a
  875. 32:19pair of wire strippers, they didn't
  876. 32:21realize that they needed them. It's just
  877. 32:23useful to know you will need your wire
  878. 32:25strippers pretty much constantly. There
  879. 32:28are super high-tech versions of these.
  880. 32:30There are also cable strippers, which
  881. 32:32when you have a cable that has four or
  882. 32:35five core of wire inside of it, it can
  883. 32:37grab the sleeve and pull it off of all
  884. 32:40of your five wires that are inside. So,
  885. 32:42this can get way more complicated and
  886. 32:45I'm kind of lumping like sets for
  887. 32:48crimping ferrules, which are nice like
  888. 32:50metal tube ends that clamp onto the
  889. 32:53copper on the end of your wire. I'm kind
  890. 32:56of roping all of the wire prep tools
  891. 32:58into you can get by with a pair of wire
  892. 33:01strippers and sometimes you might want
  893. 33:03like a box cutter type knife.
  894. 33:07If you do have a cable or if you're
  895. 33:08doing Profinet cable, which is really
  896. 33:11shielded and has a thicker edge to it
  897. 33:14and you don't have the specific tools
  898. 33:15meant for crimping that style of cable,
  899. 33:18you can usually get by with cutting a
  900. 33:20slit in the edge of the shielding,
  901. 33:22peeling it back, taking the individual
  902. 33:24wires out and then you can just strip
  903. 33:26them if need be with your wire
  904. 33:29strippers. So, in my opinion, wire
  905. 33:31strippers and a box cutter can get
  906. 33:34almost any electrical work done that you
  907. 33:35have to get done, but just know the
  908. 33:38world of wire prep is actually way
  909. 33:41deeper than that and we could go on for
  910. 33:43a very long time about the right type of
  911. 33:45ferrules, how when to use splicing and
  912. 33:48heat shrink, the different types of wire
  913. 33:50nuts or terminal mounts and things like
  914. 33:52that, but we're going to keep it simple.
  915. 33:54You absolutely will want a good pair of
  916. 33:57wire strippers. Now, item number three
  917. 33:59is something that might catch you a
  918. 34:01little by surprise if you haven't done
  919. 34:03significant work in automation and
  920. 34:05controls engineering, but I would
  921. 34:07recommend any engineer who's spending
  922. 34:09significant time in the field or bench
  923. 34:11testing stuff in the office get
  924. 34:13themselves a 120 to 24 V
  925. 34:16power supply. If you're in the UK or
  926. 34:18internationally, you might want to get
  927. 34:20yourself a 230 to 24 V DC power supply.
  928. 34:25Um
  929. 34:26But the important point here is you're
  930. 34:28taking single phase voltage, you're
  931. 34:30taking the most common type of wall
  932. 34:32outlet voltage and you're turning it
  933. 34:34into the most standard DC type of
  934. 34:38control voltage, which is 24 V DC. You
  935. 34:41are going to be stunned by the number of
  936. 34:43times having one of these on hand or in
  937. 34:46your bag is super useful. Some of the
  938. 34:48most common reasons you might need one
  939. 34:50of these power supplies is there could
  940. 34:52be a lot of scenarios where a control
  941. 34:54panel was designed with high voltage
  942. 34:57three phase 480 or higher electricity in
  943. 35:00the same cabinet as switches and PLCs
  944. 35:03and HMIs. And strictly speaking, if
  945. 35:06you're going to be working on anything
  946. 35:08with that 480 voltage live, you should
  947. 35:11be in full arc flash gear every time
  948. 35:13even if you're not touching the 480 side
  949. 35:16of your cabinet. But it's not always
  950. 35:18conducive, it's not always realistic to
  951. 35:20say that you're going to be arc flashed
  952. 35:22up. So, sometimes it's better to just
  953. 35:24kill the power to the cabinet. But then
  954. 35:27you run into the problem where if you
  955. 35:28kill the power to the cabinet and you're
  956. 35:30using that infeed power to power the
  957. 35:33lower voltage things as well with a 480
  958. 35:36to 24 V or 120 transformer, now you need
  959. 35:39some way of powering on the PLC,
  960. 35:42powering on the switch, powering on the
  961. 35:44HMI so that you can do troubleshooting
  962. 35:46and service with a power supply that is
  963. 35:49fed from somewhere else. So, one of the
  964. 35:52more common, more scrappy things that
  965. 35:54you might do as an automation engineer
  966. 35:56is get a really long extension cord,
  967. 35:58find a nearby outlet, power up a power
  968. 36:00supply, and then you can have all of
  969. 36:03those lower voltage things like the PLC
  970. 36:05and the switch online, you can do your
  971. 36:07software-based troubleshooting, you can
  972. 36:10even do wire validation with the high
  973. 36:12voltage components powered down. Some
  974. 36:14other formats that you might see power
  975. 36:15supplies in and again, like your company
  976. 36:18might already have one on hand, your
  977. 36:19customer might already have one on hand.
  978. 36:21These are kind of common, although not
  979. 36:23super frequently used in the US as far
  980. 36:26as I know.
  981. 36:27They're just like a metal box that has
  982. 36:29the circuitry for transforming the
  983. 36:31voltage on the inside and then little
  984. 36:34terminals with a plastic shield. They do
  985. 36:36exactly the same, it's just a different
  986. 36:38way of looking at it, but it's nice to
  987. 36:40know what you're looking at. And it's
  988. 36:41also worth noting some of these can take
  989. 36:44multiple input voltages. So, this one
  990. 36:46for example can work with 120 or 230,
  991. 36:49but you have to adjust a dip switch to
  992. 36:51tell it which one it's getting. And they
  993. 36:53also make these that output 5 V DC, 12 V
  994. 36:57DC, 24 V DC. So, make sure when you're
  995. 36:59specifying it, you get the right one. If
  996. 37:02the majority of the work that you're
  997. 37:03doing is bench testing or in like a
  998. 37:05garage environment like here where I
  999. 37:07want to make sure something works the
  1000. 37:08way I'm expecting it to work before I
  1001. 37:11power it up permanently and buy a power
  1002. 37:13supply just for that circuit,
  1003. 37:15uh an adjustable DC power supply is a
  1004. 37:18really tremendous tool. I don't think
  1005. 37:20you would throw this in your book bag
  1006. 37:21and keep it on hand as an automation
  1007. 37:23engineer doing a lot of work in the
  1008. 37:24field. You absolutely could. There's no
  1009. 37:27reason not to. This would be able to do
  1010. 37:29exactly the same thing that would be
  1011. 37:31able to do as long as you get one that's
  1012. 37:33able to output
  1013. 37:3524 V DC. Most common thing you would
  1014. 37:37want is 120 V in or single phase
  1015. 37:40household voltage in and then 24 V DC
  1016. 37:45out. That will let you do a ton of great
  1017. 37:47troubleshooting and give you a lot of
  1018. 37:49flexibility and the ability to make
  1019. 37:51working on systems way safer. Now, item
  1020. 37:54four I thought about roping in with item
  1021. 37:56two, which was all of the wire prep
  1022. 37:58stuff, but I decided it's important
  1023. 38:00enough and different enough that I'm
  1024. 38:02going to make it its own topic. And that
  1025. 38:04is the terminal screwdrivers. So,
  1026. 38:07when you're wiring up stuff in a control
  1027. 38:10panel, the most common thing you'll see
  1028. 38:12is a screw clamp terminal base. Some
  1029. 38:16uh plants, some people trust the spring
  1030. 38:19clamp terminal bases as well, which is
  1031. 38:21basically you push down a lever,
  1032. 38:24you put the wire in and you release the
  1033. 38:26lever and now you have a spring clamp on
  1034. 38:28it.
  1035. 38:30Um but the more common one to see
  1036. 38:32honestly, especially in older plants,
  1037. 38:35is screw clamp terminal bases where you
  1038. 38:37have to tighten down a screw to clamp
  1039. 38:39onto the copper. This is sort of the
  1040. 38:41most common way to land anything
  1041. 38:43electrically. And what's surprising and
  1042. 38:45annoying is just how tiny the terminals
  1043. 38:48can be on those. You might think that
  1044. 38:50you have a very fine screwdriver, but if
  1045. 38:52all you've ever done is around the house
  1046. 38:54home projects and home electricity, I
  1047. 38:57promise the smallest screwdriver you
  1048. 38:59have will be way too big for the
  1049. 39:02terminals used in an industrial setting.
  1050. 39:05So, what's nice is when you can find a
  1051. 39:07thin screwdriver that's rated, this one
  1052. 39:10for example is up to 1,000 V um
  1053. 39:14and they're incredibly thin. They have
  1054. 39:16very thin, typically flat heads. So, a
  1055. 39:18terminal screwdriver is not expensive,
  1056. 39:20it's incredibly important. And you would
  1057. 39:22not believe, this is an example of
  1058. 39:24terminal blocks. These aren't even close
  1059. 39:26to as small as they come and this
  1060. 39:28terminal screwdriver is already almost
  1061. 39:31too large to fit in these terminals. So,
  1062. 39:33having a set of very fine electronic
  1063. 39:36screwdrivers is super important. Now,
  1064. 39:38it's time to talk about number five, the
  1065. 39:42final most common tool that you will
  1066. 39:45need as a controls and automation
  1067. 39:47engineer. And I saved it for last
  1068. 39:48because it's a little bit of a tough one
  1069. 39:51to show, a little bit of a tough one to
  1070. 39:52talk about and explain, but I'm going to
  1071. 39:55do my best and I figured if you made it
  1072. 39:57to this point in the video, you probably
  1073. 39:59don't hate me enough to click away as I
  1074. 40:01try to explain this rather complicated
  1075. 40:03concept. But tool number five that you
  1076. 40:05will absolutely need as an automation
  1077. 40:07and controls engineer is an engineering
  1078. 40:10laptop. And the reason I specify
  1079. 40:12engineering laptop is because your work
  1080. 40:16will probably give you a laptop that has
  1081. 40:19a whole bunch of IT settings on it. They
  1082. 40:21might not let you change your IP
  1083. 40:23address. They might not let you download
  1084. 40:25software from the internet. They might
  1085. 40:27not let you have admin access to your
  1086. 40:29laptop. That is going to be a huge deal
  1087. 40:32breaker for an automation and controls
  1088. 40:34engineer. So it's very important that
  1089. 40:36you have a lot of RAM. 16 GB is probably
  1090. 40:39the bare minimum. 32 or definitely 64
  1091. 40:43would absolutely be preferable because
  1092. 40:45one of the most common things that you
  1093. 40:47would do as an automation and controls
  1094. 40:48engineer is you might have virtual
  1095. 40:50machines, which are basically
  1096. 40:52virtualized sessions of a computer that
  1097. 40:55has certain engineering software loaded
  1098. 40:57onto it that you open using the brains
  1099. 41:00of your computer. So if you're running a
  1100. 41:02laptop that has 16 gigs of RAM and you
  1101. 41:05want to open a virtual machine that
  1102. 41:07needs 8 gigs of RAM for it to be able to
  1103. 41:09run, you've just reduced the actual
  1104. 41:12memory your laptop is capable of using
  1105. 41:14to do other things to 8 gigs right away
  1106. 41:17cuz now half of it's been dedicated to
  1107. 41:19opening a virtual machine. If the
  1108. 41:20virtual machine concept confuses you a
  1109. 41:23little bit, don't worry about that too
  1110. 41:24much for now, but just know that there
  1111. 41:26are engineering softwares like TIA
  1112. 41:28Portal for Siemens or Studio 5000 for
  1113. 41:31Rockwell where depending on the task
  1114. 41:33that you're doing, if you're online with
  1115. 41:35equipment, if you're trying to make live
  1116. 41:37edits to programming, you could easily
  1117. 41:39be using 8 gigs of RAM just running
  1118. 41:42certain projects. TwinCAT for Beckhoff
  1119. 41:45will just gobble up your system
  1120. 41:46resources. So if you only have a laptop
  1121. 41:49that has 16 gigs of RAM or is super
  1122. 41:52locked down by company permissions,
  1123. 41:54you're going to have a very hard and
  1124. 41:56annoying time as a controls and
  1125. 41:58automation engineer. If you're at a
  1126. 41:59company that only has a few automation
  1127. 42:01and controls engineers, it might be hard
  1128. 42:03to properly articulate to them how badly
  1129. 42:06you need a really open laptop, but it's
  1130. 42:10super important that you be able to put
  1131. 42:13any required software to support
  1132. 42:15bringing up your system on that laptop.
  1133. 42:18Of course, you should still follow info
  1134. 42:20security protocols. You should still
  1135. 42:23have IT vet software and make sure it's
  1136. 42:25not coming from malicious parties, but
  1137. 42:27if you're not able to change your IP
  1138. 42:29address, download BootP, which is
  1139. 42:31capable of just setting IP addresses. In
  1140. 42:34theory, it never works. But then if
  1141. 42:36you're not able to go and grab the
  1142. 42:38software you need to program a drive or
  1143. 42:42a a VFD or any smart component in your
  1144. 42:45system where there's a little package or
  1145. 42:47plug-in on the vendor's machine website
  1146. 42:50and you're not able to quickly get it,
  1147. 42:52it is going to slow you down. You'll
  1148. 42:53have to open a ticket. You'll have to
  1149. 42:55cuss out the IT department every time
  1150. 42:57and nobody wants that. So just make sure
  1151. 43:00that if you're an automation and
  1152. 43:01controls engineer and you are expending
  1153. 43:04a lot of time in this field, you go
  1154. 43:06through whatever steps are required to
  1155. 43:08get yourself an engineering laptop,
  1156. 43:10admin access where you can quickly
  1157. 43:12change your IP address and network
  1158. 43:13settings, be able to download software
  1159. 43:16that you deem is necessary to do your
  1160. 43:19job, and make sure that it has a lot of
  1161. 43:21system RAM. So make sure it has a lot of
  1162. 43:24memory. And in addition to a lot of RAM,
  1163. 43:26preferably at least 500 GB or maybe a
  1164. 43:29terabyte of actual disk memory because
  1165. 43:32some of those software that you need to
  1166. 43:35program PLCs take up a ton of install
  1167. 43:38space as well. So I know it might seem
  1168. 43:40silly in 2024 to say that a laptop is
  1169. 43:43one of the most important tools that
  1170. 43:45you'll need as an automation engineer.
  1171. 43:46Like of course you have a laptop, but
  1172. 43:49this very specific type of like an
  1173. 43:51automation and controls engineering
  1174. 43:53laptop, to go out and get a beefy
  1175. 43:56laptop.
  1176. 43:58And make your company pay for it. That
  1177. 44:00is going to do it for the list. That is
  1178. 44:01going to do it for today's video. I hope
  1179. 44:03you found it useful. As always, good
  1180. 44:05luck with your work. Good luck with your
  1181. 44:06projects and I'll see you next time.
  1182. 44:08Thanks for watching. Bye.
  1183. 44:18In today's video, we're going to talk
  1184. 44:20about the IEC 61131 programming
  1185. 44:23languages. These are the five standard
  1186. 44:25programming languages you're likely to
  1187. 44:27see as an automation or controls
  1188. 44:29engineer. So hopefully this video can
  1189. 44:31answer some of the most common questions
  1190. 44:33around what these are, what programming
  1191. 44:35languages automation and controls
  1192. 44:37engineers need to be ready to see in the
  1193. 44:39field, and then also how likely you are
  1194. 44:41to see them in what different
  1195. 44:42applications you might use different
  1196. 44:44ones for. I know just the name IEC 61131
  1197. 44:49can be a little bit confusing, but IEC
  1198. 44:51is just International Electrotechnical
  1199. 44:54Committee. They are sort of regulators
  1200. 44:56and moderators of a lot of specifics and
  1201. 44:59standards in the world of industrial
  1202. 45:02electronics and controls and automation.
  1203. 45:04You don't really have to worry too much
  1204. 45:06about the numbers or the letters. You
  1205. 45:08just need to know what these different
  1206. 45:10programming languages are and when
  1207. 45:12you're most likely to encounter them in
  1208. 45:13the field. So let's start with my
  1209. 45:14personal favorite and potentially the
  1210. 45:16most common one, which is ladder. So
  1211. 45:19ladder diagram, ladder logic, or just
  1212. 45:21sometimes abbreviated LD is essentially
  1213. 45:25the first PLC programming language that
  1214. 45:27ever came up sort of organically because
  1215. 45:31it looks a lot like
  1216. 45:33electronic relay schematics. So in the
  1217. 45:37old days before we had PLCs dedicated to
  1218. 45:39running automation,
  1219. 45:41you would read sort of primitive
  1220. 45:43controls maps as schematics of different
  1221. 45:46relays. So you could, for example, have
  1222. 45:49a relay that would check to see if a
  1223. 45:50button was pressed and if maybe some
  1224. 45:54some thing in the field like a high
  1225. 45:55pressure switch was met. And if those
  1226. 45:57were both true, the relay would pull in
  1227. 45:59and then something else would happen
  1228. 46:01downstream of it. And so a standard
  1229. 46:03programmer might think of this as like a
  1230. 46:04series of and or gates to do like binary
  1231. 46:07logic. In ladder logic, it's almost like
  1232. 46:10you could trace a flow of electricity
  1233. 46:13through your program. So this is why
  1234. 46:14ladder logic looks sort of like a ladder
  1235. 46:18when you stare at it. It's rung after
  1236. 46:19rung after rung. And the individual
  1237. 46:21modules all sort of spawned from the
  1238. 46:24idea that you had relays. So the two
  1239. 46:26most common ones are like examine if
  1240. 46:28close and examine if open, which is
  1241. 46:31basically a if or an if not. So it's
  1242. 46:34basically if condition is a one or if
  1243. 46:36condition is a zero. And that's 90% of
  1244. 46:39how you do
  1245. 46:41Boolean checking, just series of ifs and
  1246. 46:43if nots. And then to turn on Boolean
  1247. 46:46conditions, you really just need to know
  1248. 46:47the difference between like an OTE,
  1249. 46:50which is a energize the whole time this
  1250. 46:52rung is true, versus like an OTL and an
  1251. 46:55OTU pair, which is latching and
  1252. 46:57unlatching a binary condition when
  1253. 46:59something is true. Now obviously
  1254. 47:01processes are a lot more complicated
  1255. 47:03than binary logic in a lot of scenarios.
  1256. 47:06So essentially what that means is you
  1257. 47:09also have things like greater than, less
  1258. 47:11than, limits where you check between
  1259. 47:13values. And then you can also move
  1260. 47:16numerical values into numerical
  1261. 47:19variables. So you don't just have binary
  1262. 47:21logic in ladder. You have all the sort
  1263. 47:23of standard formats that you'd have in
  1264. 47:25any other programming language. If you
  1265. 47:27understand general programming types,
  1266. 47:29you'll be able to pick up what these
  1267. 47:31separate variable types mean pretty
  1268. 47:33quickly and pretty easily. But ladder
  1269. 47:35logic is extremely common. It's also
  1270. 47:37super powerful and it's pretty easy for
  1271. 47:39people who don't have a computer science
  1272. 47:41background, but maybe are more familiar
  1273. 47:43with the electronics side, or frankly
  1274. 47:46they don't have a programming background
  1275. 47:48at all. Ladder logic is super logical. I
  1276. 47:50really like it. Almost every major PLC
  1277. 47:53manufacturer supports some form of
  1278. 47:56ladder logic using these same basic
  1279. 47:58building blocks. So as a controls and
  1280. 48:00automation engineer, you are super
  1281. 48:02likely to need to become pretty familiar
  1282. 48:04with ladder logic. Now for the one I
  1283. 48:06consider second most common, some people
  1284. 48:08might debate with me here, but I think
  1285. 48:10the function block diagram. It's
  1286. 48:13essentially more free form than like
  1287. 48:16traditional ladder logic. You just
  1288. 48:18basically have a blank page of workspace
  1289. 48:21and you drop blocks in there that you
  1290. 48:23want to do different functions. And
  1291. 48:25typically you tie their inputs and
  1292. 48:27outputs to different process conditions.
  1293. 48:29Some of the more common ones for this
  1294. 48:31would be like totalizers. A lot of the
  1295. 48:33time a totalizer block that would
  1296. 48:35monitor flow over a period of time and
  1297. 48:38continually add to see how much total
  1298. 48:40flow you had in that time. You would
  1299. 48:42maybe have this floating function block
  1300. 48:45diagram for a totalizer. You would tie a
  1301. 48:48start command, a stop command, a reset
  1302. 48:50command, as well as potentially like
  1303. 48:53your input signal, so your actual raw
  1304. 48:55flow meter signal. You could pass it
  1305. 48:58through some sort of like time scale or
  1306. 49:00multiplier, but it's just where having
  1307. 49:03all of the conditions that control the
  1308. 49:05totalizer and all of the outputs that
  1309. 49:07you could do using the totalizer in one
  1310. 49:10spot is just super powerful. I'm only
  1311. 49:13using totalizer as one example. Function
  1312. 49:15block diagram, its advantages are you
  1313. 49:17can see all of the components that will
  1314. 49:20control a block, a complicated block
  1315. 49:22like a totalizer, in one location. You
  1316. 49:25can also map out common programming
  1317. 49:27things like and gates, or gates, XOR
  1318. 49:30gates, nots, whatever Boolean
  1319. 49:33control in these as well. The
  1320. 49:35disadvantages are it starts to get very
  1321. 49:38hard to read a logical sequence of
  1322. 49:41things happening if you get too far down
  1323. 49:43and too long into one function block
  1324. 49:46diagram. So, you need to start
  1325. 49:48partitioning it off and making a
  1326. 49:49separate FBD for each major function
  1327. 49:53that happens. But, I have seen systems
  1328. 49:55where the entire thing is done in a
  1329. 49:57function block. I've seen things where
  1330. 49:59the entire system is done in ladder.
  1331. 50:01But, it's important to understand what
  1332. 50:03this looks like, how you can control it,
  1333. 50:05what it's used for, and also it's an
  1334. 50:07important one to familiarize yourself
  1335. 50:09with. The next language, SFC or
  1336. 50:11sequential function chart, is absolutely
  1337. 50:14the most common language you'll see if
  1338. 50:16you run batch processes. So,
  1339. 50:19GE's like FT Batch and Rockwell's batch
  1340. 50:23as well as I think
  1341. 50:25just a lot of batch processes. The way
  1342. 50:28you see a recipe is with a sequential
  1343. 50:31function chart. And this one's really
  1344. 50:33nice to kind of get an overarching view
  1345. 50:35of your process because typically you'll
  1346. 50:37have layers where you can look at one
  1347. 50:40SFC and you'll see like start phase,
  1348. 50:44validate parameters phase, manual
  1349. 50:46additions phase, mix phase, automated
  1350. 50:49additions phase, sample phase. And so,
  1351. 50:52you can look at a high-level SFC and you
  1352. 50:55can see the overall state of your
  1353. 50:57project really quickly as it relates to
  1354. 50:59your whole process. And then if you have
  1355. 51:01questions about what's going on in one
  1356. 51:03phase of that SFC, typically most
  1357. 51:07software supports you drilling in and
  1358. 51:09inside one phase at your high-level
  1359. 51:11model, you could have a number of
  1360. 51:13phases. And inside each of those phases
  1361. 51:15you could have a number of phases in
  1362. 51:17there. It's definitely most commonly
  1363. 51:20used in batch. Most PLCs themselves
  1364. 51:23don't support a really robust like SFC
  1365. 51:27without a software that you run and
  1366. 51:29configure on an actual computer. So,
  1367. 51:32PLCs typically host mainly like ladder
  1368. 51:36and FBD and even some of what we'll talk
  1369. 51:39about next, which is structured text.
  1370. 51:41But, to do an SFC-based control
  1371. 51:43schematic, you're usually in like more
  1372. 51:45of a distributed control system like DCS
  1373. 51:47platform and you usually have to put
  1374. 51:50your SFC software recipe editor,
  1375. 51:53whatever, on a computer other than your
  1376. 51:55PLC. Again, most common place you'll see
  1377. 51:58it is batch applications. Batch just
  1378. 52:00means that you separate all of your
  1379. 52:02devices at the plant and your series of
  1380. 52:05instructions that control devices into
  1381. 52:08phases. Phases still typically have to
  1382. 52:10get represented as ladder in your PLCs.
  1383. 52:14So, an SFC is almost always accompanied
  1384. 52:17by some form of ladder logic or
  1385. 52:19structured text inside of a PLC. Not
  1386. 52:22always, I'm trying to generalize and
  1387. 52:24give you guys a quick summary. But,
  1388. 52:25that's a summary of SFC. So, the next
  1389. 52:28one, structured text, is
  1390. 52:30probably the one that would look the
  1391. 52:32most familiar to someone coming in with
  1392. 52:34a programming background but not a
  1393. 52:35controls background. Structured text
  1394. 52:38really is what all programming languages
  1395. 52:40are. I mean, it's a certain syntax of
  1396. 52:43words and commands that will execute
  1397. 52:45certain things in your code. Structured
  1398. 52:47text is typically straightforward like
  1399. 52:49saying set IO point status to digital
  1400. 52:53output,
  1401. 52:54set Boolean command equal to one when
  1402. 52:58condition is met. Like, the actual text
  1403. 53:00I'm not going to spend too much time
  1404. 53:02digging into because it varies from
  1405. 53:05manufacturer to manufacturer, controller
  1406. 53:07to controller. So, if I were to tell you
  1407. 53:09a bunch of specific structured text,
  1408. 53:11there's a solid chance it wouldn't apply
  1409. 53:13to your specific manufacturer. But, the
  1410. 53:16documentation for what your manufacturer
  1411. 53:18supports, what whatever your site
  1412. 53:21standard is, if you're doing a lot of
  1413. 53:23structured text, then the controls at
  1414. 53:25your plant probably got started by a
  1415. 53:28group of people who are more comfortable
  1416. 53:30with software and programming. So, in
  1417. 53:32general, PLC programmers, controls and
  1418. 53:34automation engineers aren't going to
  1419. 53:36need to see a ton of structured text,
  1420. 53:38but it is supported and it is one of the
  1421. 53:41IEC 61131
  1422. 53:43languages. So, it's important to know
  1423. 53:45what it is. If you see it in an
  1424. 53:47application, don't be blindsided by it.
  1425. 53:50Not super common. If it's super common
  1426. 53:52at your site, you prove me wrong. Let me
  1427. 53:54know I was wrong in the comments below,
  1428. 53:55but most of the time the three we talked
  1429. 53:58about before are going to show up a lot
  1430. 54:00more in your applications. Okay, and the
  1431. 54:02fifth one is kind of neat here. It's
  1432. 54:04instruction list, typically abbreviated
  1433. 54:06IL.
  1434. 54:08And this one is going to be really
  1435. 54:10familiar for people who have done a lot
  1436. 54:12of work with like six-axis robots or if
  1437. 54:15you've done a lot of work with like CNC
  1438. 54:17machines or 3D printers. Instruction
  1439. 54:20list is not too far off from structured
  1440. 54:23text in that it's really just words
  1441. 54:27that kind of have some numbers mixed in
  1442. 54:29to command your variables to different
  1443. 54:31stuff, whereas the first three languages
  1444. 54:33we talked about were a lot more visual.
  1445. 54:35But, instruction list is basically like
  1446. 54:38machine code. So, for like a robot or a
  1447. 54:42CNC machine, it's often called G-code.
  1448. 54:45But, it usually is a series of commands
  1449. 54:48that run one after another. It's always
  1450. 54:50going to typically happen in sequence,
  1451. 54:53but a lot of the time you can have like,
  1452. 54:55oh, if this condition, then do this and
  1453. 54:58jump to this rung, but if other
  1454. 55:00condition, do this other thing, jump to
  1455. 55:02this other rung. So, it doesn't have to
  1456. 55:04be linear. But, typically it's in an
  1457. 55:06order that makes sense that you would
  1458. 55:08typically see it sequentially. And the
  1459. 55:09most common applications are for things
  1460. 55:11where you need position control in 3D
  1461. 55:14space. So, you're controlling three or
  1462. 55:16more
  1463. 55:17axes and you would typically say, "Okay,
  1464. 55:20go to certain position. All right, turn
  1465. 55:22on your tool, whether it's cutting or
  1466. 55:24drilling or welding or whatever." And
  1467. 55:26then your tool's on. "Okay, move from
  1468. 55:28point A down to your thing that you're
  1469. 55:31operating on. Okay, now move over to
  1470. 55:33point B with your tool on. Okay, now
  1471. 55:35turn your tool off and lift up. Okay,
  1472. 55:37now go back to your home spot. A
  1473. 55:39conveyor will turn on, move the next
  1474. 55:42piece in." So, it's pretty common on
  1475. 55:43like assembly line where you have a lot
  1476. 55:46of advanced like robotics or motion
  1477. 55:48control. It's normal to see instruction
  1478. 55:51list. But, again, this is sort of more
  1479. 55:54common in robotics even than you would
  1480. 55:56see it in controls and automation. So,
  1481. 55:59it is one of the IEC 61131 languages.
  1482. 56:03That's why we're talking about it. And
  1483. 56:04in general, the more well-rounded you
  1484. 56:06are as an engineer, the better you're
  1485. 56:08going to do in your field. Good luck
  1486. 56:09with your jobs. Good luck with your
  1487. 56:10projects. Thanks for watching. Bye.
  1488. 56:20This is the Arduino Opta PLC. PLCs are
  1489. 56:24pretty well known for being hundreds or
  1490. 56:26sometimes thousands of dollars because
  1491. 56:28of their industrial ratings. And often
  1492. 56:30the software and the licensing
  1493. 56:31accompanied with them is hundreds or
  1494. 56:33thousands of dollars as well. Arduino
  1495. 56:35has created a compact microcontroller
  1496. 56:38that has relay outputs and digital
  1497. 56:40inputs on board as well as programmable
  1498. 56:42buttons and LEDs so that you can learn
  1499. 56:45the basics of controls and automation or
  1500. 56:47build IoT and industrial automation
  1501. 56:49solutions for just a couple hundred
  1502. 56:51dollars. And for myself as a creator and
  1503. 56:53the person who runs Le Master Tech, I'm
  1504. 56:55really excited about this product
  1505. 56:57because it gives me a way to teach the
  1506. 56:59basics of controls and automation
  1507. 57:01engineering, which is the field I work
  1508. 57:02in professionally and something I feel
  1509. 57:04quite passionately about. At a price
  1510. 57:06point finally that's pretty accessible
  1511. 57:08for anyone who's looking to break into
  1512. 57:10this field. So, in today's video I'm
  1513. 57:11going to walk you through downloading
  1514. 57:13the PLC IDE from Arduino, getting online
  1515. 57:16with it, and creating your very first
  1516. 57:18project because in the coming videos on
  1517. 57:20Le Master Tech, we're going to be doing
  1518. 57:22progressively more advanced controls and
  1519. 57:24automation tutorials. And being able to
  1520. 57:26get started with the Arduino PLC is
  1521. 57:29going to be very important if you want
  1522. 57:30to follow along with all of those
  1523. 57:32tutorials. So, let's get right into it.
  1524. 57:34All right, let's go ahead and just pop
  1525. 57:36the Arduino PLC IDE into Google. And the
  1526. 57:40Arduino software link to the PLC IDE,
  1527. 57:43the big button that says download the
  1528. 57:45PLC IDE.
  1529. 57:47I'm going to download the Windows
  1530. 57:49version and I encourage you to
  1531. 57:52contribute and download. Arduino's
  1532. 57:53pretty awesome company. I'm going to
  1533. 57:55just download cuz this is like the fifth
  1534. 57:57time I've done this. Arduino's pretty
  1535. 57:59awesome and they give their stuff away
  1536. 58:01for free, their software stuff.
  1537. 58:03But, let's go ahead and install the PLC
  1538. 58:06IDE together.
  1539. 58:11I'm going to check yes to launch it once
  1540. 58:13it's done and I'm going to hit finish.
  1541. 58:15Okay.
  1542. 58:17All ready. So, it looks even though I
  1543. 58:19just downloaded it can remember that I
  1544. 58:21did some programs here before, which is
  1545. 58:24fine.
  1546. 58:25I'm just going to hit new project
  1547. 58:27anyways and I'm going to name it my
  1548. 58:30first PLC.
  1549. 58:32And make sure your target is the Opta
  1550. 58:34unless you're using the Portenta Machine
  1551. 58:36Control.
  1552. 58:37Um, but I'm going to use the Opta. I'll
  1553. 58:39just put it in documents is fine and
  1554. 58:41I'll hit okay. It's going to take a
  1555. 58:43minute to generate the project.
  1556. 58:46All right, then the device shows up
  1557. 58:48here.
  1558. 58:49First thing you want to do with the new
  1559. 58:51Arduino PLC that you have plugged in,
  1560. 58:53you want to go to device manager on your
  1561. 58:55computer. Make sure you know what port
  1562. 58:59your PLC is plugged into. I'm almost
  1563. 59:01sure mine's USB 13, but I'm going to go
  1564. 59:04ahead and unplug it and I see 13 goes
  1565. 59:06away.
  1566. 59:08Plug it back in and
  1567. 59:10thir-
  1568. 59:1212 and 14 come back. Interesting.
  1569. 59:14Okay.
  1570. 59:16So, this one might be in a weird state
  1571. 59:18of limbo. That's like it got half booted
  1572. 59:20before. So, I'm going to double click
  1573. 59:22the reset button. That puts it in
  1574. 59:24firmware reboot mode. So, if your USB is
  1575. 59:28if your PLC is brand new out of the box,
  1576. 59:30you should only have one USB serial
  1577. 59:32device port here.
  1578. 59:34Um so, COM 13.
  1579. 59:36We're going to come in here and select
  1580. 59:39that. And the first thing you want to
  1581. 59:41do, uh regardless of the fact that you
  1582. 59:43haven't written any code yet, is just on
  1583. 59:45port uh COM port 13.
  1584. 59:48You just want to hit download. It's for
  1585. 59:50initial setup and and reinitialization.
  1586. 59:53It tells you on on a new board, file
  1587. 59:55system formatting can take some minutes.
  1588. 59:57It takes some minutes, so just get it
  1589. 59:59started. Uh really all you're looking
  1590. 1:00:01for, you want this bottom left window to
  1591. 1:00:03keep doing stuff. You don't want it to
  1592. 1:00:05freeze and hang up. Um but it does take
  1593. 1:00:08a couple minutes, so I'll probably fast
  1594. 1:00:09forward much of this.
  1595. 1:00:12Or play games on my phone.
  1596. 1:00:23Okay, and you want file downloaded
  1597. 1:00:26successfully. That's good. Um anything
  1598. 1:00:29that's like, "Hey, DFU invalid suffix."
  1599. 1:00:31Stuff like that. Your Arduino PLC IDE
  1600. 1:00:34might have gotten uh incorrectly
  1601. 1:00:36downloaded. You might want to go to the
  1602. 1:00:38Arduino IDE and install the Opta
  1603. 1:00:40libraries. Uh you might want to try
  1604. 1:00:43double pressing reset on the Arduino
  1605. 1:00:46Opta to get it to go back into
  1606. 1:00:48bootloader mode and try again.
  1607. 1:00:50Double-check your COM ports are correct
  1608. 1:00:53with device manager. Those are all the
  1609. 1:00:55troubleshooting steps that uh I know of
  1610. 1:00:57because I've gone through very similar
  1611. 1:00:59things.
  1612. 1:01:00Um but ideally, if that works and you go
  1613. 1:01:03to device manager
  1614. 1:01:06and
  1615. 1:01:08ports, you now have two ports because
  1616. 1:01:10this is a dual-core PLC, so there are
  1617. 1:01:13two USB uh ports in use to communicate
  1618. 1:01:16with it. Uh you want so you have 12 and
  1619. 1:01:1914.
  1620. 1:01:20You want to go into online and set up
  1621. 1:01:22communication and go to Modbus and
  1622. 1:01:25properties. And you want to grab the
  1623. 1:01:26higher of those two ports. The rest of
  1624. 1:01:29the defaults should be fine. The baud
  1625. 1:01:30rate, the frame, all that stuff.
  1626. 1:01:32Hit okay. Hit okay. And now, you want to
  1627. 1:01:36uh connect to the target.
  1628. 1:01:39So, I'm actually just going to unlo- uh
  1629. 1:01:42unplug and plug back in the PLC for my
  1630. 1:01:44little
  1631. 1:01:46you know, "Hey, I'm IT. This is how I do
  1632. 1:01:48things." Um I don't think you have to do
  1633. 1:01:50that. But go back to un- unload uh
  1634. 1:01:54online setup communication Modbus COM
  1635. 1:01:5614. That all looks good. Okay. And now,
  1636. 1:01:59uh there's nothing in main except count
  1637. 1:02:02equals count plus one. That's the
  1638. 1:02:03default program Arduino gives you.
  1639. 1:02:06But when you are in resources on this
  1640. 1:02:08header page, you want to connect to the
  1641. 1:02:10PLC even before downloading anything to
  1642. 1:02:13it. You're just connecting to make sure
  1643. 1:02:14that uh all the setup stuff worked okay.
  1644. 1:02:18It'll take a second.
  1645. 1:02:20Okay. Now, I've previously licensed
  1646. 1:02:22this. Um but initially, yours will
  1647. 1:02:24probably tell you that uh you need to um
  1648. 1:02:27ref-
  1649. 1:02:29disconnect it and connect it back um for
  1650. 1:02:31the permanent license to take effect.
  1651. 1:02:34One really cool thing that Arduino does
  1652. 1:02:36that most industrial PLC uh IDE
  1653. 1:02:39providers do not do is they include a
  1654. 1:02:41permanent license for your PLC um with
  1655. 1:02:44the purchase of the hardware. So, for
  1656. 1:02:46about $200, which is not nothing, um you
  1657. 1:02:49get a micro PLC that has relay outputs
  1658. 1:02:52as well as programmable inputs that can
  1659. 1:02:54be analog or digital inputs or more
  1660. 1:02:56outputs if you need them to work that
  1661. 1:02:58way. It can also be clipped into
  1662. 1:03:00expansion IO modules, which makes it a
  1663. 1:03:02lot more useful and flexible.
  1664. 1:03:04And then a permanent license because the
  1665. 1:03:06even the more affordable hardware
  1666. 1:03:08providers, Beckhoff, Wago, uh Siemens
  1667. 1:03:11have some more affordable PLC lines,
  1668. 1:03:13they get you with licensing their
  1669. 1:03:14software as well.
  1670. 1:03:16So, really for getting into the world of
  1671. 1:03:18industrial automation and controls, uh
  1672. 1:03:20this is a pretty crazy affordable um
  1673. 1:03:24pretty crazy affordable option. So, uh
  1674. 1:03:26you should have all green. Not every
  1675. 1:03:28Opta has Wi-Fi and Ethernet, so
  1676. 1:03:30depending on the version you bought,
  1677. 1:03:31these might not all be green. Um but
  1678. 1:03:34mine does, so let's go to main, which is
  1679. 1:03:36just the default program. Okay. Now, I'm
  1680. 1:03:39just going to go uh in the to talk about
  1681. 1:03:42the two tabs that they kind of give you
  1682. 1:03:44um by default. They give you project and
  1683. 1:03:46resources. In resources, you can see the
  1684. 1:03:49Opta that we added. And in later
  1685. 1:03:51tutorials, I have some IO expansion
  1686. 1:03:53modules. You'll see where we add those
  1687. 1:03:55as well. So, we have even more inputs
  1688. 1:03:57and outputs we can play around with. But
  1689. 1:03:59the Opta right on the body of the main
  1690. 1:04:00PLC, it has a channel of inputs on the
  1691. 1:04:03top. Uh it has relay outputs on the
  1692. 1:04:05bottom. And then it has four status
  1693. 1:04:08lights uh for L1, L2, L3, and L4 at the
  1694. 1:04:10bottom. And then it has a red, green,
  1695. 1:04:12and blue LED
  1696. 1:04:17uh all all here. And then it also has
  1697. 1:04:19button inputs.
  1698. 1:04:21for now, the only thing I'm going to do
  1699. 1:04:22is I'm going to go to LED outputs and
  1700. 1:04:25I'm going to give LG, which is the green
  1701. 1:04:27light, a variable name called green. So
  1702. 1:04:30that then we can go over here to
  1703. 1:04:31projects uh and in my first PLC project,
  1704. 1:04:35I'm going to add a new program. I'm
  1705. 1:04:37going to make it structured text.
  1706. 1:04:39And I'm just going to call it green
  1707. 1:04:41light. Okay? And I messed up because you
  1708. 1:04:44need to assign it to a task. So, I'm
  1709. 1:04:47going to delete that real quick and show
  1710. 1:04:49you what I mean. Add new program.
  1711. 1:04:53We'll just call it green
  1712. 1:04:55light. We'll make it in structured text
  1713. 1:04:58and I'm going to assign it to fast.
  1714. 1:05:00Okay? So now, it doesn't have a question
  1715. 1:05:02mark over here. And all I'm going to do
  1716. 1:05:04is say green and then colon equal sign
  1717. 1:05:08true all caps and then a semicolon.
  1718. 1:05:10Okay? And you can see right now there's
  1719. 1:05:12nothing on my PLC. I'm going to hit
  1720. 1:05:14download and compile.
  1721. 1:05:16And the green light turns on. Okay? So,
  1722. 1:05:20this was not a PLC programming tutorial.
  1723. 1:05:23This was getting started with the
  1724. 1:05:24Arduino Opta PLC tutorial because we are
  1725. 1:05:26about to do a whole bunch of ladder
  1726. 1:05:28diagram structured text, hooking up
  1727. 1:05:30inputs, hooking up outputs, building
  1728. 1:05:32HMIs. All the stuff that turns you into
  1729. 1:05:35a controls and automation engineer. We
  1730. 1:05:36are going to do that and we are going to
  1731. 1:05:38use the Arduino PLC IDE and the Arduino
  1732. 1:05:41PLC itself. So, super important to go
  1733. 1:05:43through the basics together.
  1734. 1:05:45If you're running into problems with
  1735. 1:05:47this, uh
  1736. 1:05:48do not skip this and go forward to the
  1737. 1:05:50next uh few videos. If you're trying to
  1738. 1:05:52truly follow along with this tutorial,
  1739. 1:05:54you really need to be able to get online
  1740. 1:05:56with your PLC and at least make sure
  1741. 1:05:58that you can turn that green light on
  1742. 1:06:00and off. Um otherwise, you're going to
  1743. 1:06:02be trying to follow follow along with
  1744. 1:06:04tutorials in this series that will show
  1745. 1:06:06you useful information and useful
  1746. 1:06:07concepts. But if you're not online with
  1747. 1:06:09the PLC right now, the rest of the
  1748. 1:06:11tutorials will mainly just be for your
  1749. 1:06:13information, but they won't be practical
  1750. 1:06:15exercises together. So so. Thank you so
  1751. 1:06:18much for watching. Uh the tutorials are
  1752. 1:06:20really going to take off from here, so I
  1753. 1:06:22hope this basic setup was useful for
  1754. 1:06:23you. Let me know in the comments with
  1755. 1:06:25any questions. We'll see you next time
  1756. 1:06:26and thanks for watching. Bye.
  1757. 1:06:36Okay. In uh this chapter, we are going
  1758. 1:06:39to make a new project and we're going to
  1759. 1:06:41call it first
  1760. 1:06:44structured
  1761. 1:06:45struct-
  1762. 1:06:47structured text. Okay? So, we're going
  1763. 1:06:49to go new project. Make sure you have
  1764. 1:06:51the Opta selected if you're using the
  1765. 1:06:53same controller as me. And we're going
  1766. 1:06:55to say okay. It's going to generate a
  1767. 1:06:57new project. Um now, I have previously
  1768. 1:07:00loaded the firmware onto my uh Arduino,
  1769. 1:07:03so everything else here should be fine.
  1770. 1:07:05We'll go to online setup communication
  1771. 1:07:08Modbus and properties and just make sure
  1772. 1:07:10COM 10 is still selected. That looks
  1773. 1:07:12good and we are going to hit connect
  1774. 1:07:15just to make sure the connections look
  1775. 1:07:16good and the all PLC Arduino Opta still
  1776. 1:07:20looks good. All the available interfaces
  1777. 1:07:22should show green lights. So, this is
  1778. 1:07:25all good. Hopefully, uh in a previous
  1779. 1:07:27video and previous chapter, watching a
  1780. 1:07:30long-form uh tutorial, uh I covered all
  1781. 1:07:33of this stuff in some greater detail.
  1782. 1:07:35So, if you haven't gotten to this step
  1783. 1:07:37and you're not able to get online with
  1784. 1:07:38your Arduino Opta PLC, I suggest you go
  1785. 1:07:41back on the channel and you watch the
  1786. 1:07:43getting set up or getting started with
  1787. 1:07:45your Arduino PLC video. Um so, uh
  1788. 1:07:49assuming you can get to this step and
  1789. 1:07:51you have a new project just like I have.
  1790. 1:07:53And if you were to go into the project
  1791. 1:07:54tab over here on the left and hit main,
  1792. 1:07:57you just have this default program it
  1793. 1:07:59gives us that is count equal to count
  1794. 1:08:01plus one.
  1795. 1:08:03Um but if you're able to get this far,
  1796. 1:08:04then we're in the same spot and the rest
  1797. 1:08:06of this video is going to go so
  1798. 1:08:08smoothly.
  1799. 1:08:10So, let's go to resources because for
  1800. 1:08:12today's video, I'm going to use the uh
  1801. 1:08:14LEDs that are built into the Arduino
  1802. 1:08:17Opta and I'm going to use the user
  1803. 1:08:18button, which is on the front of the
  1804. 1:08:20PLC. Uh so, you could see there actually
  1805. 1:08:23when I was pushing that button, it was
  1806. 1:08:24doing stuff. That's cuz I have different
  1807. 1:08:26code on there as shown by this diff code
  1808. 1:08:29thing uh in the bottom left of my window
  1809. 1:08:31right there.
  1810. 1:08:32Um
  1811. 1:08:33so, maybe I'll hang out right there so
  1812. 1:08:34you can see my tab.
  1813. 1:08:36Um but right now, I'm going to go ahead
  1814. 1:08:39and just download this empty uh
  1815. 1:08:41PLC program to it so that there's
  1816. 1:08:43nothing on my PLC. Uh
  1817. 1:08:46and then we'll be in exactly the same
  1818. 1:08:48spot. So, compiling sketch. Please wait.
  1819. 1:08:52I will wait for you, Arduino.
  1820. 1:09:00Okay. So, once you get source okay, or
  1821. 1:09:03you might have had nothing. Um but in
  1822. 1:09:05this case, now we have PLC that has
  1823. 1:09:08nothing on it. Uh pushing the button
  1824. 1:09:10does nothing. The lights are not there.
  1825. 1:09:12The green light isn't even on. You would
  1826. 1:09:14not know anything was working on this.
  1827. 1:09:16Um so, let's go to the resources and
  1828. 1:09:20click on the Opta. Um this should still
  1829. 1:09:22look good. But since we're using the
  1830. 1:09:24button and the LEDs that are on the
  1831. 1:09:27Opta, we're going to add variables here.
  1832. 1:09:29So, the name of them is just kind of how
  1833. 1:09:32you identify what the button is. There's
  1834. 1:09:34one push button on the front of the Opta
  1835. 1:09:37that is programmable. The other one is
  1836. 1:09:39the reset button, which is used for like
  1837. 1:09:42factory resetting. So, there's only one
  1838. 1:09:44button on the front of the Opta we can
  1839. 1:09:45use.
  1840. 1:09:47It's the user push button. So, I'm going
  1841. 1:09:49to assign it a variable name that is
  1842. 1:09:51just going to be user, all caps like
  1843. 1:09:53that. Now, I'm going to go to LED
  1844. 1:09:55outputs and I'm going to do basically
  1845. 1:09:56the same thing. L1, L2, L3, L4.
  1846. 1:10:02LR, LG, LB.
  1847. 1:10:06And so, this is my
  1848. 1:10:08exist is not automatic, that's fine.
  1849. 1:10:11LR.
  1850. 1:10:13Okay, it's really unhappy.
  1851. 1:10:17Oh, mercy. Okay, I'm going to call this
  1852. 1:10:20red,
  1853. 1:10:22green,
  1854. 1:10:23and blue.
  1855. 1:10:25Uh basically, you need to assign
  1856. 1:10:27variable names to these uh
  1857. 1:10:29hard-coded inputs and outputs so that we
  1858. 1:10:32can use them in our program. So, we have
  1859. 1:10:34L1 through L4 refers to the four status
  1860. 1:10:37lights at the bottom of the Opta and
  1861. 1:10:39then red and green show up in the same
  1862. 1:10:41spot above the reset button and blue
  1863. 1:10:43shows up right above uh the user button.
  1864. 1:10:46So, we're assigning all those variable
  1865. 1:10:48names so that when we go to write our
  1866. 1:10:50program here in main, we have user and
  1867. 1:10:54uh all seven of those lights that we can
  1868. 1:10:56play around with.
  1869. 1:10:58So, let's write functionally
  1870. 1:11:01what can be considered uh the hello
  1871. 1:11:04world, the intro to programming for
  1872. 1:11:07structured text. Let's say green equals
  1873. 1:11:10true. And a couple important syntax
  1874. 1:11:12things here is green colon equals is how
  1875. 1:11:16you set a value equal to true, all caps,
  1876. 1:11:20and then a semicolon. So, for structured
  1877. 1:11:22text, it's variable that you want to
  1878. 1:11:25change the value of and then setting a
  1879. 1:11:27value is colon equals and then the value
  1880. 1:11:30you want to set it to and then a
  1881. 1:11:32semicolon. And this should compile and
  1882. 1:11:35download, so I'll hit this little button
  1883. 1:11:36for download PLC code. It'll ask me if I
  1884. 1:11:39want to compile it. Say yes.
  1885. 1:11:42And now, if I hold up the PLC, the green
  1886. 1:11:45light is on, okay? So, that's my hello
  1887. 1:11:48world right there. That's the green
  1888. 1:11:50light is on. I am talking to the PLC and
  1889. 1:11:52it is listening.
  1890. 1:11:54Now, let's go ahead and go a little bit
  1891. 1:11:56further. Let's say that red will be
  1892. 1:11:58equal to false. By default, it'll be
  1893. 1:12:00off, but
  1894. 1:12:01um let's go ahead and say blue is equal
  1895. 1:12:04to user, okay? So, uh you'll notice the
  1896. 1:12:08colon equal sign for all of those and
  1897. 1:12:10the semicolon at the end for all of
  1898. 1:12:12those. And all I'm doing is making sure
  1899. 1:12:14the red light is off, but the blue
  1900. 1:12:16light, I'm doing something a little more
  1901. 1:12:18interesting here. I'm saying it's equal
  1902. 1:12:19to the value of user. And I'm going to
  1903. 1:12:22do something here. I'm going to add all
  1904. 1:12:24of these values to watch uh just by
  1905. 1:12:27right-clicking on the variables that I
  1906. 1:12:28want to watch. I'm going to add them to
  1907. 1:12:30watch and I have this window over here
  1908. 1:12:33that's the watch window and it shows the
  1909. 1:12:35current value of them. The current value
  1910. 1:12:37of green is true because my original
  1911. 1:12:39code was just green equals true. So, now
  1912. 1:12:42if I download and compile this
  1913. 1:12:45and then hold the PLC up, you'll see
  1914. 1:12:47green is still true, red is still off,
  1915. 1:12:50and that's all good. But, if I go ahead
  1916. 1:12:51and push this button, you'll see the
  1917. 1:12:53blue light turns on. And if you're
  1918. 1:12:55watching the watch window here, you'll
  1919. 1:12:56see user and blue change when I push the
  1920. 1:12:59button.
  1921. 1:13:00Okay? So, uh that's actually it's pretty
  1922. 1:13:04cool how fast we're able to advance
  1923. 1:13:06through this uh PLC programming
  1924. 1:13:07tutorial. We're now controlling the
  1925. 1:13:09state of an output from an input. So,
  1926. 1:13:13the input being that user push button,
  1927. 1:13:15blue being the output light. Um but,
  1928. 1:13:18you're not really learning too much
  1929. 1:13:19structured text with this. We're just
  1930. 1:13:21directly setting values based on uh
  1931. 1:13:23other values. So, let's go ahead and
  1932. 1:13:25take a look at an if else if statement.
  1933. 1:13:28Uh let's say if the user push button is
  1934. 1:13:32pressed,
  1935. 1:13:34so if user semicolon, actually if user
  1936. 1:13:38then and no semicolon, I get my uh
  1937. 1:13:41Python, my C++, and my structured text
  1938. 1:13:44syntaxes messed up. But, here we're
  1939. 1:13:46checking if a Boolean value is true. So,
  1940. 1:13:49it's just if user, so if the user push
  1941. 1:13:52button is pressed, then let's go ahead
  1942. 1:13:55and set L1
  1943. 1:13:56equal to true.
  1944. 1:13:58And let's go ahead and do L2 also equal
  1945. 1:14:01to true. And let's just make sure that
  1946. 1:14:04L3 is off when the push button is
  1947. 1:14:07pressed and that L4
  1948. 1:14:09is off when I push the push button in.
  1949. 1:14:12Now, I'm going to do else if
  1950. 1:14:15not user. So, this is about the same
  1951. 1:14:18thing as an else statement um but, I
  1952. 1:14:21think it's important to call out that
  1953. 1:14:23else if in structured text looks a
  1954. 1:14:25little different than most programming
  1955. 1:14:26languages. So, it's this E L S I F and
  1956. 1:14:30then not user.
  1957. 1:14:32Then,
  1958. 1:14:33and you'll notice if user then and else
  1959. 1:14:36if user then don't have semicolons, but
  1960. 1:14:38all these command lines do. So, I'll
  1961. 1:14:41copy these four instructions here
  1962. 1:14:43and I'll
  1963. 1:14:46shift tab, there we go. I'll change L3
  1964. 1:14:50and L4 to the ones that should be on and
  1965. 1:14:52L1 and L2 to the two that should be off.
  1966. 1:14:55And then, super important in structured
  1967. 1:14:57text, you need end underscore if and
  1968. 1:15:00then a semicolon, okay? So, unless I
  1969. 1:15:02missed something important, which is
  1970. 1:15:04perfectly possible, this should make uh
  1971. 1:15:07the the bottom four status lights
  1972. 1:15:09flip-flop once it's downloaded.
  1973. 1:15:12Okay? So, actually good sign, you can
  1974. 1:15:15see that three and four turn on with the
  1975. 1:15:17button button not pressed. So, I'll go
  1976. 1:15:19ahead and press the button and there you
  1977. 1:15:21go. You can see all four of the status
  1978. 1:15:24lights on the bottom of the PLC as well
  1979. 1:15:26as the blue light are changing.
  1980. 1:15:29Okay, so that's cool. That's if and else
  1981. 1:15:31if and an end if statement. Um but,
  1982. 1:15:33again, it's all pretty uh straight-up
  1983. 1:15:36Boolean binary comparisons.
  1984. 1:15:40So, let's add one more thing here uh for
  1985. 1:15:42this introduction to structured text.
  1986. 1:15:44Let's add a variable and do a little bit
  1987. 1:15:46of sequencing, okay?
  1988. 1:15:49So, let's go into uh project and global
  1989. 1:15:52variables, double-click, and I'm going
  1990. 1:15:55to insert two variables here. I'm going
  1991. 1:15:57to call one last underscore user. And
  1992. 1:16:01this is going to be a Boolean that I'm
  1993. 1:16:03going to use to track the last state of
  1994. 1:16:06the user push button. So, similarly, if
  1995. 1:16:09you've done anything in Arduino or other
  1996. 1:16:11programming languages, sometimes you
  1997. 1:16:13want a condition that only happens on
  1998. 1:16:15the rising edge of a value. And to do
  1999. 1:16:17that, you want some sort of variable to
  2000. 1:16:20track the last state of it. Uh and then
  2001. 1:16:22at the end of your routine, you'll set
  2002. 1:16:24last user equal to user. Uh and then
  2003. 1:16:27this second variable, I will just call
  2004. 1:16:29position and I'm actually going to make
  2005. 1:16:31this an integer.
  2006. 1:16:33And I'm going to say initially I want it
  2007. 1:16:35to be zero. Initially, I'll have this be
  2008. 1:16:37false.
  2009. 1:16:39False. So, those are just initial
  2010. 1:16:41values. Come on. There we go. Oh, I have
  2011. 1:16:44caps lock on.
  2012. 1:16:46Okay. Uh and I'm going to use position
  2013. 1:16:48to track where in the sequence we are.
  2014. 1:16:53And here I'm going to give it an
  2015. 1:16:55attribute called retain, which means on
  2016. 1:16:58uh downloads and power cycles, it's
  2017. 1:17:00going to keep its value. Uh so, that's a
  2018. 1:17:03useful thing when you have some sort of
  2019. 1:17:05PLC program that you want to hold values
  2020. 1:17:08even when you download new iterations of
  2021. 1:17:10the code, you want it to be set to
  2022. 1:17:12retain, okay? So, we made a few new
  2023. 1:17:15global variables that we can use in our
  2024. 1:17:16code. Let's go back to main and we're
  2025. 1:17:19going to scrap most of this, all of this
  2026. 1:17:21really.
  2027. 1:17:23And let's go ahead and start by setting
  2028. 1:17:25L1 through L4 all equal to false here in
  2029. 1:17:29the beginning. Um and a little way that
  2030. 1:17:32structured text programming works is
  2031. 1:17:34this code is going to go through and set
  2032. 1:17:37all four of these lights equal to false
  2033. 1:17:40uh at the beginning of each scan, but
  2034. 1:17:43it's only going to matter what the value
  2035. 1:17:45of it is at the end of the scan. So, if
  2036. 1:17:47you had code here that said green equals
  2037. 1:17:50true and then you added a line here that
  2038. 1:17:52said green equals false within your code
  2039. 1:17:56right here, you're changing the value of
  2040. 1:17:59green to true and then to false, but
  2041. 1:18:01what's going to happen, the only thing
  2042. 1:18:03that would actually happen if you ran
  2043. 1:18:04this code, so let's just do it,
  2044. 1:18:07is whoops, there we go. Is the green
  2045. 1:18:10light will be false. All the lights will
  2046. 1:18:12be false. It doesn't show green turning
  2047. 1:18:14on and then green turning off because
  2048. 1:18:17the only thing that executes is the
  2049. 1:18:19value of the variables at the end of the
  2050. 1:18:21routine. So, by setting L1 through L4
  2051. 1:18:24false at the beginning, we have the rest
  2052. 1:18:26of this code to decide if we want to
  2053. 1:18:29turn uh L1 through L4 off
  2054. 1:18:32or on.
  2055. 1:18:34So, what we're going to do is we're
  2056. 1:18:35going to say if position
  2057. 1:18:38is equal to one, then I want L1 equal to
  2058. 1:18:43true, okay? And uh a couple things to
  2059. 1:18:46call out here in structured text, the
  2060. 1:18:48comparison is just single equal sign.
  2061. 1:18:52Most programming languages that you've
  2062. 1:18:54probably seen before, two equal signs is
  2063. 1:18:56how you check for equality. Um it's
  2064. 1:18:59definitely how Python works and that's
  2065. 1:19:01my favorite, so uh then we're going to
  2066. 1:19:03say else if position is equal to two, L2
  2067. 1:19:06is equal to true.
  2068. 1:19:08And then we'll say else if position
  2069. 1:19:11three, L3, else if position four, L4.
  2070. 1:19:15And then we'll say else if one more
  2071. 1:19:17thing and then I'm going to end if.
  2072. 1:19:20Okay? So, let's just get this all lined
  2073. 1:19:23up. Position three, three. Position
  2074. 1:19:26four, four. And now, let's say else if
  2075. 1:19:29position is greater than four,
  2076. 1:19:33then what I want to do here, dang, then
  2077. 1:19:36what I want to do here is say, "Okay,
  2078. 1:19:38position has been has exceeded my max
  2079. 1:19:41step, so I'm going to set back to zero.
  2080. 1:19:43I'm going to put back to the beginning."
  2081. 1:19:45And notice that the if thens don't have
  2082. 1:19:47semicolons at the end, uh but end if
  2083. 1:19:50does and all of the action lines in each
  2084. 1:19:53if condition do have semicolons.
  2085. 1:19:56Okay, so this is great, but nothing's
  2086. 1:19:58actually changing the state of position
  2087. 1:20:00yet.
  2088. 1:20:01So, let's move this down a little bit
  2089. 1:20:03and let's say if the user button gets
  2090. 1:20:06pressed
  2091. 1:20:07and it's a rising edge. So, not me
  2092. 1:20:09holding down the user button. Let me say
  2093. 1:20:12this is just when user first gets
  2094. 1:20:14pressed. So, if user and not last user,
  2095. 1:20:19then I want position to be equal to
  2096. 1:20:21position plus one
  2097. 1:20:23and then end my if statement. And I
  2098. 1:20:25missed a semicolon there.
  2099. 1:20:27Then at the very end, like we talked
  2100. 1:20:29about, we're going to say last user, set
  2101. 1:20:33it equal to the value of user. Okay? So,
  2102. 1:20:36this should be all we need. This is
  2103. 1:20:39setting the initial values of all of our
  2104. 1:20:41lights.
  2105. 1:20:43And just to make sure this new program
  2106. 1:20:45really took, let's go ahead and say we
  2107. 1:20:46actually want red to be on now and we're
  2108. 1:20:50going to turn green off. So, when this
  2109. 1:20:52boots up, if it's working properly,
  2110. 1:20:54we'll know right away from red being on
  2111. 1:20:56and green being off. Let's see if we
  2112. 1:20:58made any errors.
  2113. 1:20:59Looks good cuz I'm a professional. And
  2114. 1:21:02the red light's on, nothing else is on,
  2115. 1:21:04which makes sense based on the code that
  2116. 1:21:06we wrote. And let me try to get this
  2117. 1:21:08framed properly. I'm going to push the
  2118. 1:21:10button and the blue light turns on and
  2119. 1:21:12position one turns on. Push it again,
  2120. 1:21:15position two turns on, three, four,
  2121. 1:21:18zero. One, two, three, four, zero. Okay?
  2122. 1:21:22And you can add position to your watch
  2123. 1:21:24window, add to watch, as well as last
  2124. 1:21:27user, if you really want to, as well as
  2125. 1:21:29L1 through L4. Um and now, as you're
  2126. 1:21:32cycling through pressing the button, you
  2127. 1:21:34can see the value of position change
  2128. 1:21:36every time you push the button. As and
  2129. 1:21:38blue, user, and last user all change
  2130. 1:21:41almost exactly together. Um
  2131. 1:21:45but so that's really fun. That's basic
  2132. 1:21:47sequencing. Um a very common way to
  2133. 1:21:50write uh controls sequencing is in step
  2134. 1:21:54one, do a series of things, and then,
  2135. 1:21:56once you've checked some condition, like
  2136. 1:21:58pressure, flow, temperature, move to
  2137. 1:22:00step two, and then do a series of things
  2138. 1:22:03in step two. So, this sort of sequential
  2139. 1:22:05move through a position value uh is
  2140. 1:22:08actually a really great introduction to
  2141. 1:22:10PLC programming. So, that's some basic
  2142. 1:22:12structured text, I think. Uh up next,
  2143. 1:22:14we'll sort of recreate this program in
  2144. 1:22:17ladder logic, so you get to see both of
  2145. 1:22:19the main sort of two uh PLC programming
  2146. 1:22:22languages that sort of duke it out for
  2147. 1:22:23ultimate control.
  2148. 1:22:25Um but I hope you found this uh
  2149. 1:22:26introduction to structured text
  2150. 1:22:28programming useful. The Arduino Opta is
  2151. 1:22:30a really cool, affordable way to get
  2152. 1:22:32into PLC programming. Thank you to
  2153. 1:22:34Arduino for providing the hardware for
  2154. 1:22:35this video. I hope you learned something
  2155. 1:22:37with this structured text uh tutorial.
  2156. 1:22:39Let me know what you want to see next on
  2157. 1:22:41the channel. Thank you for watching and
  2158. 1:22:42we'll see you next time. Thanks. Bye.
  2159. 1:22:52Hello and welcome back to the channel.
  2160. 1:22:53In today's video, I'm going to show you
  2161. 1:22:55how to make your first PLC program in
  2162. 1:22:57ladder diagram. Uh this is a super
  2163. 1:23:00popular, super common PLC programming
  2164. 1:23:02language. And to show you how ladder
  2165. 1:23:05diagram works, I'm actually going to
  2166. 1:23:07show you the structured text program
  2167. 1:23:09that I built in the last tutorial. Um
  2168. 1:23:11and I'm going to convert that exact
  2169. 1:23:13program from structured text into ladder
  2170. 1:23:16line by line with you. But I wanted to
  2171. 1:23:17show you what the program does first
  2172. 1:23:20because ladder is a very visual
  2173. 1:23:21programming language.
  2174. 1:23:23And it's pretty different from C or
  2175. 1:23:25Python or C#. Uh so so if you're getting
  2176. 1:23:28into programming for the first time,
  2177. 1:23:30that's not a big deal. But if you've
  2178. 1:23:32been a programmer for a while and you're
  2179. 1:23:33getting into controls, this is a more
  2180. 1:23:36useful way to learn it in my opinion.
  2181. 1:23:38So, the code that you can see on screen
  2182. 1:23:40right now does the following to the PLC.
  2183. 1:23:42The red light is always on. I have a
  2184. 1:23:45green status light up here that is
  2185. 1:23:47always off. And then the blue light
  2186. 1:23:49turns on when I push the button that's
  2187. 1:23:51under my index finger. So, when I push
  2188. 1:23:53the button, the blue light turns on with
  2189. 1:23:55the button. Then down here, the four
  2190. 1:23:57green status lights over here, I have
  2191. 1:23:59them go in sequence from zero, position
  2192. 1:24:03zero, to position one, two, three, and
  2193. 1:24:05four. Okay? So, the whole routine that
  2194. 1:24:08you see here
  2195. 1:24:10sets the initial values of all seven of
  2196. 1:24:12those lights that I just mentioned. And
  2197. 1:24:14then it says, "Hey, if the user button
  2198. 1:24:16was just pressed and the last state of
  2199. 1:24:19the user button was that it wasn't
  2200. 1:24:20pressed, add one to this position
  2201. 1:24:22variable and then end the if statement."
  2202. 1:24:25Uh and then it checks if we're in
  2203. 1:24:27position one, turn L1 on. If we're in
  2204. 1:24:29position two, turn L2 on. If we're in
  2205. 1:24:31position three, turn L3 on. Four, L4 on.
  2206. 1:24:35And then if position exceeds four,
  2207. 1:24:36meaning I pushed it a fifth time, set it
  2208. 1:24:39back equal to zero. And then lastly, set
  2209. 1:24:42the last user variable equal to user.
  2210. 1:24:45Okay? So, if you have a PLC uh an
  2211. 1:24:48Arduino PLC in your programming along,
  2212. 1:24:51make sure that um from your overview
  2213. 1:24:53screen, you're it kind of looks like
  2214. 1:24:55this. Uh I should have started if I did
  2215. 1:24:58this the right order, I should have
  2216. 1:24:59started with a video on how to get set
  2217. 1:25:01up with your Arduino Opta PLC. Um so,
  2218. 1:25:04make sure you watch that if you're not
  2219. 1:25:06at this step and you're trying to code
  2220. 1:25:08along exactly with this tutorial. Get to
  2221. 1:25:10this step um where the license looks
  2222. 1:25:13okay and all the available interfaces
  2223. 1:25:15look okay and it says connected in the
  2224. 1:25:17bottom right. Um
  2225. 1:25:19again, I should have done a tutorial on
  2226. 1:25:21how to get here, so just check my
  2227. 1:25:22channel. Or if you're watching all these
  2228. 1:25:24videos smashed together, check the first
  2229. 1:25:26section of this video for that. Um
  2230. 1:25:29now, two other things we did uh in the
  2231. 1:25:31structured text video to set ourselves
  2232. 1:25:33up that you want double-check are in
  2233. 1:25:34there. We went to button inputs and the
  2234. 1:25:37user that is on the front of the PLC,
  2235. 1:25:40the user button,
  2236. 1:25:42we added the variable uh so that we
  2237. 1:25:44could call it user in our program. So,
  2238. 1:25:45make sure you have user or something
  2239. 1:25:47easy to remember there. And then for LED
  2240. 1:25:50outputs, I added the variable names L1
  2241. 1:25:52through L4, red, green, and blue
  2242. 1:25:56to all seven of these lights so that I
  2243. 1:25:58could call these lights from the PLC as
  2244. 1:25:59well. So, make sure you have all those
  2245. 1:26:02variable names or you'll be like,
  2246. 1:26:04"Hey, my version that I'm trying to
  2247. 1:26:06follow along with uh doesn't compile and
  2248. 1:26:09says that like those variable names
  2249. 1:26:10don't exist or something like that."
  2250. 1:26:12Okay? So, uh with that basic setup, with
  2251. 1:26:15these variable names, with these button
  2252. 1:26:17inputs, uh let's go ahead and go to
  2253. 1:26:20project and let's go to add and new
  2254. 1:26:24program. And we'll call this name we'll
  2255. 1:26:27call this ladder one cuz I might do more
  2256. 1:26:30ladder. And make sure you have LD,
  2257. 1:26:33ladder diagram, selected. Structured
  2258. 1:26:35text was what we did in the last video.
  2259. 1:26:38And we're going to assign it to fast.
  2260. 1:26:40So, these are different scan rates,
  2261. 1:26:42fast, slow, backward background, and
  2262. 1:26:44init. We might get more into it later or
  2263. 1:26:46just let me know if you have questions
  2264. 1:26:48about when to assign what to where.
  2265. 1:26:50Uh but we're going to assign it to fast.
  2266. 1:26:52No reason not to go fast. Um and let's
  2267. 1:26:55just go line by line of what's happening
  2268. 1:26:57in this main PLC and talk about how to
  2269. 1:27:00recreate that in ladder.
  2270. 1:27:02Okay? So, the first line is green equals
  2271. 1:27:04false. So, how do we make a line of code
  2272. 1:27:08in ladder diagram to set an output equal
  2273. 1:27:10to false all the time? Well, we're going
  2274. 1:27:13to use this output coil, which is what
  2275. 1:27:14this object looks like. We're going to
  2276. 1:27:16put the variable green in it. And
  2277. 1:27:20currently, what it reads as is actually
  2278. 1:27:22green is always true. So, I'm going to
  2279. 1:27:24double-click on that coil and I'm going
  2280. 1:27:26to negate it. And this strike through,
  2281. 1:27:30this uh open parentheses, let hash line
  2282. 1:27:33slash line, and then close parentheses
  2283. 1:27:35reads as not. So, it's basically green
  2284. 1:27:39is not on. If I copy this whole ladder
  2285. 1:27:42one
  2286. 1:27:43and I change this to normal and I change
  2287. 1:27:46this name to red,
  2288. 1:27:48this line of code reads as red is always
  2289. 1:27:51on. So, we have green always false, red
  2290. 1:27:55always true. That's what line one and
  2291. 1:27:57line two here are doing. And it looks
  2292. 1:28:00like this in structured text. Green is
  2293. 1:28:02false, red is true. Okay? So, you can
  2294. 1:28:05see right away just with this basic
  2295. 1:28:06comparison that ladder is a super visual
  2296. 1:28:09language. There's nothing that
  2297. 1:28:10explicitly tells you it's true or false.
  2298. 1:28:13It's telling you based on what sort of
  2299. 1:28:15relays in electrical schematics look
  2300. 1:28:16like that green will not be true and red
  2301. 1:28:19will not be false.
  2302. 1:28:21Uh green will not be true and red will
  2303. 1:28:23always be true. So, let's look at the
  2304. 1:28:25next line of code, which if you
  2305. 1:28:27remember, was that blue, the blue light,
  2306. 1:28:29will be exactly equal to the input of
  2307. 1:28:32the user push button. So, I click on
  2308. 1:28:34that coil again and I say, "Hey, we're
  2309. 1:28:36going to control the blue light." But
  2310. 1:28:38we're going to control it based on an
  2311. 1:28:40input now. So, this is called a contact.
  2312. 1:28:43These on the right that are controlling
  2313. 1:28:44outputs are called coils. This on the
  2314. 1:28:47left is called a contact. And we're
  2315. 1:28:49going to say
  2316. 1:28:50equal to
  2317. 1:28:52the user input. So, the way this line of
  2318. 1:28:54code reads as if user push button is
  2319. 1:28:58pressed, then blue light is on. But
  2320. 1:29:00there's a second thing going on here,
  2321. 1:29:02which is if user push button is not
  2322. 1:29:05pressed, blue light is off. And that's
  2323. 1:29:07because this output is a momentary
  2324. 1:29:10output, which means the blue light will
  2325. 1:29:13be on as long as the conditions on the
  2326. 1:29:15left of this rung are true. but by
  2327. 1:29:17default, the blue light will then go off
  2328. 1:29:20when the conditions on the left side are
  2329. 1:29:22false. So, this sort of has if user,
  2330. 1:29:25then blue light, and if not user, then
  2331. 1:29:28not blue light baked into one line of
  2332. 1:29:31code.
  2333. 1:29:32So, it really is the same way this says
  2334. 1:29:34blue is equal to user, whether it's
  2335. 1:29:36true, whether it's false, set blue equal
  2336. 1:29:38to user. That is basically exactly what
  2337. 1:29:41this line of code is doing. So, so far
  2338. 1:29:43we have three for three recreated from
  2339. 1:29:45structured text. Now, this is us setting
  2340. 1:29:48the initial value of all four of those
  2341. 1:29:50lights equal to false. So, we're going
  2342. 1:29:51to copy this green line, which is
  2343. 1:29:54this whole rung, which is setting green
  2344. 1:29:57equal to false. And let's see, can I
  2345. 1:30:00move that down? I really want it in
  2346. 1:30:01exactly the same
  2347. 1:30:04I really want it in exactly the same
  2348. 1:30:05spot. There we go. So, I'm going to
  2349. 1:30:07change this to L1.
  2350. 1:30:09And now, rather than make four rungs of
  2351. 1:30:12code to do the exact same thing for
  2352. 1:30:14these lights, I'm going to just control
  2353. 1:30:16C and then control V right here.
  2354. 1:30:19And you can see it sort of puts this
  2355. 1:30:21branch in, which is saying, "Hey, the
  2356. 1:30:23same input conditions are true for all
  2357. 1:30:26of the outputs on this rung." So, the
  2358. 1:30:28four outputs are just L1 through L4. Set
  2359. 1:30:31them equal to not true.
  2360. 1:30:34Um but, the input is shared by all four
  2361. 1:30:36of them.
  2362. 1:30:37All right. So, this is how we say L1,
  2363. 1:30:40L2, L3, L4 equals false. That's what
  2364. 1:30:43rung four through seven here are doing.
  2365. 1:30:46Let's just keep going. Let's take a look
  2366. 1:30:48at saying if user and not last user,
  2367. 1:30:52then position equals position plus one.
  2368. 1:30:55Okay? That's the line of code that
  2369. 1:30:57checks when the user button is first
  2370. 1:30:59pressed uh and adds one to the position
  2371. 1:31:02incrementer. So, to do that, we'll say
  2372. 1:31:04right click, new network after.
  2373. 1:31:07And now, we're going to check two
  2374. 1:31:09conditions. We're going to check if
  2375. 1:31:10user, and then I'm just going to control
  2376. 1:31:13C, control V this.
  2377. 1:31:15And we're going to check if not user so
  2378. 1:31:18last user.
  2379. 1:31:20So, last user, but this one needs to be
  2380. 1:31:22negated. And this is saying if the user
  2381. 1:31:25push button is pressed and the last user
  2382. 1:31:28Boolean is not true, then but we can't
  2383. 1:31:32use a coil anymore. A coil is
  2384. 1:31:34specifically just for Boolean
  2385. 1:31:35conditions. It's for true false things.
  2386. 1:31:38We need to adjust an integer value,
  2387. 1:31:40which is called position. Ah, and I
  2388. 1:31:42forgot to say this in the setup, but if
  2389. 1:31:44you go to global variables, these two
  2390. 1:31:46were made for the structured text
  2391. 1:31:48tutorial. The variable last user, which
  2392. 1:31:51is a Boolean, and I have the initial
  2393. 1:31:53value set to false, which will be how we
  2394. 1:31:55track the last state of the user push
  2395. 1:31:57button. And then position, which is an
  2396. 1:31:59integer, which will start out as zero.
  2397. 1:32:02And I have retain on, which means it
  2398. 1:32:03will
  2399. 1:32:04keep its value on new iterations of the
  2400. 1:32:07code being pushed. So, if position is
  2401. 1:32:09set to three, when I update the code, it
  2402. 1:32:11will stay as a three.
  2403. 1:32:13Um
  2404. 1:32:14and that will track where in the
  2405. 1:32:15sequence we currently are. So, let's go
  2406. 1:32:17back to our ladder. Just make sure you
  2407. 1:32:19have these global variables set if
  2408. 1:32:20you're following along exactly.
  2409. 1:32:22Um and we'll say if user and not last
  2410. 1:32:25user. And now, we need a new block. And
  2411. 1:32:28if you're if you don't have this toolbar
  2412. 1:32:30in here, go to project. No, go to view,
  2413. 1:32:33toolbars.
  2414. 1:32:35View, toolbars, and make sure FBD is on.
  2415. 1:32:37Uh if you have a decent size monitor,
  2416. 1:32:39you can have all of these toolbars on.
  2417. 1:32:41It doesn't really hurt to have SFC.
  2418. 1:32:44Um it's just it's not something we need
  2419. 1:32:46right now.
  2420. 1:32:47Um so, but you do need FBD because new
  2421. 1:32:50block exists in FBD.
  2422. 1:32:53And then, when you add a new block, uh
  2423. 1:32:56this object browser lets you type in
  2424. 1:32:58text and search for things, but you need
  2425. 1:32:59to have most of the objects checked and
  2426. 1:33:01selected. So, you could have them all
  2427. 1:33:03checked and selected. That's not going
  2428. 1:33:05to hurt you. It's just going to give you
  2429. 1:33:06the most options. And the first thing we
  2430. 1:33:09want to check for is an add function.
  2431. 1:33:11Okay? So, ADD because what we want to do
  2432. 1:33:15is say if user and not last user, then
  2433. 1:33:19add one
  2434. 1:33:21to
  2435. 1:33:22position.
  2436. 1:33:24And store that value in the position
  2437. 1:33:26variable, and then we don't need a coil
  2438. 1:33:28on this rung. Okay? So, this line of
  2439. 1:33:31code, if user and not user, add one to
  2440. 1:33:34position, looks very visually different
  2441. 1:33:37from this if user and not last user,
  2442. 1:33:40then position equals position plus one
  2443. 1:33:42and if, but those are clones. Those are
  2444. 1:33:44functionally equivalent. Okay?
  2445. 1:33:47And just so I don't forget cuz it comes
  2446. 1:33:49at the very end, but we might as well
  2447. 1:33:51set it right now.
  2448. 1:33:52Um we want the last network, so the
  2449. 1:33:55bottom network in this to be set
  2450. 1:33:58last user
  2451. 1:34:00equal to user because uh ladder logic
  2452. 1:34:04reads top to bottom and left to right.
  2453. 1:34:07So, every scan of the PLC will start
  2454. 1:34:09from one and go down to however however
  2455. 1:34:12many rungs we have in our code. And then
  2456. 1:34:14at the end, it will set last user equal
  2457. 1:34:17to user. So, this line of code will only
  2458. 1:34:20ever be true once at a time per button
  2459. 1:34:23press, and then last user will
  2460. 1:34:24immediately get set to the same value as
  2461. 1:34:26user.
  2462. 1:34:28Hopefully, that makes sense.
  2463. 1:34:29Uh now, let's add a new rung here
  2464. 1:34:33to do these steps here, which is if
  2465. 1:34:35position one, then L1. If position two,
  2466. 1:34:38then L2. And then, all the way through
  2467. 1:34:40to if four, uh then four. And so, let's
  2468. 1:34:43just go ahead. We need a new block here.
  2469. 1:34:45We actually don't need either of these
  2470. 1:34:47coils, but we need a new block, which
  2471. 1:34:49will be checking for equality. So,
  2472. 1:34:51that's EQ.
  2473. 1:34:53And uh you grab the EQ block and you say
  2474. 1:34:56if the position value
  2475. 1:34:59is equal to one,
  2476. 1:35:02then
  2477. 1:35:03L1.
  2478. 1:35:04And this rung of code is the exact same
  2479. 1:35:07thing as if position one,
  2480. 1:35:09uh then L1 from structured text right
  2481. 1:35:12here. So, this is if position one, then
  2482. 1:35:14L1 equals true.
  2483. 1:35:16So, we just need to copy that 1 2 3 4 so
  2484. 1:35:21that we can say, "Okay, now if two, then
  2485. 1:35:26L2.
  2486. 1:35:28If
  2487. 1:35:29three,
  2488. 1:35:31L3.
  2489. 1:35:33And I somehow got them out of order.
  2490. 1:35:36Okay, 1 2
  2491. 1:35:383
  2492. 1:35:39L3.
  2493. 1:35:42And then, if four,
  2494. 1:35:45L4. And now, we need just one more rung
  2495. 1:35:49of code because if you remember from our
  2496. 1:35:51structured text, we had if position is
  2497. 1:35:53greater than four, then we need to set
  2498. 1:35:56position back equal to four. So, we'll
  2499. 1:35:58put in a new network after this. And we
  2500. 1:36:00need two new blocks. We need to check uh
  2501. 1:36:03for greater than. So, we'll go to block
  2502. 1:36:05and we'll check uh GT is the code for
  2503. 1:36:09greater than. If you ever can't find it
  2504. 1:36:11uh because they're not all named super
  2505. 1:36:14intuitively, you can just put a star in
  2506. 1:36:16there and all of them will show up. And
  2507. 1:36:18a little bit of scrolling, you'll see GE
  2508. 1:36:20is greater than or equal to. GE GT is
  2509. 1:36:23just regular old greater than.
  2510. 1:36:26And we'll say, "Okay, if the position
  2511. 1:36:29variable is greater than four."
  2512. 1:36:32Now, the difference here is we don't
  2513. 1:36:33want to change a output based on this.
  2514. 1:36:36We actually want the next uh block in
  2515. 1:36:39the rung to be controlled by this. Cuz
  2516. 1:36:41if we just hit another block and we grab
  2517. 1:36:43MOVE, which is how you move a value into
  2518. 1:36:47a variable,
  2519. 1:36:48and we say this is when we're going to
  2520. 1:36:50want to move zero into the position
  2521. 1:36:53value like that. Problem is we need this
  2522. 1:36:56tied to this. We can't use enable
  2523. 1:36:58output. This is always going to be true.
  2524. 1:37:01We need this output to be tied into
  2525. 1:37:03that. So, to do that, you delete this
  2526. 1:37:05little tag. You right click on the body
  2527. 1:37:07of the object and you say new con Nope,
  2528. 1:37:11it's set output line.
  2529. 1:37:14There we go. Set output line. Okay? So,
  2530. 1:37:17this is what you want it to look like to
  2531. 1:37:18actually say if position greater than
  2532. 1:37:21four, go move zero into position.
  2533. 1:37:24But, these 11 lines of ladder, and you
  2534. 1:37:27can see it's quite a bit more scrolling
  2535. 1:37:29than this little view of structured
  2536. 1:37:31text, but functionally identical.
  2537. 1:37:33Setting the same preliminary values and
  2538. 1:37:35then sequencing through the PLC. And
  2539. 1:37:38just so you can see that it's
  2540. 1:37:39functionally identical, I'm going to go
  2541. 1:37:40ahead and delete this out of this uh out
  2542. 1:37:43of this structured text. And then, I'm
  2543. 1:37:45just going to delete Actually, I'm going
  2544. 1:37:47to just going to delete main out of the
  2545. 1:37:48routine so that the only thing on here
  2546. 1:37:51is this ladder routine. And now, I'm
  2547. 1:37:53going to download it to my PLC. I will
  2548. 1:37:56compile it.
  2549. 1:37:58And I've got it up here. Make sure you
  2550. 1:38:02got a good view. Okay? Push the button.
  2551. 1:38:04Blue turns on.
  2552. 1:38:06And we're cycling through it exactly
  2553. 1:38:08like the structured text that we had at
  2554. 1:38:10the start of the video. Okay? So, I know
  2555. 1:38:13it might seem a little odd to rather
  2556. 1:38:15than build something from scratch,
  2557. 1:38:17compare it to structured text, but I
  2558. 1:38:19really think if you're a PLC programmer,
  2559. 1:38:21it's really important to understand how
  2560. 1:38:24ladder logic correlates to structured
  2561. 1:38:26text. Those are by far the two most
  2562. 1:38:29common PLC programming languages that
  2563. 1:38:31drive entire factories. So, knowing both
  2564. 1:38:33of them is a really good idea. I hope
  2565. 1:38:36you found this introductory tutorial
  2566. 1:38:38useful. Be sure to let me know in the
  2567. 1:38:39comments below what you want to see next
  2568. 1:38:41on the channel. Um that's going to do it
  2569. 1:38:43for today's starter video on ladder
  2570. 1:38:45logic. Thank you to Arduino for
  2571. 1:38:47providing the hardware used in this
  2572. 1:38:48video. So, Arduino once again is making
  2573. 1:38:52uh things more accessible for hobbyists
  2574. 1:38:54and makers. So, thank you very much to
  2575. 1:38:56Arduino. I'll see you next time. Thank
  2576. 1:38:58you so much for watching. Thanks. Bye.
  2577. 1:39:06Hello and welcome back to LeMasterTech.
  2578. 1:39:08And today's video is going to be a
  2579. 1:39:10continuation in the introduction to
  2580. 1:39:12controls and automation tutorial series
  2581. 1:39:14we've been doing in the channel
  2582. 1:39:16recently. Today's video specifically,
  2583. 1:39:18we're going to take an introduction to
  2584. 1:39:20the world of wiring and electrical
  2585. 1:39:22schematics for controls and automation.
  2586. 1:39:25So, this is a super important concept
  2587. 1:39:28and aspect of controls and automation
  2588. 1:39:29engineering. It's also kind of a tricky
  2589. 1:39:32one to figure out a good intro video.
  2590. 1:39:35So, I want to start by briefly telling
  2591. 1:39:36you how we're going to attack this sort
  2592. 1:39:38of concept. So, there's way more just
  2593. 1:39:41like all these concepts, there's way
  2594. 1:39:42more than you could possibly cover in
  2595. 1:39:44just one short introduction video for
  2596. 1:39:47the world of electrical
  2597. 1:39:49controls and automation. And so, what
  2598. 1:39:51we're going to do is we're going to take
  2599. 1:39:53a look at some example control
  2600. 1:39:54schematics, not of panels that I
  2601. 1:39:56physically have here in front of me, but
  2602. 1:39:58then we're going to take a look at some
  2603. 1:40:00very basic schematics, create them from
  2604. 1:40:02scratch together, and then we'll also
  2605. 1:40:04take a look at the hands-on what that
  2606. 1:40:06actually means in the physical world.
  2607. 1:40:07So, how every wire that you add to a
  2608. 1:40:10control schematic actually communicates
  2609. 1:40:12and translates into the real world.
  2610. 1:40:14We're going to do a few hands-on
  2611. 1:40:15examples together. So, that's sort of
  2612. 1:40:17the format here. If you have basic
  2613. 1:40:19understanding of hobby electronics, like
  2614. 1:40:22you've played around with Arduinos or
  2615. 1:40:23Raspberry Pis, then this will be a cool
  2616. 1:40:25way to see how it translates into the
  2617. 1:40:27world of industrial automation and
  2618. 1:40:29controls. And then if you've been an
  2619. 1:40:30electrician or a maintenance technician
  2620. 1:40:32or anything like that, this will be a
  2621. 1:40:34really good way for you to see the
  2622. 1:40:36controls and software piece of it, but
  2623. 1:40:38you're probably pretty familiar with the
  2624. 1:40:39hands-on piece already. So, let's just
  2625. 1:40:41dive right in. In terms of visual aids,
  2626. 1:40:44it's going to be a little all over the
  2627. 1:40:45place cuz I have some like very
  2628. 1:40:47high-level bullet points in a
  2629. 1:40:48PowerPoint. Then we're going to take a
  2630. 1:40:50look super briefly at the code we write,
  2631. 1:40:52but then we're going to cut over to a
  2632. 1:40:53physical wiring as well. And again, the
  2633. 1:40:56reason wiring is kind of a broad topic
  2634. 1:40:58and a hard one to cover is because in
  2635. 1:41:00the world of industrial automation and
  2636. 1:41:02controls, a control panel schematic and
  2637. 1:41:04a drawing package could be things that
  2638. 1:41:06call out your devices and your actual
  2639. 1:41:08sensor level connections to a control
  2640. 1:41:11panel, and then all the PLC controller
  2641. 1:41:14level connections. So, from your PLC to
  2642. 1:41:16IO modules, input and output blocks,
  2643. 1:41:19relays, terminal blocks and
  2644. 1:41:20distribution, as well as connections to
  2645. 1:41:23the devices and the sensors, and then
  2646. 1:41:24your power distribution, usually a
  2647. 1:41:26high-power AC power feed into a control
  2648. 1:41:30panel, and how it translates into DC or
  2649. 1:41:32step-down transformers to be used inside
  2650. 1:41:35the control panel,
  2651. 1:41:36as well as power feed to motors and VFDs
  2652. 1:41:39and things like that. And then often
  2653. 1:41:41your networking would be encompassed in
  2654. 1:41:42that as well. So, your Profinet or
  2655. 1:41:44EtherCAT or Ethernet connections as
  2656. 1:41:46well. So, obviously it's a super broad
  2657. 1:41:48concept, but the drawing package for a
  2658. 1:41:51control panel is maybe the most
  2659. 1:41:53important thing
  2660. 1:41:54to correlate the physical world to the
  2661. 1:41:57software side that are both so important
  2662. 1:41:59for controls and automation. So, super
  2663. 1:42:02quickly, in an industrial control
  2664. 1:42:05package, a really good drawing package,
  2665. 1:42:07you'll usually have a view that looks
  2666. 1:42:09like both of these. So, this is kind of
  2667. 1:42:10two different views.
  2668. 1:42:12I'll try to drop myself in the middle
  2669. 1:42:14here. This is kind of two different
  2670. 1:42:17views most of the time. And what you've
  2671. 1:42:19got is a physical rendering of the panel
  2672. 1:42:22on the left here. So, this has these
  2673. 1:42:24green covers are usually plastic
  2674. 1:42:27wireways called Panduit or whatever sort
  2675. 1:42:30of wireway that you have. It's just an
  2676. 1:42:33industrial way of keeping your wires
  2677. 1:42:35organized. As you will see when we get
  2678. 1:42:37to my hands-on examples,
  2679. 1:42:39physical wiring in the field looks
  2680. 1:42:41really messy if you're not zip tying or
  2681. 1:42:44using cable glands and conduit and stuff
  2682. 1:42:46to keep your cords really clean. So,
  2683. 1:42:48most of the time these like gray or
  2684. 1:42:50light green rectangles will be in a
  2685. 1:42:52materials like Panduit and it'll be a
  2686. 1:42:55wireway. But then it this physically
  2687. 1:42:58will look almost identical to the
  2688. 1:43:00control cabinet when you swing the door
  2689. 1:43:02open. So, you have circuit breakers and
  2690. 1:43:04power distribution and VFDs and PLC
  2691. 1:43:07components in a very physical realistic
  2692. 1:43:10rendering. And then on the right you
  2693. 1:43:12have what's kind of called the
  2694. 1:43:13wireframe, which is usually a slightly
  2695. 1:43:16less, but still precise, but slightly
  2696. 1:43:19less precise physical rendering of the
  2697. 1:43:21panel, but everything would be labeled
  2698. 1:43:23with however it's getting called out in
  2699. 1:43:24the drawing. So, if you see these are
  2700. 1:43:26basically the same
  2701. 1:43:28control cabinet, but on the right there
  2702. 1:43:30are a lot of blue small text that's kind
  2703. 1:43:33of hard to read, but there's a lot of
  2704. 1:43:35blue labels calling these VFDs out as
  2705. 1:43:37VFD 1070, 2070, 2190.
  2706. 1:43:41Your switch in the middle row, terminal
  2707. 1:43:43blocks, PLC components. And so, this is
  2708. 1:43:46a labeled one that still has all of the
  2709. 1:43:48physical components in their correct
  2710. 1:43:50physical locations, but this one is
  2711. 1:43:53correlating
  2712. 1:43:54a wiring label like VFD 1070 or
  2713. 1:43:57whatever, some way that it's going to
  2714. 1:43:59get referred to in this control package,
  2715. 1:44:02and it's it's correlating that physical
  2716. 1:44:05component to a drawing package page that
  2717. 1:44:08we'll find. So, if we look in this next
  2718. 1:44:10page at an example page of an industrial
  2719. 1:44:12wiring package,
  2720. 1:44:14this is actually a great example of the
  2721. 1:44:17whole drawing package once you get into
  2722. 1:44:19the line level schematics, which we'll
  2723. 1:44:21talk more about during this video.
  2724. 1:44:24But to highlight a few things here, it's
  2725. 1:44:26very common to have two columns side by
  2726. 1:44:28side that have these wire numbers.
  2727. 1:44:31That's kind of hard to see, but these
  2728. 1:44:33line numbers from like 200 to 222.
  2729. 1:44:36And often the wires will get physically
  2730. 1:44:39labeled with whatever wire with whatever
  2731. 1:44:42row they're on in their drawing package.
  2732. 1:44:45So, it's very normal to see wire label
  2733. 1:44:48physically on a wire in a panel that
  2734. 1:44:50says 205 or 225.
  2735. 1:44:54It's also very normal to see their tag
  2736. 1:44:56name. So, if you have like a solenoid
  2737. 1:44:57valve, it could say SV500
  2738. 1:45:00whatever.
  2739. 1:45:01But often the label will be a
  2740. 1:45:04combination of where it physically is in
  2741. 1:45:06the field and where it is in your
  2742. 1:45:08drawing package.
  2743. 1:45:10But anyways, you'll get these two
  2744. 1:45:11columns side by side kind of drawings
  2745. 1:45:13just because most wires don't merit a
  2746. 1:45:16full page. Most schematics don't need a
  2747. 1:45:19full landscape page. So, they'll split
  2748. 1:45:21into two columns. And then the footer is
  2749. 1:45:24actually where I want to spend some time
  2750. 1:45:25here because the
  2751. 1:45:27because the footer of the drawing
  2752. 1:45:30package contains an enormous amount of
  2753. 1:45:32information. Usually on the left side
  2754. 1:45:34you have revision notes, which would be
  2755. 1:45:36the person who approved a revision, the
  2756. 1:45:38date it got changed, which revision
  2757. 1:45:40number or letter it is, and then usually
  2758. 1:45:43a brief note or comment about the
  2759. 1:45:46revision itself. Like what are you
  2760. 1:45:47adding, what are you deleting, what are
  2761. 1:45:48you changing? It's very normal to see
  2762. 1:45:51the latest revision or the newest
  2763. 1:45:53revision have all the changes in like a
  2764. 1:45:55cloud or a bubble format on your
  2765. 1:45:57drawing. And then there's usually some
  2766. 1:45:59footer information about the company
  2767. 1:46:01that the drawings are for. Like, "Hey,
  2768. 1:46:04this was for, you know, this chemical
  2769. 1:46:06plant prepared by this person, this
  2770. 1:46:08address, whatever." So, some physical
  2771. 1:46:10information about the drawing package.
  2772. 1:46:12And then over here is usually who
  2773. 1:46:14prepared it. So, you'll have like the
  2774. 1:46:16engineer's name of who prepared it, who
  2775. 1:46:18installed it, who
  2776. 1:46:20you know, engineer or designer that was
  2777. 1:46:22kind of behind that. More information
  2778. 1:46:24about the customer. And then usually in
  2779. 1:46:26the footer you also have stuff on every
  2780. 1:46:28single page that tells you the name of
  2781. 1:46:30that page and then where within the
  2782. 1:46:32broader drawing package you are. So, on
  2783. 1:46:34a huge control panel that has individual
  2784. 1:46:38motor and sensor and device schematics
  2785. 1:46:40called out, you could be on page like 12
  2786. 1:46:43of 158. So, the numbering and the
  2787. 1:46:46information in the footer is very
  2788. 1:46:47important. To talk super briefly about
  2789. 1:46:51some of the most common software out
  2790. 1:46:53there, you have like DWG like AutoCAD,
  2791. 1:46:56Autodesk are some of the more common CAD
  2792. 1:47:00software, and then EPLAN is one of the
  2793. 1:47:02more like software-intensive
  2794. 1:47:04CAD packages as well. But there's also
  2795. 1:47:07some free ones online.
  2796. 1:47:09You can use things like KiCad, which is
  2797. 1:47:11best known as an electrical package for
  2798. 1:47:14like designing PCBs, but you can do free
  2799. 1:47:16schematics as well. There's a lot of
  2800. 1:47:19online tools that are kind of free, but
  2801. 1:47:22have less power. So, I think AutoCAD
  2802. 1:47:26and basically EPLAN are like probably
  2803. 1:47:28the two biggest competitors in this
  2804. 1:47:30space. But there's plenty of companies
  2805. 1:47:33that do this just like any other piece
  2806. 1:47:35of the industrial automation and
  2807. 1:47:36controls world. Okay? Where do you
  2808. 1:47:38begin? If this is a beginner intro to
  2809. 1:47:41control panels and schematics, knowing
  2810. 1:47:43that the footer has great information,
  2811. 1:47:45knowing that there's usually a title
  2812. 1:47:46page, knowing what software to download,
  2813. 1:47:49that's all great.
  2814. 1:47:51But briefly, some some talking points.
  2815. 1:47:53So, to remind you, this is an
  2816. 1:47:55introduction and not a comprehensive
  2817. 1:47:57lesson. And then if you Google just
  2818. 1:48:00control package like electrical panel
  2819. 1:48:02wiring examples, there are some really
  2820. 1:48:05good ones out there that actually show
  2821. 1:48:07you physical ones in the field, and they
  2822. 1:48:09talk you through what you're physically
  2823. 1:48:11looking at and everything else like
  2824. 1:48:12that. So, if this in particular is the
  2825. 1:48:14aspect of controls and automation that
  2826. 1:48:16you really want to become super
  2827. 1:48:18proficient at, I suggest you just do
  2828. 1:48:20some Googling. This Solis PLC, another
  2829. 1:48:23great online company, RealPars, has some
  2830. 1:48:26other good examples, and they actually
  2831. 1:48:28talk about individual components and
  2832. 1:48:30schematics that you'll see in the field.
  2833. 1:48:31So, that's not a cop-out. This is meant
  2834. 1:48:34to get you familiar with the basics, but
  2835. 1:48:36it's also just not a deep dive. So, if
  2836. 1:48:39you want to spend a lot more time
  2837. 1:48:40studying on this, I absolutely recommend
  2838. 1:48:43just spend some time Googling. Solis PLC
  2839. 1:48:45and RealPars have some great examples as
  2840. 1:48:47well as some others out there. Okay?
  2841. 1:48:50But then I do think one thing that's
  2842. 1:48:52really important to talk about as part
  2843. 1:48:53of this video is who has standards in
  2844. 1:48:56this field. So, if you're a drawing
  2845. 1:48:58designer or an instrumentation
  2846. 1:49:01and controls engineer, it's very
  2847. 1:49:03important to be familiar with NFPA 70,
  2848. 1:49:06NFPA 79, and UL 508A.
  2849. 1:49:10Also sometimes called NEC 70, but
  2850. 1:49:13basically these are industrial guides on
  2851. 1:49:16power requirements, power distribution
  2852. 1:49:18requirements, best practices for
  2853. 1:49:20installing and creating and developing
  2854. 1:49:22control cabinets. UL or Underwriters
  2855. 1:49:24Laboratory is a listing that like panel
  2856. 1:49:27fabrication shops and places that
  2857. 1:49:29develop controls equipment, they want to
  2858. 1:49:31stamp their panel with a UL listing
  2859. 1:49:33because that means they've they've
  2860. 1:49:35adhered to a certain high standard that
  2861. 1:49:37gets validated by this company, by the
  2862. 1:49:39UL organization. Those are like
  2863. 1:49:42thousand-page
  2864. 1:49:43guidelines and books, and usually I
  2865. 1:49:45think you have to pay for a whole copy
  2866. 1:49:47of them. Practices of those are found
  2867. 1:49:50online. They talk about wire gauges,
  2868. 1:49:52power distribution concerns, and a lot
  2869. 1:49:54of other really great things to keep in
  2870. 1:49:56mind while you're developing control
  2871. 1:49:57panels, but not really what we're going
  2872. 1:50:00for in today's video. So those three
  2873. 1:50:02standards are great for looking into.
  2874. 1:50:04Um, but let's talk more practically. If
  2875. 1:50:07you're a hobbyist or an a field engineer
  2876. 1:50:09who just needs to know when I need
  2877. 1:50:11information, where can I go to get said
  2878. 1:50:14information? And it it's really
  2879. 1:50:17the internet. But anytime you buy a
  2880. 1:50:19sensor or a switch or a button or a
  2881. 1:50:21motor, the manufacturer of that
  2882. 1:50:23component should be providing the wiring
  2883. 1:50:25schematic and information to you
  2884. 1:50:28via internet manuals, downloadable
  2885. 1:50:30manuals. Ideally it would be included
  2886. 1:50:32with the component when you buy it, but
  2887. 1:50:34just a quick Google or if you're buying
  2888. 1:50:36components from Amazon like I do for my
  2889. 1:50:38garage all the time, the Amazon listing
  2890. 1:50:40itself often times has the wiring called
  2891. 1:50:43out as well.
  2892. 1:50:45Um,
  2893. 1:50:45and then control components, these are
  2894. 1:50:47actually a lot more standard. So if
  2895. 1:50:49you're buying Allen-Bradley or Siemens
  2896. 1:50:51or Beckhoff or even, you know, Arduino
  2897. 1:50:53PLC like we're using in this tutorial
  2898. 1:50:55series, they have really good pinouts
  2899. 1:50:58and wiring schematics. They can take a
  2900. 1:51:00variety of forms, so they won't always
  2901. 1:51:02look like something you can easily drop
  2902. 1:51:04into a wiring diagram, and they won't
  2903. 1:51:07always have a 3D model that you can
  2904. 1:51:09include in your panel. Sometimes you
  2905. 1:51:11just need to make a little rectangle and
  2906. 1:51:13say, "Hey, this is, you know, this
  2907. 1:51:14device." or anything like that. But the
  2908. 1:51:16actual wiring of how to wire a component
  2909. 1:51:19comes from the manufacturer you buy the
  2910. 1:51:21component from. So you don't have to do
  2911. 1:51:23any guessing of how these things work.
  2912. 1:51:25And then why it's so important and why
  2913. 1:51:28it's worth a whole video during this
  2914. 1:51:29tutorial series just to talk about this
  2915. 1:51:32component is because in the world of
  2916. 1:51:33industrial automation and controls, and
  2917. 1:51:35honestly in the tutorials that we're
  2918. 1:51:37doing just in this series, control
  2919. 1:51:39panels and control systems get very
  2920. 1:51:41large very quickly. And so manually
  2921. 1:51:44tracking down every wire and cable,
  2922. 1:51:46where it came from in the field and
  2923. 1:51:48where it landed in the panel, it's not
  2924. 1:51:50always safe, it's not always feasible if
  2925. 1:51:52you've tucked things into conduit runs,
  2926. 1:51:54or they're in, you know, an
  2927. 1:51:56explosion-proof building but your
  2928. 1:51:57control cabinet's on the outside,
  2929. 1:52:00or even wireways inside of Panduit tends
  2930. 1:52:02to get so full that you can't just trace
  2931. 1:52:05your wire accurately.
  2932. 1:52:07And it's also just faster. If you're the
  2933. 1:52:10person trying to hook up a system and
  2934. 1:52:11you're in the field and it's 2:00 in the
  2935. 1:52:13morning and you've been on site for 48
  2936. 1:52:15hours straight, you want an accurate,
  2937. 1:52:17well-documented control panel schematic
  2938. 1:52:20rather than guessing, trying to find a
  2939. 1:52:22spare channel on your PLC, trying to
  2940. 1:52:24look into the code and see if there's a
  2941. 1:52:25spare channel by like reverse
  2942. 1:52:28engineering the code. So understanding
  2943. 1:52:30the electrical schematic importance of
  2944. 1:52:33industrial automation and controls is
  2945. 1:52:35super pivotal. Okay, so that was a lot
  2946. 1:52:37of Pete talking, which is my least
  2947. 1:52:39favorite kind of video. I really like to
  2948. 1:52:41show you guys things and do engineering
  2949. 1:52:43together. So let's get into a practical
  2950. 1:52:45example, and let's just start because I
  2951. 1:52:48really want this to be a tutorial series
  2952. 1:52:49that's low to no barrier to entry,
  2953. 1:52:52right? I'm going to make all of the
  2954. 1:52:53electrical schematics today in this
  2955. 1:52:55example for you in PowerPoint. I don't
  2956. 1:52:58want this to be like, "Oh, as long as
  2957. 1:52:59you have EPLAN or as long as you have
  2958. 1:53:01AutoCAD, you can follow along." So for
  2959. 1:53:04an example, let's take a look at a
  2960. 1:53:06system that has a power supply, a PLC,
  2961. 1:53:09and one input, which is just going to be
  2962. 1:53:11a hand switch, okay? So a, you know,
  2963. 1:53:13on-off hand switch, and then a PLC and a
  2964. 1:53:17power supply.
  2965. 1:53:19And I think I also, when I prepared
  2966. 1:53:21these schematics, I had 12-V power
  2967. 1:53:23supply called out. I think I've got a
  2968. 1:53:2524-V power supply on my DIN rail right
  2969. 1:53:28now. That part doesn't matter too much
  2970. 1:53:30because the pinout's the same and the
  2971. 1:53:32Arduino PLC can take between 12 and 24-V
  2972. 1:53:35power supply, but nobody yell at me in
  2973. 1:53:37the comments if the schematic says 12-V
  2974. 1:53:39DC and the actual power supply says 24
  2975. 1:53:42V.
  2976. 1:53:42I will ignore your yelling. I want to
  2977. 1:53:44talk about what I have on on the screen
  2978. 1:53:47right now because like I said, I'm
  2979. 1:53:48making this in PowerPoint. These are
  2980. 1:53:50not, you know, shapes that you download
  2981. 1:53:53from the manufacturer, anything else
  2982. 1:53:54like this. This is literally just I have
  2983. 1:53:57a power supply that takes wall outlet
  2984. 1:53:59voltage. And then this power supply
  2985. 1:54:01gives me two plus and two minus, so two
  2986. 1:54:04zero VDC and two 12-V DC channels. I
  2987. 1:54:08need the Arduino PLC to receive power,
  2988. 1:54:11so it has two positive terminals and two
  2989. 1:54:13negative terminals as well. And then it
  2990. 1:54:15has eight input channels, and then it
  2991. 1:54:17has four relay output channels. So if
  2992. 1:54:19you've been following along with the
  2993. 1:54:20tutorial series, you've seen the the
  2994. 1:54:22body of the Arduino already. I'll have
  2995. 1:54:25some pictures of it on screen now as
  2996. 1:54:27well, but this is a simple rectangular
  2997. 1:54:31representation of the component that
  2998. 1:54:33we're dealing with. And then my hand
  2999. 1:54:35switch has two different sets of
  3000. 1:54:37terminals on the back labeled 11, 12,
  3001. 1:54:4023, and 24, and it's just two different
  3002. 1:54:42strips that are made when it's in the
  3003. 1:54:44two different positions. So that's my
  3004. 1:54:46hand switch.
  3005. 1:54:48Let's take a look at what a not
  3006. 1:54:50industrial control cabinet schematic for
  3007. 1:54:52this system might be, okay? So this,
  3008. 1:54:55again, just in PowerPoint, no fancy
  3009. 1:54:57software or anything. I'm using a solid
  3010. 1:55:00blue line to show my DC positive power,
  3011. 1:55:04and then I'm using a kind of a white and
  3012. 1:55:06blue, white with blue stripe is very
  3013. 1:55:08common in the world of electrical
  3014. 1:55:10controls for 0-V DC,
  3015. 1:55:13or just solid white is also very common.
  3016. 1:55:17But basically I have black, white, and
  3017. 1:55:19green from the wall outlet into my power
  3018. 1:55:22supply, and then I'm providing power and
  3019. 1:55:250 V.
  3020. 1:55:26So these two wires make up a power loop
  3021. 1:55:28to the Arduino PLC.
  3022. 1:55:31And then I'm using another positive lead
  3023. 1:55:33off the power supply to go into the hand
  3024. 1:55:35switch, and then when I turn the hand
  3025. 1:55:37switch into position one,
  3026. 1:55:39or which is basically connecting
  3027. 1:55:41terminal 11 and 12, then power will flow
  3028. 1:55:44through this hand switch and go to input
  3029. 1:55:46eight on my Arduino PLC. Okay? So it's a
  3030. 1:55:50very simple electrical schematic, and
  3031. 1:55:52I'm going to tie it to this structured
  3032. 1:55:54text program right here, which is just
  3033. 1:55:57going to turn the blue light on when the
  3034. 1:56:00switch is on, but then I'm going to use
  3035. 1:56:03switching logic. So rather than just a
  3036. 1:56:05boring like, "Hey, turn the green light
  3037. 1:56:08on the body of this PLC on when the
  3038. 1:56:10switch is on." I'm going to actually do
  3039. 1:56:12a little bit of switching logic. So
  3040. 1:56:14every time I turn the switch to the on
  3041. 1:56:16position, that's going to switch my
  3042. 1:56:18internal on-off variable, and then I'll
  3043. 1:56:21switch an output and a little green
  3044. 1:56:22light based on that.
  3045. 1:56:25That was probably a poor brief example,
  3046. 1:56:27but the structured text tutorial was two
  3047. 1:56:30videos ago. This is about wiring.
  3048. 1:56:34So let's go ahead and take a look
  3049. 1:56:36physically at the wiring for this
  3050. 1:56:38system, and you can see the exact wires
  3051. 1:56:41that are called out in our schematic
  3052. 1:56:42show up on here. We have the black,
  3053. 1:56:44white, and green wires coming out of the
  3054. 1:56:46outlet, and then we have two blue wires
  3055. 1:56:48going into the power feed of the Arduino
  3056. 1:56:50PLC, and onto terminal 11 of the hand
  3057. 1:56:54switch. And then on the outlet terminal
  3058. 1:56:5712 of the hand switch, it goes into
  3059. 1:56:59input eight on the Arduino PLC. And then
  3060. 1:57:02the last wire we need is a V- or 0-V DC
  3061. 1:57:06return wire to the power supply from the
  3062. 1:57:08Arduino PLC. Every wire that we have on
  3063. 1:57:10the schematic shows up physically in the
  3064. 1:57:13world exactly as it's drawn here. And
  3065. 1:57:15let's take a look at a more industrial
  3066. 1:57:17example of this. So this kind of looks
  3067. 1:57:19more like you should expect to see
  3068. 1:57:23in an industrial control cabinet, okay?
  3069. 1:57:25I'll try to drop myself in the middle
  3070. 1:57:27where I don't block anything. But this
  3071. 1:57:29is sort of how you would expect to see
  3072. 1:57:30that show up in an industrial control
  3073. 1:57:33cabinet. You have on the left you have
  3074. 1:57:35your AC voltage in, you have line one,
  3075. 1:57:37neutral, and ground, and then they go
  3076. 1:57:39into a power supply, and you can see
  3077. 1:57:41here like I put the actual part number
  3078. 1:57:44of the power supply that I got from
  3079. 1:57:45Amazon.
  3080. 1:57:46That's very common, too. So you'd see
  3081. 1:57:48maybe PSU1, like power supply unit one,
  3082. 1:57:52and then a part number for it, and then
  3083. 1:57:54the pinout has ground, neutral, L1, and
  3084. 1:57:57then plus, plus, minus, minus. Typically
  3085. 1:58:00these are grayscale control panel
  3086. 1:58:02drawings as well. They don't have to be,
  3087. 1:58:04but you saw on this example a lot of
  3088. 1:58:06color
  3089. 1:58:07where I was kind of color coordinating,
  3090. 1:58:09matching what's in the field with what's
  3091. 1:58:11on the schematic. I do actually really
  3092. 1:58:13like doing these sorts of schematics for
  3093. 1:58:15hobby circuits
  3094. 1:58:17because I just think it's clear, but
  3095. 1:58:19when you're in an industrial setting,
  3096. 1:58:20this is what you'll be dealing with more
  3097. 1:58:22frequently. So
  3098. 1:58:24you have the same Arduino PLC here.
  3099. 1:58:26Again, I dropped the power supply or the
  3100. 1:58:28part number on it.
  3101. 1:58:30And then you have the DC outlet power
  3102. 1:58:33feed of 0-V
  3103. 1:58:35kind of becomes your new power rail on
  3104. 1:58:37the left edge of the right half of my
  3105. 1:58:39screen. And here you can see the power
  3106. 1:58:41coming into the PLC, and then going
  3107. 1:58:44through a hand switch, which is
  3108. 1:58:46represented again by the part number,
  3109. 1:58:48and into input eight. Okay? So actually
  3110. 1:58:50what's important to know is that what
  3111. 1:58:52you're looking at here is very
  3112. 1:58:54industrial, and what you're looking at
  3113. 1:58:55here is sort of hobby,
  3114. 1:58:58but you'll see schematics that look a
  3115. 1:59:00lot like both of these depending on your
  3116. 1:59:02setting and the size of your
  3117. 1:59:03application. That's our first practical
  3118. 1:59:05example. We have one more slightly more
  3119. 1:59:08complicated practical example and then
  3120. 1:59:09we're going to wrap this video up. Okay,
  3121. 1:59:12so we have our industrial hobby example.
  3122. 1:59:16Let's add an output. So we have a
  3123. 1:59:18digital input in this previous example
  3124. 1:59:20and that's our hand switch. Let's go
  3125. 1:59:22ahead and say we want to add an an
  3126. 1:59:24output and it'll be an outlet. So we
  3127. 1:59:28could hook any common household
  3128. 1:59:30appliance we want up to a standard
  3129. 1:59:32outlet. And to do that, we need L1,
  3130. 1:59:36neutral, and ground. So we need that
  3131. 1:59:38same three wires that kind of come into
  3132. 1:59:40our power supply. We need those hooked
  3133. 1:59:43up to an outlet, but L1 needs to pass
  3134. 1:59:46through a relay and a relay is a super
  3135. 1:59:48important controls component which
  3136. 1:59:51allows us to switch a wire between
  3137. 1:59:53multiple contacts. So you use low
  3138. 1:59:56voltage DC power to change the state of
  3139. 1:59:59a relay and then a separate electrical
  3140. 2:00:02connection is made on the other side of
  3141. 2:00:04the relay. So I think we'll probably get
  3142. 2:00:06more into relays as we continue doing
  3143. 2:00:08the tutorials in this series, but
  3144. 2:00:11it's arguably the most important
  3145. 2:00:13component in the world of industrial
  3146. 2:00:15automation and controls. So let's take a
  3147. 2:00:17look at the hobby version of this
  3148. 2:00:19circuit now, okay? And let's walk
  3149. 2:00:21through all the wires that have been
  3150. 2:00:23added. I also put in one new sort of
  3151. 2:00:25color convention which is a wire that
  3152. 2:00:28ties directly into the PLC. I've changed
  3153. 2:00:31to orange where in the previous example
  3154. 2:00:33I just left it as blue. So basically the
  3155. 2:00:36final PLC signal wire is orange. L1 on
  3156. 2:00:40this schematic is represented in black,
  3157. 2:00:43so that's going to be your 120 V hot.
  3158. 2:00:46Neutral is going to be kind of this
  3159. 2:00:48light gray because white didn't really
  3160. 2:00:50look good on a white background. Ground
  3161. 2:00:52is green and then everywhere that's 0 V
  3162. 2:00:55DC is represented by this like light
  3163. 2:00:57blue white and blue striped wire. And
  3164. 2:01:00then dark blue represents your 12 V
  3165. 2:01:03which in my physical setup is actually
  3166. 2:01:0424 V. Um
  3167. 2:01:07but what you can see here what's
  3168. 2:01:08actually changed, nothing to do with the
  3169. 2:01:10hand switch or powering up the Arduino
  3170. 2:01:12PLC. But what we've done is we've added
  3171. 2:01:15a hot wire, so a 12 or 24 V DC wire from
  3172. 2:01:19the second terminal of the Arduino PLC
  3173. 2:01:22out feed to side one of the relay output
  3174. 2:01:25on the Arduino PLC. And if it seems
  3175. 2:01:27silly to go from a relay to a relay to
  3176. 2:01:30control something, it is a little bit
  3177. 2:01:32silly, but actually I wanted to show you
  3178. 2:01:34guys a DIN rail a DIN rail mounted relay
  3179. 2:01:37rather than just a relay PLC
  3180. 2:01:40output. Technically there's an extra
  3181. 2:01:41component in here cuz I have a relay
  3182. 2:01:43output and then I go to a relay. Let's
  3183. 2:01:45just take a look at this practical
  3184. 2:01:47example, okay? So So when the PLC
  3185. 2:01:49energizes that wire, this relay connects
  3186. 2:01:52the common to the normally open channel.
  3187. 2:01:55And then when the coil releases, the
  3188. 2:01:57common is connected to the normally
  3189. 2:01:59closed channel. That's a super important
  3190. 2:02:01concept not just for relays, but for
  3191. 2:02:03sort of all of electronics. So if you
  3192. 2:02:05look up relays and common normally open
  3193. 2:02:08and normally closed, you'll learn a lot
  3194. 2:02:10about sort of switching voltages. But
  3195. 2:02:12for now, just know that to control the
  3196. 2:02:15state of the outlet from our PLC, we
  3197. 2:02:17bring 120 V hot into the common channel
  3198. 2:02:21of our relay. And then normally open
  3199. 2:02:24means it is the one that's not going to
  3200. 2:02:26be connected until we pull that coil in.
  3201. 2:02:28So you could technically program the
  3202. 2:02:30circuit to work in normally open or
  3203. 2:02:32normally closed. We're going to use
  3204. 2:02:34normally open meaning the only time that
  3205. 2:02:36outlet will be energized is when the
  3206. 2:02:38relay is energized which is when the PLC
  3207. 2:02:41tells that output it's true. Okay, so
  3208. 2:02:44that's the schematic. Let's take a look
  3209. 2:02:46real quick at what this physically means
  3210. 2:02:48on our bench setup and you can see just
  3211. 2:02:51like I said, it's the exact same wiring
  3212. 2:02:53as before, but now we've introduced this
  3213. 2:02:56new relay and we have the additional
  3214. 2:02:59power feed from the Arduino coming into
  3215. 2:03:01channel zero of the output and then we
  3216. 2:03:03have the channel one of the output going
  3217. 2:03:05to the A1 and A2 coil side of the relay.
  3218. 2:03:09And then the other side of the relay
  3219. 2:03:11goes back to 0 V DC. And then we have
  3220. 2:03:14the downstream power feed of our
  3221. 2:03:17relay switching the common wire between
  3222. 2:03:20normally open and normally closed and
  3223. 2:03:21the normally open signal goes to the
  3224. 2:03:23outlet. So we actually didn't have to
  3225. 2:03:25modify our PLC program at all for this
  3226. 2:03:28one. All we did is we just said in
  3227. 2:03:30addition to having L1 which is the light
  3228. 2:03:33on the body of the PLC, we now also want
  3229. 2:03:36the outlet to turn on and off. And we
  3230. 2:03:39just tie our outlet, if we look at relay
  3231. 2:03:41outputs, we just tie our outlet to the
  3232. 2:03:43first output channel in the PLC. So if
  3233. 2:03:46you've been following along with the
  3234. 2:03:47tutorial series, that whole PLC side of
  3235. 2:03:50it should look pretty trivial. Don't
  3236. 2:03:51worry too much because the this purpose
  3237. 2:03:54is to be hands-on and physical and
  3238. 2:03:56electrical
  3239. 2:03:57rather than just
  3240. 2:03:59rather than software heavy, but feel
  3241. 2:04:01free to ask any questions you have about
  3242. 2:04:02it in the comments below. Now, same as
  3243. 2:04:04before, let's take a look at how this
  3244. 2:04:06would get represented in like a physical
  3245. 2:04:10in a more industrial controls package
  3246. 2:04:12drawing. So let's take a look at what's
  3247. 2:04:15changed. We still have the power feed on
  3248. 2:04:17the left going through our 24 V power
  3249. 2:04:19supply which I know I called out as 12 V
  3250. 2:04:24in in here, but it's 24 V on my bench
  3251. 2:04:26setup, sue me. Anyways,
  3252. 2:04:29and then I did something interesting
  3253. 2:04:31that I think is useful to call out on
  3254. 2:04:33this channel
  3255. 2:04:35on this tutorial is I labeled two wires
  3256. 2:04:38with numbers O1 and O2. And this is a
  3257. 2:04:41massive simplification from how like a
  3258. 2:04:44large control panel would do it, but
  3259. 2:04:46it's not always feasible to show every
  3260. 2:04:49physical connection in your drawing in a
  3261. 2:04:51continuous one nice clean view sort of
  3262. 2:04:55way. And if you look at the relay which
  3263. 2:04:57we've added to the top right, you can
  3264. 2:04:59see output channel one wire zero and
  3265. 2:05:03wire one are pulling in the A1 A2 coil
  3266. 2:05:06side of the relay just like we saw
  3267. 2:05:08before, but O1 and O2 which are linked
  3268. 2:05:12to these
  3269. 2:05:14are actually being physically
  3270. 2:05:16represented by a number that says, "Hey,
  3271. 2:05:18there's this disconnect between over
  3272. 2:05:20here and over here." And sometimes you
  3273. 2:05:22would want to link it with some
  3274. 2:05:24additional letters as well or anything
  3275. 2:05:26like that. But this is just a way of
  3276. 2:05:28calling out that the other side of this
  3277. 2:05:30wire shows up somewhere else in your
  3278. 2:05:32drawing package and it's a way for you
  3279. 2:05:34to correlate and track down those wires.
  3280. 2:05:37Again, this is sort of a non-sustainable
  3281. 2:05:40way as you get into bigger and bigger
  3282. 2:05:42and bigger systems. You can't just keep
  3283. 2:05:44drawing this like function block diagram
  3284. 2:05:47of all the crazy wiring schematics and
  3285. 2:05:49the coloring conventions can get out of
  3286. 2:05:51hand and they're sort of arbitrary. So
  3287. 2:05:53you start to see as systems get bigger
  3288. 2:05:55and bigger and bigger how essential
  3289. 2:05:57having like a standard format drawing
  3290. 2:05:59is. So this industrial example which
  3291. 2:06:02honestly I've already sort of deviated
  3292. 2:06:04cuz I'm building it in PowerPoint from
  3293. 2:06:07like some common design choices, but I
  3294. 2:06:09hope the basics are clicking for you
  3295. 2:06:12here of what you're looking at, how the
  3296. 2:06:14physical world maps onto this sort of
  3297. 2:06:17electrical schematic software world, and
  3298. 2:06:19then what you're actually looking at in
  3299. 2:06:20the field and how that ought to be
  3300. 2:06:22documented when you go and grab a
  3301. 2:06:24control cabinet. Okay, so I know by far
  3302. 2:06:27in this tutorial series this is the most
  3303. 2:06:29talking that I've done and the least
  3304. 2:06:31showing you things that I've done, but
  3305. 2:06:33it is really hard to demonstrate the
  3306. 2:06:35world of electrical controls
  3307. 2:06:38drawings and schematics and control
  3308. 2:06:40panels without like going into the field
  3309. 2:06:42and walking through one with you. And
  3310. 2:06:44frankly my company would not be okay
  3311. 2:06:46with me like walking around the plant
  3312. 2:06:48floor showing you our control cabinets.
  3313. 2:06:50So you're going to have to do with what
  3314. 2:06:51I can show you in the garage.
  3315. 2:06:53I hope it was useful. As always, let me
  3316. 2:06:55know with any comments or questions on
  3317. 2:06:58this one. I also have a pretty deep
  3318. 2:07:00library of me talking about controls and
  3319. 2:07:02automation concepts including wiring and
  3320. 2:07:04hardware and things like that on the
  3321. 2:07:06channel. So be sure to check out
  3322. 2:07:07LeMaster Tech for more. Drop me a
  3323. 2:07:09comment with any questions that you had,
  3324. 2:07:11anything that I can try to clarify for
  3325. 2:07:13you, and let me know what you want to
  3326. 2:07:15see more of on the channel next time.
  3327. 2:07:16Thank you so much for watching and we'll
  3328. 2:07:18see you next time. Thanks. Bye.
  3329. 2:07:26Hello and welcome back to LeMaster Tech.
  3330. 2:07:28And in today's video, I'm going to show
  3331. 2:07:30you how to get started with the SCADA
  3332. 2:07:32software called Ignition. And we're
  3333. 2:07:34going to show how to use it for free for
  3334. 2:07:37hobbyists and makers. So we're going to
  3335. 2:07:39use the Ignition Maker Edition. To get
  3336. 2:07:41started, just go to Bing or Chrome or
  3337. 2:07:44Google, your favorite browser, and type
  3338. 2:07:46in Ignition for Makers. The company that
  3339. 2:07:48makes the SCADA software called Ignition
  3340. 2:07:51is Inductive Automation. So you'll see
  3341. 2:07:53Inductive, you'll see Ignition, and
  3342. 2:07:55occasionally you'll hear it referred to
  3343. 2:07:57as a SCADA.
  3344. 2:07:58SCADA means Supervisory Control and Data
  3345. 2:08:01Acquisition. It's just a layer of
  3346. 2:08:04control software, but Ignition in
  3347. 2:08:06particular has a ton of cool
  3348. 2:08:07applications even for things that
  3349. 2:08:09hobbyists and makers can get behind,
  3350. 2:08:11which is why they have a Maker Edition.
  3351. 2:08:14Ordinarily this is thousands of dollars
  3352. 2:08:16to for a corporate company to get a
  3353. 2:08:18full-blown version of a SCADA software,
  3354. 2:08:20but Ignition has released a lightweight
  3355. 2:08:22version of it
  3356. 2:08:24for free, which is super exciting cuz a
  3357. 2:08:26YouTube channel like mine can give a
  3358. 2:08:28bunch of tutorials on how to do things
  3359. 2:08:30in Ignition without needing to shell out
  3360. 2:08:32thousands of dollars to get like a full
  3361. 2:08:33license. So that's pretty cool of
  3362. 2:08:35Inductive Automation.
  3363. 2:08:37To get started, I'm already logged in.
  3364. 2:08:39All you have to do is make a personal
  3365. 2:08:42account. It'll ask you to verify an
  3366. 2:08:43email,
  3367. 2:08:44and then you'll be able to sign in to
  3368. 2:08:46the link that is generated when you just
  3369. 2:08:48type when you just click this button,
  3370. 2:08:51get Ignition Maker Edition. And then the
  3371. 2:08:54first thing, I have generated a license
  3372. 2:08:56key. I'm not going to show you guys cuz
  3373. 2:08:58it's mine.
  3374. 2:08:59Um but when you generate a license,
  3375. 2:09:02there's just a big button here that says
  3376. 2:09:04no licenses and then you hit get license
  3377. 2:09:07and then it'll take like 30 seconds,
  3378. 2:09:09generate a unique code, and you'll get
  3379. 2:09:11two things. The license key, which is
  3380. 2:09:13this number and it's okay that you guys
  3381. 2:09:14can see it because the other thing you
  3382. 2:09:16get is a super long string of text,
  3383. 2:09:18which is your unique license key.
  3384. 2:09:21Um and then you want to download the
  3385. 2:09:22installer for whatever platform you're
  3386. 2:09:24on. I am on Windows, so I'll go ahead
  3387. 2:09:26and download the Windows installer. This
  3388. 2:09:29video's kind of geared at getting you
  3389. 2:09:30started with uh a SCADA software. I
  3390. 2:09:33think in the coming videos and on this
  3391. 2:09:35series, we'll get into how to do lots of
  3392. 2:09:38things with the SCADA and I'll kind of
  3393. 2:09:40talk through why you might want this.
  3394. 2:09:42One, if you're in the world of controls
  3395. 2:09:43and automation, and two, if you're a
  3396. 2:09:45hobbyist or a maker, um kind of show you
  3397. 2:09:48why it's sort of cool to have access to
  3398. 2:09:50a SCADA software even in a home setting.
  3399. 2:09:52So,
  3400. 2:09:53um I'm looking forward to this series. a
  3401. 2:09:55lot of interest in controls and
  3402. 2:09:57automation on the channel. Uh and
  3403. 2:09:59additionally, I have also had um a lot
  3404. 2:10:03of interest in um Python programming on
  3405. 2:10:06the channel and even like Arduino and
  3406. 2:10:08hobby builds and making things. And a
  3407. 2:10:11SCADA software is a really interesting
  3408. 2:10:12spot to bring SQL, Python, Java,
  3409. 2:10:16uh
  3410. 2:10:17in and automation and controls obviously
  3411. 2:10:19all together. So, I'm looking forward to
  3412. 2:10:21this series.
  3413. 2:10:22Um I'm just going to go ahead and do
  3414. 2:10:23typical installation because you can do
  3415. 2:10:26custom here and you can uh choose
  3416. 2:10:28modules to install or not install. Um
  3417. 2:10:31but you can also add modules at any time
  3418. 2:10:33down the road. So, you don't have to
  3419. 2:10:34feel like if you don't customize your
  3420. 2:10:35install in the beginning, you're stuck
  3421. 2:10:37with features or without features that
  3422. 2:10:39you might want later. That's no big
  3423. 2:10:41deal. Um so, let's just go ahead and run
  3424. 2:10:43the installer. And something super cool
  3425. 2:10:45about Ignition, it has two uh types of
  3426. 2:10:48visuals. It has perspective um and I
  3427. 2:10:51think the other one's called Vision. I
  3428. 2:10:53don't use Vision really. Perspective is
  3429. 2:10:55a web-based one. So, uh any if you had a
  3430. 2:10:58system of networked computers, it could
  3431. 2:10:59be your house or it could be a company,
  3432. 2:11:02um you could uh have hundreds of
  3433. 2:11:05computers on the same network and
  3434. 2:11:06they're all able to pull up the views,
  3435. 2:11:08the displays that you build in Ignition
  3436. 2:11:11from uh anywhere. So, Perspective is
  3437. 2:11:13pretty cool.
  3438. 2:11:14Um yeah, so let's go ahead and get the
  3439. 2:11:17Maker Edition. This standard edition is
  3440. 2:11:19pretty awesome, but you do have to pay
  3441. 2:11:21for it. So, let's just uh get the
  3442. 2:11:23personal use.
  3443. 2:11:25I do.
  3444. 2:11:26I do not agree. I do agree.
  3445. 2:11:29And here's where I'm going to pause the
  3446. 2:11:31recording cuz I need to put my license
  3447. 2:11:32key and activation token in and I don't
  3448. 2:11:34want you guys to see my activation
  3449. 2:11:35token.
  3450. 2:11:37Okay, so you punch in your activation
  3451. 2:11:39key and your license and uh then it asks
  3452. 2:11:42you to make a username and a password. I
  3453. 2:11:44make really strong passwords, so don't
  3454. 2:11:46even try to hack me. Um these we're
  3455. 2:11:49going to leave uh for now. We might mess
  3456. 2:11:51around with some gateway port HTTP and
  3457. 2:11:54HTTPS
  3458. 2:11:56but really leaving them as the
  3459. 2:11:57uh default ports will not be a problem.
  3460. 2:12:00Um so, start and launch the gateway now?
  3461. 2:12:02Sure, shoot. Who cares?
  3462. 2:12:05Um the uh Ignition gateway is sort of a
  3463. 2:12:09hub, so you could have multiple projects
  3464. 2:12:12that do different things, have different
  3465. 2:12:14views, different scripts and tags
  3466. 2:12:15underneath them, and the gateway is what
  3467. 2:12:18brings them all together. So, there's
  3468. 2:12:19really typically only one gateway per
  3469. 2:12:22installation.
  3470. 2:12:24Enable quick start and for new users?
  3471. 2:12:27No, I'm like so good at Ignition
  3472. 2:12:29already. Uh I'm going to start from
  3473. 2:12:31scratch. So, but uh when you download
  3474. 2:12:34the designer and you uh put that um
  3475. 2:12:37software on your computer, that is like
  3476. 2:12:40a desktop-based tool that you use to
  3477. 2:12:42build HMI displays in. And uh I'll
  3478. 2:12:46install for all users.
  3479. 2:12:49Install for all users. It's just me
  3480. 2:12:50using the computer.
  3481. 2:12:52Um and you can create a desktop shortcut
  3482. 2:12:54here, so this is nice. It lets you
  3483. 2:12:56um
  3484. 2:12:57access the designer from your desktop.
  3485. 2:12:59And uh real quick to look through the
  3486. 2:13:01gateway.
  3487. 2:13:03Oh, but I have to log in. Okay.
  3488. 2:13:07So, if we look at the gateway real quick
  3489. 2:13:09after logging in, just a few things to
  3490. 2:13:11highlight here. This is just your hub to
  3491. 2:13:13tell you how many devices you have
  3492. 2:13:15connected, what they can do for you, and
  3493. 2:13:18uh tell you some statistics about your
  3494. 2:13:20performance. So, by default, the gateway
  3495. 2:13:22has access to 2 GB of your RAM um when
  3496. 2:13:26you download it, and I have a computer
  3497. 2:13:28running basically nothing other than um
  3498. 2:13:31Ignition and my video capture software,
  3499. 2:13:33so the CPU is really not working
  3500. 2:13:34particularly hard. Um but you can also
  3501. 2:13:38up this number. My computer doesn't have
  3502. 2:13:402 gigs of RAM, it's given Ignition 2
  3503. 2:13:42gigs of RAM. So, we'll do uh how to
  3504. 2:13:45increase RAM on Ignition in a future
  3505. 2:13:47video.
  3506. 2:13:48Um for this video, I think the most
  3507. 2:13:50useful thing to do would be uh create
  3508. 2:13:52our first view in designer and uh maybe
  3509. 2:13:55add a couple tags and just show how to
  3510. 2:13:58display them on a view, and we'll call
  3511. 2:14:00that for the introductory video. I do do
  3512. 2:14:03quite a bit of work with Ignition, so if
  3513. 2:14:05you do have um questions, be sure to
  3514. 2:14:07drop them in the comments below and I'll
  3515. 2:14:09try to get back to you as soon as I can.
  3516. 2:14:11When you open up the designer, there's
  3517. 2:14:13going to be nothing configured and
  3518. 2:14:15initially you can just hit add designer.
  3519. 2:14:17Assuming you're doing all of this on
  3520. 2:14:18your
  3521. 2:14:19um same computer, the designer should
  3522. 2:14:21already be discoverable. You might uh
  3523. 2:14:24have to do like discover um gateways on
  3524. 2:14:27your network if you're using a different
  3525. 2:14:29computer on the same network. Uh but
  3526. 2:14:32again, that's kind of like more advanced
  3527. 2:14:34and I start questioning, are you really
  3528. 2:14:35doing this for makers? Um but I guess
  3529. 2:14:38also these videos could be super helpful
  3530. 2:14:40for people who do have a corporate
  3531. 2:14:42license. So,
  3532. 2:14:44um now uh when it shows up there and you
  3533. 2:14:46hit open designer, it's going to give
  3534. 2:14:49you a view um that is a little bit
  3535. 2:14:52daunting at first. There's it's hard to
  3536. 2:14:54make anything simple. Um let's go ahead
  3537. 2:14:57and log in, so I'm going to pause again.
  3538. 2:15:00Okay, so after logging in, uh if you
  3539. 2:15:02have been working on projects in the
  3540. 2:15:04past, they'll be here. If not, then you
  3541. 2:15:06can just hit new project. Let's call
  3542. 2:15:08this one LeMaster Tech and then we'll
  3543. 2:15:12say underscore tutorials, okay? Uh
  3544. 2:15:15project name, project title. I don't
  3545. 2:15:17know, that seemed like a good title.
  3546. 2:15:20I think
  3547. 2:15:23uh project project template parent
  3548. 2:15:25project. We'll get into that in the
  3549. 2:15:26future. You really don't need one right
  3550. 2:15:27now. Um connection settings, default is
  3551. 2:15:30fine. OPC UA module for anyone using
  3552. 2:15:33like PLCs, they're going to probably
  3553. 2:15:35want the OPC module as user source, but
  3554. 2:15:38you can also
  3555. 2:15:39um change all of this stuff later. So,
  3556. 2:15:41don't worry too much about those.
  3557. 2:15:43Leaving them as the default is just
  3558. 2:15:44fine. Um stuff we're going to get into
  3559. 2:15:47in future videos, tags and type of tags
  3560. 2:15:50and how to use them, how to use SQL with
  3561. 2:15:52Ignition, how to add PLCs and devices to
  3562. 2:15:55Ignition, different types of displays,
  3563. 2:15:57things like that. So, if you have
  3564. 2:15:58questions about anything specific with
  3565. 2:16:01Ignition, be sure to drop them in the
  3566. 2:16:02comments below. Uh and now let's take a
  3567. 2:16:05look at making a first view, okay? So,
  3568. 2:16:08let's go ahead and hit the plus on this
  3569. 2:16:10first view that pops up. We are in
  3570. 2:16:12Perspective. So again, I talked a little
  3571. 2:16:14bit earlier. Ignition has two HMI uh
  3572. 2:16:18tools. One is called Vision and it's a
  3573. 2:16:20like conventional-based
  3574. 2:16:22on a computer software. The other one is
  3575. 2:16:25Perspective and it looks to me like
  3576. 2:16:26Perspective is the only one that's
  3577. 2:16:28included
  3578. 2:16:29with the For Makers Edition, which is
  3579. 2:16:31totally fine. Um
  3580. 2:16:34but when you the cool thing about
  3581. 2:16:35Perspective is it's web-based and so
  3582. 2:16:38that means that you can give URLs to
  3583. 2:16:40every page. So, let's just make one and
  3584. 2:16:43we'll call it {slash} homepage. And it
  3585. 2:16:45asks you what primary view you want, but
  3586. 2:16:47because we haven't created any views
  3587. 2:16:49yet, there's no views. So, we'll expand
  3588. 2:16:52uh in the project browser, we'll expand
  3589. 2:16:54the Perspective section and you'll see
  3590. 2:16:56there's an area for views, but it's just
  3591. 2:16:59an empty folder right now. If you
  3592. 2:17:01right-click, then you can hit new view
  3593. 2:17:03and we'll call it homepage. Homepage.
  3594. 2:17:06Homepage. There we go. Root container
  3595. 2:17:09type, column container, breakpoint
  3596. 2:17:11container, blah blah blah blah.
  3597. 2:17:12Coordinate is going to be your default.
  3598. 2:17:14Go ahead and keep that. And when you
  3599. 2:17:16make uh check page URL, it's doing this
  3600. 2:17:19page for you uh this part for you in the
  3601. 2:17:22background. So, we'll actually hit
  3602. 2:17:24create view. Um and real quick, if you
  3603. 2:17:27click back on views, you're going to see
  3604. 2:17:30ones that are linked and ones that
  3605. 2:17:32aren't. So, this is the one I was
  3606. 2:17:33working on. I'm going to delete this.
  3607. 2:17:35Yes. What you're doing is you're telling
  3608. 2:17:37Ignition a series of pages that can be
  3609. 2:17:39navigated directly to from a web browser
  3610. 2:17:42as long as you're on the gateway, which
  3611. 2:17:44is super interesting. Um and we'll get
  3612. 2:17:47into how to access it and what that
  3613. 2:17:48actually means one video at a time right
  3614. 2:17:51now. But so, we have created a view
  3615. 2:17:53called homepage and it is linked to the
  3616. 2:17:56URL {slash} homepage. So, simplest thing
  3617. 2:18:00I can do uh to show you guys like um
  3618. 2:18:04what Ignition is is make a tag. Uh so, I
  3619. 2:18:07think what I want to do here is I want
  3620. 2:18:09to make a folder and I'll call this
  3621. 2:18:11folder tutorial tags. Um and SCADAs and
  3622. 2:18:15PLCs and basically anything automation
  3623. 2:18:17and controls really live off of the tag
  3624. 2:18:20structure, um which is just having in
  3625. 2:18:23conventional programming, you'd think of
  3626. 2:18:24it as a variable. Um in automation and
  3627. 2:18:28SCADA software, it's a tag. It
  3628. 2:18:30warehouses a tiny bit of data. It can be
  3629. 2:18:33used for reading, writing, and logic. Um
  3630. 2:18:35so, let's go ahead and make a memory
  3631. 2:18:37tag, which means it just lives on
  3632. 2:18:39Ignition. It lives on this computer. And
  3633. 2:18:42we will call it um
  3634. 2:18:43my first tag, okay? And let's make this
  3635. 2:18:47a string and let's give it an initial
  3636. 2:18:50value of why not hello world. Okay.
  3637. 2:18:54And let's go ahead and drag my first tag
  3638. 2:18:57onto the screen and all we do is click
  3639. 2:19:00on that tag and drag it onto the screen
  3640. 2:19:02and it's going to give us its top
  3641. 2:19:04recommendations for what that data
  3642. 2:19:06format might be. And so we'll hit label.
  3643. 2:19:09And there you can see we have a tag that
  3644. 2:19:11says hello world. Nothing crazy, nothing
  3645. 2:19:14fancy going on here.
  3646. 2:19:16Um
  3647. 2:19:17and if we hit save, so control S or the
  3648. 2:19:19save button up here, we should now have
  3649. 2:19:21a view called hello world. And so if we
  3650. 2:19:24go back to my my robot heard me say
  3651. 2:19:28hello.
  3652. 2:19:29Um if we go back to the web, we can see
  3653. 2:19:31how we can access this now.
  3654. 2:19:33And actually one thing we're going to do
  3655. 2:19:34before we uh access it from the web is
  3656. 2:19:37we're going to make a URL um for just
  3657. 2:19:40the homepage and we're going to address
  3658. 2:19:42it to that same page, too. So what's
  3659. 2:19:44interesting here is I've made a second
  3660. 2:19:46address that will access the same page.
  3661. 2:19:48If you've done a little bit of web
  3662. 2:19:49development, you've probably seen that
  3663. 2:19:51sort of thing. If not, no big deal, but
  3664. 2:19:53this basically means that uh this page
  3665. 2:19:56should act as your homepage as well. Um
  3666. 2:19:59so let's go ahead and see how you can
  3667. 2:20:01actually view and access this thing. If
  3668. 2:20:03I go back to uh Edge and I just go to
  3669. 2:20:07localhost 8088,
  3670. 2:20:10so this here, localhost 8088, is going
  3671. 2:20:14to be um how you access it from the
  3672. 2:20:16computer when you're on it, but you can
  3673. 2:20:19also usually get to it. If you just
  3674. 2:20:21start typing in Ignition, you'll see
  3675. 2:20:23here it'll remember like Ignition L the
  3676. 2:20:26Master Tech Engineering 1 Ignition
  3677. 2:20:28Gateway.
  3678. 2:20:29Um and anything that has this orange dot
  3679. 2:20:32is usually going to take you to
  3680. 2:20:33somewhere on the gateway. It might have
  3681. 2:20:35you log in, that's okay. Um but uh
  3682. 2:20:39anyways, when you want to view a project
  3683. 2:20:41online, this homepage has download the
  3684. 2:20:44designer, we've already done that, and
  3685. 2:20:46it has view projects. And if you do
  3686. 2:20:48that, the projects that you're making
  3687. 2:20:50should be here. And if you hit launch
  3688. 2:20:51project and agree that it is for
  3689. 2:20:54hobbyist students and individuals,
  3690. 2:20:56um then what you can see is we have a
  3691. 2:20:59page that says hello world and that's
  3692. 2:21:01super cool. Um and if you had a forward
  3693. 2:21:05slash homepage,
  3694. 2:21:07it would still be this page because we
  3695. 2:21:09gave it two different addresses. Um but
  3696. 2:21:12we're basically building a website that
  3697. 2:21:15is uh only for people who have access to
  3698. 2:21:17your gateway and that is something super
  3699. 2:21:20cool and kind of unique about the
  3700. 2:21:21Ignition SCADA software. You uh have
  3701. 2:21:24here is the first tag, the first
  3702. 2:21:28display, how to get started with
  3703. 2:21:29Ignition for makers. What we'll be doing
  3704. 2:21:32in this series is a lot of the basic
  3705. 2:21:33stuff that you might need to know about
  3706. 2:21:36um
  3707. 2:21:37to build various features in Ignition.
  3708. 2:21:39I'll definitely focus mostly on the core
  3709. 2:21:42functionality of how to do things with
  3710. 2:21:44Ignition and then I'll probably start um
  3711. 2:21:47showing how to do a lot of things for
  3712. 2:21:50makers specifically. So I have a pretty
  3713. 2:21:52cool garage workshop. I'll probably do a
  3714. 2:21:54lot of automation projects in the
  3715. 2:21:56garage, show how I use SCADA to do that.
  3716. 2:21:58So if you have ideas of what we should
  3717. 2:22:01do with Ignition or things that would be
  3718. 2:22:03useful for you to see, be sure to let me
  3719. 2:22:05know about in the comments below. Thank
  3720. 2:22:07you guys so much for checking out uh the
  3721. 2:22:09channel and if you have any questions,
  3722. 2:22:11let me know. If you have any ideas for
  3723. 2:22:13future videos, let me know. And um as
  3724. 2:22:16always, good luck with your projects.
  3725. 2:22:17Thanks for watching and we'll see you
  3726. 2:22:18next time. Thanks. Bye.
  3727. 2:22:27Hello and welcome back to the channel.
  3728. 2:22:29In today's video, I'm going to walk you
  3729. 2:22:31through how to use expression tags in
  3730. 2:22:34Ignition. All right, so this is
  3731. 2:22:36obviously a continuation in the Ignition
  3732. 2:22:38tutorial series uh we've recently
  3733. 2:22:40started on the channel. If you do have
  3734. 2:22:41any questions about how to download
  3735. 2:22:43Ignition for makers, what Ignition is,
  3736. 2:22:46why you need it, what an expression tag
  3737. 2:22:48is, be sure to check out the playlist on
  3738. 2:22:50the channel. I will be adding all
  3739. 2:22:51Ignition tutorials to that playlist and
  3740. 2:22:54hopefully building a pretty deep uh
  3741. 2:22:56backlog of how to get started and how to
  3742. 2:22:58use Ignition and eventually doing some
  3743. 2:22:59pretty cool and in-depth automation
  3744. 2:23:02slash makers uh projects with it. So um
  3745. 2:23:05as always, if you have any questions,
  3746. 2:23:06feel free to drop them in the comments
  3747. 2:23:08below, but I'll be assuming for this
  3748. 2:23:09video that you at least have downloaded
  3749. 2:23:11Ignition, know how to get into the
  3750. 2:23:13designer, and want to know how to use
  3751. 2:23:15expression tags. So I've already built
  3752. 2:23:18out a little bit of a framework here
  3753. 2:23:19that has a Boolean, meaning a bit,
  3754. 2:23:22meaning on or off, true or false, and
  3755. 2:23:24you can see I have a toggle checkbox for
  3756. 2:23:26it on the screen that I've built, and
  3757. 2:23:28you can see the tag value itself in this
  3758. 2:23:30browser on the lower left also changing
  3759. 2:23:33when I change the bit. Then I built out
  3760. 2:23:35a little just plus uh minus two buttons
  3761. 2:23:38on either side of a counter.
  3762. 2:23:40And these are just letting me change the
  3763. 2:23:41value of my integer tag. And then I have
  3764. 2:23:44a text entry box here
  3765. 2:23:47uh just where I can enter values and
  3766. 2:23:49change the value of a string tag. So the
  3767. 2:23:51reason I built out these three different
  3768. 2:23:53types of tag is because I want to
  3769. 2:23:55obviously new tag um new standard tag
  3770. 2:23:58expression tag.
  3771. 2:24:00I want to show you how to use expression
  3772. 2:24:01tags and I want to show you how to
  3773. 2:24:03interact with three different types of
  3774. 2:24:05tags in your expression, so that's why I
  3775. 2:24:07did that. And let's just call this
  3776. 2:24:10expression tag one. So nice descriptive
  3777. 2:24:13name. We'll make it an expression and we
  3778. 2:24:15will make it a Boolean because what this
  3779. 2:24:17expression is going to be doing is
  3780. 2:24:19evaluating multiple other tags and
  3781. 2:24:22making a decision whether those
  3782. 2:24:23conditions are true or whether those
  3783. 2:24:25conditions are false. So we'll come down
  3784. 2:24:27to expression and we'll hit the pencil.
  3785. 2:24:29So now we are in the expression editor.
  3786. 2:24:32Uh if you ever get like super duper lost
  3787. 2:24:34and confused, um these uh fields in the
  3788. 2:24:38top right, there's a little plus and an
  3789. 2:24:40equal sign and these are some of the
  3790. 2:24:41most common fields that you'll be using
  3791. 2:24:43in expression tags, so I find them
  3792. 2:24:45pretty useful. If you ever forget that
  3793. 2:24:47like or or and or less than uh or equal
  3794. 2:24:51to is uh is this specific symbol, it's
  3795. 2:24:54nice to have a little refresh available
  3796. 2:24:55to you right there. But to be honest, uh
  3797. 2:24:58expression tags fill a pretty tight
  3798. 2:25:00niche in Ignition because when things
  3799. 2:25:02get really complicated, you don't
  3800. 2:25:04necessarily want to be using expression
  3801. 2:25:06tags, you want to be using like Python
  3802. 2:25:08scripting, which we'll talk about in
  3803. 2:25:10future videos. But the purpose of
  3804. 2:25:11expression tags is to sort of evaluate a
  3805. 2:25:14few things in a field. Uh you could
  3806. 2:25:16think of a tank, right? That could have
  3807. 2:25:18multiple alarm issues. It could be at
  3808. 2:25:20high high level. It could be at high
  3809. 2:25:22high pressure. It could be at uh high
  3810. 2:25:24high temperature. And if any of those
  3811. 2:25:26things are true, you want to turn an
  3812. 2:25:28alarm on. Uh maybe it's a strobe light,
  3813. 2:25:31maybe it's an alert, maybe it's an email
  3814. 2:25:33that gets sent out to like maintenance
  3815. 2:25:34or something.
  3816. 2:25:35So that is kind of the perfect time to
  3817. 2:25:38use an expression tag. And uh to use an
  3818. 2:25:40expression tag, we're basically saying
  3819. 2:25:42we want to look at the value of other
  3820. 2:25:44tags and let that determine the outcome
  3821. 2:25:47of this tag. Uh it's basically
  3822. 2:25:51like let me read values about other tags
  3823. 2:25:53and make decisions uh what about what I
  3824. 2:25:56should do. I said that already. All
  3825. 2:25:57right, so let's copy the path of our
  3826. 2:26:00Boolean tag. And I went kind of fast
  3827. 2:26:02there, but if you want to look at the
  3828. 2:26:04value of another tag inside of your
  3829. 2:26:07expression, one easy way to do that is
  3830. 2:26:09go to the tag that you want to look at
  3831. 2:26:11the value of and right click and go down
  3832. 2:26:13to copy path. That will give you uh text
  3833. 2:26:16which when if you paste it into curly
  3834. 2:26:18brackets, will look like this and this
  3835. 2:26:20is going to give you uh that tag and
  3836. 2:26:23it's telling this expression tag
  3837. 2:26:25explicitly where to go and look at the
  3838. 2:26:27value. So first thing, let's say we want
  3839. 2:26:29the outcome of this tag to be determined
  3840. 2:26:32uh by whether or not that Boolean tag is
  3841. 2:26:34true. So when this thing is checked,
  3842. 2:26:37it'll say enabled and that means it's
  3843. 2:26:39true and so this will become true. Now
  3844. 2:26:42we're going to use the expression and
  3845. 2:26:44which is two ampersands. And now we're
  3846. 2:26:47going to look at the integer tag. So I
  3847. 2:26:49could do it exactly the same uh way. I
  3848. 2:26:52could copy the path just like I just did
  3849. 2:26:54and I could paste it in here, but uh one
  3850. 2:26:57additional pretty cool little thing you
  3851. 2:26:59can do inside the expression browser is
  3852. 2:27:01this insert tag button which is a little
  3853. 2:27:04tag icon over on the right. You hit
  3854. 2:27:06insert tag and uh it'll open up a tag
  3855. 2:27:09browser. So I can go to my folder for
  3856. 2:27:12tutorial tags, my expression tag
  3857. 2:27:14tutorial, and I can click on that
  3858. 2:27:16integer tag and I can hit okay.
  3859. 2:27:19And I can say uh so now integer tag and
  3860. 2:27:23I want it greater than two. And what you
  3861. 2:27:25guys notice is kind of interesting is
  3862. 2:27:27rather than all this first gobbledygook,
  3863. 2:27:30what I get is square bracket period
  3864. 2:27:33square bracket and that is because it's
  3865. 2:27:35telling this expression you don't have
  3866. 2:27:37to go look through the entire tag
  3867. 2:27:40browser to find this tag. It's in the
  3868. 2:27:41same host folder and location as you
  3869. 2:27:44are. So this dot is just a way to get uh
  3870. 2:27:47your expression optimized to look at a
  3871. 2:27:50closer location. So really we could go
  3872. 2:27:53back and we could control C this into
  3873. 2:27:55here because the Boolean tag is
  3874. 2:27:57obviously in the same location as well.
  3875. 2:28:00But for now, let's do just those two
  3876. 2:28:02things. Let's say if the Boolean tag is
  3877. 2:28:05true and if the integer tag is greater
  3878. 2:28:07than two, then we want uh that to
  3879. 2:28:09determine the outcome of our expression
  3880. 2:28:11tag, okay? And I'm intentionally not
  3881. 2:28:13using the string yet because there's one
  3882. 2:28:15thing we're going to talk about when we
  3883. 2:28:16get to that. But let's go ahead and make
  3884. 2:28:18the expression tag and uh just so it's a
  3885. 2:28:21little bit more useful for us, let's go
  3886. 2:28:23ahead and change our uh
  3887. 2:28:25yeah, I left it in run mode. Let's go
  3888. 2:28:27ahead and change the text on this
  3889. 2:28:30uh to look at the expression tag. So
  3890. 2:28:33it's still looking at my first tag.
  3891. 2:28:35Let's look at the expression tag, which
  3892. 2:28:37is just going to say true or false, and
  3893. 2:28:39let's real quick, let's just transform
  3894. 2:28:41it to tell us explicitly that false will
  3895. 2:28:45mean
  3896. 2:28:46conditions
  3897. 2:28:48not met. And I'm not really focusing on
  3898. 2:28:51stuff like how to transform
  3899. 2:28:54in what I'm doing right now. Conditions
  3900. 2:28:57all met, okay? All I'm doing is taking
  3901. 2:29:00the true false outcome of the expression
  3902. 2:29:02tag we just made and saying whether or
  3903. 2:29:04not the conditions are met in a little
  3904. 2:29:07label up top, okay? So, if you remember,
  3905. 2:29:09we said the integer has to be greater
  3906. 2:29:11than two and we said this bit has to be
  3907. 2:29:14enabled. So, the bit is enabled but the
  3908. 2:29:17integer is exactly two. Let's go ahead
  3909. 2:29:18and add one to the integer. And now it
  3910. 2:29:21says three and now the expression tag
  3911. 2:29:23says conditions all met. Now, if I were
  3912. 2:29:25to disable the bit, it says conditions
  3913. 2:29:28not met again. And what's really
  3914. 2:29:29interesting is we didn't set up our
  3915. 2:29:32expression tag to be like cyclical or
  3916. 2:29:34anything. We left it on the default
  3917. 2:29:36which was event-driven. And event-driven
  3918. 2:29:38is really interesting because
  3919. 2:29:39event-driven means it's looking at
  3920. 2:29:41changes of any of the tags that it is
  3921. 2:29:44addressing in its expression. So, it
  3922. 2:29:46knows that when this bit changes, it
  3923. 2:29:48needs to do a new evaluation because the
  3924. 2:29:50values that it's comparing to are
  3925. 2:29:53changing underneath it. So, it's a
  3926. 2:29:55really cool function of Ignition
  3927. 2:29:56expression tags. If we were to take this
  3928. 2:29:59integer back down under two, we would
  3929. 2:30:01get an issue
  3930. 2:30:02um
  3931. 2:30:03Oh, it would just say conditions not
  3932. 2:30:05met, not an issue. Now, let's take a
  3933. 2:30:07look at how to incorporate a string cuz
  3934. 2:30:08it's a little bit tricky and I left one
  3935. 2:30:11thing out of this expression on purpose
  3936. 2:30:13to show you the difference. I think now
  3937. 2:30:15is a perfect time to take a quick pause
  3938. 2:30:17and talk to you about the sponsor of
  3939. 2:30:18today's video, PCBWay. PCBWay is a
  3940. 2:30:21long-term supporter of the Le Master
  3941. 2:30:23Tech channel and I love working with
  3942. 2:30:25them because their products and services
  3943. 2:30:27are all about empowering makers. As
  3944. 2:30:29their name suggests, the core of their
  3945. 2:30:31business is manufacturing PCBs or
  3946. 2:30:33printed circuit boards. This is such a
  3947. 2:30:35cool way for hobbyists and makers to
  3948. 2:30:37turn their electronic designs into super
  3949. 2:30:39high-quality and professional-grade
  3950. 2:30:41circuit boards. Beyond that, they also
  3951. 2:30:43have the ability to support all of your
  3952. 2:30:45prototyping with high-quality 3D
  3953. 2:30:47printing and metal fabrication as well.
  3954. 2:30:49Be sure to check them out at the
  3955. 2:30:50description below this video and thank
  3956. 2:30:52you so much to PCBWay for sponsoring the
  3957. 2:30:54video. All right, now let's get right
  3958. 2:30:56back to the tutorial. Okay, now let's
  3959. 2:30:58take a look at how to take that
  3960. 2:30:59expression tag one step further and
  3961. 2:31:02incorporate our string tag here. All
  3962. 2:31:04right, so let's go ahead and say we also
  3963. 2:31:06want to keep an eye on the string and
  3964. 2:31:08make sure that it doesn't equal a
  3965. 2:31:11certain code, right? Like you might have
  3966. 2:31:13a status for a tank and it says like
  3967. 2:31:16filling, heating, mixing, idle. Um and
  3968. 2:31:19you want to make sure that tag is not
  3969. 2:31:21idle. So, we could say uh and we want to
  3970. 2:31:24make sure the string tag is not equal to
  3971. 2:31:27and not equal to is {exclamation mark}
  3972. 2:31:29{equal sign}. And let's just pick uh
  3973. 2:31:32Pete because that's my name and that's
  3974. 2:31:34something that is easy for me to
  3975. 2:31:36remember while I type it.
  3976. 2:31:39All right, and let's go hit apply and
  3977. 2:31:40let's hit save and now I'm going to say
  3978. 2:31:44all right, this is greater than three
  3979. 2:31:46and my string tag is not equal to Pete,
  3980. 2:31:49which is great. Um but if I hit enter,
  3981. 2:31:52you'll see conditions not met. So, it's
  3982. 2:31:54still working like that, which is really
  3983. 2:31:56cool.
  3984. 2:31:57Um but one weird nuance that you just
  3985. 2:32:00should be aware of is if you want to do
  3986. 2:32:03something different like and
  3987. 2:32:05uh length of the string tag is not equal
  3988. 2:32:10to zero. So, you're just basically
  3989. 2:32:12saying I don't want to have an empty
  3990. 2:32:15string. If we hit apply and we hit apply
  3991. 2:32:18and we hit okay, um it says conditions
  3992. 2:32:21all met right now and when we hit uh
  3993. 2:32:24delete it out, it seems to be working
  3994. 2:32:28properly because the string goes to
  3995. 2:32:30nothing. It might seem like an
  3996. 2:32:32unnecessary step because everything was
  3997. 2:32:34working fine without it, but just to
  3998. 2:32:36show you kind of how it's
  3999. 2:32:38interchangeable
  4000. 2:32:39but still important to know about, I'm
  4001. 2:32:41going to add {dot} value to the end of
  4002. 2:32:43all of them. And what you'll see is they
  4003. 2:32:45still all individually work. Like I can
  4004. 2:32:47still turn off uh enable disabled. I can
  4005. 2:32:50still make the integer go below three
  4006. 2:32:53and I can still make this uh go empty. I
  4007. 2:32:56hope the outcome of this video is
  4008. 2:32:58crystal clear. This is a really neat,
  4009. 2:33:00powerful way that you can get one tag
  4010. 2:33:03that tells you the status of multiple
  4011. 2:33:05things in your process and you can use
  4012. 2:33:07that to do all sorts of useful stuff
  4013. 2:33:09downstream. So, it's like doing
  4014. 2:33:12programming uh it inside of Ignition,
  4015. 2:33:15which is nice because a lot of old SCADA
  4016. 2:33:17software, you mainly wanted to do as
  4017. 2:33:19much programming as you could inside
  4018. 2:33:21like the PLC or the devices that were
  4019. 2:33:23coming into your SCADA and you want to
  4020. 2:33:26minimize developing like code and uh
  4021. 2:33:29different formulas and stuff inside of
  4022. 2:33:31the SCADA, inside of the HMI itself. But
  4023. 2:33:34Ignition really changes that in my
  4024. 2:33:35opinion. Bringing raw tags in and doing
  4025. 2:33:38math and calculations on them inside of
  4026. 2:33:40a project absolutely makes logical sense
  4027. 2:33:43uh using Ignition. So, I think this is a
  4028. 2:33:45super cool topic and I use these tags
  4029. 2:33:48all the time. So, be sure to let me know
  4030. 2:33:50in the comments below if you have any
  4031. 2:33:51questions. If you have any questions
  4032. 2:33:53about the stuff I kind of did on the
  4033. 2:33:54side to set up this example, let me know
  4034. 2:33:56as well. And be sure to let me know what
  4035. 2:33:58you want to see next on the channel. I
  4036. 2:34:00do a lot of development in in Ignition,
  4037. 2:34:02so if you have questions about how to do
  4038. 2:34:03any sort of specifics with that, just
  4039. 2:34:06let me know. As always, thank you so
  4040. 2:34:08much for watching and we'll see you next
  4041. 2:34:10time.
  4042. 2:34:16Hello and welcome back to the channel.
  4043. 2:34:18In today's video, I'm going to show you
  4044. 2:34:21how to write Python scripting inside of
  4045. 2:34:24the SCADA platform Ignition. I'm going
  4046. 2:34:26to show you how to do it in three
  4047. 2:34:28different places and we are going to
  4048. 2:34:29cover a lot of material. So, let's get
  4049. 2:34:31right into it. Today, we're going to
  4050. 2:34:32talk about one of the things that makes
  4051. 2:34:34Ignition so incredibly powerful and
  4052. 2:34:37super easy for traditional programmers
  4053. 2:34:40to break into the world of industrial
  4054. 2:34:41controls and automation, but also for
  4055. 2:34:43controls and automation engineers to
  4056. 2:34:45learn a little bit more of the
  4057. 2:34:47conventional programming skills, so to
  4058. 2:34:49speak. And part of the reason for that
  4059. 2:34:51is you can write code in Python. And so,
  4060. 2:34:56to do this, I'm going to actually save
  4061. 2:34:58us a little bit of trouble watching me
  4062. 2:35:00scrap together a piece of Python code,
  4063. 2:35:03but I'm going to propose a scenario for
  4064. 2:35:05you guys.
  4065. 2:35:06And hopefully you can see in the bottom
  4066. 2:35:08left here, I have a tag that I've
  4067. 2:35:09created called input array, okay? And it
  4068. 2:35:13is just an integer array. So, there are
  4069. 2:35:1510 integers inside of this array and
  4070. 2:35:19that is all that's in there. And we can,
  4071. 2:35:21you know, just manually remove rows if
  4072. 2:35:24we want to. It's It's just a memory tag.
  4073. 2:35:26It's a block of integers. But let's say
  4074. 2:35:28I want to write a script that's going to
  4075. 2:35:31dynamically read through that integer
  4076. 2:35:34array, look at how many elements are
  4077. 2:35:36inside of that integer array, and create
  4078. 2:35:39a tag for each of those elements
  4079. 2:35:41individually. This could be useful for
  4080. 2:35:43trending like creating historical graphs
  4081. 2:35:45of temperatures and flows and things
  4082. 2:35:47like that or a variety of purposes. So,
  4083. 2:35:49there's a lot There are a lot of reasons
  4084. 2:35:52you might want to do this inside of
  4085. 2:35:54Python rather than break it out when
  4086. 2:35:57you're like reading a block of data from
  4087. 2:35:59a PLC, for example, you might read that
  4088. 2:36:01in
  4089. 2:36:02as an array. So, let's take a look now.
  4090. 2:36:05I'm assuming you have a reason you want
  4091. 2:36:07to write Python Ignition. So, let's take
  4092. 2:36:09a look at first example of just how to
  4093. 2:36:12test a script while writing it in
  4094. 2:36:14Python. So, your best friend as a
  4095. 2:36:16developer when you're inside of Ignition
  4096. 2:36:19designer and you want to test some
  4097. 2:36:20Python script is the script console. So,
  4098. 2:36:23if you go to tools at the top and then
  4099. 2:36:25script console, it's going to open a
  4100. 2:36:27window that
  4101. 2:36:29looks kind of like a very bare-bones IDE
  4102. 2:36:33in a conventional like programming
  4103. 2:36:35setting like a Jupyter notebooks or
  4104. 2:36:37something.
  4105. 2:36:38None of the bells and whistles of like a
  4106. 2:36:40PyCharm or VS Code, but the idea is you
  4107. 2:36:43write code on the left and it gives you
  4108. 2:36:45output on the right. So, I'll talk you
  4109. 2:36:48through the code that I've written
  4110. 2:36:49already and hopefully you can tell if
  4111. 2:36:51you're somewhat familiar with the Python
  4112. 2:36:53syntax that other than knowing some
  4113. 2:36:55specific Ignition syntax in here, the
  4114. 2:36:58code really reads like Python. It's a
  4115. 2:37:00variable set equal to a value. It's for
  4116. 2:37:04I in range whatever, try except for I in
  4117. 2:37:08range, right? Like this is Python code
  4118. 2:37:10with some Ignition specific syntax.
  4119. 2:37:13You'll just have to refer to Ignition
  4120. 2:37:15forums, ask a friend, ask the internet,
  4121. 2:37:17ask Ignition support if you don't know
  4122. 2:37:20the specific syntax of the thing that
  4123. 2:37:22you're trying to do. But basically, this
  4124. 2:37:25is a script to take elements of
  4125. 2:37:30an array and break them into child tags,
  4126. 2:37:36okay? Um so, there are a lot of ways to
  4127. 2:37:38do this. This script is in no way the
  4128. 2:37:41only way you could do this sort of
  4129. 2:37:42functionality, but I start by reading
  4130. 2:37:45the raw data from the input array tag
  4131. 2:37:48and then I define the path where I'm
  4132. 2:37:51going to store and delete any child
  4133. 2:37:53tags. So, the first thing I do, and I'm
  4134. 2:37:55kind of using a fudge factor here of 20,
  4135. 2:37:59but first thing I'm going to do is clear
  4136. 2:38:00out any tags that might already be in
  4137. 2:38:03there. So, if I've already
  4138. 2:38:06done this script previously and there
  4139. 2:38:08were let's say six array elements
  4140. 2:38:10already sitting in there, this code will
  4141. 2:38:12go through and it will delete those all
  4142. 2:38:14out. And then what it's going to do is
  4143. 2:38:17for I in range length of the data. So,
  4144. 2:38:20in the length of the array, it's going
  4145. 2:38:22to define a new tag that will be called
  4146. 2:38:26array element 0 1 2 3 4 5 to whatever
  4147. 2:38:29length we have. And then it's going to
  4148. 2:38:32configure the tag, meaning create the
  4149. 2:38:34tag and then it will write a value to
  4150. 2:38:37that tag of whatever's in that array.
  4151. 2:38:39So, is this a somewhat confusing
  4152. 2:38:42example? I hope not.
  4153. 2:38:44But, remember I have an array here that
  4154. 2:38:46has the values in it of 10 20 30 40 50
  4155. 2:38:51and 60. So, our goal is to create a and
  4156. 2:38:54you can see there's no drop down in the
  4157. 2:38:56child tags folder currently. Our goal is
  4158. 2:38:58to write a Python script that is going
  4159. 2:39:01to read the data from that tag and then
  4160. 2:39:04it's going to create six children tags
  4161. 2:39:07that say 10 20 30 40 50 60. That should
  4162. 2:39:11be what this code does. And so, if I
  4163. 2:39:13execute it, you'll see I actually get
  4164. 2:39:16bad not found, which is completely fine
  4165. 2:39:18because that's the delete code not
  4166. 2:39:20finding the tags. And then all of the
  4167. 2:39:22goods are the configuration and the
  4168. 2:39:24right blocking working. So, if we click
  4169. 2:39:26on child tags over on the left, now
  4170. 2:39:28you'll see we've dynamically created
  4171. 2:39:30array element 0 1 2 3 4 5 6 just 0
  4172. 2:39:35through 5,
  4173. 2:39:36which is cool and their values are 10
  4174. 2:39:38through 60, which makes intuitive sense.
  4175. 2:39:40But, now let's pop into our array and
  4176. 2:39:42let's say between 10 and
  4177. 2:39:45between 30 and 40 we have 35, right? And
  4178. 2:39:49after 60 we have 70. Okay? So, let's say
  4179. 2:39:52that the array has just been updated and
  4180. 2:39:55now there's eight values. And what
  4181. 2:39:57you'll see is the script in the script
  4182. 2:39:58console isn't going to
  4183. 2:40:01automatically update it. We have to hit
  4184. 2:40:03execute again. But, when we hit execute
  4185. 2:40:05again, the same code works and it gives
  4186. 2:40:08us 10 20 30 35 40 50 60 and 70. Okay?
  4187. 2:40:13So, this is some very basic code to
  4188. 2:40:15generate tags as you rip them out of an
  4189. 2:40:17array dynamically as well as clear out
  4190. 2:40:20children tags that may have already been
  4191. 2:40:21in there.
  4192. 2:40:22This is pretty cool. But, I think what
  4193. 2:40:25you guys are probably noticing already
  4194. 2:40:27and it's no big deal if not,
  4195. 2:40:29but is it's not super convenient to have
  4196. 2:40:32to manually execute a script every time
  4197. 2:40:34an array updates. And so, what we want
  4198. 2:40:36to do is explore how to get that code
  4199. 2:40:39firing on tag change. And that's what
  4200. 2:40:42we're going to talk about now because
  4201. 2:40:43there are a lot of places that you can
  4202. 2:40:45embed this script that we've just
  4203. 2:40:47written
  4204. 2:40:48into a different location that will do
  4205. 2:40:51some of that functionality for you
  4206. 2:40:53automatically. So, let's take a look at
  4207. 2:40:55the first one and I'm not going to lie,
  4208. 2:40:56we are pretty much immediately going to
  4209. 2:40:58look at better places to store this
  4210. 2:41:00scripting. But, if you have simple
  4211. 2:41:02Python functionality that you want to
  4212. 2:41:04do, you can double click on a tag or
  4213. 2:41:06right click and hit edit tags. And then
  4214. 2:41:08there's an option on the left for
  4215. 2:41:10scripting and for every tag value change
  4216. 2:41:13and quality change are going to be two
  4217. 2:41:15of your options as well as alarm events,
  4218. 2:41:17but we're not going to talk about alarms
  4219. 2:41:18in today's video. And quality change
  4220. 2:41:21means like if you're reading values off
  4221. 2:41:22of a PLC and the quality goes from good
  4222. 2:41:25healthy I can see this tag to oh bad oh
  4223. 2:41:28crap I can't see the tag, you could do
  4224. 2:41:31something here. But, what we're going to
  4225. 2:41:32do is value change.
  4226. 2:41:34And when the value of an array changes,
  4227. 2:41:37that means two things. Either we've
  4228. 2:41:39changed one of the integers inside of
  4229. 2:41:41the array or we've changed something
  4230. 2:41:43about the array itself like the overall
  4231. 2:41:45dimensions.
  4232. 2:41:46So, we're going to drop the code that we
  4233. 2:41:48just wrote inside of this value change
  4234. 2:41:51location.
  4235. 2:41:53And what you can probably see
  4236. 2:41:56just by looking at kind of what's
  4237. 2:41:57available to you here, they give you
  4238. 2:41:59some values available to you just by the
  4239. 2:42:02nature of it being a value change
  4240. 2:42:04script. So, you could use the tag path
  4241. 2:42:06of this tag
  4242. 2:42:08the tag itself, the previous value or
  4243. 2:42:11the current value in this tag change
  4244. 2:42:13script. So, theoretically rather than
  4245. 2:42:15reading the value of this tag, we could
  4246. 2:42:17just use current value. That's a little
  4247. 2:42:19bit of Ignition specific syntax. If you
  4248. 2:42:22have questions about that, let me know
  4249. 2:42:23in the comments below and we can talk
  4250. 2:42:25about it more. But, I'm actually going
  4251. 2:42:27to leave the code exactly as is just to
  4252. 2:42:29illustrate that it works exactly as is.
  4253. 2:42:33And then one thing I'm going to add here
  4254. 2:42:36is I'm going to add a logger. And this
  4255. 2:42:38is basically Ignition's version of like
  4256. 2:42:41a web hosted hosted by their gateway
  4257. 2:42:44console window. So, think of the print
  4258. 2:42:47statement in a conventional Python
  4259. 2:42:50script. Logger is like Ignition's way of
  4260. 2:42:53giving you that same functionality.
  4261. 2:42:55So, if you do logger equals and then the
  4262. 2:42:57specific syntax is system.util.get
  4263. 2:43:01logger just like that. And then you get
  4264. 2:43:03to define a name. So, we will call ours
  4265. 2:43:07um
  4266. 2:43:07Python tutorial. Okay? I love Python
  4267. 2:43:12tutorials.
  4268. 2:43:13All right. And then what we're going to
  4269. 2:43:15do is logger.info and there are a few
  4270. 2:43:17classes of logger. You could do
  4271. 2:43:20logger.warn debug info. There might be
  4272. 2:43:24more, but trace I think is one. But,
  4273. 2:43:27basically I'm just going to do
  4274. 2:43:28logger.info, which is the easiest one
  4275. 2:43:31and we'll just say this came from a tag
  4276. 2:43:35change script. Okay? With an exclamation
  4277. 2:43:37mark. We'll drop it right there. And all
  4278. 2:43:40this should do is when we update this if
  4279. 2:43:43the script works, this should appear in
  4280. 2:43:45the logs on the gateway. And I'll show
  4281. 2:43:47you how to get there in just a second.
  4282. 2:43:49But, for now let's hit okay and let's
  4283. 2:43:52hit save on our project and nothing
  4284. 2:43:55happens because the array still has the
  4285. 2:43:57value it already had. But, let's pop in
  4286. 2:43:59here and let's add
  4287. 2:44:0380 90 and just to mess with the people
  4288. 2:44:07with OCD, let's make this one 1,000.
  4289. 2:44:10Okay? And let's hit apply and okay. And
  4290. 2:44:13you can see the array elements are
  4291. 2:44:14already there and they're there in the
  4292. 2:44:16order that we defined in the previous
  4293. 2:44:18scripting and they're already populated
  4294. 2:44:200 to 10 with all 11 elements. So, now if
  4295. 2:44:23I pop back into the array
  4296. 2:44:26and I delete let's say 1,000 all the way
  4297. 2:44:28up to 30. So, there's just these two
  4298. 2:44:31rows in there 10 and 20 and I hit apply
  4299. 2:44:33again and I hit okay. All right. So,
  4300. 2:44:35just by putting in a value change
  4301. 2:44:37script, this code is working. And now if
  4302. 2:44:40I go to my gateway, right? If I go to my
  4303. 2:44:42host here
  4304. 2:44:44and disregard everything before like
  4305. 2:44:4723:14
  4306. 2:44:48cuz that was me testing and setting up
  4307. 2:44:50for this tutorial. But, what you can see
  4308. 2:44:52is Python tutorial, right? The logger
  4309. 2:44:54name that I just gave
  4310. 2:44:57to this logger is saying hey this
  4311. 2:44:59message came from a tag script. This
  4312. 2:45:01came from a tag script. This came from a
  4313. 2:45:03tag script. So, that represents the
  4314. 2:45:05three times the script ran. It's logging
  4315. 2:45:07it each time and you get a timestamp of
  4316. 2:45:09when it happened. You get here when
  4317. 2:45:12you're on the gateway and you're at
  4318. 2:45:13home, you go to status and then you go
  4319. 2:45:15to logs. And this is absolutely going to
  4320. 2:45:17be an Ignition developer's best friend,
  4321. 2:45:19especially if you're trying to set up
  4322. 2:45:21Python scripting and you're getting
  4323. 2:45:23weird errors and you're not sure how to
  4324. 2:45:25track it down,
  4325. 2:45:26you're going to want to rely on logging
  4326. 2:45:29a lot of information. Okay? So, I think
  4327. 2:45:31I kind of alluded to already
  4328. 2:45:34not allude to I directly said it. We're
  4329. 2:45:36going to move this. This is not
  4330. 2:45:38necessarily the best spot to have this
  4331. 2:45:41kind of scripting live. It is absolutely
  4332. 2:45:43acceptable and if you have smaller
  4333. 2:45:45applications or you're the sole
  4334. 2:45:46developer for a plant, put the code
  4335. 2:45:48where you want to put the code. But, in
  4336. 2:45:50the instance of wanting to store the
  4337. 2:45:53code somewhere where it's maybe easier
  4338. 2:45:55to share, easier to immediately see all
  4339. 2:45:57of the scripts that are executing in a
  4340. 2:45:59project you want to keep it elsewhere.
  4341. 2:46:01Think now is a perfect time to take a
  4342. 2:46:03quick pause and talk to you about the
  4343. 2:46:05sponsor of today's video PCBWay. PCBWay
  4344. 2:46:08is a long-term supporter of Inductive
  4345. 2:46:10Automation Tech Channel and I love
  4346. 2:46:11working with them because their products
  4347. 2:46:13and services are all about empowering
  4348. 2:46:15makers. As their name suggests, the core
  4349. 2:46:17of their business is manufacturing PCBs
  4350. 2:46:20or printed circuit boards. This is such
  4351. 2:46:22a cool way for hobbyists and makers to
  4352. 2:46:24turn their electronic designs into super
  4353. 2:46:26high-quality and professional grade
  4354. 2:46:28circuit boards. Beyond that, they also
  4355. 2:46:30have the ability to support all your
  4356. 2:46:31prototyping needs with high-quality 3D
  4357. 2:46:34printing and metal fabrication as well.
  4358. 2:46:36Be sure to check them out at the
  4359. 2:46:37description below this video and thank
  4360. 2:46:39you so much to PCBWay for sponsoring the
  4361. 2:46:41video. So, what I'm going to do, I'm not
  4362. 2:46:43going to delete this right now cuz you
  4363. 2:46:45never know, maybe you want to turn it
  4364. 2:46:46back on. I'm just going to uncheck this
  4365. 2:46:49enabled box. And so, now what you'll see
  4366. 2:46:51if I update my array, okay? So, let's
  4367. 2:46:55just add
  4368. 2:46:5630 and 40 back in here. 30 40
  4369. 2:47:01Okay? And I hit apply and I hit apply
  4370. 2:47:02and I hit okay and I hit save, you'll
  4371. 2:47:04see the array elements do not update and
  4372. 2:47:07that's because we disabled the script
  4373. 2:47:08that is on there. So, if you go to the
  4374. 2:47:10scripting, you go to value change, it is
  4375. 2:47:11not enabled, okay? So, let's look at the
  4376. 2:47:15better place to put it and I already
  4377. 2:47:17have it highlighted actually. But, in
  4378. 2:47:19the project browser in the top left, if
  4379. 2:47:21you go to scripting, there is gateway
  4380. 2:47:23events as well as project library. Let's
  4381. 2:47:26start with gateway events, okay?
  4382. 2:47:28And you can see these ones over on the
  4383. 2:47:30left, they all have utility. We'll
  4384. 2:47:32probably get to a tutorial on almost all
  4385. 2:47:34of them eventually. But, for now let's
  4386. 2:47:36click on tag change, okay? And what
  4387. 2:47:38we're going to do is we're going to call
  4388. 2:47:40this array breakout. All right? That's
  4389. 2:47:43what we'll call this script. And change
  4390. 2:47:46triggers, I almost always turn off
  4391. 2:47:49quality and timestamp because I want to
  4392. 2:47:51trigger on the value changing of this
  4393. 2:47:53tag. So, I'm going to grab the path of
  4394. 2:47:56this input array tag by right clicking
  4395. 2:47:58and going down to copy path. And then in
  4396. 2:48:01my gateway events here, I'm just going
  4397. 2:48:03to drop the tag path here. Now, you
  4398. 2:48:05don't need to copy path like that, you
  4399. 2:48:07can just hit your tag and if you have a
  4400. 2:48:09small system, you're probably able to
  4401. 2:48:12just go right to it and find it pretty
  4402. 2:48:15quick just like that. But, you can see
  4403. 2:48:16that's just the same way a second way of
  4404. 2:48:19getting the same data, okay? So, we have
  4405. 2:48:22the code in here and now we need to put
  4406. 2:48:24our script in here. So, I'm going to go
  4407. 2:48:27in here and copy the entire script,
  4408. 2:48:29okay? And then back to my gateway events
  4409. 2:48:32and I'm going to drop that code in. It
  4410. 2:48:34always does this funky indentation
  4411. 2:48:36stuff, but don't worry about it. It's
  4412. 2:48:38the exact same code. The only thing I'm
  4413. 2:48:40going to do is I'm going to change from
  4414. 2:48:42logger.info, I'm going to change it to
  4415. 2:48:44this came from a
  4416. 2:48:47gateway script, okay? So, a gateway
  4417. 2:48:50event script. Now, I'm going to hit
  4418. 2:48:52apply and I'm going to hit okay and I'm
  4419. 2:48:54going to hit save, which sends it live.
  4420. 2:48:56And you can see it updated immediately,
  4421. 2:48:58right? There's 10 20 30 40. We'll go
  4422. 2:49:00back in, we'll add 50 just so you guys
  4423. 2:49:03can see I'm not crazy.
  4424. 2:49:05Um well, I'm crazy, but not that way.
  4425. 2:49:08Okay? So, we already have tag 50, which
  4426. 2:49:10is awesome. And if we go back to the la
  4427. 2:49:12la la la la logs, you'll see this came
  4428. 2:49:15from a gateway event script, okay? So,
  4429. 2:49:17we had those tag change scripts. Now, we
  4430. 2:49:19have our gateway event scripts. So, that
  4431. 2:49:21is a super useful
  4432. 2:49:24uh thing to know, a thing to store. And
  4433. 2:49:26then also useful to know
  4434. 2:49:28excuse me.
  4435. 2:49:30Tag value change scripts are obviously
  4436. 2:49:32living on the tag themselves. So, that's
  4437. 2:49:34on the tag provider in the tag browser.
  4438. 2:49:38This gateway event is going to be
  4439. 2:49:40executed at the gateway level, meaning
  4440. 2:49:42it's using gateway resources uh and is
  4441. 2:49:45not project specific. So, something that
  4442. 2:49:47we can do is we can make a project
  4443. 2:49:51library. And this is just another place
  4444. 2:49:53to store script. Um honestly, I'm not
  4445. 2:49:55here to tell you which one of these is
  4446. 2:49:57best and worst. Like, if you prefer
  4447. 2:50:00the code living on the tag that's firing
  4448. 2:50:02it, that's honestly fine. Um as you get
  4449. 2:50:05to larger systems and you maybe have
  4450. 2:50:07hundreds of tag change scripts, it might
  4451. 2:50:10be very useful for you to see all of
  4452. 2:50:12those in one spot. Um but as long as
  4453. 2:50:14you're documenting where everything
  4454. 2:50:16lives, it it's totally fine to just mix
  4455. 2:50:18and match, try a little bit of
  4456. 2:50:20everything.
  4457. 2:50:21Um but let's go ahead and copy this
  4458. 2:50:22script. And what I'm going to do is I'm
  4459. 2:50:24going to put it in a new location. And
  4460. 2:50:26so, I'm going to go into Now, I'm in
  4461. 2:50:28scripting and I am in project library.
  4462. 2:50:31And I'm going to create a new script and
  4463. 2:50:33I will call this array breakout, okay?
  4464. 2:50:36And in here, just like in a conventional
  4465. 2:50:39uh Python IDE, I'm going to create a
  4466. 2:50:41function. I'll call it run and I'll put
  4467. 2:50:44all of this code inside of it. But now,
  4468. 2:50:47I'm going to have in the logger, I'm
  4469. 2:50:49going to say this came from a project
  4470. 2:50:52stored script, okay? So, I'm going to
  4471. 2:50:55save this file, array breakout. Um and
  4472. 2:50:58first thing, easiest thing is if I go
  4473. 2:51:01back into gateway events and I
  4474. 2:51:04uh tags tags and I disable this one so
  4475. 2:51:07that it's not firing for now. First
  4476. 2:51:09thing you'll be able to see
  4477. 2:51:11is if I go in here and I add uh let's
  4478. 2:51:15say now that this is 60, okay?
  4479. 2:51:19Then uh you'll see the thing doesn't
  4480. 2:51:21update automatically, right? But if I
  4481. 2:51:23were to go back to the script console, I
  4482. 2:51:25actually don't know if this will work,
  4483. 2:51:27so let's just see. If I were to import
  4484. 2:51:30array breakout, which is the file that
  4485. 2:51:33those work in,
  4486. 2:51:34uh and let's say as AB, so I don't have
  4487. 2:51:36to type that. And now, I just do AB.run
  4488. 2:51:39like that. And if I hit execute on this,
  4489. 2:51:42execute. Okay, it actually worked. We
  4490. 2:51:45got 60.
  4491. 2:51:46Um and so, the script console is able to
  4492. 2:51:49take that command that we just stored in
  4493. 2:51:51a file and execute it. And I think if we
  4494. 2:51:54go to the logs, you can see that
  4495. 2:51:57actually that one
  4496. 2:51:59uh
  4497. 2:52:00didn't store. This came from a gateway
  4498. 2:52:02event script. Did it?
  4499. 2:52:05This came from a project. Yeah. Um which
  4500. 2:52:07is actually a feature of the script
  4501. 2:52:09console. If you're um
  4502. 2:52:11sort of new to scope in uh Ignition,
  4503. 2:52:15just know that script console is a local
  4504. 2:52:18thing and it's not hitting the gateway.
  4505. 2:52:20And so, when you are messing around in
  4506. 2:52:22here, you can't use the logger, but you
  4507. 2:52:25could use uh this interactive
  4508. 2:52:27interpreter on the right side. So, you
  4509. 2:52:29could swap out logger statements for
  4510. 2:52:31print statements and they would show up
  4511. 2:52:33on the right, but they would not appear
  4512. 2:52:35in your uh gateway logs, okay? But let's
  4513. 2:52:39go one step further, basically the final
  4514. 2:52:41step, and show how you might want to use
  4515. 2:52:43this. Rather than as this code gets
  4516. 2:52:46longer and longer and more convoluted,
  4517. 2:52:48rather than having all that code live
  4518. 2:52:50here, you could do this. You could call
  4519. 2:52:52the script that lives in the array
  4520. 2:52:54breakout folder and you could just tell
  4521. 2:52:57it to run when this tag value changes.
  4522. 2:53:00So, I'm going to enable that. I'm going
  4523. 2:53:02to say okay and say all right. And now,
  4524. 2:53:05I'm going to save everything and I'm
  4525. 2:53:06going to go into the array.
  4526. 2:53:08And I am going to add a bunch more tags.
  4527. 2:53:12And we'll say this is 63, 66, 70, 75,
  4528. 2:53:1880, okay? So, I add a bunch more tags. I
  4529. 2:53:21hit okay. And what you'll see is we get
  4530. 2:53:24all those tags. We get 63, 66, 70, 75,
  4531. 2:53:2780. Um and what just happened is this
  4532. 2:53:31root tag input array changed. We
  4533. 2:53:34triggered a gateway way event for tag
  4534. 2:53:36change script that then called a script
  4535. 2:53:39that we stored in array breakout and it
  4536. 2:53:42ran this file. Is that convoluted? You
  4537. 2:53:45bet. Was that the best way I could think
  4538. 2:53:47of showing you all the different places
  4539. 2:53:49and ways that you could write Python?
  4540. 2:53:51Also, yes. Okay? And so, if you look at
  4541. 2:53:54uh the logs after a test like that,
  4542. 2:53:57you'll see now we have this came from a
  4543. 2:53:59project stored script. This came from a
  4544. 2:54:01project stored script. Um
  4545. 2:54:04because it did. Because now, this one is
  4546. 2:54:07firing. And if you'd like to see
  4547. 2:54:09evidence that both the gateway event and
  4548. 2:54:13uh the stored script are firing, we can
  4549. 2:54:15do this. We can say both a logger for
  4550. 2:54:18this came from a
  4551. 2:54:20gateway script and uh then underneath
  4552. 2:54:23it, this came from a stored script. And
  4553. 2:54:25if we save it and delete one of our
  4554. 2:54:27tags,
  4555. 2:54:29delete, okay, apply, okay, and hit save.
  4556. 2:54:33All right, so 80 drops off, but more
  4557. 2:54:35importantly, both of those just ran. And
  4558. 2:54:37so, if you look at the script, you'll
  4559. 2:54:39see this came from a project stored
  4560. 2:54:41script fires this way came from a
  4561. 2:54:44gateway script, this came from a project
  4562. 2:54:46stored script, this came from a gateway
  4563. 2:54:48script, okay?
  4564. 2:54:50So, you see them firing one after
  4565. 2:54:51another
  4566. 2:54:52um because also every time you save in a
  4567. 2:54:55project, your tag change uh gateway
  4568. 2:54:58events are going to fire to cover their
  4569. 2:55:00butts because they don't necessarily
  4570. 2:55:02know if the tag changed during that
  4571. 2:55:04saving instance. So, just know that as
  4572. 2:55:07well. If you're seeing weird behavior in
  4573. 2:55:08logs of like multiple multiple
  4574. 2:55:10instances, odds are you're doing control
  4575. 2:55:13S a whole lot, which I do fairly
  4576. 2:55:15frequently.
  4577. 2:55:16Um but okay. Anyways, uh things we
  4578. 2:55:19covered, super speed, we covered how to
  4579. 2:55:22use the script console for basic code uh
  4580. 2:55:25um compilation. We covered how to put
  4581. 2:55:28put scripting directly on a tag with
  4582. 2:55:30value changed. Uh we even covered how to
  4583. 2:55:33generate and delete tags a little bit uh
  4584. 2:55:36using Ignition scripting in Python,
  4585. 2:55:38which is useful. And then, we covered
  4586. 2:55:39gateway tag change events as well as
  4587. 2:55:42storing scripting. So, this is a lot to
  4588. 2:55:44cram into one tutorial. I know this was
  4589. 2:55:46pretty dense and I know I moved pretty
  4590. 2:55:48fast, but there was a lot to cover, so I
  4591. 2:55:50hope you found it useful. I hope you've
  4592. 2:55:52been enjoying the Ignition tutorial
  4593. 2:55:54series. Uh if so, please leave a like on
  4594. 2:55:57the video, subscribe to the channel. Let
  4595. 2:55:59me know in the comments below what you'd
  4596. 2:56:00like to see next on the channel. Don't
  4597. 2:56:02forget to check out the uh sponsor link
  4598. 2:56:05in the description of the video as well.
  4599. 2:56:07And if you would like to consider
  4600. 2:56:08becoming a super supporter of the
  4601. 2:56:10channel, my Patreon link is down there
  4602. 2:56:12below. Uh I appreciate the heck out of
  4603. 2:56:14everyone who likes and supports
  4604. 2:56:16LeMasterTech YouTube in any way.
  4605. 2:56:18Um so, as always, thank you for
  4606. 2:56:20watching. We'll see you next time.
  4607. 2:56:21Thanks. Bye.
  4608. 2:56:28Hello and welcome back to LeMasterTech.
  4609. 2:56:30And in today's video, I'm going to walk
  4610. 2:56:32you through animations in the SCADA
  4611. 2:56:34software called Ignition. We're going to
  4612. 2:56:36cover several types of animations you
  4613. 2:56:38can do, including Boolean, color, and
  4614. 2:56:41visibility transforms, text transforms
  4615. 2:56:44including color, text strings, and
  4616. 2:56:46integers, and then enumeration as well,
  4617. 2:56:48where you can take integer values and do
  4618. 2:56:50text-based transforms with it. So, this
  4619. 2:56:53is many of the most common types of
  4620. 2:56:54animations you'd need to do in Ignition.
  4621. 2:56:57And then more importantly, it'll show
  4622. 2:56:58you how tag bindings and animations work
  4623. 2:57:01so that you can go and build whatever
  4624. 2:57:03sorts of animations you need into your
  4625. 2:57:05projects. All right, so we're going to
  4626. 2:57:07try to cover a lot of content in this
  4627. 2:57:08video. So, let's dive right into it. To
  4628. 2:57:11start, let's go ahead and make a new tag
  4629. 2:57:15called a memory tag because I don't have
  4630. 2:57:17a PLC hooked up right now. I'm doing
  4631. 2:57:19that just to show you that this doesn't
  4632. 2:57:21really matter what platform you're
  4633. 2:57:23using. As soon as you get a tag to
  4634. 2:57:26Ignition, they're all kind of the same.
  4635. 2:57:28So, I'm just going to make a Boolean tag
  4636. 2:57:30and call it color bool to start, all
  4637. 2:57:32right? Now, I'm going to go to the
  4638. 2:57:34perspective components window and I'm
  4639. 2:57:36going to grab an icon.
  4640. 2:57:38Um this is just something Ignition
  4641. 2:57:40includes. They have a number of icons uh
  4642. 2:57:43that you can kind of select and play
  4643. 2:57:45around with. And actually, I'm going to
  4644. 2:57:47make two. One to act sort of as a button
  4645. 2:57:50for us. So, I'm going to go to the path
  4646. 2:57:51and I'm going to type in button. And I'm
  4647. 2:57:53just going to grab this one that looks
  4648. 2:57:55like a button. And then, the second one
  4649. 2:57:56is what we're actually going to animate,
  4650. 2:57:58okay? So, I'm going to write a very
  4651. 2:58:00basic script here with you um that is
  4652. 2:58:03going to uh I'm going to go to the icon
  4653. 2:58:06that's our button. I'm going to go to
  4654. 2:58:08configure events, mouse events, on
  4655. 2:58:10click, plus, add a script. And what I'm
  4656. 2:58:13going to do is I'm going to read the
  4657. 2:58:15tag, system.tag.readBlocking.
  4658. 2:58:21And then, I'm going to read the value
  4659. 2:58:23of that tag. dot value, there we go. And
  4660. 2:58:27then, if my value is high, I'm going to
  4661. 2:58:29basically write uh to that tag. So,
  4662. 2:58:32system.tag.
  4663. 2:58:36write blocking. There we go. And then
  4664. 2:58:39the same tag path
  4665. 2:58:41Control C.
  4666. 2:58:42And what we're checking here is if it's
  4667. 2:58:44high, we want to write false. And then
  4668. 2:58:48else would be it's low. So, in that
  4669. 2:58:50case, we will write true.
  4670. 2:58:53All right. And honestly, that tag path
  4671. 2:58:56had to be typed out three times. Should
  4672. 2:58:58probably put that in a variable. But,
  4673. 2:59:00we're not here to optimize my scripting
  4674. 2:59:02abilities. We're here to make sure that
  4675. 2:59:04this tag
  4676. 2:59:05[Music]
  4677. 2:59:06works for toggling. So, I'm going to go
  4678. 2:59:08ahead and quickly just go into this run
  4679. 2:59:11mode and I can see that's toggling in
  4680. 2:59:13the lower window.
  4681. 2:59:14All right. Now, let's talk about the
  4682. 2:59:16actual animation that is the subject of
  4683. 2:59:18the video. I'm going to copy that tag
  4684. 2:59:21path preemptively cuz I know we want it.
  4685. 2:59:23And I'm going to go to the perspective
  4686. 2:59:26property editor window. By default, it's
  4687. 2:59:29usually tabbed in the right when you
  4688. 2:59:30open up the designer.
  4689. 2:59:32But, if you go to views and panels and
  4690. 2:59:35toolbars, you have a lot of
  4691. 2:59:36configurability over that. And you just
  4692. 2:59:38need the perspective property editor
  4693. 2:59:41toolbar active. Okay?
  4694. 2:59:43So, in props, you can see color is
  4695. 2:59:46already there. But, if it wasn't there,
  4696. 2:59:48you're always able to add a property.
  4697. 2:59:50And then you can add in color if you
  4698. 2:59:53need to. In this case, it won't let me
  4699. 2:59:55because it would be a duplicate.
  4700. 2:59:58But, you should have color already if
  4701. 2:59:59you're using the icons. And then for
  4702. 3:00:01binding type, we're going to go to tag.
  4703. 3:00:03We're going to paste in that color
  4704. 3:00:05boolean. And now, if we were to do just
  4705. 3:00:07this right now, it's going to give us an
  4706. 3:00:09error because it can't convert true and
  4707. 3:00:13false to a different color. So, what we
  4708. 3:00:15need to do is hit this add transform
  4709. 3:00:17button. And we're going to do a map. And
  4710. 3:00:19it should open up this window for you.
  4711. 3:00:21And we're just going to hit two pluses.
  4712. 3:00:23The input type is going to be a value.
  4713. 3:00:25And specifically, it's going to either
  4714. 3:00:28read true or false. And you can see in
  4715. 3:00:30the bottom, it's also telling you what
  4716. 3:00:33the tag is currently reading, which is
  4717. 3:00:35nice. And then the output type we want,
  4718. 3:00:37you can see they have a number of
  4719. 3:00:39options. But, value and color are by far
  4720. 3:00:42the two most common ones. And so, when
  4721. 3:00:44it's true, let's go ahead and make it
  4722. 3:00:46green. And when it's false, let's make
  4723. 3:00:48it red. And then fallback would be like,
  4724. 3:00:50"Hey, we're having error." Like, this is
  4725. 3:00:52a boolean tag and we don't have true or
  4726. 3:00:54false. So, fallback will make this
  4727. 3:00:56yellow just in case there's an error.
  4728. 3:00:59Okay? And as soon as I hit apply, you
  4729. 3:01:00can see that it goes green. Now, if I
  4730. 3:01:03hit run and I click this button, you can
  4731. 3:01:05see it turns red. So, the button is
  4732. 3:01:07changing color bool between zero and
  4733. 3:01:09one. But, then the animation on the tag
  4734. 3:01:13is reading that back and determining
  4735. 3:01:15which color it should go to.
  4736. 3:01:17All right. So, color is one of the most
  4737. 3:01:20common animations you're going to want
  4738. 3:01:22to do if you're in a factory setting or
  4739. 3:01:24in a home setting. It's a really easy
  4740. 3:01:26way to quickly tell you the status of
  4741. 3:01:27something as either okay or not okay.
  4742. 3:01:31So, let's go ahead and delete color and
  4743. 3:01:33take a look at what I think is kind of
  4744. 3:01:35the next most common one,
  4745. 3:01:37which would be let's take that same tag
  4746. 3:01:39color boolean and we already have a
  4747. 3:01:41button set up for it. And let's take a
  4748. 3:01:43look at doing a visibility animation.
  4749. 3:01:45So, I'm going to use the I'm going to
  4750. 3:01:47use the same tag, which is color bool.
  4751. 3:01:50Copy path. I'm going to use the same
  4752. 3:01:52tag. But, what's nice is because
  4753. 3:01:54visibility is a true or false, you don't
  4754. 3:01:56actually need any expression or any
  4755. 3:01:59transform here if you want it to change
  4756. 3:02:01true and false with the tag. So, if I go
  4757. 3:02:04into run mode
  4758. 3:02:07and I toggle the bit, you can see that
  4759. 3:02:09second smiley face appearing and
  4760. 3:02:11disappearing on the boolean.
  4761. 3:02:14Again, I know I went through that one
  4762. 3:02:15pretty quick. But, down in meta, there's
  4763. 3:02:17this visible option. You can toggle it
  4764. 3:02:20true or false just from the designer.
  4765. 3:02:22But, if you want it to be tied to a tag,
  4766. 3:02:24you do it just like this.
  4767. 3:02:27Now, I know in the beginning I had like
  4768. 3:02:29a sun and a moon
  4769. 3:02:31toggling back and forth. So, it also
  4770. 3:02:33kind of makes it look like it's doing a
  4771. 3:02:36transform if you have two icons and that
  4772. 3:02:39their visibility toggles inversely of
  4773. 3:02:42each other. So, let's do that pretty
  4774. 3:02:43quick.
  4775. 3:02:44Um
  4776. 3:02:46I
  4777. 3:02:47don't want to spend too much of the
  4778. 3:02:48tutorial looking for the moon icon, but
  4779. 3:02:52I found it quick last time.
  4780. 3:02:54Typing in moon didn't work. So,
  4781. 3:02:56um
  4782. 3:02:58Yeah, there we go. There's one. Um so,
  4783. 3:03:00if I have these copies and I have them
  4784. 3:03:02both set to visible, then you do need a
  4785. 3:03:05you do need a transform to get you the
  4786. 3:03:08opposite. And the easiest one is just
  4787. 3:03:10add a script transform and return not
  4788. 3:03:13value. That way, the output is going to
  4789. 3:03:15be the opposite of whatever boolean
  4790. 3:03:17you're reading. So, if I hit apply now
  4791. 3:03:19and I save and I enter runtime, you can
  4792. 3:03:21see my sun and my moon are toggling as
  4793. 3:03:24the color here toggles. So, that's a
  4794. 3:03:26basic animation
  4795. 3:03:28for visibility and for color based on a
  4796. 3:03:31boolean tag. Now, let's go ahead and
  4797. 3:03:33take a look at two cool things, which is
  4798. 3:03:35dynamically changing color and text
  4799. 3:03:38based on a non-boolean condition. So, an
  4800. 3:03:40integer or a float.
  4801. 3:03:42Heck, a string if you really wanted to,
  4802. 3:03:44but I don't. So, memory tag. I'm going
  4803. 3:03:46to call this one
  4804. 3:03:48color integer. And then I'll start it
  4805. 3:03:51out as a zero and it'll be a memory tag.
  4806. 3:03:54Um now, I'm going to go back to
  4807. 3:03:55perspective components and I'm going to
  4808. 3:03:57grab a label for this one. Uh I'm going
  4809. 3:04:00to just drop in a label here in the
  4810. 3:04:03middle. And so that it's a little easier
  4811. 3:04:05to see on the tutorial
  4812. 3:04:08Whoop. Come on.
  4813. 3:04:10That was weird. Okay. So, it's a little
  4814. 3:04:12easier to see on the tutorial, I am
  4815. 3:04:14going to just preemptively make the font
  4816. 3:04:16size
  4817. 3:04:17uh
  4818. 3:04:18pretty big. And then we're actually
  4819. 3:04:20going to mess with the font size in a
  4820. 3:04:22second. But, I'll make it what's big?
  4821. 3:04:2432? Yeah, we'll start there.
  4822. 3:04:27Okay?
  4823. 3:04:28So, it is basically just what we already
  4824. 3:04:31saw at a very basic point. If I copy the
  4825. 3:04:33path of my integer and I go to text now,
  4826. 3:04:36the text property of a label, and I go
  4827. 3:04:38to tag for binding, and then I just drop
  4828. 3:04:41in the color integer, then I hit okay.
  4829. 3:04:43It is that value. And if I go into this
  4830. 3:04:45value and I write it to a 10 instead, it
  4831. 3:04:48immediately changes to a 10. So, that is
  4832. 3:04:51actually a basic style of animation.
  4833. 3:04:54It's animating the text. But, all you're
  4834. 3:04:57really doing is uh
  4835. 3:04:59you know, changing the text on a label.
  4836. 3:05:01You probably found that one out with
  4837. 3:05:02just forms. So, let's look at something
  4838. 3:05:05a little more interesting, which would
  4839. 3:05:06be like the color of the text changing
  4840. 3:05:10with that value as well. Right? So,
  4841. 3:05:13let's say we have the label and the
  4842. 3:05:15color and I don't know, we'll make it
  4843. 3:05:18red initially.
  4844. 3:05:19If we go into the same spot before that
  4845. 3:05:22we had that color animation and tag and
  4846. 3:05:25we drop in the same tag and we add a
  4847. 3:05:27transform and we go to map, uh now,
  4848. 3:05:30what's going to be kind of annoying is
  4849. 3:05:32if you go in here and you do value and
  4850. 3:05:35you just add a bunch and you make your
  4851. 3:05:36output color, what's annoying is if you
  4852. 3:05:39just do mapping value to color, then you
  4853. 3:05:42would have to go integer by integer or
  4854. 3:05:44value by value that that integer could
  4855. 3:05:46be and you have to choose what color you
  4856. 3:05:48want it to be. So, what's easier is this
  4857. 3:05:51numeric range option where we say,
  4858. 3:05:53"Okay, between zero and 50,
  4859. 3:05:57the level is good, let's say." So,
  4860. 3:06:00level's going to be green. Between 50
  4861. 3:06:03and 75, let's say we're talking about
  4862. 3:06:06percentages on on a tank. It's getting
  4863. 3:06:10too high. So, we maybe want to make it
  4864. 3:06:12yellow. And then between 75
  4865. 3:06:16and 100, we are at high level. So, we're
  4866. 3:06:19going to make it red to warn people. And
  4867. 3:06:22then the fallback will be like yeah,
  4868. 3:06:24fallback will be black
  4869. 3:06:26to basically say like, "Hey, we're
  4870. 3:06:28getting unexpected values here." Okay?
  4871. 3:06:30So, with this numeric range to color
  4872. 3:06:32mapping, I'm going to hit okay. And what
  4873. 3:06:34you can see is it's green right now
  4874. 3:06:36because we're at that zero to 50 range.
  4875. 3:06:38If I go to 60, it turns yellow, which is
  4876. 3:06:41actually not super easy to see because
  4877. 3:06:44the
  4878. 3:06:45background color is white. I spelled
  4879. 3:06:49background wrong.
  4880. 3:06:50Background color is white. But, if we
  4881. 3:06:52make it a
  4882. 3:06:54dark gray, I think all of these colors
  4883. 3:06:56will show up. So, 10, it's green, it's
  4884. 3:06:59healthy. Yellow,
  4885. 3:07:02it's it's you know, "Hey, you're getting
  4886. 3:07:04up there." And then 80, there's red. And
  4887. 3:07:06let's say this went to 105, it turns
  4888. 3:07:09black because the value is out of range.
  4889. 3:07:12So,
  4890. 3:07:13that's kind of a cool way to take a look
  4891. 3:07:15at doing
  4892. 3:07:16um
  4893. 3:07:17dynamic animation. So, I'm going to go
  4894. 3:07:19back. I had pre-written a gateway script
  4895. 3:07:21that was going to take that color
  4896. 3:07:23integer and just keep sending it up
  4897. 3:07:26until it hits 100 so that we can do some
  4898. 3:07:29testing and I don't have to like
  4899. 3:07:30manually
  4900. 3:07:32um I don't have to manually go in and
  4901. 3:07:34toggle
  4902. 3:07:35uh
  4903. 3:07:36Come on, Pete. Talking right at the same
  4904. 3:07:38time. So, I don't have to manually go in
  4905. 3:07:40and toggle that value. I can just
  4906. 3:07:44I can just automate it away. But, that
  4907. 3:07:46only works if you keep consistent naming
  4908. 3:07:50standards. So, I called it color tag
  4909. 3:07:52before. All right. So, with that script,
  4910. 3:07:54you can now see every 100 milliseconds I
  4911. 3:07:56have the gateway going through and
  4912. 3:07:58adding one to that value. It's just so
  4913. 3:08:00that we can kind of see our animation
  4914. 3:08:02working and I don't have to keep typing
  4915. 3:08:04in a value. And just before we get to
  4916. 3:08:06the last section, I think now is a great
  4917. 3:08:08time to tell you about the sponsor of
  4918. 3:08:10today's video, PCBWay. PCBWay is an
  4919. 3:08:12incredibly cool company that
  4920. 3:08:14manufactures printed circuit boards and
  4921. 3:08:16printed circuit board assemblies for
  4922. 3:08:17hobbyists and makers. On top of that,
  4923. 3:08:19they have high-quality 3D printing and
  4924. 3:08:21metal prototyping services. They have
  4925. 3:08:24super helpful and friendly staff,
  4926. 3:08:25including an engineering team that
  4927. 3:08:27reviews every order before sending it to
  4928. 3:08:29production, fair pricing, and great
  4929. 3:08:30turnaround times. So, thank you to
  4930. 3:08:32PCBWay for sponsoring the video. Be sure
  4931. 3:08:34to check them out in the link in the
  4932. 3:08:35description below. Now, back to the
  4933. 3:08:37tutorial. The next thing I want to do is
  4934. 3:08:39show, let's say you also wanted to
  4935. 3:08:41animate uh something else. Now, we have
  4936. 3:08:44two animations based on the same tag
  4937. 3:08:47already. So, if I wanted to go in and
  4938. 3:08:49also have the font size change based on
  4939. 3:08:51the same tag, um
  4940. 3:08:53one, that's a pretty enormous changing
  4941. 3:08:56value, and it starts pretty small. So,
  4942. 3:08:58let's also add a transform
  4943. 3:09:01um and a little script here to say
  4944. 3:09:05um return let's just return the value
  4945. 3:09:09divided by 2 + 10. So, it'll change a
  4946. 3:09:11little bit slower like this. Um
  4947. 3:09:15now, what I wanted to show you is you
  4948. 3:09:18can animate multiple properties by using
  4949. 3:09:20a custom property that you pass in once.
  4950. 3:09:22So, obviously, we now have three
  4951. 3:09:24animations based on this one color
  4952. 3:09:27integer tag. If I were to go into custom
  4953. 3:09:29and add a tag property and put in the
  4954. 3:09:32mapping of that tag, this gets way
  4955. 3:09:35easier because I can come into each of
  4956. 3:09:36these spots, and rather than this being
  4957. 3:09:40um
  4958. 3:09:41uh directly linked to a tag, whoops.
  4959. 3:09:45Uh you can go to indirect tag binding,
  4960. 3:09:47and you can give it the property of this
  4961. 3:09:50thing, and then custom parameters, and
  4962. 3:09:52then we called the tag this custom tag.
  4963. 3:09:55So,
  4964. 3:09:56you can go and do this for all three,
  4965. 3:09:58and you may be saying it doesn't
  4966. 3:10:00actually save you time cuz you have to
  4967. 3:10:02go back and uh do this part uh three
  4968. 3:10:05times, which is true, but what I'm going
  4969. 3:10:07to show next is this is what you really
  4970. 3:10:10want to do if there is any chance that
  4971. 3:10:12you're going to use this thing again for
  4972. 3:10:15similar animations for a different tag.
  4973. 3:10:18So, um what do I mean by that? Just give
  4974. 3:10:20me a second to finish tying all three of
  4975. 3:10:23these to
  4976. 3:10:24the tag indirect property.
  4977. 3:10:28Um
  4978. 3:10:29and let's hit okay and apply. Now,
  4979. 3:10:33that took just as long as manually tying
  4980. 3:10:36it uh in all three places, but let's say
  4981. 3:10:39I have a second one of the same object,
  4982. 3:10:41and I want to make sure that all of the
  4983. 3:10:44animations that it was doing for this
  4984. 3:10:46first integer, it does again for what
  4985. 3:10:49I'll call color integer whoop
  4986. 3:10:51color int two. Uh I'm going to call it
  4987. 3:10:55slow cuz I'm going to have it change
  4988. 3:10:56slower than the first one.
  4989. 3:10:59Alrighty. So, what I'm going to do then
  4990. 3:11:02is I'm going to say everywhere that I
  4991. 3:11:04was using color int for that first one,
  4992. 3:11:06I want to use color int slow for that
  4993. 3:11:08second one. And initially, cuz we don't
  4994. 3:11:10have the value changing, it's just
  4995. 3:11:12looking at 29. But if I go into gateway
  4996. 3:11:15events, and I make a same
  4997. 3:11:18I make another script color int
  4998. 3:11:21slow
  4999. 3:11:22color int slow, and this one runs once
  5000. 3:11:26per second rather than uh every 100
  5001. 3:11:29milliseconds. Okay, apply, okay. And
  5002. 3:11:32then we go back to our home screen. You
  5003. 3:11:34can see I have this on the right
  5004. 3:11:36changing much slower than the first one,
  5005. 3:11:38but the font size is updating, the color
  5006. 3:11:40is updating, and the text is updating
  5007. 3:11:43just by changing that custom tag
  5008. 3:11:44property. So, that's a cool little thing
  5009. 3:11:47to make it replicatable. Even with
  5010. 3:11:49buttons and things like this, if you're
  5011. 3:11:50going to generate a lot of toggle
  5012. 3:11:52buttons, you want to write that script
  5013. 3:11:55to look at custom tag parameters so that
  5014. 3:11:58all you have to do is pass in what tag
  5015. 3:12:00you're looking at, and all of the rest
  5016. 3:12:02of it is extrapolated away by using
  5017. 3:12:03those shared parameters. So, that's kind
  5018. 3:12:06of one step past an animation tutorial,
  5019. 3:12:09but I think we have the time to make
  5020. 3:12:11this useful.
  5021. 3:12:12So, let's go ahead and do one additional
  5022. 3:12:15thing, which is going to be transforming
  5023. 3:12:17text based on an integer. Uh and I think
  5024. 3:12:21this is super useful because it's kind
  5025. 3:12:23of the basis of like enumeration, which
  5026. 3:12:25is why I'm going to call it an enum tag.
  5027. 3:12:29And it's going to be an integer, and I'm
  5028. 3:12:30going to initially set it to zero. And
  5029. 3:12:33the thing about enumeration is it's
  5030. 3:12:35embedding detailed text status or some
  5031. 3:12:39meaningful thing in an integer value
  5032. 3:12:41because PLCs don't always want to store
  5033. 3:12:45long strings of text when they could
  5034. 3:12:49just store it as an integer. So, the
  5035. 3:12:51most common thing I'm thinking of is for
  5036. 3:12:53a sequence or a vessel like a tank in a
  5037. 3:12:55tank farm
  5038. 3:12:57is tank status would just tell you 0 1 2
  5039. 3:13:013 4 or 5, but to make that useful to an
  5040. 3:13:04operator, you would want to transform
  5041. 3:13:06that to say running, idle, starting,
  5042. 3:13:09stopped, whatever status the tank is in.
  5043. 3:13:12Um so, let's go ahead and go to
  5044. 3:13:13perspective components, and let's grab a
  5045. 3:13:15new label,
  5046. 3:13:17and I'll show you in a little more
  5047. 3:13:18detail what I'm talking about. I
  5048. 3:13:20accidentally made a second label, that's
  5049. 3:13:22okay.
  5050. 3:13:24I'm going to grab this enum tag, and I'm
  5051. 3:13:26going to uh have the tag
  5052. 3:13:29tied to the enumeration tag, and now I'm
  5053. 3:13:32going to add another transform just like
  5054. 3:13:34before. And we're going to take input
  5055. 3:13:36values and output values. You don't have
  5056. 3:13:40to change this to string or anything
  5057. 3:13:41like that. It'll know you want a string
  5058. 3:13:44by default. So, I'm going to say, let's
  5059. 3:13:46say 0 1 2 3 and 4 are our statuses that
  5060. 3:13:52we could get. And let's say zero means
  5061. 3:13:54idle for a tank, one means it's
  5062. 3:13:57starting, two means it's running, three
  5063. 3:14:02means it's
  5064. 3:14:04paused, and four means it is aborting or
  5065. 3:14:08stopping. Let's just say stopping.
  5066. 3:14:11Aborting always means like something's
  5067. 3:14:13wrong. Okay. Fallback will be error
  5068. 3:14:17uh error bad status, okay? That's what
  5069. 3:14:21it'll say.
  5070. 3:14:23Now, because the value's initially set
  5071. 3:14:25to zero, oh, let me make it a bigger
  5072. 3:14:27font size, too.
  5073. 3:14:29Font size 40, heck yeah. Um because it's
  5074. 3:14:32initially zero, uh it says idle.
  5075. 3:14:36Let's go ahead and make a new button,
  5076. 3:14:39and let's change the script on this one
  5077. 3:14:41to uh
  5078. 3:14:43I'm eating my earlier words. I should
  5079. 3:14:44have just made it look at a tag. Let's
  5080. 3:14:47look at the enumeration tag in this
  5081. 3:14:49script.
  5082. 3:14:51And let's say the tag path is equal to
  5083. 3:14:54this, and then let's read the tag here
  5084. 3:14:58in the beginning,
  5085. 3:15:00and then whoop
  5086. 3:15:01I caps lock. It is case sensitive. And
  5087. 3:15:04then we'll say if value is less than
  5088. 3:15:06four, let's just go ahead and
  5089. 3:15:10add one to the tag, which will be value
  5090. 3:15:14plus one, and then we'll say else, let's
  5091. 3:15:16write to the tag and have it be equal to
  5092. 3:15:20zero, okay? So, this is just giving me a
  5093. 3:15:23button that is going to let me increment
  5094. 3:15:26the status. So, there you go. It goes to
  5095. 3:15:28one, it says starting, two, it says
  5096. 3:15:30running, three, it says paused, four, it
  5097. 3:15:32says stopping, and then zero, it says
  5098. 3:15:35idle. And if I were to go in and
  5099. 3:15:37manually make it a five, you can see it
  5100. 3:15:38says error bad status. If you don't like
  5101. 3:15:41it on multiple lines like that, just
  5102. 3:15:42make your object a little wider. All
  5103. 3:15:44right? And then what's cool is you can
  5104. 3:15:46also transform these values, and then
  5105. 3:15:48you can add another transform if you
  5106. 3:15:50want. And so, you can give a little
  5107. 3:15:51clarity around what this is. Like if
  5108. 3:15:53this is tank status, you can say tank
  5109. 3:15:57status, and then the value, all in one
  5110. 3:16:00tag and one object, and you can say,
  5111. 3:16:03okay, the tank status is idle. Now, if
  5112. 3:16:06you have a bunch of text strings on a
  5113. 3:16:08screen, you're able to show a lot of
  5114. 3:16:10information just by adding a label to
  5115. 3:16:13this, and you could also go in that same
  5116. 3:16:16expression, and if it was, you know, a a
  5117. 3:16:19pressure reading, let's say, you could
  5118. 3:16:21then add units to the end. So, if it
  5119. 3:16:23wasn't tank status, if it was tank
  5120. 3:16:25pressure, you could all in one
  5121. 3:16:27expression, you could say tank pressure,
  5122. 3:16:30then the value, and then the units, all
  5123. 3:16:32in one string, and you would get this
  5124. 3:16:35object that is just one cohesive object.
  5125. 3:16:37You don't have to deal with formatting
  5126. 3:16:39like three different strings all in one.
  5127. 3:16:42Um and I actually think that that's
  5128. 3:16:44pretty darn cool and pretty darn uh
  5129. 3:16:46easy. So, obviously, the tank status uh
  5130. 3:16:49being PSI doesn't make much sense, so
  5131. 3:16:51I'll delete that PSI part cuz that's my
  5132. 3:16:54OCD acting up.
  5133. 3:16:57Apply, okay.
  5134. 3:16:58All right, but right there, we have
  5135. 3:16:59covered so many of the basic animations
  5136. 3:17:02that you can use in Ignition in a fairly
  5137. 3:17:04short period of time. If you have
  5138. 3:17:06specifics about how to do more advanced
  5139. 3:17:09uh animations, or if I missed an obvious
  5140. 3:17:11one, and you guys let me know about in
  5141. 3:17:13the comments below, I will make sure to
  5142. 3:17:15do a follow-up video uh to address the
  5143. 3:17:17most sought-after tutorials in Ignition
  5144. 3:17:21that people have. So, be sure to let me
  5145. 3:17:23know in the comments below what you want
  5146. 3:17:24to see more of. Thank you so much for
  5147. 3:17:26checking out the channel. I appreciate
  5148. 3:17:28your time. I hope this video was useful
  5149. 3:17:30for you. Please consider leaving a a
  5150. 3:17:32like on the video, subscribing to the
  5151. 3:17:33channel. It helps me out a ton. And if
  5152. 3:17:36you want to become a super supporter of
  5153. 3:17:37the channel, consider checking out my
  5154. 3:17:39Patreon link at uh the description of
  5155. 3:17:41this video as well. It helps me out so
  5156. 3:17:43much, and I could not have gotten the
  5157. 3:17:45channel to where it was without my
  5158. 3:17:46Patreon supporters. So, thank you all
  5159. 3:17:48for watching, and we'll see you next
  5160. 3:17:50time. Thanks. Bye.
  5161. 3:17:58Hello, and welcome back to The Master
  5162. 3:18:00Tech. In today's video, we're going to
  5163. 3:18:02continue our introduction to the basics
  5164. 3:18:04of controls and automation uh through
  5165. 3:18:07practical tutorials. Today, we are going
  5166. 3:18:09to take a look at tying a PLC into an
  5167. 3:18:12HMI service and building your first HMI,
  5168. 3:18:15or human-machine interface. Our specific
  5169. 3:18:18setup is going to be the Arduino Opta
  5170. 3:18:20PLC using the Arduino IDE, the PLC IDE,
  5171. 3:18:25and we're going to talk to Ignition for
  5172. 3:18:27Makers.
  5173. 3:18:28Um so, we've previously done a setup
  5174. 3:18:30video on how to get started with the
  5175. 3:18:32Opta PLC
  5176. 3:18:33um
  5177. 3:18:34as well as your first structured text
  5178. 3:18:36and ladder logic languages. We'll
  5179. 3:18:38continue building on those skills in
  5180. 3:18:40this video. And then, we've previously
  5181. 3:18:42done how to set up Ignition for Makers.
  5182. 3:18:45So, the basics, if you want to start
  5183. 3:18:47from the same point that I'm starting
  5184. 3:18:48this tutorial from, would be have
  5185. 3:18:50Ignition for Makers. It can run on any
  5186. 3:18:52computer. It can run on your laptop. Um
  5187. 3:18:55Ignition for Makers and the Arduino PLC
  5188. 3:18:58and PLC IDE hooked up. And we'll be in
  5189. 3:19:01the exact same spots when we start this
  5190. 3:19:03video. So, today we're going to look at
  5191. 3:19:06setting the IP address of the Arduino
  5192. 3:19:08Opta PLC, setting up variables to talk
  5193. 3:19:11over Modbus TCP, tying a Modbus TCP
  5194. 3:19:14device into Ignition,
  5195. 3:19:17adding tags from that device, and
  5196. 3:19:20building an HMI or a human machine
  5197. 3:19:22interface, a graphical screen that looks
  5198. 3:19:25at the PLC. You don't need any project
  5199. 3:19:28built in either of these already. So,
  5200. 3:19:30what we'll be starting from is an
  5201. 3:19:32Ignition project that has no HMI. So,
  5202. 3:19:35we'll build a brand new project
  5203. 3:19:36together. And an Arduino PLC that has
  5204. 3:19:39nothing running on it other than the
  5205. 3:19:40base code that is on there when uh you
  5206. 3:19:43load a new project on there. So, I have
  5207. 3:19:45this count uh equals count plus one,
  5208. 3:19:48which if we watch it live, you can see
  5209. 3:19:50that is the only thing running on the
  5210. 3:19:51PLC is the default main code. So,
  5211. 3:19:54without any further ado, without me
  5212. 3:19:56explaining to you where we're starting
  5213. 3:19:57and what we're doing, let's just get
  5214. 3:19:59into some of the basics together. So, up
  5215. 3:20:02to this point, we've seen a little
  5216. 3:20:03structured text. We've seen a little
  5217. 3:20:05ladder diagram. Um
  5218. 3:20:07but we haven't tied the PLC into
  5219. 3:20:09anything. So, what we want to do is we
  5220. 3:20:12want to uh give this Arduino Opta PLC an
  5221. 3:20:17IP address because Modbus TCP uses uh
  5222. 3:20:21RJ45 connection. It uses an Ethernet
  5223. 3:20:23connection uh to talk and send data over
  5224. 3:20:26Modbus. And what's interesting is if you
  5225. 3:20:29go to the resources tab of your Opta
  5226. 3:20:31project, and then you go to sketch,
  5227. 3:20:33there will already be a commented out
  5228. 3:20:36section for configure IP address, which
  5229. 3:20:38is really nice, super useful.
  5230. 3:20:41Um
  5231. 3:20:42So, all we're going to do actually is
  5232. 3:20:43remove the comments. And this is
  5233. 3:20:46actually just giving us what we need for
  5234. 3:20:47it to talk over the network. The only
  5235. 3:20:49difference is we don't want to keep this
  5236. 3:20:51IP address. 192168.1's
  5237. 3:20:54kind of fine for home use, but usually
  5238. 3:20:57it and if you're in any kind of
  5239. 3:20:59industrial setting, they'll have a a
  5240. 3:21:01different block of IPs they want you to
  5241. 3:21:03adhere to. Super easy to adjust that.
  5242. 3:21:06You just type in what you want the IP to
  5243. 3:21:08be here. So, I'll use 42069169.
  5244. 3:21:11That's nice and secure. And then uh in
  5245. 3:21:14the gateway, I'll say 42
  5246. 3:21:17069.1.
  5247. 3:21:20That would be pretty normal
  5248. 3:21:22um for a gateway on any sort of like
  5249. 3:21:24corporate network to be the same first
  5250. 3:21:27three blocks as your as your uh device
  5251. 3:21:30IP, but then dot one for the gateway.
  5252. 3:21:32So, that's all we're going to do uh to
  5253. 3:21:34set the IP address on on the machine,
  5254. 3:21:37and that's really simple. We don't have
  5255. 3:21:39to do anything additional beyond that.
  5256. 3:21:41Um but what we do want to do so that
  5257. 3:21:43this actually does something when we tie
  5258. 3:21:45it into Ignition is we want to come into
  5259. 3:21:47parameters, and we want to just add a
  5260. 3:21:49few variables here that we'll actually
  5261. 3:21:52be able to monitor from Ignition. So, if
  5262. 3:21:54you go to parameters, um this is going
  5263. 3:21:56to be your Modbus addresses. So, if we
  5264. 3:21:58just add four things here real quick,
  5265. 3:22:01um we could add let's say we want to add
  5266. 3:22:04some tags for monitoring the
  5267. 3:22:07user push button. So, if you remember
  5268. 3:22:09the Arduino Opta PLC from previous
  5269. 3:22:11videos, we have a push button on the
  5270. 3:22:14front, and then we have some LEDs as
  5271. 3:22:16well. We have the uh red light. We'll
  5272. 3:22:18just call it red. We have the blue
  5273. 3:22:20light, and we have the green light. And
  5274. 3:22:22it's important to note that we are not
  5275. 3:22:24tying these currently to the red light,
  5276. 3:22:26blue light, green light, or user push
  5277. 3:22:28button. We're creating new variables,
  5278. 3:22:31and we want to change them all to
  5279. 3:22:32booleans.
  5280. 3:22:34But what we're doing is we're assigning
  5281. 3:22:35those variables to Modbus addresses
  5282. 3:22:38where they'll actually populate when
  5283. 3:22:40something that can read data over Modbus
  5284. 3:22:42TCP connects to these addresses. So,
  5285. 3:22:45this addressing is important when we get
  5286. 3:22:47to the Ignition piece.
  5287. 3:22:49And we'll take a look at it. But right
  5288. 3:22:51now, they're not going to do anything
  5289. 3:22:52cuz we haven't tied them to anything
  5290. 3:22:54yet. So, let's take user push button,
  5291. 3:22:56red, blue, and green, and let's tie them
  5292. 3:22:58to the actual values that uh they need
  5293. 3:23:01to be tied to. And to do that, we also
  5294. 3:23:03want to come to uh LED outputs. And here
  5295. 3:23:06we have LR. Uh and so, we'll call that
  5296. 3:23:10LR, LG, and LB. And if you've been
  5297. 3:23:13following along with the tutorial
  5298. 3:23:14series, you know why we're doing this
  5299. 3:23:16piece. Um and if you aren't following
  5300. 3:23:19along with the tutorial series, maybe
  5301. 3:23:21consider doing that. Um but basically,
  5302. 3:23:24we are assigning the actual red, green,
  5303. 3:23:26and blue lights on the front of the uh
  5304. 3:23:29Arduino Opta, as well as the user push
  5305. 3:23:32button, to variables that we can use in
  5306. 3:23:34our main uh PLC program now.
  5307. 3:23:37So, if in here, we just come in and we
  5308. 3:23:39say like first thing we want to do is
  5309. 3:23:42set the red light to be equal to true,
  5310. 3:23:44the green light to be equal to false,
  5311. 3:23:48and then the blue light to be equal to
  5312. 3:23:51the state of the user push button. So,
  5313. 3:23:53the blue light will change as we press
  5314. 3:23:56and release the user push button. Uh
  5315. 3:23:58then that would give us sort of those
  5316. 3:24:01four variables populated. And then, what
  5317. 3:24:03we need to come down here and do is we
  5318. 3:24:05need to say blue should be equal to L
  5319. 3:24:08LB. Whoop.
  5320. 3:24:11So, now we're taking our Modbus
  5321. 3:24:13variables, and we're setting them equal
  5322. 3:24:15to the status
  5323. 3:24:17of the variables we're controlling in
  5324. 3:24:18the program. So, the first lines were to
  5325. 3:24:21actually set the state of our outputs.
  5326. 3:24:23Whoop. I'm trying to talk and type, and
  5327. 3:24:25that never goes well.
  5328. 3:24:28And then, user_pb
  5329. 3:24:31is equal to user.
  5330. 3:24:34So, to recap what we're doing here,
  5331. 3:24:35we're just telling the red light to be
  5332. 3:24:37true, the green light to be false, the
  5333. 3:24:39blue light to turn on and off with the
  5334. 3:24:41user push button, and then we're telling
  5335. 3:24:44the blue, red, green, and user push
  5336. 3:24:46button Modbus variables that they should
  5337. 3:24:48be equal to these variables that we're
  5338. 3:24:51using in the code. So, if we uh download
  5339. 3:24:54this to the PLC, and we hit yes and
  5340. 3:24:57compile,
  5341. 3:24:58it should compile without error. I don't
  5342. 3:25:00always write perfect code, but I'm not
  5343. 3:25:02that bad at it.
  5344. 3:25:05It'll want us to restart, and that's
  5345. 3:25:07okay. And then, we'll initialize, and
  5346. 3:25:09that's okay.
  5347. 3:25:11Okay, so it looks like it completed.
  5348. 3:25:14If we connect to the PLC,
  5349. 3:25:21we can also enter this cool mode that I
  5350. 3:25:23don't think I explicitly called out
  5351. 3:25:24before called live debug mode. Um and
  5352. 3:25:27this actually lets us see the value of
  5353. 3:25:30all of those variables. And what's cool
  5354. 3:25:32is my PLC, which is on some DIN rail and
  5355. 3:25:35connected to a power supply, so it's a
  5356. 3:25:37little harder to show on camera than
  5357. 3:25:40before. Um but what's cool is you can
  5358. 3:25:43see the red light is on, the green light
  5359. 3:25:45is off, and if I push the push button,
  5360. 3:25:47the blue light turns on uh and off with
  5361. 3:25:50the push button. So, that's cool. Um
  5362. 3:25:52that means that the PLC program took,
  5363. 3:25:55and we should be all set now to actually
  5364. 3:25:58tie it into Ignition.
  5365. 3:26:02Okay, so let's go ahead now. We have an
  5366. 3:26:04IP address set on this. We have a few
  5367. 3:26:06variables that we can address here in
  5368. 3:26:08our Modbus addresses. So, let's jump
  5369. 3:26:10over to the Ignition gateway. So, you go
  5370. 3:26:13to your
  5371. 3:26:15web page.
  5372. 3:26:17I have a lot of security on mine, very
  5373. 3:26:19secure.
  5374. 3:26:21All right. So, for a Modbus device, it's
  5375. 3:26:23a little different than adding most like
  5376. 3:26:25um tier one PLC manufacturers. Most
  5377. 3:26:29Allen-Bradley, Siemens, Beckhoff
  5378. 3:26:31devices, like major PLC manufacturers
  5379. 3:26:34that you'd talk to, you may go to OPC
  5380. 3:26:36connections and create a new OPC
  5381. 3:26:38connection. But if you have a um
  5382. 3:26:42device using a slightly older or
  5383. 3:26:43slightly less common communication
  5384. 3:26:45protocol, a lot of that times you're
  5385. 3:26:47just going to go to config, and then
  5386. 3:26:49you're going to go to device connections
  5387. 3:26:51instead.
  5388. 3:26:52Uh and for us, we'll create a new
  5389. 3:26:54device. You can see a lot of their
  5390. 3:26:56default browser
  5391. 3:26:57um default uh data types that they have
  5392. 3:27:00in here. And we are just looking for
  5393. 3:27:02Modbus TCP, okay?
  5394. 3:27:04And it's cool. It just needs a name, and
  5395. 3:27:07then a description. It can be first Opta
  5396. 3:27:11PLC to Ignition for description. That
  5397. 3:27:15part's optional. And then here, you can
  5398. 3:27:17enter your IP address. That's all you
  5399. 3:27:19need to enter. And then, port 502 is by
  5400. 3:27:22default. You can leave that be, and that
  5401. 3:27:23should work. And just go ahead and
  5402. 3:27:26create new device. You don't have to
  5403. 3:27:27look at any of the advanced options or
  5404. 3:27:29anything like that. Uh if you hit create
  5405. 3:27:31device, and it says connected, you're
  5406. 3:27:34money. If it says failure to connect, it
  5407. 3:27:36may give you a reason why here. It may
  5408. 3:27:38give you information. Um you can try to
  5409. 3:27:41open the command window, and you can try
  5410. 3:27:43to just ping uh you can try to just ping
  5411. 3:27:47your IP address.
  5412. 3:27:49Um and you should be able to get a reply
  5413. 3:27:53from it. If you haven't, I didn't
  5414. 3:27:54explicitly call this out, make sure your
  5415. 3:27:56network adapter is on the same uh
  5416. 3:27:59subnet. So, make sure your laptop that
  5417. 3:28:02is plugged into your Arduino, or
  5418. 3:28:04whatever computer is plugged into your
  5419. 3:28:06PLC, make sure that Ethernet port is on
  5420. 3:28:09the same 420.69
  5421. 3:28:11or whatever you're using. Make sure it's
  5422. 3:28:13on the same subnet cuz Ignition can't
  5423. 3:28:15see devices on different subnets unless
  5424. 3:28:18you open them up and configure your
  5425. 3:28:19network that way.
  5426. 3:28:21Uh the industrial networking side of
  5427. 3:28:23controls and automation might be the
  5428. 3:28:25least fun part of the job.
  5429. 3:28:27But important thing while we're here on
  5430. 3:28:30the device, it says connected and that's
  5431. 3:28:31awesome. But if we were to like for
  5432. 3:28:34example use the OPC quick client um
  5433. 3:28:37to try to browse
  5434. 3:28:39uh the Opta for tags, we have basically
  5435. 3:28:42nothing. We have diagnostics which is
  5436. 3:28:44nice and it's proof that the device
  5437. 3:28:46connected, but we have no useful data.
  5438. 3:28:48We can't find those four tags that we
  5439. 3:28:50added because they don't exist yet
  5440. 3:28:52because after you add a Modbus device
  5441. 3:28:55you have to hit more and you have to go
  5442. 3:28:57to addresses and then uh you need to add
  5443. 3:29:01a row of uh the tags that you want to
  5444. 3:29:03read from. So if for us specifically
  5445. 3:29:08Let me find my notes. Good. We want to
  5446. 3:29:10go add row
  5447. 3:29:12and then if we look back at the Arduino
  5448. 3:29:14PLC, we started at 16384
  5449. 3:29:18which means back in Ignition
  5450. 3:29:23minimize this.
  5451. 3:29:24We can go to prefix and here's where you
  5452. 3:29:27just call it something you want to
  5453. 3:29:29reference this. So we'll call we'll just
  5454. 3:29:30call it um
  5455. 3:29:33Opta tags is fine. Uh we'll start from
  5456. 3:29:36one and we'll go to four cuz we only
  5457. 3:29:38have four tags and then you give it a
  5458. 3:29:40unit ID. Um this part doesn't matter so
  5459. 3:29:44much. Uh I've used 255 multiple times.
  5460. 3:29:48Um it it really doesn't matter. You can
  5461. 3:29:50put any unit ID number you want here. Uh
  5462. 3:29:53you just need to remember what that is
  5463. 3:29:55when you're looking at the tags. This is
  5464. 3:29:56the part that matters. 16384 is where it
  5465. 3:29:59starts. So now it knows to grab 16384
  5466. 3:30:03and then go four uh bytes or words or
  5467. 3:30:06addresses registers is what they're
  5468. 3:30:08called um from the first 16 384. So if
  5469. 3:30:13we hit save, uh disconnected should turn
  5470. 3:30:16to connected pretty quick. And now the
  5471. 3:30:18difference is if we go to OPC quick
  5472. 3:30:21client
  5473. 3:30:22and we go to devices and the Opta and
  5474. 3:30:25now we have unit ID 255 which we just
  5475. 3:30:28added. Opta tags one through Opta tags
  5476. 3:30:30four. And now if I subscribe by hitting
  5477. 3:30:33this little S on all four of those, down
  5478. 3:30:36here in the bottom window it shows me
  5479. 3:30:37the value of all four of those tags.
  5480. 3:30:40It'll take a second to update cuz this
  5481. 3:30:41is not the fastest tool. This isn't like
  5482. 3:30:44scanning the tags live. But you can see
  5483. 3:30:46we have 0100.
  5484. 3:30:49Um if we were back in the Arduino PLC,
  5485. 3:30:51we know that correlates to the user push
  5486. 3:30:53button, the red light, the blue light,
  5487. 3:30:55and the green light. So if I were to go
  5488. 3:30:58ahead and hold down the user push button
  5489. 3:31:01you can see that zero the first tag and
  5490. 3:31:04the third tag both turn to one because
  5491. 3:31:06that's me pushing the user push button
  5492. 3:31:08and the blue light turning on. So that's
  5493. 3:31:10cool. Now we have tags that live in the
  5494. 3:31:13PLC that are reading through Ignition.
  5495. 3:31:15We haven't built an HMI yet, but we've
  5496. 3:31:18verified that we can get tags
  5497. 3:31:20uh into Ignition. So that's half the
  5498. 3:31:22battle.
  5499. 3:31:24It's actually over half the battle. So
  5500. 3:31:26let's go to the designer launcher now
  5501. 3:31:28which is for Ignition. That's where you
  5502. 3:31:30you know build your visualization.
  5503. 3:31:33And let's go ahead to our Ignition
  5504. 3:31:36session. Let's open the designer and
  5505. 3:31:38we're going to make a new project
  5506. 3:31:40together so that we can do every step of
  5507. 3:31:42this together. Username will be
  5508. 3:31:45LaMasterTech cuz it's cool.
  5509. 3:31:48And then this is top secret and
  5510. 3:31:52definitely totally different. Okay, so
  5511. 3:31:55rather than open Arduino PLC tutorial,
  5512. 3:31:57but I promise you there's nothing in
  5513. 3:31:59there. We'll do Arduino Opta HMI.
  5514. 3:32:04Project must start with a letter or
  5515. 3:32:06underscore and contain only Okay, so
  5516. 3:32:08it'll be Arduino Opta HMI all like that
  5517. 3:32:10smooshed together. We'll copy that three
  5518. 3:32:12times. I don't need to inherit anything.
  5519. 3:32:14Leave all these as defaults. Let's just
  5520. 3:32:16create a project. Okay, so
  5521. 3:32:19should be pretty similar to the default
  5522. 3:32:21window you get uh when you open this up.
  5523. 3:32:23Let's just go to perspective
  5524. 3:32:26and uh let's go to views and let's right
  5525. 3:32:29click and hit new view and we will just
  5526. 3:32:31call this homepage. Okay? So it's going
  5527. 3:32:35to give you a default window. I'm going
  5528. 3:32:37to hit save real quick. Force of habit.
  5529. 3:32:39Like every 3 seconds I impulsively do
  5530. 3:32:42control S and hit save. You don't have
  5531. 3:32:45to. Perspective components. Let's go
  5532. 3:32:48over on the right. You should have a
  5533. 3:32:50little palette here. If you ever want to
  5534. 3:32:51play around with the tools and toolbars
  5535. 3:32:54in Ignition, feel free to. There's lots
  5536. 3:32:56of panels and toolbars.
  5537. 3:32:59Um
  5538. 3:32:59Inductive Automation is always adding
  5539. 3:33:01new features to this stuff. So it's not
  5540. 3:33:03a bad idea to comb through toolbars and
  5541. 3:33:06check for updates and whatnot. But I use
  5542. 3:33:09labels for a lot of stuff. So for this
  5543. 3:33:13label, let's just call this our Arduino
  5544. 3:33:15Opta PLC and let's take 3 seconds real
  5545. 3:33:19quick to uh make this label kind of look
  5546. 3:33:22like our PLC, okay? I'm going to go to
  5547. 3:33:24style over here on the right. I'm going
  5548. 3:33:26to hit plus and I'm going to go to
  5549. 3:33:28background color
  5550. 3:33:30and I'm going to make it dark gray.
  5551. 3:33:34And I guess actually before we get too
  5552. 3:33:36deep into this or while I'm building
  5553. 3:33:38this, uh we'll also go to style. We'll
  5554. 3:33:41go to color.
  5555. 3:33:42Just just color.
  5556. 3:33:45And we'll make the text color white. And
  5557. 3:33:48now I'm going to make it a little bit
  5558. 3:33:50bigger cuz I'm going to drop a bunch of
  5559. 3:33:52images and icons on it. And then I'm
  5560. 3:33:54going to align vertical top. So now I
  5561. 3:33:57have this rectangle. I'm going to drop
  5562. 3:33:59inputs and outputs and lights and
  5563. 3:34:01statuses on this HMI so that it looks
  5564. 3:34:03like the PLC. I'm going to hit save and
  5565. 3:34:06I'm going to pause for just a second
  5566. 3:34:07about what an HMI is meant to be and
  5567. 3:34:10what you want to put on an HMI.
  5568. 3:34:13So HMI human machine interface is what a
  5569. 3:34:16conventional software programmer would
  5570. 3:34:18refer to as their GUI or graphical user
  5571. 3:34:20interface. It is where the person
  5572. 3:34:23interacts with a virtual system so that
  5573. 3:34:26they can control the outputs and monitor
  5574. 3:34:28the inputs and interact with the
  5575. 3:34:30physical system from an easy to use and
  5576. 3:34:32easy under to understand screen.
  5577. 3:34:36So while it may look like I'm kind of
  5578. 3:34:37rapidly building a thing and it's sort
  5579. 3:34:40of like PowerPoint, the important extra
  5580. 3:34:43piece to know is that you're linking
  5581. 3:34:45tags and you're creating animations of
  5582. 3:34:48objects based on those tags and the
  5583. 3:34:51animations of those objects as well as
  5584. 3:34:53the output actions from clicking on
  5585. 3:34:55buttons and things like that should go
  5586. 3:34:57back and affect your PLC. So in addition
  5587. 3:35:01to reading things like the statuses of
  5588. 3:35:03lights and the status of your push
  5589. 3:35:05button, you can also click buttons from
  5590. 3:35:08an HMI that go and activate sequences in
  5591. 3:35:11the PLC. So for basic first step let's
  5592. 3:35:13tie those three
  5593. 3:35:15uh lights and the push button in so that
  5594. 3:35:17we can get an HMI just working and then
  5595. 3:35:20we'll start building sequences that
  5596. 3:35:21really show how powerful this is.
  5597. 3:35:24So let's go into icon and let's look for
  5598. 3:35:28uh a light.
  5599. 3:35:29Um I went into perspective components. I
  5600. 3:35:32know some of these tabs are a little
  5601. 3:35:34small and I'm going kind of fast. I went
  5602. 3:35:36to perspective components and I grabbed
  5603. 3:35:38an icon.
  5604. 3:35:39Um
  5605. 3:35:40There's symbol factories, drawings, you
  5606. 3:35:42can import SVGs. You can do a lot of
  5607. 3:35:45different ways in a lot of different
  5608. 3:35:47HMIs. There's also different syntax and
  5609. 3:35:49all these different icons and whatever.
  5610. 3:35:52But icons are kind of nice in Ignition
  5611. 3:35:54because they're all simple objects uh
  5612. 3:35:56just like circles or smiley faces or
  5613. 3:35:59light bulbs and they're pretty easy to
  5614. 3:36:01animate. So like if I want this to be
  5615. 3:36:03tied to the user push button, I can grab
  5616. 3:36:06it and I can say that I want the uh I
  5617. 3:36:09want to add a custom property that I'll
  5618. 3:36:12call tag and I'll put a tag path in here
  5619. 3:36:15in just a second cuz I haven't added my
  5620. 3:36:17Ignition tags yet. But what I want is
  5621. 3:36:20the color of this button to change with
  5622. 3:36:24the tag. And to do that, I'll go to
  5623. 3:36:26indirect which means I'm calling a
  5624. 3:36:27parameter on this tag. Again, I do
  5625. 3:36:31several Ignition tutorial uh
  5626. 3:36:33introductions videos on uh my channel.
  5627. 3:36:36It would take a lot of time to do all of
  5628. 3:36:39the basics of Ignition
  5629. 3:36:42and then a practical example together.
  5630. 3:36:45Um so to keep this tutorial moving, I'm
  5631. 3:36:47not going to deep dive every concept
  5632. 3:36:49that we're doing, but I will try to
  5633. 3:36:51still gear this at beginners. But
  5634. 3:36:53basically we're going to do an indirect
  5635. 3:36:55tag binding. Click the sort of hamburger
  5636. 3:36:57menu over on the right and go to view
  5637. 3:37:01uh root icon zero. Icon zero is actually
  5638. 3:37:05what we're working on. You can see that
  5639. 3:37:06highlight on the left. Um and then
  5640. 3:37:09custom per like custom parameters and
  5641. 3:37:12then tag. But what it really shakes out
  5642. 3:37:14to is the tag path is curly brackets
  5643. 3:37:17around tag and then the property is
  5644. 3:37:20this.custom.tag.
  5645. 3:37:22All I'm saying is I'm going to grab a
  5646. 3:37:24tag that I just want to pass in that
  5647. 3:37:26text field and I'm going to add one
  5648. 3:37:28transform which is just going to be map
  5649. 3:37:31the true false boolean of whether or not
  5650. 3:37:34the button is pressed to a color. So the
  5651. 3:37:36output will be the color and the input
  5652. 3:37:38will be the value. And what I'll do is
  5653. 3:37:41I'll say if it's true
  5654. 3:37:44then I want it to be it's a push button
  5655. 3:37:47so color
  5656. 3:37:49doesn't actually change. Let's say if
  5657. 3:37:51it's true, then I want it to be black.
  5658. 3:37:53If it's false, I want it to be light
  5659. 3:37:55gray. And if I don't have any reading, I
  5660. 3:37:58want it to be white. Okay? So it's white
  5661. 3:38:01right now because there's no tag
  5662. 3:38:03which is a great opportunity for us to
  5663. 3:38:05go and add our first tag. So I'm going
  5664. 3:38:08to hit the little plus in the tag
  5665. 3:38:10browser menu on the left side of
  5666. 3:38:11ignition and I'm going to say
  5667. 3:38:14Arduino tags and I'm going to make a new
  5668. 3:38:16folder. Now, I'm going to browse
  5669. 3:38:19devices. I'm going to expand out my
  5670. 3:38:21devices, go to the Opta, go to unit 255
  5671. 3:38:25and I'm going to add Opta tags 1 through
  5672. 3:38:274 to my Arduino tags folder.
  5673. 3:38:30Okay? And what you probably can see so
  5674. 3:38:33that a little arrow populates and all
  5675. 3:38:35these zeros and ones populate. Modbus by
  5676. 3:38:37default is going to call pretty much
  5677. 3:38:39everything a short when you add it, but
  5678. 3:38:42these are all booleans. They're lights
  5679. 3:38:44and push buttons. So, I can I can select
  5680. 3:38:46all the tags, right click, go to edit
  5681. 3:38:49tags and at the same time I can make
  5682. 3:38:51them all booleans. So, I can bulk edit
  5683. 3:38:55all of these tags. I could change them
  5684. 3:38:56all to arrays or strings or whatever at
  5685. 3:38:59same time. I can make them all booleans
  5686. 3:39:01and hit okay or apply and they'll all
  5687. 3:39:04update to be booleans.
  5688. 3:39:07Now, Opta tags 1 through 4 isn't that
  5689. 3:39:10useful and if we go back to our PLC, you
  5690. 3:39:12can see that it's user push button and
  5691. 3:39:15then red, blue, and green. So, what I'm
  5692. 3:39:17going to do is I'm going to rename these
  5693. 3:39:19user underscore push button as the name
  5694. 3:39:23and then
  5695. 3:39:26red
  5696. 3:39:29and then green
  5697. 3:39:35and then
  5698. 3:39:37blue.
  5699. 3:39:39Okay?
  5700. 3:39:41Cool. So, now close. Now, I can right
  5701. 3:39:44click on user push button and I can go
  5702. 3:39:46to copy path
  5703. 3:39:48and I can paste that path right here
  5704. 3:39:50control V into tag
  5705. 3:39:53and now you can see hopefully you can
  5706. 3:39:56see that went from gray to uh or that
  5707. 3:39:58went from white to gray because now the
  5708. 3:40:00tag exists. Now, I'm going to push the
  5709. 3:40:03button now on my HMI or on my PLC and
  5710. 3:40:07you can see it changes to black. That's
  5711. 3:40:09really cool.
  5712. 3:40:10Um I think it's really cool. If you
  5713. 3:40:12don't,
  5714. 3:40:13I don't care.
  5715. 3:40:15Uh now, let's get rid of this smiley
  5716. 3:40:16face cuz we're not using it and let's
  5717. 3:40:18add in some additional stuff. So, this
  5718. 3:40:20is the push button which is cool. Let's
  5719. 3:40:22go ahead and just add the three lights
  5720. 3:40:24as well. So, the blue light on the PLC
  5721. 3:40:27is kind of physically
  5722. 3:40:28uh right above it. So, let's say if that
  5723. 3:40:30one's true, we want it to be blue.
  5724. 3:40:34And then let's copy this over here
  5725. 3:40:39and the green and red lights are
  5726. 3:40:40actually in the same spot. So, I'll just
  5727. 3:40:43put them right next to each other so
  5728. 3:40:44that we can see two different lights.
  5729. 3:40:46And let's say that this one should be
  5730. 3:40:49green.
  5731. 3:40:50Okay? And this one should be red. So,
  5732. 3:40:55all I'm going to all I'm doing is I'm
  5733. 3:40:58changing the linking, the color
  5734. 3:41:00animation on these circles
  5735. 3:41:02uh to be different colors, but now I
  5736. 3:41:05have to go and I have to copy that tag
  5737. 3:41:07path. So, I copy the path for blue and
  5738. 3:41:10I'm going to replace user push button
  5739. 3:41:12with blue. But what's cool is the way we
  5740. 3:41:14did that custom tag pathing, this will
  5741. 3:41:17now update uh just when I click the blue
  5742. 3:41:21button. But what you'll see is right now
  5743. 3:41:23I've only updated the blue light and not
  5744. 3:41:26red or green. So, when I push the
  5745. 3:41:27button,
  5746. 3:41:30okay, all of them except blue updated.
  5747. 3:41:32So, my blue light tag is not actually
  5748. 3:41:35working. Let's check that out in the
  5749. 3:41:37code.
  5750. 3:41:39Little live debugging together.
  5751. 3:41:41Oh, yeah. I called the green light blue
  5752. 3:41:44and the blue light green.
  5753. 3:41:46That can get you in trouble if you're
  5754. 3:41:48not very careful about the order that
  5755. 3:41:50you do things in. So, we'll correct this
  5756. 3:41:52to blue. We'll move this to green.
  5757. 3:41:56So,
  5758. 3:41:58basically what happened there is because
  5759. 3:42:00the Opta tags got added as Opta tags 1
  5760. 3:42:03through 3, I misnamed uh I got blue and
  5761. 3:42:07green backwards. So,
  5762. 3:42:09now if we go in here and we correct this
  5763. 3:42:12tag path to be just tied to red.
  5764. 3:42:17Okay? And then this tag path to be just
  5765. 3:42:20tied
  5766. 3:42:21to green.
  5767. 3:42:25Okay?
  5768. 3:42:27We have
  5769. 3:42:29Now, if I push the button, you can see
  5770. 3:42:31the black button getting pushed in and
  5771. 3:42:33the blue light turning on at the same
  5772. 3:42:35time.
  5773. 3:42:36Uh if we were to go back in the Arduino
  5774. 3:42:38PLC, let's say and uh just change from
  5775. 3:42:41LR being equal to true to setting LR
  5776. 3:42:46equal to we got to go offline.
  5777. 3:42:50Let's say we want LR to be false now and
  5778. 3:42:54we want LG to be true and we want to
  5779. 3:42:56compile that and say yes and send the
  5780. 3:43:00new code.
  5781. 3:43:02Now, we should be able to go to
  5782. 3:43:06Yep, we can go to our PLC. I can push
  5783. 3:43:08the button in and I can have blue and
  5784. 3:43:11the blue light turns on and then the
  5785. 3:43:12green light turns on
  5786. 3:43:14uh and red never turns on uh because of
  5787. 3:43:17the code that we have running on it. So,
  5788. 3:43:19this is really cool. We have an Arduino
  5789. 3:43:21PLC connected to ignition and uh we
  5790. 3:43:24built our first HMI actually looking at
  5791. 3:43:27tags off of the ignition PLC. So, in the
  5792. 3:43:30next video, I think what we'll do is
  5793. 3:43:32we'll build multiple sequences in ladder
  5794. 3:43:35logic and structured text that actually
  5795. 3:43:37interact back and forth with the HMI.
  5796. 3:43:39So, we'll take a look at controlling
  5797. 3:43:41sequences uh from the HMI, reporting
  5798. 3:43:44statuses, doing enumeration,
  5799. 3:43:47and a lot more interesting SCADA HMI
  5800. 3:43:50plus PLC development together. So,
  5801. 3:43:53today's video was a great way to get you
  5802. 3:43:55connected,
  5803. 3:43:57get tags reading back and forth. If
  5804. 3:43:59you're a somewhat competent programmer,
  5805. 3:44:01this can be a fun spot to play around
  5806. 3:44:03and explore with animations and things
  5807. 3:44:05like that. Um but this is really also
  5808. 3:44:08the legwork so that the next uh chunk of
  5809. 3:44:10this tutorial series can move along
  5810. 3:44:12really well and we can focus on
  5811. 3:44:14programming and we can focus on HMI
  5812. 3:44:16development and we don't have to get all
  5813. 3:44:18of the basic interconnections done. So,
  5814. 3:44:20I hope you found this video useful. I
  5815. 3:44:22hope you've been finding this tutorial
  5816. 3:44:23series useful. I have really been
  5817. 3:44:25enjoying using Ignition for Makers and
  5818. 3:44:28the Arduino Opta PLC. All right, so I'll
  5819. 3:44:30leave you with that. I'm looking forward
  5820. 3:44:31to the next video. Please leave comments
  5821. 3:44:34with any questions on what you saw here
  5822. 3:44:36today or things you want to make sure we
  5823. 3:44:38cover on future videos on the channel. I
  5824. 3:44:40appreciate all the support and as always
  5825. 3:44:43good luck with your projects and thanks
  5826. 3:44:44for watching. We'll see you next time.
  5827. 3:44:46Thanks. Bye.
  5828. 3:44:53Hello and welcome back to The Master
  5829. 3:44:54Tech and today's video is going to be a
  5830. 3:44:56continuation in our introduction to
  5831. 3:44:58controls and automation tutorial series.
  5832. 3:45:01And in today's video, we're going to
  5833. 3:45:02write some uh pretty specific form of
  5834. 3:45:05PLC logic called sequences. So, one of
  5835. 3:45:08the most common ways that long
  5836. 3:45:11complicated routines get controlled to
  5837. 3:45:13do things in order in factories is with
  5838. 3:45:16sequential programming and sequences
  5839. 3:45:19often involve interaction from the
  5840. 3:45:21operators at specific points in the
  5841. 3:45:23sequence. So, we're going to take a look
  5842. 3:45:25at how to create a step and then a
  5843. 3:45:27function where you step through it in
  5844. 3:45:29order and then we'll also add some
  5845. 3:45:31features to the HMI so that uh you can
  5846. 3:45:33see how the HMI could interplay with the
  5847. 3:45:36sequence. And most important thing is
  5848. 3:45:38because this is kind of a continuation
  5849. 3:45:40in a tutorial series, the concepts in
  5850. 3:45:42this video stand alone. So, if you just
  5851. 3:45:44want to see an example of sequential
  5852. 3:45:47logic being programmed in ladder logic
  5853. 3:45:49on a PLC, you're in the right place.
  5854. 3:45:51Keep watching. But if you want to follow
  5855. 3:45:53along line by line and build the same
  5856. 3:45:55sort of things as we go, make sure that
  5857. 3:45:57you have uh Ignition connected to an
  5858. 3:46:00Arduino Opta PLC. You've already set up
  5859. 3:46:03the Modbus connections. So, I have it so
  5860. 3:46:06that the red, green, and blue buttons as
  5861. 3:46:08well as the user push button are already
  5862. 3:46:10tied to my PLC and then I have a PLC
  5863. 3:46:13program where I've already set the IP
  5864. 3:46:16address, set it up with Modbus
  5865. 3:46:17connections, and created some very basic
  5866. 3:46:20logic
  5867. 3:46:21So, if you haven't been following along
  5868. 3:46:23with the tutorial series, but you really
  5869. 3:46:25want to do this piece together, all you
  5870. 3:46:27really need to do is watch the previous
  5871. 3:46:29video on the channel. I'll try to
  5872. 3:46:30remember to leave a link to it below, a
  5873. 3:46:32card to it somewhere in the top of the
  5874. 3:46:34screen now. But I don't want a ton of
  5875. 3:46:36comments on this video that are like,
  5876. 3:46:39"Oh, you jumped right into it with no
  5877. 3:46:40context or background." So, um please
  5878. 3:46:43get yourself in the same spot as me if
  5879. 3:46:45you would like to follow along exactly.
  5880. 3:46:50Otherwise, let's dive into the tutorial
  5881. 3:46:52and the concepts in this video. Okay?
  5882. 3:46:54Now, I've prepared uh a pretty simple
  5883. 3:46:56prompt that is going to step out a
  5884. 3:46:59five-step sequence and it's basically
  5885. 3:47:01going to tell us what we should be
  5886. 3:47:02trying to program because a really
  5887. 3:47:04important thing about controls and
  5888. 3:47:06automation is if you just sit down to
  5889. 3:47:08write PLC code and you have no idea what
  5890. 3:47:11you're trying to code, it gets really
  5891. 3:47:13hard uh in terms of inputs, outputs,
  5892. 3:47:16variables, what you need to put on an
  5893. 3:47:17HMI. So, anytime in controls and
  5894. 3:47:19automation when you go to write new PLC
  5895. 3:47:22code, you should have a basic vision of
  5896. 3:47:24what you are trying to accomplish. Bit
  5897. 3:47:26of a tangent, but basically step zero of
  5898. 3:47:28our sequence will be considered idle and
  5899. 3:47:30it'll just be waiting for an operator to
  5900. 3:47:32press the start button on the screen.
  5901. 3:47:34Then step one, we're going to be
  5902. 3:47:36activated and then I still have the hand
  5903. 3:47:38switch connected to my PLC uh from the
  5904. 3:47:41wiring examples that we did a few videos
  5905. 3:47:43back. But instead of the hand switch,
  5906. 3:47:45you could use the user push button on
  5907. 3:47:47the front of the Opta like we've been
  5908. 3:47:49doing lately. It's up to you. But in
  5909. 3:47:51sequence step two, we're going to wait
  5910. 3:47:53for a timer to complete so I can show
  5911. 3:47:55you guys the timer function block. And
  5912. 3:47:56then in sequence step three, we're going
  5913. 3:47:58to click a button on the HMI until we
  5914. 3:48:00get up to a set point. So, I'm going to
  5915. 3:48:02show you how to create a set point on
  5916. 3:48:04the HMI screen that operators can change
  5917. 3:48:07and interact with, and then we will use
  5918. 3:48:09that in our sequence. And then step four
  5919. 3:48:10will be sequence completed, and it'll be
  5920. 3:48:12sitting there waiting for us to send it
  5921. 3:48:14to idle by pressing a stop button. Uh
  5922. 3:48:16let's dive right back in. I'll let's
  5923. 3:48:18dive into the programming. I'll probably
  5924. 3:48:20pull up this notepad if we forget what
  5925. 3:48:22the next step is supposed to be. I'll
  5926. 3:48:23try to go slow. I'll try to explain
  5927. 3:48:25everything as I do it. Hopefully a lot
  5928. 3:48:27of this is familiar if you've been
  5929. 3:48:28following the series along. So, let's go
  5930. 3:48:30ahead and go to our program. Let's go to
  5931. 3:48:33project, and then uh we're going to
  5932. 3:48:35right-click, and we're going to add a
  5933. 3:48:36new program in LD, ladder diagram, and
  5934. 3:48:40we will call this ladder underscore
  5935. 3:48:43sequence,
  5936. 3:48:44and let's assign it to fast task and hit
  5937. 3:48:47okay.
  5938. 3:48:48All right. So, sequence step zero equals
  5939. 3:48:52idle, and we're going to wait for the
  5940. 3:48:53HMI start button to be pressed. So, the
  5941. 3:48:56first thing we need to do is we need to
  5942. 3:48:58check with an equals block.
  5943. 3:49:01So, EQ.
  5944. 3:49:04We need to check if sequence step is
  5945. 3:49:06equal to
  5946. 3:49:08zero.
  5947. 3:49:09So, we're going to
  5948. 3:49:10need a variable that we'll call sequence
  5949. 3:49:14underscore step.
  5950. 3:49:16And if it does equal zero, then we just
  5951. 3:49:19want to tie this into the output line.
  5952. 3:49:24So, uh this should look familiar from
  5953. 3:49:25the first ladder uh tutorial that we
  5954. 3:49:28did. Okay. Now, we're also not going to
  5955. 3:49:30worry about making all of these
  5956. 3:49:31variables right now. I'm going to write
  5957. 3:49:33the sequence, and then I'm going to go
  5958. 3:49:35and look at what variables I used and
  5959. 3:49:37kind of add them all at once.
  5960. 3:49:39Uh if that feels a little backwards, if
  5961. 3:49:41you're more of a person who wants to
  5962. 3:49:43define all of your variables and then
  5963. 3:49:44use them or define them as you go, um
  5964. 3:49:48you know, dealer's choice. But, uh
  5965. 3:49:50basically, we have sequence step equals
  5966. 3:49:52zero. We're going to listen then for a
  5967. 3:49:56uh push button from a tag that we'll
  5968. 3:49:59just call HMI
  5969. 3:50:01start.
  5970. 3:50:02Okay. And when the HMI start button gets
  5971. 3:50:05pressed, that'll be something that we
  5972. 3:50:07click on the ignition screen. So, then
  5973. 3:50:10we'll go ahead and start by resetting
  5974. 3:50:13the HMI start push button. Okay. So,
  5975. 3:50:16you're going to turn it on from the HMI
  5976. 3:50:19screen, and then the code will turn it
  5977. 3:50:21off. But, when it turns it off, we will
  5978. 3:50:24also add one to the sequence. You could
  5979. 3:50:27add one to sequence step at this step,
  5980. 3:50:30or you could say move one to sequence
  5981. 3:50:32step. It doesn't really matter. Just
  5982. 3:50:34like any form of programming, there's a
  5983. 3:50:36few different ways that you could write
  5984. 3:50:37it. Um what's nice about this rung that
  5985. 3:50:40we've built is it's sort of good for
  5986. 3:50:42reusability. So, we can copy it, and now
  5987. 3:50:45we can say, "All right. Now sequence
  5988. 3:50:47step equals one." And I'm not looking
  5989. 3:50:50for HMI start anymore. Now I'm probably
  5990. 3:50:53looking for input eight, right? So, I
  5991. 3:50:55have a hand switch. If you don't have
  5992. 3:50:57the hand switch still hooked up from a
  5993. 3:50:59few tutorials ago, you could put
  5994. 3:51:02the user push button right here. Um but
  5995. 3:51:05instead, I'm going to put
  5996. 3:51:07an HMI tag in that uh is monitoring
  5997. 3:51:10input eight. Uh actually, I'll just
  5998. 3:51:12Yeah. That's fine.
  5999. 3:51:15And then when it's made, we'll go to
  6000. 3:51:17step two.
  6001. 3:51:18Um and then we could do the same reset,
  6002. 3:51:21but that doesn't make a lot of sense
  6003. 3:51:23because this is actually going to be
  6004. 3:51:24looking at the hand switch. Um now, the
  6005. 3:51:27hand switch has on position and off
  6006. 3:51:30position. And I specifically want to
  6007. 3:51:33listen for the rising edge of the hand
  6008. 3:51:36switch. So, let's say you had left this
  6009. 3:51:38on, I don't want it to automatically
  6010. 3:51:41blast through this step. I want it to
  6011. 3:51:43listen for a person to intentionally
  6012. 3:51:45turn the hand switch on. So, to do that,
  6013. 3:51:48I'm not just going to use a regular
  6014. 3:51:50examine if closed block, uh this regular
  6015. 3:51:53normal contact. I'm going to use
  6016. 3:51:56positive edge of the contact. So, this
  6017. 3:51:58is rising edge. This is as you detect
  6018. 3:52:02that that Boolean variable transitions
  6019. 3:52:04to a one pulse. So, it's basically a
  6020. 3:52:06one-shot on transition high.
  6021. 3:52:09So, this step is just going to listen
  6022. 3:52:12when we're in sequence step one and only
  6023. 3:52:15when we're in sequence step one for the
  6024. 3:52:17hand switch to turn on, and then it'll
  6025. 3:52:19move a two into sequence step.
  6026. 3:52:22So, if we're tracking our little notepad
  6027. 3:52:25of instructions,
  6028. 3:52:27we have step zero, we're in idle, and
  6029. 3:52:30we're waiting for the HMI start button
  6030. 3:52:31to be pressed. And then we have step
  6031. 3:52:33one, we've activated the sequence, and
  6032. 3:52:36we're waiting for the hand switch uh to
  6033. 3:52:38move us to step three.
  6034. 3:52:39Uh step two. Now, in step two, we're
  6035. 3:52:42going to wait for a timer to complete.
  6036. 3:52:44So, we haven't talked about timers yet.
  6037. 3:52:46There's a timer on delay where when the
  6038. 3:52:49conditions that make the timer uh start
  6039. 3:52:52begin, the output is false until a set
  6040. 3:52:55point is met. Then there's a timer off
  6041. 3:52:58delay, which is kind of the opposite,
  6042. 3:53:00which is where uh when the conditions go
  6043. 3:53:04when the conditions to start the timer
  6044. 3:53:06begin, the output is immediately true,
  6045. 3:53:09but then when the conditions that make
  6046. 3:53:10the timer true go away, the timer will
  6047. 3:53:13then start counting and stay true for a
  6048. 3:53:16period of time after that. That's a lot
  6049. 3:53:18of gobbledygook and stuff to try to
  6050. 3:53:22explain what ought to be a simple
  6051. 3:53:24concept, but um with PLC programming,
  6052. 3:53:26there is just a little game within the
  6053. 3:53:28game of knowing the nuances going on
  6054. 3:53:30here.
  6055. 3:53:31Um so, let's go ahead and drop a new
  6056. 3:53:33block that we haven't seen before, but
  6057. 3:53:35it's TON, timer on delay. And just to
  6058. 3:53:37show you real quick, there's timer off
  6059. 3:53:39delay. So, when you make function blocks
  6060. 3:53:41like timers that have a few parameters
  6061. 3:53:44to them, you have to give them an
  6062. 3:53:45instance name. So, for this one, we can
  6063. 3:53:47just call it the step two uh TON, the
  6064. 3:53:50step two TON.
  6065. 3:53:52Um but the reason you need to do that is
  6066. 3:53:54because there's an output tag, an input
  6067. 3:53:57tag, a set time, and then an elapsed
  6068. 3:54:00time. All of these uh four parameters,
  6069. 3:54:03and they need to be stored in a variable
  6070. 3:54:05or instance. Okay. So, for this timer,
  6071. 3:54:08we're going to go down to PT, and you
  6072. 3:54:10can add constants. So, if you know you
  6073. 3:54:12always want it to be 5 seconds or
  6074. 3:54:14something like that, um you can put a
  6075. 3:54:16constant here. I'm going to want to tie
  6076. 3:54:18it to a variable, which I will call um
  6077. 3:54:21I will just call step two time. That's
  6078. 3:54:25what I'll call the variable. Um and
  6079. 3:54:27that'll be my uh
  6080. 3:54:29my time that uh is set for the timer.
  6081. 3:54:33So, that's how long I want the timer to
  6082. 3:54:34count up for, which will be something
  6083. 3:54:36we'll let the user set from the HMI
  6084. 3:54:38screen we're about to build.
  6085. 3:54:40Um and then we will make on the output
  6086. 3:54:43of this timer completing, we will make
  6087. 3:54:45it move to sequence step three.
  6088. 3:54:49Okay. Now, there's a few things Oh, I
  6089. 3:54:51have two moves here.
  6090. 3:54:53Okay. Um there's a few things we're
  6091. 3:54:54going to change now. We don't want the
  6092. 3:54:56input of uh eight anymore. We don't need
  6093. 3:54:59that. But, there is one thing about PLC
  6094. 3:55:02timers that we haven't included yet. Um
  6095. 3:55:05and that's that the default time for
  6096. 3:55:07almost every PLC is in milliseconds.
  6097. 3:55:12I don't want the operator, I don't want
  6098. 3:55:13the user on the HMI entering a time in
  6099. 3:55:16milliseconds. It's not that intuitive.
  6100. 3:55:18It's not how people think. So, I'm going
  6101. 3:55:20to add uh a multiply block in here, MUL,
  6102. 3:55:25and I'm going to drag it before the
  6103. 3:55:27timer, if it'll let me. There we go. Um
  6104. 3:55:30and I'm going to take the HMI time
  6105. 3:55:35SP, so set point, HMI time set point. If
  6106. 3:55:38you don't like my uh tag naming
  6107. 3:55:40conventions, I don't know what to tell
  6108. 3:55:42you.
  6109. 3:55:44You know, that's okay. And then I'm
  6110. 3:55:46going to multiply it by 1,000, and I'm
  6111. 3:55:48going to store that in
  6112. 3:55:50step two time, which is the name of the
  6113. 3:55:53variable that we just defined. Okay. So,
  6114. 3:55:56what this line is doing now is saying
  6115. 3:55:58when I get to this step, I'm going to
  6116. 3:56:00take the set point that's on the HMI,
  6117. 3:56:03and I'm going to multiply it by 1,000,
  6118. 3:56:05and then we're going to use that value
  6119. 3:56:08in the timer. So, we'll enter a time in
  6120. 3:56:10seconds on the HMI.
  6121. 3:56:12This will convert it to milliseconds for
  6122. 3:56:14us, and then once the timer finishes,
  6123. 3:56:17it'll move us to step three.
  6124. 3:56:19Okay. And then, if we remember step
  6125. 3:56:22three,
  6126. 3:56:23we're going to have a counter. So, we're
  6127. 3:56:25going to have a target number of times a
  6128. 3:56:26button has to get clicked, and we're
  6129. 3:56:28going to keep track of how many times
  6130. 3:56:30it's been clicked, and then once we hit
  6131. 3:56:32our set point, we'll move to step four.
  6132. 3:56:35So, this one's a little bit different,
  6133. 3:56:36and it'll probably make more sense once
  6134. 3:56:39we get to uh the HMI where you can see
  6135. 3:56:42the interaction part. Um but I'm just
  6136. 3:56:45choosing to sort of start in the PLC
  6137. 3:56:47code, and then we'll move into uh the
  6138. 3:56:49HMI all at once. So, it's still not too
  6139. 3:56:52bad. We're going to say now if we equal
  6140. 3:56:55three, and then we want to move to four
  6141. 3:56:57when this step finishes. In the middle,
  6142. 3:57:00what we're actually checking for,
  6143. 3:57:01because we'll do most of the hard work
  6144. 3:57:04uh on the HMI for this step, so what
  6145. 3:57:06we're going to check for here is that
  6146. 3:57:08we're greater than or equals. So, GE, a
  6147. 3:57:11new block. Um and we can delete the
  6148. 3:57:13multiplication that was for the previous
  6149. 3:57:15step.
  6150. 3:57:16And we're going to want to check that
  6151. 3:57:18HMI counter
  6152. 3:57:21Oop. So, let's go ahead and make a new
  6153. 3:57:23tag called HMI counter in here.
  6154. 3:57:27Um and we want to check that the live
  6155. 3:57:29counter gets greater than the uh HMI
  6156. 3:57:33count, and we'll say set point, SP,
  6157. 3:57:35right there. Okay. And uh now we need to
  6158. 3:57:38delete this block because what we want
  6159. 3:57:41the output to be is just set the output
  6160. 3:57:44line.
  6161. 3:57:45Okay. So, very simply, this line means
  6162. 3:57:49when we get to step three,
  6163. 3:57:51wait until the HMI counter gets above
  6164. 3:57:54the HMI count set point, and then move
  6165. 3:57:57uh to step four after that. But, one
  6166. 3:58:00thing that we want to keep in mind is
  6167. 3:58:02that if you were to restart the PLC or
  6168. 3:58:05you didn't properly clear the sequence
  6169. 3:58:07or anything like that, how do we
  6170. 3:58:09guarantee that the HMI counter has been
  6171. 3:58:11reset to zero by the time we get to this
  6172. 3:58:14step? One of the easiest ways is
  6173. 3:58:16actually just go to the step before it
  6174. 3:58:18and add some branching logic add some
  6175. 3:58:21branching logic around your output
  6176. 3:58:23conditions. Okay? And we're going to
  6177. 3:58:25come down here
  6178. 3:58:27and we're going to add a new block to
  6179. 3:58:28just move a zero, so come over here. And
  6180. 3:58:32here we're going to move a zero into
  6181. 3:58:35HMI counter. So, this is just my way of
  6182. 3:58:38saying I really don't care what's
  6183. 3:58:39happened to that variable up until now.
  6184. 3:58:42I haven't needed my sequence up until
  6185. 3:58:44now, but I'm about to enter step three
  6186. 3:58:46and I know I want that to be a zero when
  6187. 3:58:48I get there. So, I'm going uh to set it
  6188. 3:58:51equal to zero before I get into step
  6189. 3:58:52three. So, that's all we're doing there.
  6190. 3:58:55And then that's really it for our
  6191. 3:58:57sequence. So, step four is sequence
  6192. 3:59:00completed, press HMI stop to send to
  6193. 3:59:03idle. That is basically exactly what we
  6194. 3:59:06did with line one. Since that's exactly
  6195. 3:59:08like the first line, we have a really
  6196. 3:59:10good thing to reference here already.
  6197. 3:59:11And we'll just go ahead and uh say,
  6198. 3:59:14"Okay, that was a coil." And we are
  6199. 3:59:16going to say, "All right, when I get to
  6200. 3:59:17step four then I want to move to step
  6201. 3:59:20zero when HMI stop gets pressed." HMI
  6202. 3:59:25stop. And if you remember from that
  6203. 3:59:28first line, we also went ahead and we
  6204. 3:59:30reset the uh output as part of that. So,
  6205. 3:59:33if we go over here
  6206. 3:59:36we also want to put HMI stop
  6207. 3:59:41in a reset. That's going to say you
  6208. 3:59:43wrote a one to it from the HMI, we're
  6209. 3:59:45going to write a zero to it from the
  6210. 3:59:47PLC.
  6211. 3:59:49All right, we did a lot of ladder here
  6212. 3:59:52without looking at the HMI. We need to
  6213. 3:59:54add a lot of variables, so let's try to
  6214. 3:59:56do this carefully and methodically now.
  6215. 3:59:59Um if we go into the uh resources tab
  6216. 4:00:03and then parameters, I'm basically going
  6217. 4:00:05to default to wanting every one of these
  6218. 4:00:07tags uh in parameters because I want to
  6219. 4:00:10give the HMI
  6220. 4:00:13as much information as we can. So, we're
  6221. 4:00:15going to have sequence step, that's
  6222. 4:00:17going to be an integer. We're going to
  6223. 4:00:18have HMI start.
  6224. 4:00:21That's going to be a Boolean. We're
  6225. 4:00:23going to have HMI input eight, that'll
  6226. 4:00:26be a Boolean and we'll tie it to my hand
  6227. 4:00:28switch. We're going to have
  6228. 4:00:31HMI I spelled HMI wrong. Uh we're going
  6229. 4:00:35to have HMI time set point.
  6230. 4:00:39I'm struggling to type today.
  6231. 4:00:42Time set point, that'll be an integer
  6232. 4:00:43where the operator enters something in
  6233. 4:00:45seconds. We'll have step two time,
  6234. 4:00:48that'll also be an integer, it'll just
  6235. 4:00:51be uh multiplied by a thousand.
  6236. 4:00:54And then we're going to have HMI
  6237. 4:00:58counter.
  6238. 4:00:59That's going to be an integer as well.
  6239. 4:01:03And then we'll have
  6240. 4:01:06You know, we could also put the elapsed
  6241. 4:01:08time from that timer in a variable, so
  6242. 4:01:10we could call that HMI
  6243. 4:01:12elapsed and we could make
  6244. 4:01:16Yeah, that could be an integer as well,
  6245. 4:01:18that's fine.
  6246. 4:01:19Uh so, we can put how much time has
  6247. 4:01:21progressed in another variable. So, on
  6248. 4:01:24the HMI we could also show how far the
  6249. 4:01:26timer has progressed. Um I just decided
  6250. 4:01:29that was a good idea right now.
  6251. 4:01:31Then we're also going to have the HMI
  6252. 4:01:33count set point, so that'll be what you
  6253. 4:01:36need to press the button up to.
  6254. 4:01:38And then we want
  6255. 4:01:40HMI
  6256. 4:01:42stop.
  6257. 4:01:43Uh and I may have missed some things,
  6258. 4:01:45but that's what we're going to start by
  6259. 4:01:47making. So, let's go into parameters.
  6260. 4:01:49And we have the user push button red,
  6261. 4:01:51blue, and green from before. No reason
  6262. 4:01:53to delete those, let's just go ahead and
  6263. 4:01:55add. Um
  6264. 4:01:57and we'll add sequence step and that can
  6265. 4:02:00be an integer.
  6266. 4:02:02And then we'll add
  6267. 4:02:04HMI start.
  6268. 4:02:07Careful on spelling, that'll be a
  6269. 4:02:09Boolean.
  6270. 4:02:12And then we'll add
  6271. 4:02:14HMI I8 and that'll be a Boolean.
  6272. 4:02:21Now we will add
  6273. 4:02:24HMI
  6274. 4:02:26time set point integer.
  6275. 4:02:29Add
  6276. 4:02:31step
  6277. 4:02:32step two time.
  6278. 4:02:35That'll be an integer.
  6279. 4:02:40We'll add HMI counter.
  6280. 4:02:43Also an integer.
  6281. 4:02:47We have HMI elapsed.
  6282. 4:02:50You guessed it, that's an integer.
  6283. 4:02:53We have HMI count set point. Integer.
  6284. 4:02:59And then we have
  6285. 4:03:01HMI stop. And that's a Boolean.
  6286. 4:03:06Okay, one thing that we need to do
  6287. 4:03:08because it's the thing that interacts
  6288. 4:03:10with the physical world is we need to go
  6289. 4:03:13in here
  6290. 4:03:15and we need to set HMI
  6291. 4:03:18I8 here being, sorry, I should have
  6292. 4:03:20clarified, here being the main routine
  6293. 4:03:23that we set up uh in the previous video
  6294. 4:03:25where we just mapped our lights and uh
  6295. 4:03:29push button to the we mapped our Modbus
  6296. 4:03:32tags to the physical tags that actually
  6297. 4:03:34represent them. So, here we want to set
  6298. 4:03:36HMI I8 equal to input eight and we want
  6299. 4:03:41to go to our um programmable inputs and
  6300. 4:03:44make sure that I8 or whatever. I have my
  6301. 4:03:47hand switch wired up to I8 on my
  6302. 4:03:49Arduino.
  6303. 4:03:50Um
  6304. 4:03:51so, I'm just going to make a variable
  6305. 4:03:53called I8 that physically represents the
  6306. 4:03:56state of the hand switch. And then in
  6307. 4:03:58main, I am mapping the HMI tag that we
  6308. 4:04:01just made to share with Ignition and I
  6309. 4:04:04am mapping that to the physical hand
  6310. 4:04:06switch.
  6311. 4:04:08All right, so I am
  6312. 4:04:10naively optimistic that this is going to
  6313. 4:04:12compile. Let's just go ahead and compile
  6314. 4:04:15and see what we missed. And it appears
  6315. 4:04:17that it works, so let's go ahead and try
  6316. 4:04:19to download it. A warm restart's
  6317. 4:04:21required, that's fine.
  6318. 4:04:23Initialize the database with default
  6319. 4:04:25values, that's fine.
  6320. 4:04:26Warm reboot, it says source code okay.
  6321. 4:04:29So,
  6322. 4:04:30uh if you were to throw on the little
  6323. 4:04:32live debug mode, which is a a cool
  6324. 4:04:34feature of ladder
  6325. 4:04:36um and most PLC IDEs, you can see the
  6326. 4:04:39live value of all of these tags come in.
  6327. 4:04:42And so, sequence step zero is active
  6328. 4:04:44right now.
  6329. 4:04:45And if I were to uh click the HMI start
  6330. 4:04:49button
  6331. 4:04:50um or just within the code by double uh
  6332. 4:04:53clicking, I can set it equal to true.
  6333. 4:04:56What you can't see is that the HMI start
  6334. 4:04:59went true and it immediately reset
  6335. 4:05:01itself, but what you can see is that the
  6336. 4:05:03sequence step is now one.
  6337. 4:05:06So, now we're waiting for HMI uh I8 to
  6338. 4:05:09go true.
  6339. 4:05:10If I set equal to a one, that one
  6340. 4:05:13actually won't let me force it through
  6341. 4:05:15because it's being overridden in the
  6342. 4:05:16main PLC routine, but what I can do is
  6343. 4:05:19boot up my 24-V power supply real quick
  6344. 4:05:21and I can actually trigger the hand
  6345. 4:05:23switch. And if I go in here and I watch
  6346. 4:05:26HMI I8, if I make the hand switch it
  6347. 4:05:29goes true.
  6348. 4:05:31Okay? And actually, predictably,
  6349. 4:05:34um it went straight to sequence step
  6350. 4:05:36four because our time set point is equal
  6351. 4:05:39to zero. So, the timer finished
  6352. 4:05:41immediately and went to step three. And
  6353. 4:05:43then our counter is equal to zero, so it
  6354. 4:05:46went immediately to four. It's waiting
  6355. 4:05:48for someone to press uh HMI stop.
  6356. 4:05:51So, if I go ahead and I write a true to
  6357. 4:05:54that Boolean, it'll go back to step
  6358. 4:05:56zero.
  6359. 4:05:58So, that's kind of as fast as you can
  6360. 4:05:59walk through it just on the PLC to make
  6361. 4:06:01sure it's working. So, we added a total
  6362. 4:06:04of 1 2 3 4 5 6 7 8 nine new tags. We
  6363. 4:06:08need to go into Ignition. And first
  6364. 4:06:11thing from the gateway, if you were
  6365. 4:06:12following along last tutorial, we need
  6366. 4:06:14to expand our addresses to include those
  6367. 4:06:17new um nine tags. So, before we went
  6368. 4:06:20from one to four, this is super easy.
  6369. 4:06:22Now we just go from one to 13
  6370. 4:06:25and hit save. Uh the status is
  6371. 4:06:27connected, which is great. The live
  6372. 4:06:30screen won't change, so we open up
  6373. 4:06:31designer launcher and we open our
  6374. 4:06:34gateway uh designer.
  6375. 4:06:40Open the designer.
  6376. 4:06:41All right, so we've got our home page.
  6377. 4:06:43I'm going to I'm going to leave the Opta
  6378. 4:06:45up there exactly like it was from last
  6379. 4:06:47time. I don't have a problem with that.
  6380. 4:06:49Um but I'm going to add to my tags. I'm
  6381. 4:06:51going to add a new folder and call these
  6382. 4:06:54sequence tags. And then I'm going to
  6383. 4:06:57browse devices
  6384. 4:06:59and go to my
  6385. 4:07:01Opta.
  6386. 4:07:02And I'm going to go to my unit ID. And I
  6387. 4:07:04just added tags
  6388. 4:07:07uh 1 2 3 4. I just added tags five
  6389. 4:07:11through 13. So, I'm going to store those
  6390. 4:07:15in sequence tags. Okay? So, I am adding
  6391. 4:07:18all of the new tags that we just added
  6392. 4:07:19in the PLC to uh a the HMI. They're all
  6393. 4:07:23zeros. They also all came in as shorts.
  6394. 4:07:27Um but if we look back at our PLC real
  6395. 4:07:29quick, we have sequence step, HMI start.
  6396. 4:07:32We have the exact order we actually
  6397. 4:07:34wrote on this notepad for easy
  6398. 4:07:35reference. Um we have 1 2
  6399. 4:07:39three bools. And so, we need to change
  6400. 4:07:41those tag types to bools. Modbus uh
  6401. 4:07:44holding registers always look like
  6402. 4:07:4616-bit signed ints to Ignition if you
  6403. 4:07:49don't tell it otherwise. So, um Opta tag
  6404. 4:07:52five was the
  6405. 4:07:55sequence step.
  6406. 4:07:58Okay.
  6407. 4:07:59Opto tag six
  6408. 4:08:02was the HMI start. And you don't
  6409. 4:08:05actually have to call them exact and
  6410. 4:08:07this one was a Boolean. You don't have
  6411. 4:08:09to call them exactly what they're called
  6412. 4:08:11in the PLC. It's just an easier way to
  6413. 4:08:13keep them straight.
  6414. 4:08:15HMI input eight was also a Boolean and
  6415. 4:08:18was the next tag.
  6416. 4:08:21And then
  6417. 4:08:24HMI
  6418. 4:08:26time set point was an integer.
  6419. 4:08:30And the next tag was
  6420. 4:08:33step
  6421. 4:08:34two
  6422. 4:08:36time integer. Okay.
  6423. 4:08:39The next tag HMI counter.
  6424. 4:08:43Counter.
  6425. 4:08:45And that's an integer. Okay. Step 11.
  6426. 4:08:51The next one HMI elapsed and that is how
  6427. 4:08:55much time has passed. That can be an
  6428. 4:08:57integer.
  6429. 4:08:58The next tag is
  6430. 4:09:01HMI
  6431. 4:09:03count set point integer. Okay. And the
  6432. 4:09:08last tag will be HMI stop and that's a
  6433. 4:09:13Boolean.
  6434. 4:09:15Go to the PLC. Uh okay, HMI start
  6435. 4:09:19needs to be
  6436. 4:09:23Oh, well, it is case-sensitive. So, this
  6437. 4:09:25needs to be a capital S for HMI start.
  6438. 4:09:28Do you want to reassign this variable
  6439. 4:09:30and use it as parameter? Yes.
  6440. 4:09:32Um okay, so that should be a Boolean.
  6441. 4:09:34That should work. Uh this should also be
  6442. 4:09:37a Boolean.
  6443. 4:09:39And then this should also be Boolean.
  6444. 4:09:42That should work.
  6445. 4:09:44Uh all right, all the addressing should
  6446. 4:09:46still be fine. And then I guess since we
  6447. 4:09:47have to download anyways,
  6448. 4:09:50um we can go back to our ladder sequence
  6449. 4:09:52really quickly and we can add that
  6450. 4:09:54elapsed time that I forgot to put in
  6451. 4:09:56here. So,
  6452. 4:09:58um if we go back to resources, we just
  6453. 4:10:00called it HMI {underscore} elapsed.
  6454. 4:10:02Let's go to our timer block and let's
  6455. 4:10:04add a variable to the ET. And we called
  6456. 4:10:07it HMI {underscore} elapsed.
  6457. 4:10:11Okay.
  6458. 4:10:12Okay. And uh one thing to call out here
  6459. 4:10:15that you could kind of see which is also
  6460. 4:10:17kind of nice and maybe I did this in the
  6461. 4:10:20bad order. If you define all your
  6462. 4:10:21variables that you're going to need for
  6463. 4:10:23your routine before writing your
  6464. 4:10:26program, then they're available when you
  6465. 4:10:28go to add variables and you can see that
  6466. 4:10:30they exist and what data type they are.
  6467. 4:10:32So, maybe I did a little bit backwards.
  6468. 4:10:35Uh
  6469. 4:10:35I'm not perfect. Let's compile and
  6470. 4:10:38download and restart the PLC.
  6471. 4:10:41Initialize the database again.
  6472. 4:10:43Okay, so with all of our tags added, we
  6473. 4:10:45can finally do the fun part. Depends who
  6474. 4:10:48you are. I enjoy the graphical user
  6475. 4:10:50interface, the HMI development portion
  6476. 4:10:53of the job. Um let's go ahead and add
  6477. 4:10:55that sequence step, right? So, to the
  6478. 4:10:57visuals and Ignition's kind of nice. You
  6479. 4:10:59can just grab a device and or a tag and
  6480. 4:11:02drag it onto the screen and based on
  6481. 4:11:05what type of tag it is, it'll show you
  6482. 4:11:06all the recommendations for it. So, like
  6483. 4:11:08an integer, by default they have gauges,
  6484. 4:11:11one-shot buttons, cylindrical tanks, uh
  6485. 4:11:13labels, things like that. So, we'll just
  6486. 4:11:15do a label for the sequence step and
  6487. 4:11:17then we'll build some more cool features
  6488. 4:11:19into it. Um but let's go ahead and do
  6489. 4:11:21little checkbox uh buttons for um start
  6490. 4:11:24and stop and the text will say start for
  6491. 4:11:28the start button. That seems like a good
  6492. 4:11:30thing to say. And then we'll say stop
  6493. 4:11:33for the stop button.
  6494. 4:11:35So, uh text stop. Cool.
  6495. 4:11:40And then we'll throw What do we want to
  6496. 4:11:43throw? We want to throw our set points
  6497. 4:11:45on the screen as um
  6498. 4:11:48as a numerical entry. So, if we click
  6499. 4:11:50the little palette over on the right, uh
  6500. 4:11:53perspective components toolbar, we'll
  6501. 4:11:55type in numerical numeric entry field
  6502. 4:12:00and drag it onto the screen. And the
  6503. 4:12:02value will be what it's asking for.
  6504. 4:12:05It'll be asking for a tag. So, let's
  6505. 4:12:07make this one our count set point. And
  6506. 4:12:10we'll say value tag path
  6507. 4:12:12count set point and make sure to click
  6508. 4:12:14bidirectional so that people can write
  6509. 4:12:16to it. Okay, so this is our count set
  6510. 4:12:19point. So, why don't we uh go back to
  6511. 4:12:21perspective components and add another
  6512. 4:12:24label that just says
  6513. 4:12:27count set point. So, count set point.
  6514. 4:12:32And that doesn't have to be linked to
  6515. 4:12:34anything. It's just telling us what this
  6516. 4:12:35numeric entry field is. And then we had
  6517. 4:12:38one other thing that uh people could
  6518. 4:12:40edit willy-nilly and that was uh time
  6519. 4:12:44set point in seconds, right? And that
  6520. 4:12:49has to go to a different tag. That one
  6521. 4:12:51needs to go to HMI time SP. So, time SP.
  6522. 4:12:57And I know some people are going to be
  6523. 4:12:58furious at my lack of consistency with
  6524. 4:13:02capitalization and camel case, snake
  6525. 4:13:04case,
  6526. 4:13:06made up case, you pick it. Um okay, but
  6527. 4:13:09so that'll let us enter a time set
  6528. 4:13:11point. That'll let us enter a number of
  6529. 4:13:13times to be counted. Uh so, then the
  6530. 4:13:16only other thing I want to add real
  6531. 4:13:18quick is I want to add a button,
  6532. 4:13:21perspective components, button that is
  6533. 4:13:24going to button
  6534. 4:13:28that is going to add one
  6535. 4:13:30to the counter. So, if you remember, we
  6536. 4:13:32get to a step where Ooh, I also want to
  6537. 4:13:35add indication. Let's finish that
  6538. 4:13:37counter first.
  6539. 4:13:38Press to count up. Okay. So, we're going
  6540. 4:13:42to make a little button and when you
  6541. 4:13:44press it, the count goes up and then we
  6542. 4:13:46will show the counter right next to it
  6543. 4:13:48in a label.
  6544. 4:13:50So, this is the HMI counter tag and then
  6545. 4:13:53on click so, button, right click,
  6546. 4:13:57configure events. We're going to do a
  6547. 4:13:59little script here, a little Ignition
  6548. 4:14:01script to add one to the value
  6549. 4:14:04um
  6550. 4:14:04when the button is pressed. So, we go to
  6551. 4:14:06mouse events in configuration events, on
  6552. 4:14:09click, press the plus button and we're
  6553. 4:14:12going to do a quick little script that
  6554. 4:14:14is going to be
  6555. 4:14:16uh val equal to so, the current value of
  6556. 4:14:21the counter is equal to system.tag
  6557. 4:14:25.readBlocking
  6558. 4:14:26and that's a little bit of just Ignition
  6559. 4:14:28syntax for you. The tag path is going to
  6560. 4:14:31be that counter variable. So, we're
  6561. 4:14:34going to say read the value that the
  6562. 4:14:37counter currently has.
  6563. 4:14:39And then little Jython syntax fun that
  6564. 4:14:43we get to play here is if we actually
  6565. 4:14:45want the value, we say square brackets
  6566. 4:14:48z- zero.value. So, this is how you get
  6567. 4:14:51the actual value that is in the counter
  6568. 4:14:54tag already.
  6569. 4:14:56And then what we're going to say is
  6570. 4:14:58value equals val plus one. Okay, so
  6571. 4:15:02we're just saying you could just say val
  6572. 4:15:04again is equal to val plus one. But now
  6573. 4:15:07we're going to do system.tag.
  6574. 4:15:09writeBlocking.
  6575. 4:15:11And in that same tag path we're going to
  6576. 4:15:14write value. So, we're just adding one
  6577. 4:15:19to the value of the counter when that
  6578. 4:15:21button gets pressed. And what's cool is
  6579. 4:15:23it'll let you It'll let you click the
  6580. 4:15:26button at any time, but what you'll see
  6581. 4:15:28is when we get to step three, which is
  6582. 4:15:30where it's actually checking it, you'll
  6583. 4:15:31see it get reset to zero cuz we only
  6584. 4:15:34care about it when we get there. So,
  6585. 4:15:35you're starting to see how the HMI and
  6586. 4:15:38the PLC work together to create a system
  6587. 4:15:40that the operator has some control over,
  6588. 4:15:42but the PLC can also be programmed
  6589. 4:15:44intelligently to protect it.
  6590. 4:15:48So, this is how we just make a button in
  6591. 4:15:49Ignition to increment a value.
  6592. 4:15:53And let's see. What am I missing? When
  6593. 4:15:56we're in step zero, we're idle. We press
  6594. 4:15:58start, we should go to step one. Yeah,
  6595. 4:16:00we want to monitor
  6596. 4:16:02input eight. And actually, to do that,
  6597. 4:16:05I'll grab one of these buttons that we
  6598. 4:16:06made in the previous step. This was the
  6599. 4:16:08blue button. Uh and I'll just drag it up
  6600. 4:16:11here. This is This is input eight up
  6601. 4:16:13here cuz that's kind of physically where
  6602. 4:16:14it is on the Arduino. And we'll have it
  6603. 4:16:17uh when it's true, we'll have it go um
  6604. 4:16:21pink. I don't care. Pick a color.
  6605. 4:16:25All right, so then all I have to do is
  6606. 4:16:26copy the path for that tag and I have to
  6607. 4:16:28say, "Hey, here's the tag that you're
  6608. 4:16:30animating off of." Again, I'm assuming
  6609. 4:16:32you uh watched the previous video and
  6610. 4:16:34you know that we set this tag parameter
  6611. 4:16:36to tie into that color animation. Okay,
  6612. 4:16:39so real quick we can check that color
  6613. 4:16:40animation cuz I have the hand switch
  6614. 4:16:42right here with me and we can see
  6615. 4:16:44whether the hand switch is on or off.
  6616. 4:16:46Okay? Very cool. So, obviously it looks
  6617. 4:16:50like crap because we haven't formatted
  6618. 4:16:52it. We haven't made it stylistically
  6619. 4:16:55pleasant. Uh we don't animate things
  6620. 4:16:57whenever, but let's go into read write
  6621. 4:16:59mode real quick for the gateway. So,
  6622. 4:17:01that's what these two little arrows are.
  6623. 4:17:04And right here in the designer, we can
  6624. 4:17:06toggle into uh preview mode. So, now we
  6625. 4:17:08can interact with the things. Let's say
  6626. 4:17:10when we get to the countdown step, we
  6627. 4:17:12want 5-second countdown. And when we get
  6628. 4:17:15to the count up step, we want to have to
  6629. 4:17:17click the button three times. Okay, I'm
  6630. 4:17:19going to enter those. You can see right
  6631. 4:17:21here, I can start counting up just by
  6632. 4:17:23clicking it and the counter is at eight.
  6633. 4:17:26What's cool is when we get to the count
  6634. 4:17:28up step, that should go back to zero and
  6635. 4:17:30we should have to start over again. Um
  6636. 4:17:32one thing we didn't add, but I want to
  6637. 4:17:34put here is the elapsed time um and I'm
  6638. 4:17:37going to put it in a label.
  6639. 4:17:39But where did it go?
  6640. 4:17:41Oh, there it is. Um
  6641. 4:17:43But you guys are going to see something
  6642. 4:17:45cool. Let me Let me go up here. You guys
  6643. 4:17:47are going to see that this value is
  6644. 4:17:48going to come in in milliseconds.
  6645. 4:17:51Um so, I'm going to let it do that this
  6646. 4:17:53first test through and then I'm going to
  6647. 4:17:54show you how you can scale it in the
  6648. 4:17:56HMI. You could scale it in the PLC, you
  6649. 4:17:58can scale it in the HMI.
  6650. 4:18:00Just kind of pick something and try to
  6651. 4:18:02be consistent on your project.
  6652. 4:18:04So, we're in step zero. I hit the start
  6653. 4:18:06button. Now, we're in step one and we're
  6654. 4:18:09waiting for HMI. We're waiting for input
  6655. 4:18:12eight. So, I'm going to turn the hand
  6656. 4:18:13switch.
  6657. 4:18:15And now we're in step two and you can
  6658. 4:18:16see the counter counting up and when it
  6659. 4:18:18hits 5,000, we go to step three. Okay?
  6660. 4:18:22Pretty cool. And now it's waiting for us
  6661. 4:18:24to count up to three. So, you see this
  6662. 4:18:25was eight, now it's just waiting at
  6663. 4:18:27zero. So, we click once, twice, a third
  6664. 4:18:31time.
  6665. 4:18:32Now, we're in step four
  6666. 4:18:35and we press stop and it goes back to
  6667. 4:18:37zero. Okay? So, the sequence step is
  6668. 4:18:40working and that's really cool. What's
  6669. 4:18:42not great is it doesn't tell you
  6670. 4:18:44anything useful. So, what we're going to
  6671. 4:18:46do is we're going to add a transform and
  6672. 4:18:48we're going to map it. Okay? So, this is
  6673. 4:18:51very common when you have a numerical
  6674. 4:18:54value that tells you something that you
  6675. 4:18:57would prefer to explain with text. Some
  6676. 4:19:01a common way to refer to this is
  6677. 4:19:02enumeration.
  6678. 4:19:04Enumeration just refers to taking a
  6679. 4:19:07integer value or a numerical value and
  6680. 4:19:10it telling you more than just a number.
  6681. 4:19:12It's telling you a string of text, but
  6682. 4:19:14it's easier for PLCs to pass a simple
  6683. 4:19:17integer back and forth than long
  6684. 4:19:19strings.
  6685. 4:19:21So, in zero, we're in idle
  6686. 4:19:24waiting to press start button
  6687. 4:19:28on HMI. That's the text that we want to
  6688. 4:19:31display in step zero. Oh, where'd my
  6689. 4:19:34There we go.
  6690. 4:19:37In step one, we're
  6691. 4:19:39active
  6692. 4:19:41waiting to see
  6693. 4:19:43input eight transition high.
  6694. 4:19:47In step two, we're
  6695. 4:19:50active waiting for
  6696. 4:19:54timer to complete based on time set
  6697. 4:19:59point. Step three, we're active
  6698. 4:20:05and we want to
  6699. 4:20:07wait
  6700. 4:20:08for
  6701. 4:20:11pushes to reach
  6702. 4:20:14push count
  6703. 4:20:17up set point. You can call it whatever
  6704. 4:20:21you want if you don't like my step
  6705. 4:20:23names. And then step four, we can say
  6706. 4:20:26complete. Press stop button
  6707. 4:20:30on HMI to
  6708. 4:20:33idle sequence. And what's nice about
  6709. 4:20:36Ignition 2 is they have a feature called
  6710. 4:20:38fallback, which is I don't know how I
  6711. 4:20:40got here. And we can just basically say
  6712. 4:20:43sequence
  6713. 4:20:45step somehow
  6714. 4:20:48out of normal
  6715. 4:20:51boundaries.
  6716. 4:20:55And that's just basically saying you
  6717. 4:20:57should not have been able to get here.
  6718. 4:20:59Here's an error message telling you that
  6719. 4:21:00something bad is happening. That can
  6720. 4:21:03come in handy a lot. So, we're going to
  6721. 4:21:04make that label a lot wider cuz that
  6722. 4:21:07text is a lot longer. And then other
  6723. 4:21:10than that, I think the only other thing
  6724. 4:21:12I want to do right off the bat is I want
  6725. 4:21:14to take this thing on the screen and I
  6726. 4:21:17want to make it in seconds. So, what
  6727. 4:21:20we're going to do is we're actually
  6728. 4:21:21going to make this scale mode linear and
  6729. 4:21:26I'm going to say, "Okay, well, it's
  6730. 4:21:27showing me milliseconds, but I want
  6731. 4:21:30seconds. So, if the raw high is 1,000,
  6732. 4:21:34that means the scaled high is one." And
  6733. 4:21:37as long as you don't do clamp mode, then
  6734. 4:21:39it will automatically say, "Okay, even
  6735. 4:21:41if I'm more than zero or more than one,
  6736. 4:21:44that's okay." And then we'll make the
  6737. 4:21:46value a float since now we're dividing
  6738. 4:21:48it by 1,000, we'd like to see decimal
  6739. 4:21:50precision.
  6740. 4:21:53Okay, so this is this should be a little
  6741. 4:21:55bit better now when we test through it
  6742. 4:21:57because it's giving us instructions and
  6743. 4:21:59we'll actually open the web page now.
  6744. 4:22:05And we'll actually open the web page now
  6745. 4:22:06and we'll run it from here. So, I'm
  6746. 4:22:08going to
  6747. 4:22:09go ahead and hit start. I'm waiting to
  6748. 4:22:12see input eight transition high and you
  6749. 4:22:13can see it's already high, but we put in
  6750. 4:22:16that positive transition bit.
  6751. 4:22:19So, it needs to see it high again. And
  6752. 4:22:22here you can see fractional seconds
  6753. 4:22:24counting up, which is nice cuz we set
  6754. 4:22:26the set point in seconds. Now, we need
  6755. 4:22:28to count up to three. 2 3. And now we
  6756. 4:22:31need to press stop on the HMI.
  6757. 4:22:34Okay, we can pretty easily say, "Let's
  6758. 4:22:36make the count set point 11. Let's make
  6759. 4:22:39this time set point seven and let's do
  6760. 4:22:42it again. Let's press start here. Let's
  6761. 4:22:45flip the hand switch."
  6762. 4:22:48We're going to get to seven seconds.
  6763. 4:22:53We are going to count up to 11 clicks.
  6764. 4:22:58And now we finished the sequence, we can
  6765. 4:22:59hit stop and we're back to idle.
  6766. 4:23:02Overall, this was a challenging tutorial
  6767. 4:23:05to put together because where to start,
  6768. 4:23:07how to make it useful, how to explain
  6769. 4:23:09the concepts, but not get bogged down
  6770. 4:23:10the details was all a little bit
  6771. 4:23:12daunting. I do hope you found it useful.
  6772. 4:23:15I think we're getting to the point where
  6773. 4:23:16all of the basics have been covered and
  6774. 4:23:18I think we want to build one complete
  6775. 4:23:22automation and controls project
  6776. 4:23:23together. So, I am looking forward to
  6777. 4:23:25doing that. I am already sort of
  6778. 4:23:28fleshing out what that's going to look
  6779. 4:23:29like and entail. So, as always, be sure
  6780. 4:23:32to ask any questions that you may have
  6781. 4:23:33in the description below. Thank you so
  6782. 4:23:35much for watching. Let me know what you
  6783. 4:23:37want to see next time on the channel and
  6784. 4:23:38keep an eye out for more controls and
  6785. 4:23:40automation tutorials. Thanks. We'll see
  6786. 4:23:42you next time. Bye.
  6787. 4:23:49Hello and welcome back to The Master
  6788. 4:23:51Tech and in today's video, we're going
  6789. 4:23:52to continue our controls and automation
  6790. 4:23:54tutorial series by introducing the
  6791. 4:23:57concept of a historian or a continuous
  6792. 4:24:00trending tool as well as SQL, which is
  6793. 4:24:02kind of a more conventional database
  6794. 4:24:04tool. So, by far, these are the two most
  6795. 4:24:07common ways that data gets represented
  6796. 4:24:09in the world of industrial automation
  6797. 4:24:11and controls. SQL SQL stands for
  6798. 4:24:13structured query language. There are
  6799. 4:24:16ample tutorials on the internet on how
  6800. 4:24:17to get started with SQL, but
  6801. 4:24:19specifically how to embed it within like
  6802. 4:24:21a controls and automation project is
  6803. 4:24:24very much like an automation concept.
  6804. 4:24:26And then historians are sort of the
  6805. 4:24:29standard for continuous trending of
  6806. 4:24:31automation data. So, if you are just
  6807. 4:24:33watching this video on its own, it will
  6808. 4:24:35stand alone as a tutorial on how to use
  6809. 4:24:38both the historian tool and create a SQL
  6810. 4:24:41query from Ignition, which I think is
  6811. 4:24:43useful on its own. But if you've been
  6812. 4:24:45following along with the tutorial
  6813. 4:24:46series, you know that we physically have
  6814. 4:24:48this Arduino Opto PLC. We have the
  6815. 4:24:51button and the blue light and the green
  6816. 4:24:53light and the red light all all tied to
  6817. 4:24:57the HMI on Ignition and then as well as
  6818. 4:24:59input eight there in the top right
  6819. 4:25:01corner, which I have a physical hand
  6820. 4:25:03switch for. So, when I make the hand
  6821. 4:25:05switch, we can see that input eight goes
  6822. 4:25:07on. So, in the last video, we kind of
  6823. 4:25:09introduced sequential programming and we
  6824. 4:25:12made this sequence where we could start,
  6825. 4:25:15we could wait to see that hand switch go
  6826. 4:25:17high and then we start a timer that's
  6827. 4:25:20going to count to a set point that we
  6828. 4:25:22can adjust and then we need to click
  6829. 4:25:24this button until we get to a target
  6830. 4:25:26value and then we press stop. Okay? So,
  6831. 4:25:30I have a sequence. If you don't want to
  6832. 4:25:32follow along exactly with my example,
  6833. 4:25:34that's okay. But you should have
  6834. 4:25:37something sequential that you want to
  6835. 4:25:39track if you want to this to be like a
  6836. 4:25:41practical hands-on example for you. So,
  6837. 4:25:44we're using Ignition for Makers, which
  6838. 4:25:46is very popular SCADA supervisory
  6839. 4:25:49control and data acquisition software.
  6840. 4:25:52We're using Ignition Maker Edition,
  6841. 4:25:53which is which is an awesome free tool
  6842. 4:25:57that Inductive Automation put out.
  6843. 4:25:59We have a basic HMI project that shows
  6844. 4:26:01some of our tags and then we have the
  6845. 4:26:04Arduino Opto PLC sharing data with
  6846. 4:26:06Modbus TCP data. So, we're going to go
  6847. 4:26:09into the designer of Ignition and we're
  6848. 4:26:11going to take a look first at a very
  6849. 4:26:13simple continuous trend.
  6850. 4:26:16So, one thing to note is when you start
  6851. 4:26:18storing data, when you start looking at
  6852. 4:26:21data history over time, you need some
  6853. 4:26:24version of a database to store that in.
  6854. 4:26:27One really nice feature of Ignition for
  6855. 4:26:29Makers and the industrial version of it
  6856. 4:26:32is it'll by default have a sample SQL
  6857. 4:26:35light database enabled and it'll use
  6858. 4:26:38some of the storage of your computer by
  6859. 4:26:40default because SQL light is just a
  6860. 4:26:43file. So, it's a way of storing data
  6861. 4:26:45that looks like, you know, Microsoft SQL
  6862. 4:26:48or any other sort of like table and
  6863. 4:26:50columns and rows version of a SQL, but
  6864. 4:26:53SQL light is just a file. So, by
  6865. 4:26:56default, we don't have to do anything
  6866. 4:26:57special in Ignition. We have one
  6867. 4:27:00connection to a database and it's a
  6868. 4:27:02sample SQL light database.
  6869. 4:27:04That's really important because anytime
  6870. 4:27:06you want to store data, you have to
  6871. 4:27:07store it somewhere. Okay, now let's go
  6872. 4:27:10ahead and just pull up the HMI that we
  6873. 4:27:12were developing before. It's kind of
  6874. 4:27:14just a little square here. And I had it
  6875. 4:27:17mode fixed. So, what I'm going to do is
  6876. 4:27:19zoom out a little bit and widen it to be
  6877. 4:27:22a little closer to the width of the
  6878. 4:27:23screen. I'm going to hit save and then
  6879. 4:27:26I'm going to do one thing here. I'm
  6880. 4:27:27going to change mode from fixed to
  6881. 4:27:29percent. So, now it should scale with
  6882. 4:27:31the screen. Before we did that, if we
  6883. 4:27:34were zooming in and zooming out, all
  6884. 4:27:36those objects would also be zooming in
  6885. 4:27:38and out, but now it's scaled to always
  6886. 4:27:40be full screen. So, it's just a little
  6887. 4:27:42feature of Ignition in particular.
  6888. 4:27:45But that also means if we want to add a
  6889. 4:27:46trend over here, uh we can. So, if we
  6890. 4:27:49hit the Perspective Components uh
  6891. 4:27:51palette over on the right, um I'm just
  6892. 4:27:53going to grab a
  6893. 4:27:56power chart.
  6894. 4:27:58And I'm going to drag it onto the
  6895. 4:27:59screen. And what's really cool is you
  6896. 4:28:01don't have to tell it what tag to look
  6897. 4:28:03at or anything. You just drag this power
  6898. 4:28:05chart onto the screen and Ignition has a
  6899. 4:28:09pre-built object that will let you
  6900. 4:28:10browse tags within that. So, just by
  6901. 4:28:13hitting save and going back to the web
  6902. 4:28:15page, you can see this chart is on
  6903. 4:28:17screen. The only problem is there's only
  6904. 4:28:19example data in here. So, I have uh I
  6905. 4:28:22have tags that I added before for
  6906. 4:28:24testing. And then they give you these
  6907. 4:28:26sample tags of realistic values to show
  6908. 4:28:28you what navigating it looks like. Um
  6909. 4:28:31but since in the designer, we haven't
  6910. 4:28:33added historical data to any tags,
  6911. 4:28:36um
  6912. 4:28:37we're not seeing anything, okay? So, if
  6913. 4:28:40you've been following along with the
  6914. 4:28:40tutorials, you should have the same
  6915. 4:28:42tags. But if you don't, that's okay. Um
  6916. 4:28:45I don't have data trending enabled on
  6917. 4:28:47any of these tags. So, let's grab a few
  6918. 4:28:50that we might want to historize. So,
  6919. 4:28:52sequence step is a good one to start
  6920. 4:28:55with as an example. If I want to see the
  6921. 4:28:57sequence step over time, that would tell
  6922. 4:28:59me where in the sequence it was over
  6923. 4:29:01time.
  6924. 4:29:02Um and all I have to do when I open the
  6925. 4:29:04tag editor is go to history and then
  6926. 4:29:08true, and I need to give it a storage
  6927. 4:29:10provider, which in this case we'll make
  6928. 4:29:11that sample SQLite database. And then
  6929. 4:29:14there's a few important things here.
  6930. 4:29:15There's uh dead bands, there's dead band
  6931. 4:29:17styles. You can leave most of these on
  6932. 4:29:20the default and it'll just start working
  6933. 4:29:22if all you do is enable history and give
  6934. 4:29:25it a storage provider and hit apply.
  6935. 4:29:27Um
  6936. 4:29:28it's important, I think, to call out on
  6937. 4:29:30change versus periodic because on change
  6938. 4:29:33by default will only store new values
  6939. 4:29:36when the value changes. That's kind of
  6940. 4:29:38like a memory optimization. But you can
  6941. 4:29:40tell it no matter what, I want uh it to
  6942. 4:29:43store at a certain periodic interval as
  6943. 4:29:46well. So, we'll leave it as on change.
  6944. 4:29:48I'm going to hit apply and okay. And so
  6945. 4:29:51now it should have history enabled. And
  6946. 4:29:53let's go to that web page and let's open
  6947. 4:29:56the tag browser and let's browse through
  6948. 4:29:58this uh to default and then sequence
  6949. 4:30:01tags and then sequence step and let's
  6950. 4:30:03add that selected tag here. So, if I
  6951. 4:30:06collapse the tag browser, what you can
  6952. 4:30:08hopefully see, although it might be hard
  6953. 4:30:10on the recording,
  6954. 4:30:12and we can click this X trace tool which
  6955. 4:30:14tells us the value.
  6956. 4:30:15We can see that sequence step is a
  6957. 4:30:18constant zero. And if I change my
  6958. 4:30:20real-time uh value to show the last 5
  6959. 4:30:23minutes and hit apply,
  6960. 4:30:26and you can always edit that here in the
  6961. 4:30:27set date range.
  6962. 4:30:29But if I show the last 5 minutes,
  6963. 4:30:32uh now let's go ahead and start that
  6964. 4:30:33sequence and I hit start and it should
  6965. 4:30:36go to step one. And you can see this
  6966. 4:30:38trend jumped right to one in real time.
  6967. 4:30:41Now it's waiting to see input eight
  6968. 4:30:42transition high. So, I'll go ahead and
  6969. 4:30:44turn on that hand switch. And you can
  6970. 4:30:46see it the value jumps up to two right
  6971. 4:30:49away. Now it hits our 5-second timer and
  6972. 4:30:52it jumps up to three. Now it's waiting
  6973. 4:30:54for the pushes to reach the set point.
  6974. 4:30:571 2 3 should jump up to five. And then
  6975. 4:31:01if I hit the stop button,
  6976. 4:31:04the sequence step goes back to zero. So,
  6977. 4:31:06it's really cool. You can see just right
  6978. 4:31:08there us stepping through the sequence.
  6979. 4:31:10So, if I were to go to
  6980. 4:31:12uh time set point 10 now and we did it
  6981. 4:31:15one more time, kind of as fast as we can
  6982. 4:31:18here, hit start, uh turn the set point
  6983. 4:31:21on,
  6984. 4:31:23and then it's going to take 10 seconds.
  6985. 4:31:27And then we count up to three.
  6986. 4:31:30And then we hit stop.
  6987. 4:31:34But what's cool is you can see between
  6988. 4:31:35those two runs, step two, which is the
  6989. 4:31:38time-based step, was 5 seconds here and
  6990. 4:31:40was 10 seconds here. And we can narrow
  6991. 4:31:43that window as well. We can say last 2
  6992. 4:31:45minutes and you get a more precise uh
  6993. 4:31:47you get a more precise graph going.
  6994. 4:31:49Okay, so that's going to do it for our
  6995. 4:31:50very basic introduction to the historian
  6996. 4:31:53because that is objectively the simpler
  6997. 4:31:55of the data tracking tools that we're
  6998. 4:31:57trying to cover today. Um kind of like I
  6999. 4:32:00said in the outset, when you just want
  7000. 4:32:02to see process data continuously over
  7001. 4:32:04time, a historian tool is great for that
  7002. 4:32:07and is plenty to do that. But when you
  7003. 4:32:09want to create a more um
  7004. 4:32:11a more, I guess, logical data story over
  7005. 4:32:14time and you want to tie what time I
  7006. 4:32:16started, what time I stopped with, you
  7007. 4:32:18know, what were these settings at that
  7008. 4:32:20time, who was doing that work, um that's
  7009. 4:32:23usually when you want to go to something
  7010. 4:32:24like a SQL database. And uh like I said,
  7011. 4:32:28we have a um SQLite already here in
  7012. 4:32:32Ignition. Again, if you're not using the
  7013. 4:32:34Ignition platform, I guarantee your
  7014. 4:32:36SCADA supports some way of interfacing
  7015. 4:32:38with a database like a SQL tool. Um you
  7016. 4:32:41just have to do a little reading on how
  7017. 4:32:42to connect insert name of your SCADA or
  7018. 4:32:45HMI platform to SQL and I guarantee
  7019. 4:32:48someone's done it. All right, so from
  7020. 4:32:50the Ignition designer, I'm going to go
  7021. 4:32:51ahead and go to the database query
  7022. 4:32:53browser. And I previously had um a
  7023. 4:32:57sequence data table I was testing. I'm
  7024. 4:33:00going to go ahead and delete that real
  7025. 4:33:01quick with this drop table command so
  7026. 4:33:03that we can rebuild it from scratch. So,
  7027. 4:33:05I had sequence data. I just deleted it
  7028. 4:33:07there. Um so you guys can follow the
  7029. 4:33:10exact steps that I do. So, I'm going to
  7030. 4:33:12kind of think about our sequence real
  7031. 4:33:14quick and the things that I would want
  7032. 4:33:16to add to capture how the sequence was
  7033. 4:33:18running. So, I would want to capture the
  7034. 4:33:21time it started. I'll call that start
  7035. 4:33:22time. I would want to capture end time.
  7036. 4:33:25I want to capture what the time delay
  7037. 4:33:26set point was and the count set point
  7038. 4:33:29were
  7039. 4:33:29um and then
  7040. 4:33:31potentially a username if someone was
  7041. 4:33:33logged in. Um and then maybe like a run
  7042. 4:33:36count, an ID that says, "Hey, this was
  7043. 4:33:38run 1 2 3 4 5 6." And it just keeps
  7044. 4:33:41incrementing up, okay? So, I don't have
  7045. 4:33:44all of those variables defined yet, but
  7046. 4:33:46I have many of them. We're not going to
  7047. 4:33:47worry about the tags existing yet. We're
  7048. 4:33:50going to make that table first. So,
  7049. 4:33:52let's go back into our tools and let's
  7050. 4:33:55go into our database query browser and
  7051. 4:33:57let's create a table in the query
  7052. 4:33:59browser that's going to have that data
  7053. 4:34:01that we want. So, to do this, we're
  7054. 4:34:02going to say create
  7055. 4:34:04table. And at this point, you guys have
  7056. 4:34:07probably seen Ignition can use Python in
  7057. 4:34:09some places. It has specific Ignition
  7058. 4:34:12syntax for certain things. This is SQL
  7059. 4:34:15syntax and in particular SQLite, but all
  7060. 4:34:18uh SQL is pretty similar if you know
  7061. 4:34:21what you're looking at. So, we're going
  7062. 4:34:22to create a table. We'll call it
  7063. 4:34:24sequence data and we'll expand these
  7064. 4:34:25parentheses out. And we'll have a field
  7065. 4:34:28called run count and we'll make that an
  7066. 4:34:30integer. And we'll make this the primary
  7067. 4:34:32key. So, you don't have to know about
  7068. 4:34:35keys and primary keys and stuff to build
  7069. 4:34:37a simple table. You don't have to
  7070. 4:34:39include that primary key bit. Um but if
  7071. 4:34:41you want something that is like uh
  7072. 4:34:44unique for a table, which would be a
  7073. 4:34:46primary key, you're saying, "Hey, run
  7074. 4:34:48can never repeat itself. If I already
  7075. 4:34:51did run one or run two or run three, I
  7076. 4:34:54can't have another run one or run two or
  7077. 4:34:56run three. That's going to corrupt my
  7078. 4:34:57data." So, you can make that a primary
  7079. 4:34:59key.
  7080. 4:35:01And then we'll have a username, which
  7081. 4:35:03we'll make a varchar 50. If you haven't
  7082. 4:35:05seen that format before, that's SQL's
  7083. 4:35:07way of saying it could be a string.
  7084. 4:35:09Varchar means variable character and you
  7085. 4:35:12can basically pass anything in there.
  7086. 4:35:15Okay. And then we'll say start date
  7087. 4:35:18time. And the reason I'm putting null at
  7088. 4:35:20the end is kind of SQL's format for
  7089. 4:35:23saying, "Do you want that field to be
  7090. 4:35:25able to be left empty or not?" Um and in
  7091. 4:35:28my case, I'm actually okay if any of
  7092. 4:35:31these fields get left empty except for
  7093. 4:35:33uh the run count because I'm sort of
  7094. 4:35:36just trying to prove out the function.
  7095. 4:35:38Uh but a lot of the times you might say,
  7096. 4:35:40"Hey, a row of data is going to be
  7097. 4:35:42useless if I don't have start time or
  7098. 4:35:44end time or a username." And in that
  7099. 4:35:46case, you would say not null.
  7100. 4:35:50Click count int null.
  7101. 4:35:52Okay. So, what I am doing right here
  7102. 4:35:54with this command is creating a table
  7103. 4:35:56that has an integer for run count, a
  7104. 4:35:59string variable character for username,
  7105. 4:36:02a date time parameter for start time and
  7106. 4:36:04end time, and then I'm going to store
  7107. 4:36:05the set points for time delay and click
  7108. 4:36:07count. And if I hit execute on this and
  7109. 4:36:10then I refresh my little browser over
  7110. 4:36:12here in the right, you can see sequence
  7111. 4:36:15data has those six columns. And a
  7112. 4:36:17statement that we'll use a few times is
  7113. 4:36:20I'm going to select all by using the
  7114. 4:36:21star from sequence data. Okay. And if I
  7115. 4:36:26hit execute, you can see nothing exists
  7116. 4:36:29in there. Um and that's actually what we
  7117. 4:36:31expect. We expect nothing because we
  7118. 4:36:33just made that table. So, we're going to
  7119. 4:36:35go ahead and close this.
  7120. 4:36:37Uh and what we're going to do next is
  7121. 4:36:38take a look at from Ignition, from our
  7122. 4:36:41sequence, how to uh store that data, how
  7123. 4:36:44to trigger um events in our Ignition
  7124. 4:36:47sequence that are going to write data to
  7125. 4:36:49SQL. And that'll give you an example of
  7126. 4:36:51how to store batch data out of a
  7127. 4:36:54sequence that you might have written in
  7128. 4:36:55the PLC and are monitoring from an HMI.
  7129. 4:36:58So, very cool interconnected automation
  7130. 4:37:00controls concepts going on here. And to
  7131. 4:37:02do this, we're going to add a few new
  7132. 4:37:04tags. So, we had our original Arduino
  7133. 4:37:06tags from our first example of tying
  7134. 4:37:08Arduino into Ignition. We had our
  7135. 4:37:10sequence tags from our additional
  7136. 4:37:11sequence. We're going to make a few new
  7137. 4:37:14tags um just so we can keep track of
  7138. 4:37:16when we added what. So, we're going to
  7139. 4:37:18make a new folder called SQL tags. I
  7140. 4:37:20accidentally added it inside that
  7141. 4:37:22folder. Let's go ahead and liberate it.
  7142. 4:37:25Um and we need to add a few new tags.
  7143. 4:37:27One of the first tags is going to be a
  7144. 4:37:30new standard tag. I'm going to make it a
  7145. 4:37:32memory tag and I'm just going to call it
  7146. 4:37:34run count.
  7147. 4:37:36Okay. Uh and we're going to leave it in
  7148. 4:37:38the default tag group. It's It's to be
  7149. 4:37:40memory. It's going to be integer, and to
  7150. 4:37:42start, it'll be a zero.
  7151. 4:37:45Okay, so the run count is going to be
  7152. 4:37:47that primary key that tells us how many
  7153. 4:37:49times we've run through this sequence,
  7154. 4:37:51and we're going to make a another new
  7155. 4:37:53tag.
  7156. 4:37:54Standard tag, memory tag, and this one
  7157. 4:37:57we'll call username.
  7158. 4:38:01Okay, so if you were going to log in,
  7159. 4:38:03you could store that info in a string
  7160. 4:38:05tag. Initially, we'll say it's Pete.
  7161. 4:38:07That sounds like a cool guy.
  7162. 4:38:11And then the last new tags that we have
  7163. 4:38:13to create are start time and end time.
  7164. 4:38:15So, I'm going to do new standard tag,
  7165. 4:38:18memory tag. This format is going to be
  7166. 4:38:21date time, and we'll call this start
  7167. 4:38:24time. And actually, getting a little bit
  7168. 4:38:27ahead of ourselves here, but I'm going
  7169. 4:38:28to only make start time, and we're not
  7170. 4:38:31going to need a tag for end time because
  7171. 4:38:33we're going to use the trigger event
  7172. 4:38:35that finishes the sequence as the time
  7173. 4:38:38to go do end time. Um
  7174. 4:38:41All right, so
  7175. 4:38:43There's There's just me adding the tags
  7176. 4:38:46that round out what we're going to write
  7177. 4:38:48to SQL because everything else already
  7178. 4:38:50existed. Let's capture the start time of
  7179. 4:38:53our sequence. So, when we click this
  7180. 4:38:55button
  7181. 4:38:56for start and we're in step zero, that's
  7182. 4:38:59when we go from step zero to step one.
  7183. 4:39:02So, I'm going to click on the sequence
  7184. 4:39:03step tag, and I'm going to go to
  7185. 4:39:05scripting, and I'm going to go to value
  7186. 4:39:07change, and I'm going to add a little if
  7187. 4:39:10current value.value
  7188. 4:39:14is equal to one and
  7189. 4:39:18previous value.value
  7190. 4:39:21was equal to zero. So, here I'm taking
  7191. 4:39:24advantage of the tag change event, which
  7192. 4:39:26has current value and previous value as
  7193. 4:39:29parameters of the event. And
  7194. 4:39:31technically, the sequence only ever goes
  7195. 4:39:33to step one from step zero. So, this is
  7196. 4:39:35kind of an over-engineered statement,
  7197. 4:39:37but we're going to leave it, and I'm
  7198. 4:39:39going to say okay. That means someone
  7199. 4:39:41just started up the sequence. So, I'm
  7200. 4:39:43going to do system.tag.write
  7201. 4:39:47blocking
  7202. 4:39:48which is the
  7203. 4:39:50Ignition syntax for writing a value to a
  7204. 4:39:52table.
  7205. 4:39:53And I'm going to copy the path for that
  7206. 4:39:55start time tag that I just made. Copy
  7207. 4:39:57path. And I'm going to paste that path
  7208. 4:40:00in here, and then I'm just going to say
  7209. 4:40:03use system.date.now. Okay, so this is
  7210. 4:40:05Ignition's like system-formatted.
  7211. 4:40:07Go grab a timestamp
  7212. 4:40:11of what my computer says it currently
  7213. 4:40:13is, and store that in a tag. And I'm
  7214. 4:40:15going to hit apply, and I'm going to hit
  7215. 4:40:17okay, and I'm going to hit save. And
  7216. 4:40:20now, we're going to go back here, and
  7217. 4:40:22we're going to hit start real quick.
  7218. 4:40:24And now, we're in step one. And if we go
  7219. 4:40:27back into the designer, now we can see
  7220. 4:40:30we have, you know, August 12th at 10:17
  7221. 4:40:33p.m. stored in start time. So, that's
  7222. 4:40:36cool. That tells us that our script
  7223. 4:40:38worked. Now, we've got the time
  7224. 4:40:39capturing into start time, which is very
  7225. 4:40:42cool.
  7226. 4:40:43But to actually write to SQL, we need to
  7227. 4:40:45hit a database, which is technically a
  7228. 4:40:47gateway
  7229. 4:40:49scoped thing. So, we're going to go to
  7230. 4:40:51gateway tag change events, and we're
  7231. 4:40:53going to go to tag change, and we're
  7232. 4:40:55going to create new event, and we're
  7233. 4:40:56going to call it
  7234. 4:40:58write to SQL. But basically, we're going
  7235. 4:41:01to say when that sequence step tag
  7236. 4:41:03changes, when the value specifically
  7237. 4:41:06changes, so not the quality, not the
  7238. 4:41:08timestamp, but the value of that tag
  7239. 4:41:10changes, we're going to trigger this
  7240. 4:41:11write to SQL script. But we don't want
  7241. 4:41:15to trigger that script every time the
  7242. 4:41:17value changes, only when it resets. So,
  7243. 4:41:20we're going to start by doing
  7244. 4:41:21system.tag.
  7245. 4:41:24read
  7246. 4:41:26blocking on that sequence step, and then
  7247. 4:41:30square bracket zero.value. That's just a
  7248. 4:41:33little Ignition-specific syntax for how
  7249. 4:41:35to read the value out of a tag. And
  7250. 4:41:37we're specifically going to say if value
  7251. 4:41:39equals zero.
  7252. 4:41:41Because value equaling zero means that
  7253. 4:41:44the sequence has just reset. This is an
  7254. 4:41:46on change on tag change event script.
  7255. 4:41:50So, the tag is only changing to zero
  7256. 4:41:53when someone hits stop because it was in
  7257. 4:41:55sequence step five. So, that's when
  7258. 4:41:57we're actually going to trigger write
  7259. 4:41:59data to SQL. Now, all we really need to
  7260. 4:42:02do is we need to go out and read all
  7261. 4:42:06tags that have SQL data, and then we're
  7262. 4:42:09going to do a section of define the SQL
  7263. 4:42:14query and
  7264. 4:42:17arguments.
  7265. 4:42:19And then we're going to call
  7266. 4:42:22the SQL query and increment the counter.
  7267. 4:42:26So, if you remember, we have like a
  7268. 4:42:27counter variable. It's currently at
  7269. 4:42:29zero, and we're going to increment that
  7270. 4:42:31every time we do a new run. Okay, so
  7271. 4:42:33these are kind of the three sections we
  7272. 4:42:35have to create in this script, and it's
  7273. 4:42:37immediately hopefully sort of apparent
  7274. 4:42:40why you don't want to do this just on a
  7275. 4:42:42tag change script. It's a little bit
  7276. 4:42:44easier with gateway events to keep
  7277. 4:42:47revision control and sight on things
  7278. 4:42:49like that. So, we're going to read all
  7279. 4:42:51the tags that have SQL data. And if we
  7280. 4:42:53remember our table, we want to start
  7281. 4:42:55with start time, and I'm going to try to
  7282. 4:42:57keep the convention. Going to try to
  7283. 4:42:59keep the convention of first letter
  7284. 4:43:03lower case, and then all following
  7285. 4:43:05words. What is that called? Snake case,
  7286. 4:43:07I think, or camel case. I get the two
  7287. 4:43:09backwards. Okay, in any case, we need
  7288. 4:43:11start time, we need end time, we need
  7289. 4:43:13the username, we need the count set
  7290. 4:43:16point, we need the time
  7291. 4:43:19delay set point.
  7292. 4:43:22And we need the
  7293. 4:43:24run count, that unique parameter. So, we
  7294. 4:43:27need to read all these tags. I'm going
  7295. 4:43:29to steal this system.tag.readBlocking
  7296. 4:43:32command here.
  7297. 4:43:35And I'm going to just replace the tag.
  7298. 4:43:37So, start time is going to be that start
  7299. 4:43:40time tag. Copy path.
  7300. 4:43:43And paste it in here instead. And then
  7301. 4:43:46actually, that isn't what we want it to
  7302. 4:43:49be for end time. We want
  7303. 4:43:50system.date.now.
  7304. 4:43:53No, system.time.now.
  7305. 4:43:56Um No, system.date.now. Come on, Pete.
  7306. 4:43:59Getting tired.
  7307. 4:44:01So, we want system.date.now
  7308. 4:44:03for end time, and then for the username,
  7309. 4:44:06that's going to be
  7310. 4:44:07We're going to copy this line and look
  7311. 4:44:10at
  7312. 4:44:11username instead of start time. So,
  7313. 4:44:14we're just going to update this bit
  7314. 4:44:16to username.
  7315. 4:44:18And to write the Basically, all we're
  7316. 4:44:21trying to do, just to be super clear, is
  7317. 4:44:23that when we write a SQL query, we need
  7318. 4:44:25to pass in all of the data we want
  7319. 4:44:27stored in SQL. So, within our script, we
  7320. 4:44:30have to go out and grab the data that we
  7321. 4:44:31want to read. You can read all of these
  7322. 4:44:34tags in one line of code. I think it's a
  7323. 4:44:36little easier for beginners to see it
  7324. 4:44:38broken out this way. So, let's go ahead
  7325. 4:44:40and say
  7326. 4:44:42run count is this just
  7327. 4:44:45run count like that. And then time delay
  7328. 4:44:48set point is actually copy path.
  7329. 4:44:52And a little bit of a different
  7330. 4:44:53location. So, we'll copy that one. And
  7331. 4:44:57then count set point is right next to
  7332. 4:44:59time delay set point, but it's called
  7333. 4:45:02HMI_
  7334. 4:45:05count SP. Okay.
  7335. 4:45:08So, that should give us the six fields
  7336. 4:45:10that we want to write into SQL.
  7337. 4:45:13One thing that is worth calling out. So,
  7338. 4:45:15we've got start time. We're actually
  7339. 4:45:17going to format start time here. We're
  7340. 4:45:19going to use a command called
  7341. 4:45:20system.date.format
  7342. 4:45:23because the Ignition date and what MySQL
  7343. 4:45:27or SQLite uses are slightly different.
  7344. 4:45:30So, we're going to take that start time,
  7345. 4:45:33and we're going to explicitly tell it to
  7346. 4:45:34be four-digit year with YYYY, two-digit
  7347. 4:45:38month two-digit day, and then two-digit
  7348. 4:45:42hour, two-digit minute, and then
  7349. 4:45:45two-digit second. So, we're explicitly
  7350. 4:45:48defining a date format because SQL will
  7351. 4:45:50throw an alarm
  7352. 4:45:52throw an error if it uses the exact
  7353. 4:45:55Ignition format. So, we're going to make
  7354. 4:45:56this new variable start and end instead
  7355. 4:45:59of start time and end time, and they're
  7356. 4:46:01just going to have the transform data.
  7357. 4:46:03You can do system.date.format
  7358. 4:46:06and system.tag.readBlocking on the same
  7359. 4:46:08line. I think it's easier to split it
  7360. 4:46:10out this way, especially for beginners.
  7361. 4:46:12But if you look at this tag
  7362. 4:46:15and if you were to see that printed,
  7363. 4:46:17it's got p.m. on it, and it can also,
  7364. 4:46:20depending on the Ignition statement, it
  7365. 4:46:22can sometimes have the date, too. Like
  7366. 4:46:24it'll say Monday, the whatever.
  7367. 4:46:27So, this is just us explicitly calling
  7368. 4:46:29out a format that we know SQL will
  7369. 4:46:31support. Okay, so we've got all of the
  7370. 4:46:35We've got all of the raw data we need.
  7371. 4:46:37Now, we're going to define a query. And
  7372. 4:46:40this is a cool thing about Ignition. You
  7373. 4:46:41can just write simple queries in a
  7374. 4:46:44string of text. This is true of Python
  7375. 4:46:46as well, if you're if you're a bit of a
  7376. 4:46:48Python programmer. We can just type in
  7377. 4:46:51insert into
  7378. 4:46:52sequence data, and we can say username
  7379. 4:46:56username. Let's go real quick to the
  7380. 4:46:59database browser, query browser, and
  7381. 4:47:01make sure I get all these column names
  7382. 4:47:03right. Oops. Where'd they go?
  7383. 4:47:06Um Yeah, so we've got run count. I'm
  7384. 4:47:10just going to take a snip of this real
  7385. 4:47:12quick. Run count. No, I'm going to leave
  7386. 4:47:13it up the whole time, even better.
  7387. 4:47:15Gateway events. Okay.
  7388. 4:47:17So, we want username
  7389. 4:47:21like that. So, this is case-sensitive,
  7390. 4:47:24which is the main reason I'm being extra
  7391. 4:47:25careful about this. Oh, where'd my
  7392. 4:47:27gateway event go?
  7393. 4:47:30And we're going to insert using Now, the
  7394. 4:47:31order also doesn't really matter. It's
  7395. 4:47:34okay that we
  7396. 4:47:35grabbed the
  7397. 4:47:37grabbed the order in a different
  7398. 4:47:40grabbed these raw tags in a different
  7399. 4:47:42order than I'm defining them right here.
  7400. 4:47:45Click count.
  7401. 4:47:47What else did we have? Let's just finish
  7402. 4:47:49typing these in so that then I can talk.
  7403. 4:47:52Time delay.
  7404. 4:47:53Start
  7405. 4:47:55time and end time. Okay, what I was
  7406. 4:47:58trying to say is it's okay that these
  7407. 4:48:00are in different orders because then we
  7408. 4:48:02say the values are going to be
  7409. 4:48:06parameters that we pass in so that we do
  7410. 4:48:08that with these question marks. So there
  7411. 4:48:09should be six parameters that we're
  7412. 4:48:11passing in.
  7413. 4:48:13So our sequence our SQL statement is
  7414. 4:48:16just saying we're going to insert values
  7415. 4:48:18into those six columns
  7416. 4:48:20and the values are things we're going to
  7417. 4:48:22pass in. They're going to be arguments.
  7418. 4:48:24So args is equal to and then a square
  7419. 4:48:26bracket.
  7420. 4:48:28And here I'm going to do a little type
  7421. 4:48:30casting. I'm going to
  7422. 4:48:31say okay string username. It's never a
  7423. 4:48:35bad idea even if you're pretty sure it's
  7424. 4:48:37already the right format to explicitly
  7425. 4:48:40make sure that it gets defined as the
  7426. 4:48:42right format. So like
  7427. 4:48:44run count needs to be an integer for it
  7428. 4:48:47to work.
  7429. 4:48:49Click count same deal which what do we
  7430. 4:48:51call click count? Count set point.
  7431. 4:48:54Count set point
  7432. 4:48:57and then we have the time delay set
  7433. 4:48:59point. Same thing that needs to be an
  7434. 4:49:01integer time delay SP.
  7435. 4:49:05And then we have our start time and our
  7436. 4:49:07end time. And actually for
  7437. 4:49:10another just my SQL light thing that I'm
  7438. 4:49:14sharing with you all is that casting it
  7439. 4:49:16to a string in the correct format is the
  7440. 4:49:20best way to ensure that it gets stored
  7441. 4:49:22in SQL light appropriately. So there's a
  7442. 4:49:24little bit of just knowing how to play
  7443. 4:49:26the game here. But basically what we've
  7444. 4:49:28done is we've said username run count
  7445. 4:49:30click count time delay start time end
  7446. 4:49:32time are going to be passed in as six
  7447. 4:49:34parameters. That's what the question
  7448. 4:49:35marks mean and then this order is very
  7449. 4:49:38important. These need to correlate to
  7450. 4:49:40the column order that you just did. So
  7451. 4:49:42it needs to be username run count click
  7452. 4:49:44count time delay start time end time.
  7453. 4:49:48Um
  7454. 4:49:48Now there's only two lines of code left
  7455. 4:49:50and then we're done.
  7456. 4:49:52We want to do system.db.
  7457. 4:49:55run
  7458. 4:49:57prep
  7459. 4:49:58update and we're going to pass in the
  7460. 4:50:00query and we're going to pass in the
  7461. 4:50:02arguments.
  7462. 4:50:03And then I'm going to delete out all the
  7463. 4:50:05other auto-generated stuff.
  7464. 4:50:06system.db.run prep update query and the
  7465. 4:50:09arguments. And then the last thing I
  7466. 4:50:11want to do which will also show us when
  7467. 4:50:13we run it that it's working is I want to
  7468. 4:50:15do system.tag.writeBlocking
  7469. 4:50:18and I want to write to the
  7470. 4:50:21uh
  7471. 4:50:22count set point. No, run count. I want
  7472. 4:50:25to write to this tag.
  7473. 4:50:29Write to this tag
  7474. 4:50:32a value of
  7475. 4:50:34run count plus one. Okay, so this is me
  7476. 4:50:39saying hey at the very end of logging
  7477. 4:50:41data to SQL I want to increment the run
  7478. 4:50:43count parameter by one. Okay? So we're
  7479. 4:50:47going to go ahead and hit save and to
  7480. 4:50:49see if it's working we're going to go
  7481. 4:50:51ahead and run through the sequence. So
  7482. 4:50:53all right, let's count up 1 2 3.
  7483. 4:50:56Now it's in step four. Let's go ahead
  7484. 4:50:59and hit stop. Okay? Now it's idle it's
  7485. 4:51:03ready to go again. Let's go ahead and go
  7486. 4:51:05back to the designer and you can see run
  7487. 4:51:07count is one. So if you weren't looking
  7488. 4:51:09before
  7489. 4:51:10it was zero. To make sure that it
  7490. 4:51:12actually got to SQL we'll go to tools
  7491. 4:51:15we'll go to query browser and again
  7492. 4:51:17we'll go ahead and select all from
  7493. 4:51:19sequence data like we did before. Hit
  7494. 4:51:21execute and that's pretty cool. Now we
  7495. 4:51:23have run count username Pete start time
  7496. 4:51:26end time look accurate. I had a pretty
  7497. 4:51:29big break between when we started and
  7498. 4:51:31now.
  7499. 4:51:32The time delay set point and the click
  7500. 4:51:34count. Okay? So let's go ahead and go
  7501. 4:51:36back there one more time. Let's say now
  7502. 4:51:38the count set point is only going to be
  7503. 4:51:39two but our time delay is going to be
  7504. 4:51:41five seconds and in the designer you
  7505. 4:51:45could make it a label on the field but
  7506. 4:51:47in the designer I'm just going to change
  7507. 4:51:49the username from Pete to Peter.
  7508. 4:51:52And let's go ahead and start this thing
  7509. 4:51:54again. So start
  7510. 4:51:56and waiting to see him put eight. There
  7511. 4:51:58we go.
  7512. 4:52:00Time set point count up to five.
  7513. 4:52:03Count set point count up to two.
  7514. 4:52:06And press stop.
  7515. 4:52:08Okay? So back to designer we go.
  7516. 4:52:12And now we can see run count is up to
  7517. 4:52:14two. We go ahead and we go to the query
  7518. 4:52:16browser and we search again. We have two
  7519. 4:52:18entries. So one last thing because it's
  7520. 4:52:21nice to tie it back into a visualization
  7521. 4:52:23in SQL tags we're going to add a new tag
  7522. 4:52:25and a new standard tag and a query tag
  7523. 4:52:28and we're just going to say SQL results.
  7524. 4:52:31I'm trying to go pretty fast now because
  7525. 4:52:33I know how long this tutorial's gotten
  7526. 4:52:35and we're going to make this a query
  7527. 4:52:37tag. We're going to make it a data set.
  7528. 4:52:41Data set I know you're in here.
  7529. 4:52:44There it is.
  7530. 4:52:45And we're going to just make it
  7531. 4:52:48every let's say 10 seconds. No, five
  7532. 4:52:51seconds. What the heck? It's
  7533. 4:52:53not doing much.
  7534. 4:52:55We're going to make a query that is just
  7535. 4:52:57going to be select all from
  7536. 4:53:01sequence data just like we've been
  7537. 4:53:04running. And the data source is going to
  7538. 4:53:06be our SQL light database. I'm going to
  7539. 4:53:08hit apply.
  7540. 4:53:09And now I'm going to drag that SQL
  7541. 4:53:11results onto the screen and I'm going to
  7542. 4:53:12make it a table.
  7543. 4:53:14And one Ignition thing I've seen a lot
  7544. 4:53:17of forums a lot of people are like why
  7545. 4:53:18do my dates
  7546. 4:53:20look jacked up? This is just a little
  7547. 4:53:22bonus lesson for you. When you have a
  7548. 4:53:24table
  7549. 4:53:25you need to explicitly define the
  7550. 4:53:27columns are date time to get the date
  7551. 4:53:30and time to look correct. So if we go to
  7552. 4:53:33columns in the table
  7553. 4:53:35and we add
  7554. 4:53:37array elements and we say 1 2 3 4 5 and
  7555. 4:53:406 we can go to
  7556. 4:53:43two and three which in this case are
  7557. 4:53:45start time and end time and we can say
  7558. 4:53:47start time
  7559. 4:53:49and then you come down to date format
  7560. 4:53:51date time and there you go start time
  7561. 4:53:53looks good. We can do the same thing go
  7562. 4:53:55to three
  7563. 4:53:56end time. This very much is a tidbit of
  7564. 4:54:00useful if you're working in Ignition. No
  7565. 4:54:03other SCADA that I've seen has this like
  7566. 4:54:05explicitly needing to define dates and
  7567. 4:54:07times. We're not going to worry about
  7568. 4:54:09that. We have a table on the screen.
  7569. 4:54:11Let's go ahead and run it one more time
  7570. 4:54:12so you you guys can see this power of
  7571. 4:54:15live updating. So we're going to start
  7572. 4:54:17it again. Let's change this to six and
  7573. 4:54:20this to four
  7574. 4:54:21and transition the hand switch.
  7575. 4:54:24We've got to wait six seconds. So we
  7576. 4:54:26should have one now that shows starting
  7577. 4:54:28after this 2303. 1 2 3 4.
  7578. 4:54:33And push stop.
  7579. 4:54:35And within five seconds this table here
  7580. 4:54:37should update. There it goes way less
  7581. 4:54:39than five seconds. New start time new
  7582. 4:54:41end time new time delay new click count.
  7583. 4:54:43Okay, so we've seen just in a couple
  7584. 4:54:46minutes we've seen how quick and easy it
  7585. 4:54:48is with a good SCADA software to be able
  7586. 4:54:51to monitor live data. This also this
  7587. 4:54:54same tool can go back in history pretty
  7588. 4:54:57far so you can look at days or weeks
  7589. 4:54:59past as long as your computer's
  7590. 4:55:01retaining it
  7591. 4:55:02and you can look at continuous trending
  7592. 4:55:04data like that. You can look at SQL data
  7593. 4:55:06like that.
  7594. 4:55:09Far and away historian and SQL are the
  7595. 4:55:11two most powerful data analysis tools
  7596. 4:55:14for automation and controls engineers to
  7597. 4:55:16get familiar with.
  7598. 4:55:17So I hope you found this to be a useful
  7599. 4:55:19introduction. I hope you have found the
  7600. 4:55:21introduction to the automation and
  7601. 4:55:23controls tutorial series if you've been
  7602. 4:55:25following the whole series to be super
  7603. 4:55:27useful. We've covered the majority of
  7604. 4:55:29the basics to the point where you should
  7605. 4:55:31at least understand the major fields
  7606. 4:55:34that we're addressing. So as always if
  7607. 4:55:36you have any questions about what you
  7608. 4:55:38saw in this video today or things you'd
  7609. 4:55:40like to see in the future on the channel
  7610. 4:55:42be sure to let me know about them in the
  7611. 4:55:43comments below. Thank you so much for
  7612. 4:55:45watching and we'll see you next time.
  7613. 4:55:47Thanks. Bye.
  7614. 4:55:54Welcome back to The Master Tech and in
  7615. 4:55:55today's video we are going to continue
  7616. 4:55:57our series on industrial automation and
  7617. 4:56:00controls tutorials with a quick but
  7618. 4:56:02super important and useful concept which
  7619. 4:56:05is adding IO expansion modules. So with
  7620. 4:56:07pretty much any PLC manufacturer
  7621. 4:56:10Allen-Bradley Rockwell Siemens Arduino
  7622. 4:56:14you're going to run out of input and
  7623. 4:56:16output channels with whatever came on
  7624. 4:56:19board the PLC module itself. In fact
  7625. 4:56:21some of the high-end Siemens and
  7626. 4:56:23Allen-Bradley PLCs are just CPU modules.
  7627. 4:56:26They're just brains and they don't have
  7628. 4:56:28any IO on board. So you design a project
  7629. 4:56:31and automation system for a certain
  7630. 4:56:33number of inputs and outputs and you
  7631. 4:56:36need to be able to add IO modules to
  7632. 4:56:38those PLCs.
  7633. 4:56:40So the Arduino Opta line is a pretty new
  7634. 4:56:43line. They only have three expansion
  7635. 4:56:45modules that they offer right now but it
  7636. 4:56:47covers all of the basics. They have two
  7637. 4:56:49different versions of input and output
  7638. 4:56:51digital input and output cards. One that
  7639. 4:56:54has electromagnetic relays and one that
  7640. 4:56:56has solid state relays. And then they
  7641. 4:56:58have a little bit of a grab bag card
  7642. 4:57:00that has pulse width modulation outputs
  7643. 4:57:02analog inputs analog outputs as well as
  7644. 4:57:04a few conventional input and output
  7645. 4:57:06channels as well. But the important
  7646. 4:57:09thing is you design an overall system.
  7647. 4:57:11You make like an IO list of the total
  7648. 4:57:13inputs and outputs that you're going to
  7649. 4:57:15have and you need to be able to add
  7650. 4:57:17these modules to your PLC. So we've been
  7651. 4:57:19doing this tutorial series with the
  7652. 4:57:21Arduino Opta PLC so we're going to
  7653. 4:57:23continue using that in today's video.
  7654. 4:57:25Whatever PLC and system you have just
  7655. 4:57:28know that your manufacturer should
  7656. 4:57:31provide all sorts of recommendations for
  7657. 4:57:33cards that support digital inputs,
  7658. 4:57:36digital outputs, analog in, analog out,
  7659. 4:57:38IO-Link, Profinet, high-speed counter.
  7660. 4:57:41There's so many different variations on
  7661. 4:57:43inputs and outputs, RTDs and
  7662. 4:57:45thermocouples. You just need to look up
  7663. 4:57:47the card that's compatible with your
  7664. 4:57:49PLC. Or you're following along with this
  7665. 4:57:51Arduino Opta series,
  7666. 4:57:53and I'll leave all of the cards that I'm
  7667. 4:57:54using linked in the description below
  7668. 4:57:56this video if you want to follow along
  7669. 4:57:58exactly. So that we start from exactly
  7670. 4:58:00the same spot, just make a new project
  7671. 4:58:02for this tutorial and I'll call it IO
  7672. 4:58:04add-ons,
  7673. 4:58:06and I'll just make a brand new project.
  7674. 4:58:09And then in terms of my physical setup
  7675. 4:58:11right now, all I have is the Arduino
  7676. 4:58:13Opta PLC plugged in via USB-C cable to
  7677. 4:58:16my laptop and then plugged in to a 12-V
  7678. 4:58:19power supply
  7679. 4:58:21for DC power. So that is the total
  7680. 4:58:23physical wiring. There's no cards
  7681. 4:58:25clamped on there yet. I have them just
  7682. 4:58:27sitting here waiting to be hooked up.
  7683. 4:58:29But so we have a brand new project,
  7684. 4:58:31nothing going on. I'm going to go ahead
  7685. 4:58:33and onboard the file system just like
  7686. 4:58:35you do first time with any PLC so we can
  7687. 4:58:37really start from scratch together. I
  7688. 4:58:39mean that takes a little time, but it
  7689. 4:58:40looks like it works. So if we just go
  7690. 4:58:43into our LED outputs real quick and we
  7691. 4:58:45just give ourselves
  7692. 4:58:47like L1, L2, L3, and L4 variables real
  7693. 4:58:52quick as well as let's just say, you
  7694. 4:58:55know, red,
  7695. 4:58:56green, and blue. And then let's grab
  7696. 4:58:58that user button input and let's call it
  7697. 4:59:02user so we can program with those
  7698. 4:59:04variables now. Hopefully you've been
  7699. 4:59:05following this series and that's all
  7700. 4:59:07pretty familiar to you.
  7701. 4:59:09And we have this count program. Let's
  7702. 4:59:11just go ahead and say that we want green
  7703. 4:59:13to be on and we want blue to be equal to
  7704. 4:59:16the user. This is just kind of like a
  7705. 4:59:18great one-two line to make sure that PLC
  7706. 4:59:22is actually working when you connect to
  7707. 4:59:24it and then download to it. So we
  7708. 4:59:26connect, it says no code, that's good
  7709. 4:59:28cuz it's the first boot up, so there is
  7710. 4:59:31no code running on there. And we're
  7711. 4:59:33going to go ahead and just send this and
  7712. 4:59:34hopefully it compiles okay, downloads
  7713. 4:59:36okay, and then we'll get the green light
  7714. 4:59:38turning on, and then the blue light will
  7715. 4:59:40turn on and off as we push the user push
  7716. 4:59:43button in. That means our PLC is all
  7717. 4:59:45rocked and rolling and ready to go.
  7718. 4:59:48It'll ask you to restart, go ahead and
  7719. 4:59:49hit yes. Target reboot, shouldn't take
  7720. 4:59:53too long.
  7721. 4:59:54Okay, and it does look like it worked.
  7722. 4:59:56The bottom right says source okay and
  7723. 4:59:57connected. If I come in here and turn on
  7724. 5:00:00live debug mode, I can see the count
  7725. 5:00:02counting up, which is good. I'll grab a
  7726. 5:00:04video real quick here of the front of
  7727. 5:00:06the Opta. So the green light's on and as
  7728. 5:00:09I push the user push button in, I get
  7729. 5:00:11the blue light. So that's great. It's
  7730. 5:00:13online and we're communicating with it.
  7731. 5:00:16We've been in this point a few times
  7732. 5:00:18before, that's not really the new
  7733. 5:00:19content for the video. But this is where
  7734. 5:00:22we're going to start from because now
  7735. 5:00:23it's time to now it's time to add those
  7736. 5:00:26IO expansion modules. And the wiring and
  7737. 5:00:30the IDE, the PLC software side of things
  7738. 5:00:33are both really simple, but it's easiest
  7739. 5:00:35to just do them one at a time. So let's
  7740. 5:00:37go ahead and take a look at the wiring
  7741. 5:00:39really quickly and then we'll look at
  7742. 5:00:41the IDE side really quickly. Now the
  7743. 5:00:43wiring required to get one of these
  7744. 5:00:46expansion modules, again there are three
  7745. 5:00:48and they all look very similar to the
  7746. 5:00:50body of the PLC because they all clip
  7747. 5:00:53into the same chassis.
  7748. 5:00:55It's very simple for wiring. They just
  7749. 5:00:57need their own power feed, which you can
  7750. 5:01:00daisy chain off of the PLC or the card
  7751. 5:01:02right next to it, or you can give it
  7752. 5:01:04dedicated 12-V power.
  7753. 5:01:07But then they have these little slots in
  7754. 5:01:09the side. The PLC has that same slot
  7755. 5:01:11right there. And they need these little
  7756. 5:01:1310-prong I squared C communicators.
  7757. 5:01:16Whoop, I dropped that one. Okay, well
  7758. 5:01:18there's one right here. They need these
  7759. 5:01:20little communicators and they just clip
  7760. 5:01:22in right next to each other, and that's
  7761. 5:01:24how they communicate card to card. And
  7762. 5:01:26we'll see in the IDE once we get these
  7763. 5:01:28clipped in
  7764. 5:01:30that the PLC actually knows what cards
  7765. 5:01:32it's plugged into because of those
  7766. 5:01:34little communication tabs. So that's all
  7767. 5:01:36we have to do is get the power hooked up
  7768. 5:01:38and then get these clipped in together.
  7769. 5:01:39So I'll go ahead and do that now and
  7770. 5:01:41we'll go back to the software side.
  7771. 5:01:43Okay, so I've got them powered up. I've
  7772. 5:01:46got them hooked up to power and I've got
  7773. 5:01:48them communicating down the line, which
  7774. 5:01:51is great. But you can see the lights are
  7775. 5:01:53kind of doing their own thing. Green for
  7776. 5:01:55power is good, definitely means they're
  7777. 5:01:57connected, but the PLC is throwing an
  7778. 5:01:59error because it doesn't know what to do
  7779. 5:02:01with these cards cuz we haven't told it
  7780. 5:02:03what to do from the software yet. So the
  7781. 5:02:05physical wiring very simple to connect
  7782. 5:02:07them. Now we have to look at what to do
  7783. 5:02:09in the PLC IDE to connect them. So if we
  7784. 5:02:12come back into the PLC IDE and we try to
  7785. 5:02:14connect to it,
  7786. 5:02:16well we'll see that because I unplugged
  7787. 5:02:17it.
  7788. 5:02:19Now that we're plugged in, if I just try
  7789. 5:02:20to connect to it again, I'm going to get
  7790. 5:02:22errors
  7791. 5:02:23because it's not in a running state
  7792. 5:02:25because the IO configuration has
  7793. 5:02:27changed. So the PLC has thrown an error.
  7794. 5:02:30If I go to IO expansions and I hit scan,
  7795. 5:02:33this is really cool. It's going to say,
  7796. 5:02:35"Hey, the configuration's not matching."
  7797. 5:02:37And it's going to say, "Hey, I have
  7798. 5:02:38these cards here. Do you want to add
  7799. 5:02:40them?" And I can just hit apply detect
  7800. 5:02:42config. If you hit scan and they're not
  7801. 5:02:45detected, you should double-check your
  7802. 5:02:47wiring because something is probably
  7803. 5:02:49wrong with the physical wiring. But if
  7804. 5:02:51you're sure the wiring is correct, or if
  7805. 5:02:53you're trying to set one of these up
  7806. 5:02:54ahead of time, you can always add a card
  7807. 5:02:56just by right-clicking on IO expansions
  7808. 5:02:59and hit add,
  7809. 5:03:01and you can select the cards and you can
  7810. 5:03:04add them to your project manually. But
  7811. 5:03:06it's a lot easier to scan and then say,
  7812. 5:03:08"Okay, apply the detected config." And
  7813. 5:03:10then it adds the cards as well as all
  7814. 5:03:12the programmable inputs and outputs that
  7815. 5:03:14you can use for those cards. So if we
  7816. 5:03:17take two of the LED channels
  7817. 5:03:19on the first card and we just say
  7818. 5:03:21that'll be light 11, that'll be light
  7819. 5:03:2412. And then I take the relay outputs on
  7820. 5:03:27the second card and I say that'll be
  7821. 5:03:29output 21 and that'll be output 22.
  7822. 5:03:32We'll use those two lights on those two
  7823. 5:03:34cards to do a little bit of programming
  7824. 5:03:37with, okay? So I'm going to go ahead and
  7825. 5:03:39hit save and then I'm going to try to
  7826. 5:03:41download this now that it has these
  7827. 5:03:43cards on it.
  7828. 5:03:44Well, first let's go to the program and
  7829. 5:03:46let's do something.
  7830. 5:03:49Let's say that we also want we just want
  7831. 5:03:52light 11 to be on all of the time and we
  7832. 5:03:57want light 12 to be on when the user
  7833. 5:04:01push button is pressed as well. And then
  7834. 5:04:03let's say the opposite
  7835. 5:04:06for
  7836. 5:04:07the second card. Let's say we want
  7837. 5:04:09output two on all the time and then the
  7838. 5:04:12light for one to come on when the user
  7839. 5:04:14push button is pressed. Okay, so this
  7840. 5:04:17should compile unless I missed
  7841. 5:04:19something, which is possible.
  7842. 5:04:22Build, looks fine. Now let's go ahead
  7843. 5:04:24and download.
  7844. 5:04:25Download, yes. It's okay that it's going
  7845. 5:04:28to want to restart.
  7846. 5:04:29Restarted pretty quick, but there's no
  7847. 5:04:32lights on because the PLC is not
  7848. 5:04:34running, that's an important clue. You
  7849. 5:04:36can go ahead and hit cold restart here,
  7850. 5:04:38the blue circle there, and hit yes. And
  7851. 5:04:41that's cool. That's best-case scenario
  7852. 5:04:44for sure. It's normal to need to power
  7853. 5:04:46cycle at this point. Stuff goes goofy
  7854. 5:04:48sometimes,
  7855. 5:04:49but I have now
  7856. 5:04:51one LED on both of the expansion
  7857. 5:04:54modules. And if I push the push button
  7858. 5:04:57in, you can see the other LED on both
  7859. 5:05:00cards turns on with the blue LED on the
  7860. 5:05:03Opta itself. So that is proof that the
  7861. 5:05:05cards are talking to each other and that
  7862. 5:05:07I can program any input or output
  7863. 5:05:09channels for any of these cards from the
  7864. 5:05:12PLC now and I've got all the
  7865. 5:05:14communication. Okay, so at this point
  7866. 5:05:17you should understand how to get
  7867. 5:05:19expansion modules added to your PLC.
  7868. 5:05:21Like I said in the beginning, they're
  7869. 5:05:23not all this straightforward for all PLC
  7870. 5:05:25manufacturers out there. But Arduino has
  7871. 5:05:28made it really easy to add their
  7872. 5:05:29expansion modules. And it is generally
  7873. 5:05:32the same steps of set the network
  7874. 5:05:34parameters, connect them to your
  7875. 5:05:36network, and then discover them in your
  7876. 5:05:38PLC IDE or related software. Like with
  7877. 5:05:42Siemens, they have TIA Portal, but they
  7878. 5:05:44also have a software called Proneto
  7879. 5:05:46where you can discover and set up
  7880. 5:05:48network parameters for Profinet devices.
  7881. 5:05:51RSLogix, they have Studio 5000, which is
  7882. 5:05:53this integrated software, but they've
  7883. 5:05:55always had this RX RSLinks software
  7884. 5:05:58where you can see network devices and
  7885. 5:06:01you can see remote IO and things like
  7886. 5:06:03that. So there's definitely some
  7887. 5:06:05industry knowledge. It's hard to become
  7888. 5:06:07an expert in every type of remote IO,
  7889. 5:06:10but now you understand the basics of
  7890. 5:06:12adding IO expansion modules to your
  7891. 5:06:14projects, especially for the Arduino
  7892. 5:06:16Opta PLC. I'll have all the hardware I
  7893. 5:06:19used in this tutorial linked in the
  7894. 5:06:21description below this video.
  7895. 5:06:23Let me know of any questions or snags
  7896. 5:06:25that you ran into
  7897. 5:06:27on this video, and let me know what you
  7898. 5:06:29want to see more of next on the channel.
  7899. 5:06:31Thanks so much for watching and see you
  7900. 5:06:33next time. Thanks, bye.
  7901. 5:06:41Welcome back to The Master Tech, and in
  7902. 5:06:42today's video, I'm going to show you how
  7903. 5:06:44to use push buttons and switches for
  7904. 5:06:47industrial controls and automation. I
  7905. 5:06:49will probably skew the topics in this
  7906. 5:06:52video towards applications that might
  7907. 5:06:54involve controls and automation, but
  7908. 5:06:57this also is applicable for anyone who
  7909. 5:06:59wants to use push buttons or switches
  7910. 5:07:01for hobby applications. And far and away
  7911. 5:07:04the most common example of a digital
  7912. 5:07:07on-off input that is used in controls
  7913. 5:07:10and automation and hobby circuitry and
  7914. 5:07:12electronics are the push button and the
  7915. 5:07:15switch. With a push button,
  7916. 5:07:17it's either pushed or it's not pushed.
  7917. 5:07:20With a switch, it's either in position
  7918. 5:07:22one or position two. So today we'll be
  7919. 5:07:25looking at the most common wiring and
  7920. 5:07:27talking about some of the uses and
  7921. 5:07:28applications of push buttons and
  7922. 5:07:30switches for controls, automation, and
  7923. 5:07:33electronics. And a huge thank you to APL
  7924. 5:07:36who provided the hardware we use in this
  7925. 5:07:38video. More about them later in the
  7926. 5:07:40video. Now, let's start with the most
  7927. 5:07:43common type of push button you will see
  7928. 5:07:45anywhere and everywhere, a momentary
  7929. 5:07:48push button. This is a type of device
  7930. 5:07:50that is only going to read a one or high
  7931. 5:07:54or energized when it is actively being
  7932. 5:07:57pushed in. At an absolute minimum, these
  7933. 5:08:00buttons may only have two wires because
  7934. 5:08:03that's all you need to get the effects
  7935. 5:08:05of a push button. It's basically the
  7936. 5:08:08power feed in and then it's broken by a
  7937. 5:08:11strip of metal that is not made until
  7938. 5:08:14you push the button in. When you push
  7939. 5:08:16the button in, power flows into the
  7940. 5:08:18second wire and goes downstream. When
  7941. 5:08:21you have a slightly more advanced button
  7942. 5:08:23that has things like a built-in LED or a
  7943. 5:08:25normally opened and normally closed
  7944. 5:08:27wire, you can do a lot more
  7945. 5:08:29functionality with it. To understand the
  7946. 5:08:31concept of normally open and normally
  7947. 5:08:34closed, it's useful to start from the
  7948. 5:08:36concept of common. On this momentary
  7949. 5:08:39push button in particular, there are
  7950. 5:08:41five wires total. Now, two of them are
  7951. 5:08:43just the power circuit for the LED. So,
  7952. 5:08:46to discuss the controls concept going on
  7953. 5:08:48here, we actually just want to focus on
  7954. 5:08:51the other three wires first. And those
  7955. 5:08:53three wires are common, normally open,
  7956. 5:08:56and normally closed. In our case, we'll
  7957. 5:08:58put our positive power from the 9-V
  7958. 5:09:01battery on the common wire, which is
  7959. 5:09:04green for these buttons. When I'm not
  7960. 5:09:06pushing in my momentary push button, one
  7961. 5:09:09of the wires will read 9 V
  7962. 5:09:12and the other wire will read 0 V.
  7963. 5:09:15The wire that's going to read 9 V when
  7964. 5:09:17it's not being acted upon is the
  7965. 5:09:19normally closed wire, which in this case
  7966. 5:09:22is yellow. The wire that is going to
  7967. 5:09:24only read 9 V when we're pushing the
  7968. 5:09:26button in is the normally open wire or
  7969. 5:09:30blue in this case. So, when you have a
  7970. 5:09:32device that offers you both normally
  7971. 5:09:34open and normally closed feedback, what
  7972. 5:09:37you're saying is there's a wire there
  7973. 5:09:39that will be connected to common until
  7974. 5:09:42you push the button in and then there's
  7975. 5:09:43another wire there that won't be
  7976. 5:09:45connected to common until you push the
  7977. 5:09:48button in. So, for my application, I
  7978. 5:09:50have the ground of the LED pin connected
  7979. 5:09:53to the negative terminal of the battery.
  7980. 5:09:56And then I have the positive terminal of
  7981. 5:09:57the battery connected currently to my
  7982. 5:10:00normally open contact, meaning the light
  7983. 5:10:03will not turn on until I close this
  7984. 5:10:05button. Then, I have the positive power
  7985. 5:10:08from the battery coming into the common
  7986. 5:10:09terminal and currently I don't need any
  7987. 5:10:12purpose for my normally closed contact,
  7988. 5:10:15so I'm just going to cap that off. It's
  7989. 5:10:17not a good idea to leave live copper
  7990. 5:10:19wires around even when you're only
  7991. 5:10:21working with low volt DC. Now, what
  7992. 5:10:24we'll see when I push the button in is
  7993. 5:10:26I'm actually powering the normally open
  7994. 5:10:29wire, which now becomes closed and
  7995. 5:10:31because it's connected to the power of
  7996. 5:10:33the LED, it turns the LED on. To
  7997. 5:10:36understand the difference between the
  7998. 5:10:37normally open wire and the normally
  7999. 5:10:40closed wire, we can just flip which one
  8000. 5:10:43our power LED is connected to. So, the
  8001. 5:10:46red wire, which determines whether or
  8002. 5:10:48not we have the LED powered on, is now
  8003. 5:10:51going to get connected to my yellow
  8004. 5:10:53wire, which correlates to normally
  8005. 5:10:56closed on the button. Because it's
  8006. 5:10:59normally closed, we can see that the LED
  8007. 5:11:01turns on right away and it doesn't turn
  8008. 5:11:03off until I push the button in. In my
  8009. 5:11:06handy-dandy box where I have a whole
  8010. 5:11:08bunch of these hooked up, that's how I
  8011. 5:11:10have both of my momentary push buttons
  8012. 5:11:12hooked up. Now, that's not just a deep
  8013. 5:11:14dive into how momentary push buttons
  8014. 5:11:16work. We also covered the fundamentals
  8015. 5:11:19of how normally open and normally closed
  8016. 5:11:21terminals work. For that reason, we'll
  8017. 5:11:23really be able to fly as we talk through
  8018. 5:11:26the next one, which is a latched push
  8019. 5:11:28button. So, the biggest difference
  8020. 5:11:30between a latching push button and a
  8021. 5:11:32momentary push button is right there in
  8022. 5:11:35the name. With a momentary push button,
  8023. 5:11:37you have to be actively holding and
  8024. 5:11:39affecting the button for it to change
  8025. 5:11:42from a one to a zero. With a latching
  8026. 5:11:45push button, there's an internal and
  8027. 5:11:47rather interesting ratcheting mechanism,
  8028. 5:11:49which will hold it in place until you
  8029. 5:11:51press it again to release it. So,
  8030. 5:11:53effectively, you're getting the
  8031. 5:11:56switching between a one and a zero
  8032. 5:11:58effect that you get with a momentary
  8033. 5:12:00push button when you press it in and
  8034. 5:12:02release it, but it holds its state. So,
  8035. 5:12:05you can put it in one and leave it and
  8036. 5:12:08come back later and put it to a zero.
  8037. 5:12:10So, using the exact same wiring
  8038. 5:12:12configuration that we just had with the
  8039. 5:12:14momentary push button, where the LED was
  8040. 5:12:17connected to the normally closed contact
  8041. 5:12:20and when we push the button in, the LED
  8042. 5:12:22goes off, you can now see that I get the
  8043. 5:12:25same functionality that I was getting
  8044. 5:12:27before by having to hold it, but now I
  8045. 5:12:30can release it and leave it in place.
  8046. 5:12:32So, now with the exact same normally
  8047. 5:12:34open, normally closed configuration, now
  8048. 5:12:36I have the LED connected to the normally
  8049. 5:12:39open terminal. So, once I push the
  8050. 5:12:41button in, the light comes on. When I
  8051. 5:12:43push it again, the light turns off. Now,
  8052. 5:12:46in my opinion, because we're looking at
  8053. 5:12:48a latching push button, that's a good
  8054. 5:12:50chance for us to take a look at pivoting
  8055. 5:12:52into the latching switch. Now, I have a
  8056. 5:12:55couple different types of latching
  8057. 5:12:58switches here on my handy-dandy box. One
  8058. 5:13:01that has no visual indication of whether
  8059. 5:13:04or not it's passing power onward, but
  8060. 5:13:06has two positions, and one that does
  8061. 5:13:10have an LED to show you whether or not
  8062. 5:13:12it's feeding power out of the load line.
  8063. 5:13:15The limitation of these switches, as
  8064. 5:13:16we'll see in a second, is there's only
  8065. 5:13:18one way for you to feed power out. So,
  8066. 5:13:20you don't have the normally open,
  8067. 5:13:22normally closed connections that you do
  8068. 5:13:25actually have with a two-position switch
  8069. 5:13:27like this. So, it's important before
  8070. 5:13:29selecting your hardware for any
  8071. 5:13:31application to think through the use
  8072. 5:13:33case. If you have a switch that is as
  8073. 5:13:35simple as it needs to pass power on, so
  8074. 5:13:40you just want to be able to flick a
  8075. 5:13:41switch and feed power to a bunch of
  8076. 5:13:43devices, flick it back the other way,
  8077. 5:13:46and kill power to those devices,
  8078. 5:13:48something that only has one signal wire
  8079. 5:13:50coming off of it is probably perfectly
  8080. 5:13:53fine. In the case of my switch here, I
  8081. 5:13:55can turn it on and I get the visual
  8082. 5:13:57indication that the LED is on. And in
  8083. 5:13:59this case, I'm actually triggering
  8084. 5:14:01another LED on this push button just as
  8085. 5:14:04an example of how to use the switch. So,
  8086. 5:14:07when I sit here flicking my switch, I'm
  8087. 5:14:10turning not just the LED on this, but
  8088. 5:14:12also the LED on this light on. However,
  8089. 5:14:15a limitation is when I turn it off, the
  8090. 5:14:18light has to turn off. There's no way
  8091. 5:14:21for me to use this light
  8092. 5:14:24to turn on this light in an inverse
  8093. 5:14:27manner, where if I wanted the green
  8094. 5:14:29light to be on while the switch was in a
  8095. 5:14:31de-energized way. Because the switch
  8096. 5:14:34only has one load wire and the other two
  8097. 5:14:37are the power feed, there's no way for
  8098. 5:14:39me to effectively do that. So, if I had
  8099. 5:14:41an application where I needed a switch
  8100. 5:14:43to do one thing in one position and a
  8101. 5:14:45different thing in another position,
  8102. 5:14:48this would not be the right switch to
  8103. 5:14:49select.
  8104. 5:14:50But it does give me visual indication of
  8105. 5:14:53whether or not it's feeding power down
  8106. 5:14:55the line. So, we move on to the selector
  8107. 5:14:58switch that has four terminals on the
  8108. 5:15:01back. And when it has four terminals,
  8109. 5:15:03what it actually has is two sets of
  8110. 5:15:06electrically independent contacts. So,
  8111. 5:15:09when I am in position one on this
  8112. 5:15:11switch, two terminals are being
  8113. 5:15:13connected in the back and the other two
  8114. 5:15:16terminals are not connected to each
  8115. 5:15:18other.
  8116. 5:15:20Then, when I flip the switch into its
  8117. 5:15:22other position, the opposite two
  8118. 5:15:24terminals get connected and the original
  8119. 5:15:26two terminals that were connected are
  8120. 5:15:27now broken. You can see that here by my
  8121. 5:15:30blue and green LEDs that change
  8122. 5:15:34Hopefully, you can see that. That change
  8123. 5:15:36state every time I actuate the switch.
  8124. 5:15:39So, here again, I have not so much
  8125. 5:15:41normally open, normally closed
  8126. 5:15:43configuration, but position one,
  8127. 5:15:46position two. These are very often used
  8128. 5:15:48not just for on-off like I have here,
  8129. 5:15:51where I use my switch to kill power to
  8130. 5:15:54the entire enclosure. I could use it
  8131. 5:15:57where when it's in position one, it
  8132. 5:15:58powers only this half of the box and in
  8133. 5:16:01position two, it powers only this half
  8134. 5:16:03of the box. That would be a normal
  8135. 5:16:05application for it. They do make a
  8136. 5:16:07three-position selector switch as well
  8137. 5:16:09that has the same four terminals on the
  8138. 5:16:11back, but it also has an off position
  8139. 5:16:14where no terminals are being connected.
  8140. 5:16:16The most common use for that would be
  8141. 5:16:18like on a pump. You might see a
  8142. 5:16:19hand-off-auto.
  8143. 5:16:21In hand, the left two terminals might be
  8144. 5:16:24made. In off, no terminals might be
  8145. 5:16:26connected. And then in auto, it might be
  8146. 5:16:29the right two terminals. There are
  8147. 5:16:31definitely more selector switch options
  8148. 5:16:33out there, some of which have eight
  8149. 5:16:35terminals on the back, some have six
  8150. 5:16:37terminals on the back, but far and away
  8151. 5:16:39a two-position selector switch with two
  8152. 5:16:42sets of isolated terminals is the most
  8153. 5:16:45common type that you'll run into and the
  8154. 5:16:47most common type you would need. So,
  8155. 5:16:48just to show one cool variation on the
  8156. 5:16:51two-position selector switch, I also
  8157. 5:16:53wanted to talk about this cool keyed
  8158. 5:16:55selector switch. It's effectively
  8159. 5:16:57exactly the same device as this
  8160. 5:17:00two-position selector switch, but rather
  8161. 5:17:02than being able to be turned by a human
  8162. 5:17:05hand, you have to turn it using the key
  8163. 5:17:07that matches it. And this way, you're
  8164. 5:17:10able to control access to who can power
  8165. 5:17:12up a piece of equipment or machinery
  8166. 5:17:14using a set of keys. In this case, too,
  8167. 5:17:17the key is actually locked in the device
  8168. 5:17:19while it's on. So, you can't turn
  8169. 5:17:21something on and walk away with the
  8170. 5:17:23keys. Anyone has the ability to turn it
  8171. 5:17:26back off and then you can take the keys
  8172. 5:17:28away. This is a safety measure to make
  8173. 5:17:31sure that anybody is able to deactivate
  8174. 5:17:33a piece of equipment if they feel it's
  8175. 5:17:35unsafe. It's not incredibly common to
  8176. 5:17:37see these, but it is an interesting and
  8177. 5:17:40useful to know about variation on the
  8178. 5:17:42selector switch. The last and most
  8179. 5:17:44important maybe piece of equipment in
  8180. 5:17:46industrial controls and automation that
  8181. 5:17:48I want to talk about that is really just
  8182. 5:17:50another form of a latching push button
  8183. 5:17:53is the e-stop. And the purpose of an
  8184. 5:17:56e-stop is really to kill power to an
  8185. 5:17:58application. Some e-stops do have
  8186. 5:18:01terminals and feedback to a PLC or a
  8187. 5:18:04controller or a stack light to let you
  8188. 5:18:06know that they have been pressed, but
  8189. 5:18:09typically the main reason you hit an
  8190. 5:18:11e-stop is something is wrong and you
  8191. 5:18:14want to kill power to a device or at a
  8192. 5:18:16minimum put it in a safe state. Wiring
  8193. 5:18:19and functionality-wise, you everything
  8194. 5:18:21we discussed about momentary push
  8195. 5:18:23buttons still applies here, but
  8196. 5:18:25typically there's an extra motion like a
  8197. 5:18:27twisting motion or a hard pull to
  8198. 5:18:30release an e-stop when it gets pressed.
  8199. 5:18:33It's supposed to be easy to press in
  8200. 5:18:36to put things back into a safe state and
  8201. 5:18:38require effort and intentionality to
  8202. 5:18:40release and put back into an operational
  8203. 5:18:43state. But, it's a super useful piece of
  8204. 5:18:46equipment to know about, especially if
  8205. 5:18:47you're in the world of automation or
  8206. 5:18:49controls. Well, I know at first glance
  8207. 5:18:52how to use push buttons and switches can
  8208. 5:18:54seem really intuitive or like a basic
  8209. 5:18:56concept, but it's actually one of the
  8210. 5:18:58most important fundamental things to get
  8211. 5:19:00down if you want to be doing industrial
  8212. 5:19:03controls and automation or hobby
  8213. 5:19:05electronics and building with robotics
  8214. 5:19:07at home. The topics and concepts covered
  8215. 5:19:09here will serve you great not just as
  8216. 5:19:12you build physical things, but it also
  8217. 5:19:14helps you think through logic and how
  8218. 5:19:16programming using normally open and
  8219. 5:19:18normally closed conditions work as well.
  8220. 5:19:20As always, good luck with your projects.
  8221. 5:19:22Thank you for watching and we'll see you
  8222. 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.