sending serial data from Arduino to simulink
1 回表示 (過去 30 日間)
古いコメントを表示
Hi Every one
I am trying to send data from arduino to simulink through a serial receive block in simulink. I have written a simple code in arduin and created a simple simulink code for receiving serial data. I am using two arduino boards. First, I deployed the arduino code on the first one and then run the simulink code in external mode on the second one. The baud rate of port 1 which is used as transmitter in board 1 and as receiver in board 2, is 115200 and the time step is fixed to 0.01 in simulink code.
This is my arduino code:
void setup() {
Serial1.begin(115200);
}
void loop() {
Serial1 .write('2');
Serial.print('\n');
delay(10);
}
and bellow is a photo of the simulink code and the configuratin windws.
what I gt after running this coded is that no data is shoen in dispaly windows. Both displat data nd status are zero.
I also tried it by changing the baud rate and sample time but the same result.
I would really appreciate if any one could help me to understand what I have done wrong!
0 件のコメント
回答 (1 件)
Arun Kumar
2019 年 10 月 22 日
編集済み: Arun Kumar
2019 年 10 月 22 日
Hi,
Can you try putting the display block in enabled subsytem triggered by Status output of Serial Receive block. I think the data is being received but you are not able to see because the Serial Receive block outputs 0 when no data is available to read. Since your data is coming every 100mS, most of the time, Serial receive block will output 0.
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modeling についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!