Main Content

Input Capture

Measure frequency and duty cycle of external input signal

Since R2020b

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • Input Capture block icon

Libraries:
Simulink Support Package for Arduino Hardware / Common

Description

The Input Capture block measures the frequency and duty cycle of the external input signal on the digital pin of the Arduino® hardware board. The block utilizes the timer counters available on the Arduino hardware board along with the interrupt service routines to compute the frequency and duty cycle of the external input signal.

You can run a Simulink® model containing Input Capture block in Connected IO mode on Arduino boards.

For more information on the conflicting usage of digital pins for a Simulink model that uses one or more combination of PWM, Standard Servo Read, Standard Servo Write, Continuous Servo Write, and Input Capture blocks, see the Conflicting Pin Configurations on Arduino Timer section.

Limitation

Arduino Board ArchitectureMaximum Measurable FrequencyMeasurable Duty Cycle Range
AVR50KHz20% to 80%
SAMD400KHz
SAM400KHz
Nano 33 BLE Sense50KHz

Ports

Output

expand all

The block outputs the frequency of the external input signal in Hertz.

Data Types: uint32

The block outputs the duty cycle of the external input signal as a percentage.

Data Types: uint8

Parameters

expand all

Enter the Arduino hardware board pin number to which the external input signal is connected.

Note

Do not assign the same pin number to multiple blocks within a model.

To know more on how to assign pins or to view the fixed pins for the Input Capture block, see Pin Mapping for Arduino Timer Dependent Blocks.

Enter the time interval in seconds at which the block reads the external input signal from the specified pin number.

Version History

Introduced in R2020b