0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

simulink UART出力 その2

Last updated at Posted at 2023-03-26

 前回、matlabのsimulinkの環境で、シリアル(UART)で信号を出力する実験をしました。今回は、その出力を、Arduinoのシリアルで受けます。

simulink-UARTa.png

動作環境

  • Windows10 Pro 22H2
  • matlab R2023a
  • Arduino IDE2.0.4

 USB-UART変換ボートは、前回の記事を参照してください。
 ボード間の接続です。

USB-UART変換ボード Arduino Zero
TxD 13->Rx
RxD 14<-Tx
GND GND

IMGP1644.png

simulinkの設定

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3430373633352f34373062653665322d643433342d623139342d353165652d3539623934386136633062322e706e67.png

 プロパティです。
68747470733a2f2f71696974612d696d6167652d73746f72652e73332e61702d6e6f727468656173742d312e616d617a6f6e6177732e636f6d2f302f3430373633352f61336432376330352d363862392d643263642d623037302d3136346533326633643163622e706e67.png

 定数のプロパティです。32ビットのデータで、”AB”を送ります。(uint16でいいのかな?)
s101.png

s102.png

シリアルでデータを受けるArduino側

 スケッチです。Serialはシリアルモニタで、Serial1はUARTポートです。

void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }
}

 シリアルモニタを起動しておきます。simurinkを実行します。
 受信しました。

2023-03-26 (2).png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?