You are here

Pulse Counter Event

Both pulse counters can notify the user:

  • when the pulse counter overflows (Free Run Mode and Time Based Mode);

  • when user-defined time period is exceeded (Time Based Mode);

  • when user-defined threshold number of pulses is detected (Pulse Based Mode);

  • periodically with predefined repeat interval.

 

For this purpose GPIO-24 adapter sends GPIO_EV_PLS_CNT event to your application. The conditions of the event generation are set with GPIO_SET_PLS_CNT_CFGcommand as described below.

If you want to receive the event when the counter overflows:

Specify 1 in Bit 0: EV_OVERFLOW of Byte 3. In this case the event is generated when maximum number of pulses (16,777,215) is reached. The event of this type can be sent in Free Run Mode and Time Based Mode. Byte 2: EVENT_TYPE of the event will contain GPIO_PLS_CNT_EV_OVERFLOW (1) value. The event will return the time, elapsed since last reset.

If you want to receive the event when the time period is exceeded:

Specify 1 in Bit 2: EV_MATCH of Byte 3. The event of this type can be sent in Time Based Mode, when user-defined time period is reached. Byte 2: EVENT_TYPEof the event will contain GPIO_PLS_CNT_EV_MATCH (3) value. The event will return the number of detected pulses.

If you want to receive the event when the user-defined number of pulses is detected:

Specify 1 in Bit 2: EV_MATCH of Byte 3. The event of this type can be sent in Pulse Based Mode, when user-defined threshold number of pulses is reached. Byte 2: EVENT_TYPE of the event will contain GPIO_PLS_CNT_EV_MATCH (3) value. The event will return the elapsed time.

If you want to receive the event periodically with predefined interval:

Specify the non-zero repeat interval in Byte 4: REPEAT. The repeat interval is set in units of 10 ms in the range from 10 to 167,772,150 ms (46.5 h). The event will return current number of detected pulses.

To summarize, the event returns the following information:

  • cause of the event (Byte 2: EVENT_TYPE):

    • GPIO_PLS_CNT_EV_OVERFLOW (1) – pulse counter overflows (maximum number of pulses – 16,777,215 – is reached);

    • GPIO_PLS_CNT_EV_REPEAT (2) – pulse counter is configured to send events periodically and the repeat interval has passed;

    • GPIO_PLS_CNT_EV_MATCH (3) – user-defined limit is reached: time period is exceeded (Time Based Mode) or threshold number of pulses is detected (Pulse Based Mode).

     

  • ID number of the pulse counter, which has generated the event (Byte 3: PLS_CNT_NUMBER);

  • returned value (Bytes 4..6: VALUE):

    • if Byte 7: VALUE_TYPE = GPIO_PLS_CNT_VAL_PULSES (0) – the event returns current number of detected pulses;

    • if Byte 7: VALUE_TYPE = GPIO_PLS_CNT_VAL_TIME (1) – the event returns elapsed time.

     

  • type of returned value (Byte 7: VALUE_TYPE):

    • GPIO_PLS_CNT_VAL_PULSES (0) – the event contains the number of detected pulses in Bytes 4..6: VALUE;

    • GPIO_PLS_CNT_VAL_TIME (1) – the event contains the elapsed time in Bytes 4..6: VALUE.