PWM and serial communication

2 次查看(过去 30 天)
Shawn Chang
Shawn Chang 2012-6-19
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 个)

社区

更多回答在  Power Electronics Control

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by