Home / Micro800 / Micro800 Programming
Description
A video walk thru of the lab assignment to program the CTU, CTD, and CTUD counters in the Micro800 PLC.
Transcript
(00:02) okay this video we’re going to look at lab number five which will be on counters and counters are used in all all makes and models of plcs it’s a very standard instruction available again in any brand plc but a counter by its nature is there to count count either up or count down and they are triggered by typically a discrete input that when it transitions to a high it will count up by one so basically the trigger will have to turn on and then turn back off again and then when it turns on the second time it would count up again so starting
(00:51) with zero first time it gets triggered it would go to one second time it gets triggered it would go to two and it would keep counting up potentially indefinitely another feature of a counter is you usually would give it a maximum value so that when it reached that maximum value it would turn on the output let you know that you have counted up to your maximum allowed count so for instance in our lab we’re going to have the premise that we’re counting boxes that are on a conveyor belt so as every box passes a photoelectric sensor
(01:34) when that box passes in front of that sensor it’ll trigger the sensor that the sensor will go from from a low to a high that’ll be the trigger and it’ll therefore count that box as 1. and when we get to 10 when we count to 10 or 10 boxes have passed by the photo eye sensor then the counter will basically tell us that we’ve reached the maximum that we want right we’ve reached 10.
(02:06) that’ll turn on the output or the q of this count up block once you’ve reached the the maximum value the counter will continue to count up so if more boxes cross in front of the sensor it’ll continue to count to 11 12 13 etc so we need to do is we need to reset the counter by resetting the counter we will put the counter back to zero and we will start to count the 10 again so if we’re trying to keep you know tabs on something or the number of boxes maybe we’re trying to you know put 10 boxes on one pallet perhaps if we’re in a packaging
(02:44) situation we would count the 10 and then we would want to reset the counter and count to another set of 10 reset count to 10 again maybe the palette can only handle 10 boxes if we didn’t reset the counter then like i said the counter will just continue to to count upwards the other version of this is a countdown so the countdown works in the opposite manner we’re going to start with a a value such as 10 and we’re gonna count down from 10 to zero and when the counter reaches zero that’s when the q or the output will
(03:27) turn on so it works the same way we’re going to trigger it with a discrete input which typically goes into the cd cd standing for counts down that’ll be our that’s where we put in our our trigger point our discrete signal every time we trigger it it’ll count down by one we will start from 10 we will go down to zero and then we will reset it and do it again the difference between the count up is that we don’t use the term reset here we’re going to use the term load and load essentially means that we’re copying whatever is in the
(04:11) pv putting it into the cv so in the count up version the counter starts with zero in the cv and we start counting up from zero to the uh until we reach the pv you know defined p pv value which when our case is 10. in this case pv will be you know what do we want the counter to start at and instead of a reset where we bring the counter back to zero we’re going to do a load which will basically put that starting value into the cv as our as our point where our starting point for the counter to count down from so it’s important that we load the
(05:03) counter and we’ll need to load the counter first time we actually use it we we just so we’ll have to use the load feature and just like the reset the load is a discrete trigger as well so it could be we could use a push button to um to initiate the load and we can use the push button to initiate the reset in the count up the third type of counter that we’re going to play with in this lab is a count up down so this one basically takes the features of both the count up and countdown and put them into one so we’ll
(05:41) be able to use one counter to count up and count down at the same time so we’ll have two inputs into this counter we’ll have a cu and a cd the cu will be when we uh you know when we trigger the cu we will count up by one when we trigger the cd we will count down by one and now we have a reset and a load here so if we wanted to um clear the counter and bring it back to zero we could trigger the reset or if we wanted to bring the counter up to a preset value and then count down from that we could do that by pressing
(06:20) the load and then we have a pv which will be our our program maximum value which again will be 10 as in all cases then we have a couple different outputs those are on the uh the left hand side or i’m sorry the right hand side here we’ve got q u q d and the cv of course will be our our count value so the q u would be when we’ve reached our our upper limit if we reach 10 then the qu will turn on and qd will be if we reached our lower limit which would be zero the qd would turn on so we can use those two outputs and and and use those in our lab
(07:05) probably more specifically the q u so as far as the lab goes we have three exercises each one using you know those those counter blocks so we call them skills so skill one will be count up and basically we’re going to use the premise i had described a bit earlier we have a a a photo eye a photoelectric sensor nothing more than a light beam sensor that gets triggered every time a box passes in front of it when the box passes in front of the sensor again the the light beam gets broken the sensor sees that as a as a transition to a high basically the
(07:47) sensor turns on basically a discrete contact closure happens and we’ll send the signal to the plc the plc will see that as a on when that happens we will feed that into the counter so we will trigger the basically we’ll simulate this by triggering the the input for the photo eye when it goes to high the counter will get that high signal and it will count the counter up by one then we have to clear that signal back out again to zero and then we can do it again and again and again and we can count up and up and up when we reach 10
(08:25) we will turn on an output that basically says that the that the conveyor has been you know that we’ve reached our our account um and that we’ve you know we’ve counted 10 boxes so we’ll turn on an output basically our belt exceeded is the terminology i’d use but basically when we reach 10 we’re going to turn on our indicator and let somebody know that we reach 10.
(08:53) the second skill will be the exact opposite we’re going to use the ctd or the countdown so now we’re going to start the counter at 10 and we’re going to count down from 10 to zero and we’re going to use a different photo eye this time we’re going to use what we’ll call the exit photo eye so the countdown we we had to count up we would have the the what we call the entrance photo eye so we’re looking at boxes that enter the conveyor and now that we’re going to do a countdown well we could probably look at the exit
(09:27) sensor or the exit photo eye so we’re looking at the boxes that are leaving the conveyor belt therefore we can count down from how many have left the belt so same will apply every time the exit photo eye gets triggered by you turning it on and off simulating it by turning it on and off the countdown counter will count down by one but again we must press the load button initially to load the counter to 10 and therefore count down from 10 and then when we get to 0 we can press load and reset the counter back to 10.
(10:08) the third skill will be the condition where we’re going to use the count up and countdown timer the ctud and the premise of this one is that we we have a we’ll have like a buffer on the conveyor belt and our buffer is we want to make sure that we stay under 10 boxes in that buffer so we’re going to count the number of boxes that are entering and count the number of boxes that are leaving and we’ll have a overall count of what is on the conveyor that way right we know what’s coming in we know it’s going out and we can keep a track of how many
(10:46) boxes are in that buffer if that number of boxes exceeds 10 or if it gets to be 10 or more then we’re going to shut down the belt so part of the project 2 here in skill 3 or so part of the program is we’re going to write a little bit of code to start and stop the motor for the conveyor belt because the conveyor belt is nothing more than a motor that gets turned on to make the conveyor belt move so just like we did in some previous labs we’re going to use that same kind of latch circuit with a start and stop push
(11:19) button so that when i press the start button the conveyor starts running when i press the stop button the conveyor stops running and if the number of boxes are 10 or more that’ll also be a condition that’ll make the conveyor motor turn off as well so those are our three labs now let’s go look at ccw or kinetic components workbench so one more thing actually before we leave the the document i i did give the uh i did give the ladder of how these look so you can use that as a reference i also gave you the the tags and the the i o points that will have so
(12:03) so for all the labs we will have these these tags in the in the controller so for inputs we will have the photo in the photo eye out we’ll have a reset button load button we’ll have the conveyor start and the conveyor stop so those would be our our inputs and then for our outputs we’ll have the belt exceeded we’ll have the belt empty which is what we’re using in that countdown lab we’ll have the buffer exceeded which we’ll be using in the skill 3 and the conveyor motor which is also used in skill 3.
(12:36) all right so now let’s go to ccw i went ahead and made an example program and i went ahead and defined the aliases just like i did in that chart so here but remember in ccw that the dos or the discrete outputs come first so do 0 0 1 2 and 3 are defined just like i showed in the chart a minute ago and then our discrete inputs which are the d i’s the i 0 1 2 3 4 and 5.
(13:06) and they are aliased just like we talked about a moment ago i also go ahead and create three programs i created one for skill one skill two and skill three this is not necessary to do you could just create one program and just you know keep changing the logic for each time and testing it but i did this just to make it easier to show on the video so if i open up skill one this is essentially all we have to do for skill one we’re going to have a an input right first we have our counter of course our ctu is our is our counter as
(13:44) our count up counter and we have to trigger the counter we have to give it an input in order for it to trigger there’s no input to the counter it’ll never count anything so like we like we said our our input to this counter is going to be our our photo eye in so the entrance the entrance photo eye so we’re looking at the you know at the beginning of the conveyor belt it’ll be a photo eye and it’ll look at whenever a box enters the conveyor so we’ll use photo i in in and that’ll be tied to discrete input zero zero so that just gets wired right
(14:23) to the cu of the counter and then we have an output of the counter so once again when the counter does reach its maximum value which is set here in the pv box of 10 we just put the number of 10 there as our constant when we reach 10 this output will turn on and when that output turns on we can use that to drive the output um for the belt exceeded indicator which will be a discrete output d000 and the only other thing we have to do to counter at this point is we have to tie a reset to it um because if we don’t put a reset to it
(15:04) then the counter will keep counting up and up and up and up so we have to be able to reset the counter so we can clear it and bring it back to zero and i went ahead and indicated in the in the assignment that we’re going to use discrete input zero two we’ll make that our reset so we just actually put the uh instead of putting the contact into the reset we’re just going to put that that trigger that address of the trigger right here and the reset box so the io emdi02 which is tied you know again alias as a reset so let’s watch this guy and uh work so
(15:45) what we’re going to do i’m going to use a simulator because that’s going to be what i have available for me so we’re going to tools i’m going to open up the microwave simulator and i have it right here now the simulator is not running and i know that because the power light is not on neither is any other indicators so i’m going to go ahead and start the simulator so now the simulator is running that is green as well as a green power light and i’m going to go ahead and download this project to the simulator and make sure that we
(16:19) actually have it you know put in and working it’s going to ask you want to download to the controller we’re going to say yes it will prompt another time here in a moment do you want to download and we’re going to say download and we’ll get one more prompt and that will be do you want to put the controller back into the run mode once the once the um the project has actually finished its download down is complete do you want to change the controller to remote run and execute the controller project and
(17:23) we’re going to say yes one more warning comes up just says that the simulator can only operate in the run mode for 10 minutes and that’s just a limitation and we will say okay so you got 10 minutes to test all right so now we are actually online and connected to the simulator we know that because the background has changed yellow and we actually can see the red we can start to see you know some of the animation uh here of the line now i’m going to bring the simulator back up so i can actually show these two things
(18:02) simultaneously so right now our cv is set to zero on the counter and our preset value is at the 10. so 10 again is going to be where the counter will trigger what you know when the counter will be when it reaches 10 when the cv you’re just 10 that’s when this q will turn on and turn on the belt exceeded output so to make that happen we have to trigger the input so photo i input zero zero so if i cycle it there’s our count to one i’ll cycle it again there’s our count the two cycle it again now we’re to three all right
(18:47) and keep doing that ten times now what i want to show you at this point is is if i do trigger the reset which is the di002 if i trigger the reset that will clear the counter back to zero and it’s going to start all over again so one two three four five six seven eight nine and last one is 10. now i reached 10 this turned red and my output turned on so um so my output is tied to the um i think the do 0 0.
(19:42) now if i triggered this one more time i will continue to count i guess not in that micro 800 so looks like it will not allow you to go past 10 some some controllers will continue to count up regardless micro 800 just actually does clamp it now i’m going to go ahead and hit the reset button and now when i hit the reset button that brought the cv back to zero and it also turned off zero zero which is this output right here so the output turned off and this cleared back to zero so now i can count up again start all over again
(20:28) if i hit reset it brings it back to zero okay now let’s look at skill two skill two is basically the exact same um ladder diagram with the exception of uh we put in oh it’s like i made a mistake here i did not have skill to open so i opened up skill two here and uh skill two is ctd so i have multiple programs and i didn’t realize that i was still in skill one now i’m in skill two i’m going to get reconnect so they can to the to the micro 800 simulator should not prompt me to download
(21:31) anything since i have uh since i didn’t change any logic so i just got connected and um so what’s happening is is right now the photo eye out of course is not being triggered um i’ll bring up my simulator again to show you right so the di001 is going to be my photo eye out and but my output is actually on saying the belt is empty and that is true because there is nothing currently on the counter so like i had mentioned when i was just you know introducing on the countdown we have to load the counter prior to starting to
(22:18) count on the count up we don’t do that we start with zero we count up and then we reset it to bring it back to zero on the countdown we have to load the counter first to put the value into the cv and then we count down from there so i need to trigger the load button and the load button is tied to the discrete input zero three so i’m going to trigger the load button when i do that it actually put a 10 in cv so what load those is when i press the load button it’ll copy whatever is here in the pv and move it into the cv so now we’re starting
(22:58) to count from 10. when i did that this also turned off because this is no longer zero so this works the exact same way now so i’m just going to trigger the photo eye out 10 times when i get to 0 this will turn on so again it’s the di01 so down to nine eight seven six five four three two one and zero once we get to zero the output turned on so we got our output turned on and once i press the load button we now reset that and it’s good to go and the last one is
(24:01) using the count up down now um we’ve i’m going to clear these out because i was using the same reset and load here that we used in the previous labs so i’m going to go ahead and press the reset button and clear everything out now there was two pieces to this last skill one we wanted to have a a simple motor start kind of logic so when we press the start button we would start the conveyor motor and the conveyor would stop if i either press the stop button or if we exceeded our buffer if we had more than 10 boxes or 10 boxes or more on the belt at one
(24:51) time we were going to shut down the motor then we had in rung 2 our ctud which is our count up down so we have a cu input for counting up input we have a cd input for counting down so when cu gets triggered we count up by one when cd gets triggered we count down by one then i have a reset and a load and i have my pv which is my my program maximum value so that’s 10 as our number just like before and then we have two outputs we have a qu which gets tied right to a coil we have the qd which is if you’re at basically
(25:38) zero the qd gets turned on so it is showing true right now because our cv is set to zero so we’re at the lower end of our account so we can use that output if we needed to to let us know that we have an empty belt right now and cv of course is our count value so we’re going to use the same two photo eyes that we’re using before the the zeros you know di00 for the photo in and the di01 for the photo eye out and i hit the reset button already so we’re all good to go so we’re gonna start the motor by pressing the start
(26:18) button which is di004 so i built the latch circuit so i was able to just pulse the start button and i have my latch around with the conveyor motor contact itself so i got the conveyor stop and the buffer exceeded is normally closed if the one of these two opens then our conveyor motor will turn off and there’s our conveyor motor output right there so we can monitor it in the simulator and here we’re going to this is going to count up so buffer so we have one box comes on the belt and there now we’re at one one box another box comes on the belt
(27:01) third box comes on the belt let’s get that one looks like i reached my 10 minute uh 10 minute time so i’m just gonna um i’m gonna go ahead and just uh i’m going to disconnect from the from the simulator i’m just going to shut it down i’m going to reopen it start it and i’m going to oops press the wrong button i’m going to connect to it all right i have reconnected and i am
(28:24) back online with the controller we can see that our our count values remain two even though i shut the controller the simulator down and brought it back up and now i’m going to continue to trigger my input so this is actually a good piece of troubleshooting because i was sitting here trying to operate the uh the thing and it’s and it’s not going and mainly because we do not have the run it is not running right now so i can change its run status by coming up here in ccw and saying run mode and i probably did not catch that earlier so
(29:27) after the 10 minutes timed out it changes it went it dropped off a run mode would have to just put it back into run mode to um to get it running again so very important piece of troubleshooting with any kind of hardware or any type of plc regardless of its simulator or the real physical hardware if that run light is not on it is not running if it’s not running then it’s not actually executing the program so always keep that in mind so we are sitting at two still and i’m going to go ahead and keep triggering my photo i start now we’re
(30:02) three so we’re back running again if i were to trigger the the out you’ll see that my count does actually go down so now i’m back to two i’m going to keep counting up so basically we have tested that i can you know add to the buffer or subtract from the buffer by using the two photo eyes i’m at the six i want to get to i want to get to 10 so that we can see what happens one more and there we go so we reached 10 when 10 occurred we got our buffer exceeded output turned on and when the buffer exceeded turned on that opened this contact
(30:55) and therefore we dropped out our conveyor motor now what’s important here is is that if i were to reset this this counter this brings it back to zero but and it also brought the buffer exceeded back right turned it off but we did not start the motor back again right because we did this latch so we have to press the start button on the motor to restart the conveyor that will take a a human operator to go and do that which is usually good by design um have some safety there so we’re gonna start the motor back up again
(31:39) so now we’re running again and we can start our buffer counter once more so for the lab i want you to just basically do this and just play around with the counter use the uh use the ability to you know to trigger it on and off and see how the counter behaves reset it and just kind of get comfortable with understanding the operation of the count up countdown and the count up down box
