https://www.automationdirect.com/adc/home/home
(VID-BS-0009) Follow along with this tutorial to learn how to program a factory PLC for the new Programming Merit Badge!
AutomationDirect donated time and equipment for the creation of these Boy Scouts of America Merit Badge videos.
pretty much every product you touch was made in a factory that uses machines that are controlled by a special kind of computer called a programmable logic controller or PLC for short your uniform the electronic devices you use your tent your flashlight your knife your shoes water bottle pen paper notebook handbook this table this computer just about everything you use every day was made possible because somebody programmed a PLC to do it and in about 15 minutes you're going to know how to do it too PLC's come in all shapes and sizes but they all share the same characteristics they're reliable and rugged enough to work in a factory environment and they're used to control machines they keep doing the exact same thing over and over again all day long and most plc's are programmed using something called ladder logic the ladder logic programming language was created to make it easy for factory workers who are mostly electrical guys to learn how to program that explains why ladder logic looks a lot like a wiring diagram so it'd be easy for them to learn and understand of course it looks a lot like a ladder to which explains the name right remember before computers they had to control machines with electronic devices that were all wired together in a cabinet it was a mess and really hard to rewire and maintain when changes had to be made they would have to shut down a factory for days just to make a change when the PLC came along it changed everything and life got a whole lot easier for the factories here's a simple example think of this vertical line on the left is your power source we call that a power rail we connect the power source to a switch which is then wired to a motor or a light or something like that when the switch connects the power to the motor it turns on we call this guy at contact because it generically refers to anything that connects or contacts these wires together there's all kinds of input devices we can put here it can even be something like a temperature or pressure sensor the inputs on this PLC a label with X's we have eight inputs on this PLC labeled X 1 through X 8 we're using X 1 and X 2 for these two push buttons here x3 and x4 for this joystick switch and x5 is a simdi sensor it detects metal objects this guy's called a coil because you're usually energizing the coil of wire on a motor or a heater or a light bulb or relay or something like that the outputs on our plc your label with wise we have six on this plc y 1 through y 6 these two fan motors in this light are connected to 30 our outputs when you buy a plc you specify how many iOS you want and you can always add more with extra modules this line of code is called a rung like the rung on a ladder as we add more lines of code we get more rungs on the ladder let's try this program your laptop should already be connected to the PLC you can tell that by seeing that we're online and that the PLC is currently running so while we need to do to transfer this program down to the PLC is hit the transfer button right here go ahead and do that click on the transfer button this dialog tells me how much memory i'm using blue is remember i've used red is the memory that's available as you can see we're not using very much memory are we this looks good so hit ok it's asking if we want to save the project you can just put the word temp in here and say save the software is telling us that the project in the plc is different from the project we're getting ready to send down there are we sure we want to overwrite that this is really important remember you could be controlling a big machine or even a whole factory of this plc you better be pretty sure you want to make changes right we do so yes and this dialogues telling us that plc is running are we sure we want to stop it again we want to make sure it's ok to shut down the factory when we do this we're good so yes the program downloads the transfer is complete so hit ok and one more time it's asking us are we sure we want to put this PLC back in run mode we are so we say ok and that's it we've transferred the program down to the PLC well try it press button next one the defan turn on great well that's it that's an entire PLC program pretty easy isn't it now pretend you're the factory PLC programmer and your boss just told you he wants you to change it so the button x1 controls the fan that's hooked up to y2 not y 1 how do you do that well easy just double click on this guy change it to Y to the fan on y2 and transfer it down to the PLC go ahead and do that hit the transfer button answer all the questions ok the memory looks good yes we want to change the project yes we want to stop the PLC program transfers down transfer is complete are we sure we want to run the PLC yes we are and our programs ready to go ok now when you press switch x1 does it turn on fan y tu it sure does good job now if that's all plc's did they wouldn't be worth spending the money on because you can do all of that with simple wires and switches right but plc's can do so much more ok your boss just give you a new assignment when you press button one he wants fan one to turn on for two seconds and then turn off by itself well things just got a lot more complicated didn't they that's going to be a lot harder to do with wires isn't it but guess what doing what the PLC is easy look instead of switch one controlling fan one directly what we're going to do is we're going to replace that with a timer drop the timer on that and we use timer one there's lots of timers you can use we want the timer to run for two seconds and let's see this says when the switch turns on turn the fan on two seconds after the switch turns on that's not what we want this one says turn the fan on when you press the switch and when you release the switch wait two seconds and turn the fan off that's closer what you want we'll take that one great now the button press kicks off a timer well look all we do is grab another contact put it down here on wrong to go ahead and do that now we want this contact to be controlled by the timer so now you press the button it kicks off a timer and then the timer now controls what the fans I'll grab an output coil and we wanted fan one to be controlled by that timer now the PLC program needs to know when it's done so grab an end statement and put it down here on the last wrong great that's a complete program but we missed one important thing go back into the timer double click on it and we said two milliseconds now we want two seconds don't we guys so make that two seconds and say okay great now we have a whole program the button press kicks off a timer the timer then controls the fan try it hit the transfer button remember he looks good do we want to change the PLC yes we do the plz is currently in run mode we want to change the stop mode yes we do it's downloading the program downloading the project it's all set do we want to run the PLC yes we do and away we go now if you reach down and press and release button one does the fans down for two seconds it sure does how cool is that did you notice that you can see when things happen right on the screen for example when I press the button I actually see it light up and I also see the timer light up and then when I release the button watch this you can see the timer starts to count up to two seconds and then releases the fan so since you can see everything that's going on right here on the screen it makes it really easy to debug your PLC program okay well guess what that's not what your boss asked for is it he wants the fan to turn off two seconds after you start pressing a switch not after you let go well how do you do that easy this contact here stays active the whole time you hold the button down right what we're going to do is we're going to replace that with something called an edge contact that detects either the rising edge of the falling edge of the button that is it detects when you press the button or when you release the button well we want to detect when we press the button so we'll say okay so look has a little arrow in there now so it says only send a signal to the time or when you first press the button so that time will immediately start timing and we'll see the fan turn on for just two seconds regardless of how long you hold the button down okay let's try it again transfer the program memory looks good do we want to transfer the project do want to stop the PLC transfers in process good so we want to run the PLC yes we do okay we're up and running now this time I want you to hold the button down and see if the fan turns off after two seconds anyway here we go and sure enough it does awesome mission accomplished okay well guess what your boss just came in and he said he wants button to to turn on the fan that's on output Y 2 and he wants that same button to turn on the light which is on output Y three at the same time how do we do that well it's the same as before we're going to take a regular contact drag this one down one to rung three we want that to be the button that's on input X 2 so we put that there and then this guy is going to control both the fan and the light so let's do the fan first we grab an output coil drop it right here and let's see that second fan he's located at y 2 and the light is located at y 3 but how do we get this button to control both of them well it's easy make sure this guy's highlighted hold down the control key and look it says we can add a coil here right so while you're holding down the control key press the down arrow once and let go now we can add another output coil in here and we can say we want that to drive the output at y 3 which is our light don't forget your end statement down here at the bottom and now we have another complete program x1 runs a timer which controls fan1 the button at x2 controls both the fan at y 2 and the light at y 3 and go ahead and transfer the program here's our memory we're okay do we really want to transfer this project yes we do do we want to stop the PLC yes we do it transfers the program down to the PLC and we really want to run this project yes we do okay well button one should still turn off fan one for two seconds and it does and now the button that input X 2 should turn on the fan and output y 2 and the light it output y 3 while it's held down and it does well that's how you program a PLC you just keep adding more and more contacts and coils the bigger the factory the more of these you'll need but it's still the same kind of thing please understand peel cease can do a lot more than we covered here but hopefully you see the PLC programming is definitely something you can do after all you just drove for PLC programs from scratch didn't you and keeping our factories running is a pretty important and rewarding job so you might even want to consider it as a career someday we want to thank automationDirect for supplying the PLC hardware and software for this demo and for hosting the programming mayor badge at the jamboree
Voted #1 mid-sized employer in Atlanta
Check out our
job openings