serial send ブロックで数値列を送る方法
조회 수: 2 (최근 30일)
이전 댓글 표시
シリアル通信でサーボモータを操作するプログラムをmatlabで作成、実行することができ、
同じものをsimulinkでも作ろうとしたのですが行き詰ってしまいました。解決方法を教えて頂けると嬉しいです。
作成したmatlabのコードは以下の通りです。
------------------------------------------------------------------------------------------------------
s = serialport("COM4",115200,"Parity","even");
write(s,[0x0B,0x10,0x04,0x00,0x00,0x00,0x00,0x01,0xFF,0x7F,0x9E],"uint8")
for i = 1:5
write(s,[0x07,0x0F,0x02,0x32,0x70,0x17,0xD1],"uint8")
pause(2)
write(s,[0x07,0x0F,0x02,0x01,0x28,0x23,0x64],"uint8")
pause(1)
end
write(s,[0x0B,0x10,0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0xA0],"uint8")
clear s;
---------------------------------------------------------------------------------------------------------
simulinkでは instrument control toolbox のserial send ブロックで同じ数値列を送るモデルを作成しましたが、
サーボモータが動作しませんでした。comportとの接続はできているようで、実行時にエラーは出ませんでした。

使うブロックが間違っていたり、足りなかったりするのかと色々調べてみましたが、解決に至りませんでした。
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Motor Control Blockset에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!