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 Community

카테고리

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