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!