How to set Arduino TCCR1A and TCCR1B PWM-parameters in MATLAB?

4 次查看(过去 30 天)
Hello World,
It's needed to change Pulse-width modulation frequency on Arduino Board by Matlab, but could not find the way to do so.
In arduino coder it's perfectly realized by:
void setup()
{ TCCR1A = TCCR1A & 0xe0 | 1;
TCCR1B = TCCR1B & 0xe0 | 0x09;
}
but in MatLab?

采纳的回答

Sergiy Sheyko
Sergiy Sheyko 2019-1-27
In the Matlab Arduino package there is the file:
c:\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\matlab\hardware\supportpackages\arduinoio\src\ArduinoServer.ino
Modify it setup() function:
void setup()
{ MWArduino.begin([connection_type]);
TCCR1A = TCCR1A & 0xe0 | 1;
TCCR1B = TCCR1B & 0xe0 | 0x09;
}
  1 个评论
hongjie cui
hongjie cui 2019-4-28
编辑:hongjie cui 2019-4-28
hi,i want to change arduino pwm frequency using simulink Arduino package,i used arduino pwm block in simulink,but it can not change pwm frequency.i set Arduino TCCR1A and TCCR1B PWM-parameters following your answer, it works in matlab,but it does not work in simulink.
so,i want to know how to change arduino pwm frequency using simulink?thank you for your reply!
if you have any ideas,please reply me or email to me:1945235463@qq.com.thank you very much!

请先登录,再进行评论。

更多回答(0 个)

社区

更多回答在  Power Electronics Control

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by