PWM and serial communication
2 次查看(过去 30 天)
显示 更早的评论
Hi,
i wish to communicate with mcu ATmega128 with PWM. I used to program the PWM pulse by setting the timer 0 and the mcu PWM port.
In Matlab, may i know how the PWM is generated, after i had the serial communication with the mcu code:
s=serial('COM6');
fopen(s);
fwrite(s,170,'unit8');
fwrite(s,170,'unit8');
fwrite(s,85,'unit8');
fwrite(s,85,'unit8');
fwrite(s,value,'unit8');
fwrite(s,value,'unit8');
fclose(s);
delete(s);
Besides, there's 1 more problem when I'm using fscanf(s,'*IDN?'), it show empty array and timer out because it can't reach the terminator. Is there any wrong in my code? Thanks. Your help is much appreciate.
0 个评论
回答(0 个)
社区
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!