Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Henryp on May 30, 2018, 11:04:14 AM

Title: Counting the number of times a stage has ran
Post by: Henryp 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.
Title: Re: Counting the number of times a stage has ran
Post by: ATU 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.
Title: Re: Counting the number of times a stage has ran
Post by: PLCGuy 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.
Title: Re: Counting the number of times a stage has ran
Post by: Henryp 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"
Title: Re: Counting the number of times a stage has ran
Post by: b_carlton 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.)
Title: Re: Counting the number of times a stage has ran
Post by: LWgreys on June 02, 2018, 02:23:42 AM
Check your to make sure the stage is activated either with a JMP or SGSET command.
Title: Re: Counting the number of times a stage has ran
Post by: plcnut on June 02, 2018, 12:38:51 PM
I would not even use a counter, and instead use an INC, or even MATH.
Title: Re: Counting the number of times a stage has ran
Post by: Garyhlucas 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.