Div_by_zero Posted September 30, 2014 Report Posted September 30, 2014 I have a program with a counter in it. Sometimes, I might have to count two different events that can both go high on the same scan. When this happens, the counter only increases by one, not two. I band-aided this by adding a 5 millisecond delay timer to the second event. I am not particularly fond of coding like this. Is there a way to delay the second event going by exactly one scan so that it properly advances the counter? For what it's worth, using P3K. As always, thanks for any help.
IO_Rack Posted October 9, 2014 Report Posted October 9, 2014 (edited) Use your second event as a NOT then drive a PLS. Use the PLS contact to drive your counter. EDIT: Depending upon your second event timing this may not be what you want. Have your second event drive a PLS 'A' then use PLS 'A' NOT drive PLS 'B'. Use PLS 'B' to drive your counter. Edited October 9, 2014 by IO_Rack
Div_by_zero Posted October 9, 2014 Author Report Posted October 9, 2014 Excuse my ignorance, but what is a PLS? Not sure if P3K has a NOT in it. I assume it must...
IO_Rack Posted October 9, 2014 Report Posted October 9, 2014 My appologies. I am the one confused here. I thought you were programming a PLC. I've not worked with the P3K.
IO_Rack Posted October 9, 2014 Report Posted October 9, 2014 In case it is helpful, the PLS I'm referring to is a Pulse or 'On for One Scan' instruction used in most AD PLCs. If you can make this happen with the P3K then consider this...
b_carlton Posted October 9, 2014 Report Posted October 9, 2014 (edited) Count both events individually then add the accumulated values together. Edited October 9, 2014 by b_carlton 1
IO_Rack Posted October 9, 2014 Report Posted October 9, 2014 I was going to suggest that since the scan delays were getting more messy than his timer. :)
Div_by_zero Posted October 10, 2014 Author Report Posted October 10, 2014 What I'm going to do (I think this suggestion has actually been implied) is ditch the counter and the baggage associated with it and just use integer math to index my sequencer.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now