フィルターのクリア

generating square wave to control a motor without using simulink

2 ビュー (過去 30 日間)
Jonathan Duncan
Jonathan Duncan 2017 年 12 月 27 日
コメント済み: Jonathan Duncan 2017 年 12 月 29 日
Hello I'm trying send a square pulse to an arduino board using just coding in matlab no SIMULINK I've used this so far.
while v <=5
for v = [0:0.1:5 5:-0.1:0]
writePWMVoltage(a,'D9', v);
pause(0.333);
writePWMVoltage(a,'D3', v);
pause(1);
this code helps to dim a light via PWM I was wondering if the pulstran() function would work to generate a square wave I have used this so far.
y = pulstran(t,d,'rectpuls',0.03)
I need to be able to control the pulse width, has anyone done anything like this without using simulink?

回答 (1 件)

Nick Choi
Nick Choi 2017 年 12 月 29 日
The 'writePWMDutyCycle' function in the MATLAB Support Package for Arduino would allow you to control the duty cycle/pulse width of the PWM signal. The following example in the documentation shows how to control the brightness of an LED using this function:
Additional information on the 'writePWMDutyCycle' function can be found here:
  1 件のコメント
Jonathan Duncan
Jonathan Duncan 2017 年 12 月 29 日
I will try when I get back to my lab on holiday right now.

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

コミュニティ

カテゴリ

Help Center および File ExchangeArduino Hardware についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by