Reading serial data (NMEA) into simulink
조회 수: 11 (최근 30일)
이전 댓글 표시
I have a NMEA compass connected to my PC through COM1 (4800 baud, 8 data bits, 1 stop bit, no parity).
It sends heading data into the following format:
$HCHDG,hhh.h,,,,<CR><LF>
where hhh.h is the direction the compass is heading in degrees with 1 decimal.
I am able to read the output of the compass using the "Query instrument". I tried saving the output of this block into a matlab file to check what happens, and it yields me a series of ascii codes corresponding to the format above (eg. 36 72 67 72 etc. which corresponds to $HCH). It's reading out the output as long as mu simulation runs, so I get a long string with multiple sentences in the format described above.
However, I am only interested in the heading hhh.h, and do not want all the other characters. I want to have a signal in my simulink model which is equal to the (realtime) heading to control my direction.
How can I filter out the heading from the Query Instrument output?
댓글 수: 0
답변 (2개)
Shankar Subramanian
2011년 10월 13일
Hi Jan,
Do you receive a response from the compass after you send a query command to it? Or do you continuously get data from the compass? If it is streaming, have you tried to use Serial Configuration and Serial Receive blocks? The Serial receive block has the option of specifying header and terminator on the mask to separate out the required data alone.
Thanks
Shankar
Marc
2013년 5월 7일
Hello,
I am trying to use "serial receive block" to recieve data from the gyros conected to my arduino. I send this with Serial.write() which sends bytes. My problem is: when I try to select my port (COM3) in the "serial receive block" no port apperas, just the sentence "please select a port..".
Is there any configuration that I might be missing? How can I select the port?
Thank you
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Development Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!