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!