PWM Frequency and Duty Measurement

This example shows how to measure PWM signal frequency and duty using Simulink Desktop Real-Time™. The measured signal is connected to gate pins of two counter inputs of your data acquisition board. The first Counter Input block is configured to measure signal duty by measuring the time between rising and falling edge of the signal. The other Counter Input block is configured to measure signal period by measuring the time between two rising edges of the signal. Both the counters use internal on-board clock as the clock source. PWM frequency and duty are then computed based on these values.

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

Run Model in Normal Mode

This model is pre-set to be used with the National Instruments PCIe-6323 board. You can use it with any board from the PCIe-63xx series. To change the board, open both the Counter Input blocks and select your data acquisition board. You may need to register the board by clicking the Install new board button first.

Alternatively, you can also use any board from the PCI-62xx series or the PCI-60xx series. For these boards, please change the Counter base frequency from 100 MHz to 80 MHz or 20 MHz, respectively.

To switch to normal mode if needed, double-click the orange button in the model.

To start the real-time execution, on the Simulation tab, click Run.

Run Model in External Mode

This model is pre-set to be used with the National Instruments PCIe-6323 board. You can use it with any board from the PCIe-63xx series. To change the board, open both the Counter Input blocks and select your data acquisition board. You may need to register the board by clicking the Install new board button first.

Alternatively, you can also use any board from the PCI-62xx series or the PCI-60xx series. For these boards, please change the Counter base frequency from 100 MHz to 80 MHz or 20 MHz, respectively.