Sign in to follow this  
Followers 0
Gnomes

Counter Reset Help

8 posts in this topic

Hello, I'm having some trouble trying to get my counter to reset all the time. In the following pictures part of my code is shown. The problem I'm running into is getting my counter LDCNT to reset. It will reset after the call function LDIS but it will not reset after the call LEADRE and I'm not sure why it won't reset. Both call functions seem to work correctly but after one of them the reset will work and after the other the counter doesn't reset. Any help on this problem would be great and if for some reason some more information is needed just let me know! Thanks!

Share this post


Link to post
Share on other sites
You have the same coil address in both rungs 16 and 21. Use two different addresses and then OR them together the generate the LCTRRES signal. The reason that the counter doesn't reset following the LEADRE subroutine is that the LCTRRES bit is only true for the few microseconds between when it gets turned on at rung 16 before it gets turned off again at rung 21.

Share this post


Link to post
Share on other sites
Thanks for your help Steve. I switched some things around and tried what you suggested and so far now my counters always reset when I wish them too! Trying to correlate your explanation with my code I'm still not quite sure what the problem was. I thought that if my ldcnt was in the range it would fire off the reset and if it was greater then 17, it would fire off the reset then. My code would reset the counter after LDIS was called so I was getting a little confused. In your response you said that the lctrres bit is turned on at rung 16 and then turned off at rung 21, how is it turned off at rung 21? Thanks again.

Share this post


Link to post
Share on other sites
The logic for governing a coil evaluates to either True or False. If the logic evaluates True, the coil is turned on. If the logic evaluates false, the coil is turned off. If your count was in range, you would call the subroutine LEADRE on rung 16 and turn on the coil LCTRRES. But when the program got to rung 21, the logic would be false and the coil would get turned off. You seem to be thinking that when the coil gets turned on at rung 16, the program execution will backtrack to rung 13 and reset the counter. That's not the way it operates.

Share this post


Link to post
Share on other sites
OK, I think I'm starting to understand what you're trying to say and how this programming operates. So during my testing of this program when I was able to get the counter to reset only after the function GT INT was true was because the coil LCTRRES wasn't turned on in the earlier rung thus not having a chance to get turned off on rung 21 (if it's logic was false) before the program swept back around to the counter. So if I get this right, if I would swap rungs 15 and 16 with 20 and 21, the counter would now only reset after the call to LEADRE and not after the call to LDIS? Also if I removed rung 21 and only had the one coil on rung 16 to reset my counter it would probably work there as well? (I will edit my program to try this for fun) Thanks for your help Steve, I've been doing most of the learning by myself with little previous experience and some answers to questions such as these are appreciated!

Share this post


Link to post
Share on other sites
It sounds like you're well on your way to understanding. My solution: Replace the coil LCTRRES on rung 16 with a new coil called (for example) RANGERESET and the coil LCTRRES on rung 21 with a new coil called (for example) GT17RST. Now anywhere in the ladder logic, add this rung: RANGERESET*****************************LCTRRES ---] [------------+-----------------------( )- ******************| GT17RST********** | ---] [------------+ If you can understand why this works and your original approach didn't, you understand how the PLC scan works. Edited by Steve Bailey

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0