フィルターのクリア

RS485 communication in matlab

35 ビュー (過去 30 日間)
Toke Søltoft
Toke Søltoft 2014 年 9 月 2 日
回答済み: Toke Søltoft 2014 年 9 月 2 日
Does matlab support RS485 support via com port? If so, I can't find any guide to how it works.
I have tried this code, but it does not work. If I send the numbers through realterm n RS485, it works fine.
s = serial('COM3','BaudRate',38400);
set(s,'StopBits',1);
set(s,'DataBits',8);
fopen(s);
fprintf(s,'2 7 2 2 255 255 255 248');
fwrite(s,'2 7 2 2 255 255 255 248');
fclose(s)

採用された回答

Toke Søltoft
Toke Søltoft 2014 年 9 月 2 日
I figured it out. I just needed to change the output to ascii characters, e.g.
fwrite(s,char(2,7,1,2,0,0,0,4));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by