This article explains how to implement a pulse counting mechanism using SCADAPack 474 logic, leveraging a soft counter and a digital input (DI) for reset functionality. The logic is designed to work with physical I/O constraints, where the external counter retains its value and cannot be reset to zero.
Connections
- Pulse Input: Connect the pulse signal to
PIO_SP474_CI1, which acts as the physical counter input. - Soft Counter: Use a
SoftCountervariable to track the pulse count logically. - Reset Input: Connect a digital input to
PIO_SP474_DI1, which will be used to trigger a logical reset.
Key Logic Operations
-
Copy Counter Value to SoftCounter
The current value fromPIO_SP474_CI1is copied toSoftCounter.VALUEduring each scan cycle. -
Reset Temporary Counter Value
AMOVEblock resetstempCounterValuewhen required. -
Trigger-Based Reset Using DI1
WhenPIO_SP474_DI1transitions from high to low (falling edge), the value ofPIO_SP474_CI1is loaded intotempCounterValue. This simulates a reset by establishing a new reference point. -
Calculate Difference and Update SoftCounter
The logic comparesPIO_SP474_CI1.VALUEwithtempCounterValueusingGT,LT, andEQblocks.
Based on the comparison, aSUB_UDINTblock calculates the difference and updatesSoftCounter.VALUE.
Working Principle
Since the physical counter (PIO_SP474_CI1) cannot be reset, the logic uses a reference value (tempCounterValue) to simulate a reset. The SoftCounter reflects the number of pulses counted since the last reset trigger, calculated as:
The below image shows a screenshot of the counter working principle.
This approach ensures accurate pulse tracking while respecting the hardware limitations of SCADAPack I/O.