« Close

Datasheets and User Guides

App Notes

Software & Driver

 

13.2.6 Pulse Width In [T-Series Datasheet]

Overview

 

T4 Capable DIO: DIO4, DIO5 (aka FIO4, FIO5)

 

T7 Capable DIO: DIO0, DIO1 (aka FIO0, FIO1)

Requires Clock Source: Yes

Index: 5

Streamable: Yes—integer READ registers only.

Operation

Pulse Width In will measure the high time and low time of a digital input signal, by counting the number of clock source ticks while the signal is high and low.  This could also be referred to as duty-cycle input or PWM input.  The number of high ticks can be read from DIO#_EF_READ_A and the number of low ticks can be read from DIO#_EF_READ_B.

Clock#Frequency = CoreFrequency / DIO_EF_CLOCK#_DIVISOR    //typically 80M/Divisor
HighTime(s) = DIO#_EF_READ_A / Clock#Frequency
LowTime(s) = DIO#_EF_READ_B / Clock#Frequency
Resolution(s) = 1 / Clock#Frequency
Max High or Low Time(s) = DIO_EF_CLOCK#_ROLL_VALUE / Clock#Frequency

CoreFrequency is always 80 MHz at this time, but in the future some low-power operational modes might result in different core frequencies.  The valid values for DIO_EF_CLOCK#_DIVISOR are 1, 2, 4, 8, 16, 32, 64, or 256, and a value of 0 (default) equates to a divisor of 1.  For more details about Clock#Frequency and DIO_EF_CLOCK#_DIVISOR, see the DIO-EF Clock Source section.

Roll value for this feature would typically be left at the default of 0, which is the max value (2^32 for the 32-bit Clock0), but you might be using a lower roll value for another feature such as PWM Out.

A couple typical scenarios with roll value = 0 and using the 32-bit clock (Clock0):

  • Divisor = 1, Resolution = 12.5 nanoseconds, MaxTime = 53.7 seconds
  • Divisor = 256, Resolution = 3.2 microseconds, MaxTime = 229 minutes

Once this feature is enabled, a new measurement happens on every applicable edge and both result registers are updated on every rising edge.  If you do another read before a new rising edge has occurred, you will get the same values as before.  Many applications will want to use the read-and-reset option so that a value is only read once and extra reads will return 0. (See Reset below.)

Configure

DIO#_EF_ENABLE: 0 = Disable, 1 = Enable
DIO#_EF_INDEX: 5
DIO#_EF_OPTIONS: Bits 0-2 specify which clock source to use ... 000 for Clock0, 001 for Clock1, and 010 for Clock2. All other bits reserved and should be set to 0.
DIO#_EF_CONFIG_A: Bit 1: 1=continuous, 0=OneShot. All other bits reserved.
DIO#_EF_CONFIG_B: Not used.
DIO#_EF_CONFIG_C: Not used.
DIO#_EF_CONFIG_D: Not used.

Update

No update operations can be performed on Pulse Width In.

Read

Results are read from the following registers.

DIO#_EF_READ_A: Returns the measured high time in clock source ticks and saves the low time so that it can be read later. If a full period has not yet been observed this value will be zero.
DIO#_EF_READ_B: Returns the measured low time in clock source ticks.  This is a capture register ... it is only updated when one of the READ_A registers is read.
DIO#_EF_READ_A_F: Returns the measured high time in seconds and saves the low time so that it can be read later. If a full period has not yet been observed this value will be zero.
DIO#_EF_READ_B_F: Returns the measured low time in seconds.  This is a capture register ... it is only updated when one of the READ_A registers is read.

Only reading DIO#_EF_READ_A or DIO#_EF_READ_A_F triggers a new measurement.

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: Performs the same read as READ_A, but then also clears the register so that zero is returned until another full period is measured.

DIO#_EF_READ_A_F_AND_RESET: Performs the same read as READ_A_F, but then also clears the register so that zero is returned until another full period is measured.

Example

First, configure the clock source.  Roll value would usually be set to 0 to provide the maximum measurable period, but assume for this example that we have to use 10000 because of PWM output on another channel:

DIO_EF_CLOCK0_DIVISOR = 8    // Clock0Frequency = 80M/8 = 10 MHz
DIO_EF_CLOCK0_ROLL_VALUE = 10000
DIO_EF_CLOCK0_ENABLE = 1

This clock configuration results in:

Resolution = 1 / 10M = 0.1 us

and

MaxPeriod = 10000 / 10M = 1 ms

Now configure the DIO_EF on DIO0 as pulse width input.

DIO0_EF_ENABLE = 0
DIO0_EF_INDEX = 5    // Pulse width input feature.
DIO0_EF_OPTIONS = 0  // Set to use clock source zero.
DIO0_EF_ENABLE = 1   // Enable the DIO_EF

After a full period (rising edge, falling edge, rising edge) has occurred, the values are stored in the result registers. This repeats at each rising edge. READ_A and READ_A_F both return the high time and save the low time that can be read from READ_B and READ_B_F. This ensures that both readings are from the same waveform cycle.

Rate Limits

T-Series IC Rate Limits

The maximum measurable frequency varies based on the one-shot setting, concurrent stream rate, and other DIO-EFs set to an input mode. 

One-shot or Continuous: When one-shot is enabled, the T-series devices will take a single measurement, then wait for a READ_A register to be read before taking another measurement. This means that with one-shot, only a small fraction of the total periods of a signal are measured. One-shot allows for higher maximum measurable frequency than continuous does.

Stream: The stream process is the highest priority process on T-series devices. When stream needs the processor, all other operations are put on hold. That hold occurs more frequently at higher stream speeds. When a DIO-EF process has to wait, the max frequency that can be measured is reduced.

Multiple DIO-EFs: DIO-EFs on other different lines also require processor time. The amount of processor time required depends on the signal being processed and the DIO-EF's settings. The maximum frequencies in the below table give the total max frequency for all running DIO-EFs—divide the max frequencies below by the number of enabled DIO-EFs to get the max frequency for each individual DIO-EF.

Refer to the following table for maximum measurable frequencies in various combinations of stream and one-shot.

Index One-shot or Continuous Stream Rate Max Frequency
3 or 4 Continuous Stream not running 200 kHz
3 or 4 One-shot Stream not running 750 kHz
3 or 4 Continuous 10 kHz 75 kHz
3 or 4 One-shot 10 kHz 750 kHz
3 or 4 Continuous 100 kHz 20 kHz
3 or 4 One-shot 100 kHz 250 kHz
       
5 Continuous Stream not running 200 kHz
5 One-shot Stream not running 750 kHz
5 Continuous 10 kHz 75 kHz
5 One-shot 10 kHz 750 kHz
5 Continuous 100 kHz 20 kHz
5 One-shot 100 kHz 250 kHz