Reading serial data (NMEA) into simulink
12 views (last 30 days)
Show older comments
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 Comments
Answers (2)
Shankar Subramanian
on 13 Oct 2011
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
on 7 May 2013
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 Comments
See Also
Categories
Find more on Development Computer Setup in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!