フィルターのクリア

Varying PWM dutycycle with session-based interface in Data Acqusition Toolbox

2 ビュー (過去 30 日間)
Eddy H
Eddy H 2016 年 3 月 30 日
コメント済み: jAwA 2016 年 7 月 5 日
Hi,
I want to vary the duty cycle of PWM without stopping the session. My code is based on this example: http://uk.mathworks.com/help/daq/examples/generate-pulse-width-modulated-signals-using-ni-devices.html.
s = daq.createSession('ni');
ch = addCounterOutputChannel(s,'Dev1', 0, 'PulseGeneration')
ch = s.Channels(1);
ch.Frequency = 50;
ch.InitialDelay = 0;
ch.DutyCycle = 0.1;
s.Rate = 1000;
s.DurationInSeconds = 10;
s.startForeground();
If I want to change the duty cycle, I currently have to use this code, but it creates a jutter:
s.stop
ch.DutyCycle = 0.05
startBackground(s)
Can anyone suggest an alternative that does not require stopping the session? The documentation suggests that I can change without stopping the session, see bottom line of http://uk.mathworks.com/help/daq/ref/dutycycle.html, but this does not work in practice and I get an error message.
FYI I'm using this to control a servo.
Many thanks
  1 件のコメント
jAwA
jAwA 2016 年 7 月 5 日
Any news on this? I am also very interested in a solution for this issue for a DC motor control with PWM.

サインインしてコメントする。

回答 (0 件)

コミュニティ

カテゴリ

Help Center および File ExchangeData Acquisition Toolbox Supported Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by