フィルターのクリア

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 件)

コミュニティ

カテゴリ

Help Center および File ExchangePulse width modulation (PWM) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by