Siemens PLC programming tutorial – Counters


this factory simulation shows the process will use to explore how the siemens plc counter drives the counter display we switch the factory simulator to run mode and the counter starts counting pallets the bottom photo why and the safety like curtain detects each pallet passing by the operator can manually reset the counter to zero with this factory simulator you can also toggle on the sensor tags see color code status of sensor in the tag name associated with sensor address ok let’s pull back the curtain and see what controls this counter displays in a siemens simulation software we have a counter function you can see the current value of counter 107 matches the displayed count via the binary integer output from siemens plc counter shown here the siemens counter number 107 is programmed to reset if the operators reset push button is pressed or the internal counter done bits becomes true you can see here by pressing the manual reset button on operators control panel it makes the counters reset rung become true and reset the counter to zero the count then starts over now let’s take a closer look we saved a copy of the sort height basic program we renamed it and added the word counter to it so now we have a backup copy a separate copy from the original the sort height basic is a demo that comes with the siemens simulation software where we have the plc in run mode right now but have the editor in edit mode so that you can see the acronyms used for the different settings on the counter this is counter number 107 it’s counted up incremented with a photo eye palette bit in other words a photo eye that detects each pallet release and then it increments the counter up over here is a place where we could have put an output bit that indicates the counter is counting but more useful would be a counter done bit like an Allen Bradley PLC you would have an output for counter done siemens plc doesn’t have that will create another rung below this one that will have a comparative statement to create our own counter done bit siemens has the ability to put a preset in the counter but you have to put a rung here with an extra bit and it is a bits (pun intended) confusing so we don’t use this we’re ad our own compare statement below that performs that functionality put our preset and everything like that in the counter then you have a reset function and we have the operators push button that can reset the counter or it can automatically reset when we get our counter done bit which is a bit we designed down here using our compare statement we said if the current counter value equals 11 then output to the counter done bit and outputting to that done bit would make this true which would reset it so this counter resets itself after it reaches 11 which in turn causes the counter display on control panel to have a zero to ten display then at eleven the counter gets reset to zero so you don’t see the value 11 on the counter display you will notice there are two outputs here for the current counter value there is a binary one which is an integer and there is a BCD binary-coded decimal with a binary coded decimal we would have two create yet another rung below network or rung 21 that will convert BCD to an integer so we just use the counters integer since that is what the counter display requires now let’s see it run live and will see the values in here the setting acronyms will be a little distorted here during the live run this is block 0 B 1. Block 1. This is like the main sub-routine in an Allen Bradley PLC it would be called subroutine instead of block so this is your main subroutine ob1 block one we want to monitor that block so we turn on monitoring it gives you a little warning here, that things are going to get slow and stuff. Capabilities get a little limited while monitoring. That’s okay. So now we’re monitoring the real world values we are currently in the run mode on this so the counter is counting, two three, etc. So then you will see when this is true, it increments the counter by one, from four to five and this is the current display value it shows here when we are monitoring it it shows it in hexadecimal even though it is an integer it is showing it in hexadecimal value so when this counters current value gets to 10 you will see an ‘A’ here which is a hexadecimal value for ten. There’s your ‘A’. When the counter gets to 11 it resets to zero automatically that fired this bit when it got to 11 from the compare statement that’s where the compare statement is right now the current value in the counter is three and the preset is 11 so when this current value reaches 11 this output would become true that in turn would cause in wrung 20 this to become true and reset the counter to zero so that’s a closer look at the counter please subscribe because in our next video we’re going to show you how to add to the sort height basic program this counter and the comparative rung below it. We’ll show you how to add them to an existing demo program that comes with the siemens simulator. thank you

Leave a Reply

Your email address will not be published. Required fields are marked *