News:

  • August 22, 2026, 07:46:09 PM

Login with username, password and session length

Author Topic: Counting the number of times a stage has ran  (Read 8802 times)

Henryp

  • Hero Member
  • *****
  • Posts: 161
Counting the number of times a stage has ran
« on: May 30, 2018, 11:04:14 AM »
I'm trying to count the number of times a stage has ran by using the $main.S3 signal to increment a counter. However it doesn't work. I tried using a control relay driven by the $main.S3 signal it doesn't work either. However, if  I force then un-force the control relay it works just fine. Attached is a print screen showing the logic.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Counting the number of times a stage has ran
« Reply #1 on: May 30, 2018, 11:59:07 AM »
The counter won't increment because it never sees the input to the counter off. When the stage is inactive, the counter is not scanned.

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Re: Counting the number of times a stage has ran
« Reply #2 on: May 30, 2018, 12:09:29 PM »
Would a one shot work for the input to the counter? But can not jump out of the stage before that happens. If the bit on the rung of your jmp happens before the one shot is able to work then that won't work either. Maybe just put the counter in a stage or section of the program that is always running.

Henryp

  • Hero Member
  • *****
  • Posts: 161
Re: Counting the number of times a stage has ran
« Reply #3 on: May 30, 2018, 01:23:37 PM »
I can try it in the always on stage but according to the documentation "Each time this input logic transitions from OFF to ON, the Counter's accumulator will increment by one"

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: Counting the number of times a stage has ran
« Reply #4 on: May 30, 2018, 01:28:33 PM »
Reserve a C bit. Place an 'always on' rung at the end of the stage leading to an OUT of the C bit. Somewhere earlier in the stage place a rung with a normally closed of the C bit leading to an increment of a register. The register will increment once per execution of the stage. (This is assuming there is at least one scan between the stage ending and it being called again. If this may not be true place an RESET of the chosen C bit in the same rung or stage which triggers the monitored stage.)
« Last Edit: May 30, 2018, 01:41:02 PM by b_carlton »
An output is a PLC's way of getting its inputs to change.

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Counting the number of times a stage has ran
« Reply #5 on: June 02, 2018, 02:23:42 AM »
Check your to make sure the stage is activated either with a JMP or SGSET command.

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Counting the number of times a stage has ran
« Reply #6 on: June 02, 2018, 12:38:51 PM »
I would not even use a counter, and instead use an INC, or even MATH.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: Counting the number of times a stage has ran
« Reply #7 on: June 03, 2018, 07:57:27 PM »
I would not even use a counter, and instead use an INC, or even MATH.
My thought as well.