Skip to main content
Skip table of contents

13.2.8 High-Speed Counter [T-Series Datasheet]

Overview

T4/T7 Capable DIO: DIO16, DIO17, DIO18, DIO19 (aka CIO0, CIO1, CIO2, CIO3)

T8 Capable DIO: DIO6, DIO7, DIO8, DIO10, DIO13, DIO14, DIO15 (aka FIO6, FIO7, EIO0, EIO2, EIO5, EIO6, EIO7)

Requires Clock Source: No

Index: 7

Streamable: Yes—integer READ registers only.

T4 and T7 devices support up to 4 high-speed rising-edge counters that use hardware to achieve high count rates. These counters are shared with other resources as follows:

  • CounterA (DIO16/CIO0): Used by EF Clock0 & Clock1.
  • CounterB (DIO17/CIO1): Used by EF Clock0 & Clock2.
  • CounterC (DIO18/CIO2): Always available.
  • CounterD (DIO19/CIO3): Used by stream mode.

The T8 supports up to 7 high-speed rising-edge counters that use hardware to achieve high count rates. These counters are shared with other resources as follows:

  • DIO14/EIO6: Used by EF Clock0 & Clock1.
  • DIO15/EIO7: Used by EF Clock0 & Clock2.

Configure

DIO#_EF_ENABLE: 0 = Disable, 1 = Enable
DIO#_EF_INDEX: 7
DIO#_EF_CLOCK_SOURCE: Not used.
DIO#_EF_CONFIG_A: Not used.
DIO#_EF_CONFIG_B: Not used.
DIO#_EF_CONFIG_B: Not used.
DIO#_EF_CONFIG_B: Not used.

Update

No update operations can be performed with High-Speed Counter.

Read

Results are read from the following register.

DIO#_EF_READ_A: Returns the current count which is incremented on each rising edge.

Stream Read

All operations discussed in this section are supported in command-response mode.  In stream mode, you can read from the integer READ registers (A, B, A_AND_RESET), but as mentioned in the Stream Section those reads only return the lower 16 bits so you need to also use STREAM_DATA_CAPTURE_16 in the scan list to get the upper 16 bits.

Reset

DIO#_EF_READ_A_AND_RESET: Reads the current count then clears the counter. There is a brief period of time between reading and clearing during which edges can be missed. During normal operation this time period is 10-30 µs. If missed edges at this point are not acceptable, then do not use reset but rather just note the "virtual reset" counter value in software and subtract it from other values.

Frequency Measurement

Counters are often used to measure frequency by taking change in count over change in time:

Frequency = (CurrentCount - PreviousCount) / (CurrentTimestamp - PreviousTimestamp)

Typically the timestamps are from the host clock (software), but for more accurate timestamps read the CORE_TIMER register in the same Modbus packet as the READ registers. See the System Timing Register section for more information about the CORE_TIMER.

Also note that other digital extended features are available to measure frequency by timing individual pulses rather than counting over time.

Example

Enable a high speed counter on DIO18/CIO2 (use DIO6 for the T8):

DIO18_EF_ENABLE = 0
DIO18_EF_INDEX = 7
DIO18_EF_ENABLE = 1

Enable a high speed counter on DIO17/CIO1 (use DIO14 for the T8):

DIO_EF_CLOCK0_ENABLE = 0    //Make sure Clock0 is disabled.
DIO_EF_CLOCK2_ENABLE = 0    //Make sure Clock2 is disabled.
DIO17_EF_ENABLE = 0
DIO17_EF_INDEX = 7
DIO17_EF_ENABLE = 1

Results can be read from the READ registers defined above.

Edge Rate Limits

See Appendix A-2.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.