How do I store a value in Simulink (sample hold)?

9 ビュー (過去 30 日間)
Martin
Martin 2015 年 4 月 22 日
回答済み: James Brown 2017 年 2 月 14 日
I have a motor control system in Simulink-Realtime (fixed execution 16 kHz) and would like to display the average power per motor revolution (at 1 rev/s). The averaging is easy with a discrete integrator, but how do I store the final value? I want an updated display every motor turn. Currently I solved it by placing a memory block inside a triggered subsystem, but this seems overly complicated to me. Is there a more efficient way of implementing a sample-hold? As it is a real time system (62.5 us max. task execution time), I have to watch out for inefficient coding.

採用された回答

James Brown
James Brown 2017 年 2 月 14 日
I do this all the time with an enabled subsystem. Simply connect the input port to the output port inside the enabled subsystem. Configure the output port: "Output when disabled" to be 'held.' You can now raise the enable signal for one sample period whenever you want the data to be help. For example, pulse the enable port to high at one hertz to create a 1 second sample and hold.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by