Using the period measuring mode allows to:
-
determine the duration of an event.
-
determine the time between two events.
-
set and measure the execution time for a process.
This counting mode consists of two sub-modes:
-
Rising edge to falling edge mode (edge to opposite): allows you to measure the duration of an event.
-
Rising edge to rising edge mode (edge to edge): allows you to measure the length of time between two events.
The user may also use the IN_SYNC input to enable or stop a measurement. It is also possible to specify a time out value in the configuration screen. This function allows to stop a measurement that exceeds this time out. In this case, the counting register is not valid until the next complete measurement.
The units used to measure the length of time of an event or between two events are defined by the user (1 μs, 100 μs or 1 ms).
In this sub-mode, the measurement is taken between the rising edge and the falling edge of the IN_A input. The counting register is updated as soon as the falling edge is detected.
The trend diagram below shows the operating mode of the edge to opposite sub-mode:
In this sub-mode, the measurement is taken between two rising edges of the IN_A input. The counting register is updated as soon as the second rising edge is detected.
The trend diagram below shows the operating mode of the edge to edge sub-mode:
Using the Synchronization Function
The trend diagram below illustrates the period measurement counting process in edge to opposite mode when using the synchronization function:
(1)
The falling edge of the IN_SYNC input stops measurement C.
(2)
This pulse is not measured because the IN_SYNC input is not at the high level.
NOTE: The valid_sync bit (%QWr.m.c.0.0) must be set to 1 to enable the IN_SYNC input. If the IN_SYNC input is not wired, the application must force the setting of the force_sync bit (%Qr.m.c.4) to 1 to authorize the measurements.
Counter Status Bits in Period Measuring Mode
The table below shows the composition of the counter’s %IWr.m.c.0 status word in period measuring mode:
|
Bit
|
Label
|
Description
|
|
%IWr.m.c.0.3
|
VALIDITY
|
Validity bit is used to indicate that the counter current value (period value) and compare status registers contain valid data.
If the bit is set to 1, the data is valid.
If the bit is set to 0, the data is not valid.
|
|
%IWr.m.c.0.4
|
HIGH_LIMIT
|
The bit is set to 1 when the measured period exceeds the user-defined timeout.
The bit is reset to 0 at the next period if the timeout is not reached.
|
|
%IWr.m.c.0.5
|
LOW_LIMIT
|
The bit is set to 1 when more than one measure occurs within 5 ms period.
The bit is reset to 0 at the next period if the limit is not reached.
|
In this mode, the type of the IODDT must be T_UNSIGNED_CPT_BMX.
The module can perform a maximum of 1 measurement every 5 ms.
The shortest pulse that can be measured is 100 μs, even if the unit defined by the user is 1 μs.
The maximum duration that can be measured is 1,073,741,823 units of time (unit defined by the user).
NOTE: You have to check the validity bit (%IWr.m.c.0.3) before taking into account the numerical values such as the counter and the capture registers. Only the validity bit at the high level (set to 1) guarantees that the mode will operate correctly within the limits.