https://www.automationdirect.com/brx
(VID-BS-0002) Learn how to create Pinewood derby finish line controller using a Factory Automation PLC
Our FREE Practical Guide to Programmable Logic Controllers eBook: https://www.automationdirect.com/ebooks/plc-handbook
programmable logic controllers or PLC's are typically used to run factory equipment and you're probably even wearing or using something right now that was made in a factory controlled by a PLC and somebody had to program the PLC to make that happen in this video we're going to use the PLC to decide which pinewood derby car wins the race let's assume that the Pinewood Derby track electronics has sensors wired to the PLC to tell us when the cars have crossed the finish line now as soon as the first car crosses the finish line we want to turn on the light over that car's lane to indicate the winner so it looks like our PLC needs to watch these two finish line signals and it means to output these two light signals we'll have the finish line wires come in to the PLC on inputs x1 and x2 and will control the winter lights and the PLC's output terminals y1 and y2 let's also as soon as a reset signal to clear the lights and get us ready for the next race will have that signal come in to the PLC on input X is zero now our job as a PLC programmer is to watch these finish line signals make a decision and then turn on one of these outputs to indicate the winner of the race and also to use the reset to clear the lights PLC's come in lots of different shapes and sizes we're going to use this do-more plc from automationDirect because the software is free and it has a free built-in simulator so we can test our code without having to buy any hardware if we were going to use a real PLC and not a simulated one we would set it up like this first you get a base this is a nine slot base but you can get them at several different sizes this is one I just happen to have laying around then you select the process you want this is the do-more processor that comes with a free software and free simulator okay we need some inputs to read those Lane sensors right so we grab an input module like this one and plug it into the base now based on that diagram we had a second ago we wire lane 1 to terminal 1 lane 2 to terminal 2 and our reset button to terminal 0 and we'll also need a wire to supply a reference signal to the sensors let's see we need two outputs to turn on the lights so we add an output module this one has 16 outputs we only need two of the outputs to this project one for each light we want to turn on from our diagram we want to wire light 1 2 terminal 1 and light 2 to terminal 2 and again we'll need a reference signal here for the lights so again if we were using a real PLC that's how we would wire it up the good news is we don't have to buy and wire up a PLC to try out our program the do-more software comes with a free simulator which looks like this using this we can test our code for free let's see it looks like this simulated PLC has 16 inputs X 0 through X 15 again we're only using X 0 1 & 2 right and when we click on these buttons it's just like the track electronics send us a signal this X 1 input is lane 1 the X 2 input is lane 2 and the X 0 input is our reset button this simulated PLC also has 16 outputs y 0 through y 15 again we're only using two of them y1 and y2 to turn on the finish-line lights there's a bunch of other stuff here but we don't need to worry about that for this program okay so let's write our program go ahead and launch the software and you should get a screen something like this now we want to start a new projects we click on new let's give it a name I'm just gonna call it PWD for Pinewood Derby and you want to make sure you're connected to the do-more simulator and then say ok great we're ready to start programming here we go PLC's use something called ladder logic because it looks kind of like a ladder each line of code is called a rung like a rung on a ladder think of this as the power and we want to connect that power to drive an output like a light or a motor in our case it's the finish line lights now right now this power is running directly across this wire to the output well we want to control the output based on a finish line signal right so we highlight this block and we click on this contact right here now let's give it a name let's call that finish 1 that's the sensor that tells us when the pinewood derby car has crossed the finish line now the software needs to know which input that's connected to so click on this guy right here and let's see finish 1 was connected to x1 right let me say ok so now in the powered derby car crosses the finish line this contact will close and all that power flow down to what while we needed to flow to our finish line light right so click on that and we want to set the winner light so I'll call it winter light number one and say okay the software wants to know what that's connected to so when the light one is connected to what y1 exactly great so now when the car crosses the finish line it'll turn on light 1 let's do the same thing for lane 2 we need to put a contact here we'll call that finish - the software says what input is that connected to well that's connected to x2 and he's gonna set the signal at winter light - again the software wants to know what terminal is connected to that's connected to terminal y2 on our PLC and we're ready to go now the only problem with this is this is not really what we want to do is it all this is going to do is turn on the light when the car crosses the line for both of them we really want only one light to turn on and we want it to be the light of the winning car don't we okay well how do we do that let's see if the car crosses the line and light 2 is not lit yet he must be the winner right well that's easy click right here and grab this contact right here and put winter light 2 in there let's try that okay so what this says is this contact is always closed until winter light 2 goes active so in other words when the car crosses the line it'll close this switch it'll see this switch is already closed because cartoon has across the finish line yet and it'll light our light we need to do the same thing down here if car 2 crosses the line but light number 1 is not lit then we need to turn on light number 2 so let's do that cursor right here use this guy we want winter light number 1 now and say okay well great this is exactly what we want if car 1 crosses the finish line and light number 2 is not lit then turn on light one if car number two crosses the finish line and winner one is not lit then turn on light two we need to do one more thing we need to reset these lights when the user presses the reset button well again come over here grab a regular contact and we want the reset line which we assigned to x0 to reset let's just go right here the two lights we need winter one and here's a trick with the cursor right there hold down the control key press the down arrow and let go of the control key now we can add another light here so we want to reset again that's this guy when you're light number two well that's our whole program this is Lane one this is Lane 2 and then we can reset the winter lights when we're done this yellow line here says we haven't checked our program yet so you hit this checkmark and it verifies that everything's great the green line means we haven't saved it something's gonna save it real quick and we're ready to go now normally we would download this to a PLC we don't have a PLC so let's bring up our simulator click on the simulator button right here a little dialog comes up telling me about it just say ok say ok it's asking us what do we want to do do we want to go online with this PLC and view our disc gets this guy right here do we want to go online and view what's currently in the PLC now we don't want to do that do we want to cancel so we want this guy and it's warning us it's saying hey the PLC does not have this program in it yet yeah we know that so let's continue and we're ready to go here's our simulator right here now there's a lot of stuff here but we really don't need very much of it all we need is these three inputs right here x0 1 and 2 and the 2 outputs y1 and y2 right now this switch right here tells me that the PLC is in stop mode we need to bump that up to terminal mode so we can program it to write the program to the PLC we just hit this button right here we're gonna take this program hit this button and that transferred the program down to our PLC let's go ahead and run our program by clicking on run and we should be ready to go if the car in lane one comes down and trips the finish-line sensor which we know is connected to x1 what happens sure enough the light connected to y1 lights up and then when car 2 comes down and trips his sensor nothing happens that's exactly right ok let's get rid of those guys let's reset our lights remember that was x0 and try it again this time car 2 comes down he hits his sensor and sure enough that light lights up saying car 2 won the race when car one comes down nothing happens perfect that's exactly what we wanted so that's all there's to it we now have a Pinewood Derby track controller that tells us which car won the race what if we wanted to modify this program to control a four-lane track how would we do that well it would look a lot like this it's the exact same program except now we've added two more rungs of ladder to handle lane three in lane four and now each Lane needs to check all of the other lanes before lighting its light for example lane one needs to check the lights two three and four before lighting it's light and lane four needs to check lanes one two and three before lighting it's light otherwise it's the exact same thing that we did before isn't it then let's do one more thing the reset button needs to reset all four lanes not just two and that's all the logic you need to implement a four lane track so for your project I'm gonna challenge you to see if you can do an eight Lane track controller that wouldn't be hard at all would it you're just gonna add four more rungs of ladder four lanes five through eight and you're gonna clear lights five through eight that's it then you have an eight Lane controller see if you can program that and test it in a simulator well that's how PLC programming goes the bigger the factory you want to monitor and control the more rungs of ladder logic you add and now you know how to do it now please understand this was a very simple example of what a PLC can do PLC's can do a whole lot more but this should be enough to get you started and hopefully help you understand that maybe someday you could be programming their controllers that run our factories check out the resources listed on the website to learn more about programming PLC's with ladder logic we want to thank automationDirect for supplying the resources for this video automationDirect sells PLC's and just about everything else you need to automate a factory including sensors wire motors drys push buttons lights tools safety gear servos just about anything you can imagine so if you want to learn more about factory automation check out automationDirect at automationDirect calm
Voted #1 mid-sized employer in Atlanta
Check out our
job openings