Reading serial data (NMEA) into simulink

조회 수: 11 (최근 30일)
Jan De Vries
Jan De Vries 2011년 10월 2일
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?

답변 (2개)

Shankar Subramanian
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
  댓글 수: 2
Jan De Vries
Jan De Vries 2011년 10월 13일
The compass is sending signals constantly, 10 times a second.
Jan De Vries
Jan De Vries 2011년 10월 13일
Just took a quick look at the serial receive block, might be what I'm looking for.
Now I need to find a way to extract the heading info from the NMEA sentence, that is, to get hhh.h from the sentece
$HCHDG,hhh.h,,,,<CR><LF>

댓글을 달려면 로그인하십시오.


Marc
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

카테고리

Help CenterFile Exchange에서 Development Computer Setup에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by