Main Content

Frequency Measurement

This example shows how to measure input signal frequency by using Simulink Desktop Real-Time™. The measured signal is connected to the counter input of your data acquisition board. Counter Input block is configured to reset counter each sample-hit after counter read. Dividing counter value by sample time gives input signal frequency.

Note: To run this model, you must have a data acquisition board with counter input connected to your computer.

Run Model in Connected IO Mode

  1. Open the Counter Input block and select your data acquisition board. If there is no board installed, install it by clicking the Install new board button.

  2. To switch to Connected IO mode if needed, on the Desktop Real-Time tab, select Mode > Connected IO.

  3. To start the real-time execution, click Run in Real-Time.

Run Model in Run in Kernel Mode

  1. Open the Counter Input block and select your data acquisition board. If there is no board installed, install it by clicking the Install new board button.

  2. To switch to Run in Kernel mode if needed, on the Desktop Real-Time tab, select Mode > Run in Kernel.

  3. To start the real-time execution, click Run in Real-Time.

The model builds, connects to Run in Kernel mode, and starts.

Open the Model

open_system(fullfile(matlabroot,'toolbox','sldrt','sldrtexamples','sldrtex_counter'));

Close Open Scopes

close_system(find_system(gcs ,'BlockType', 'Scope'));

Clean Up Model

clear
close all
bdclose all

See Also