Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 13-10-2017, 07:54   #1
Registered User

Join Date: Oct 2017
Posts: 7
Opencpn - nmea sentence generator

Hi all

My aim is give a random GPS location in opencpn without a gps plugged in
then generate nmea gps sentences based on this gps location to control the boat on open cpn.

Any advice or plugins which could help?

All suggestions welcomed
new_to_cuiser is offline   Reply With Quote
Old 13-10-2017, 10:31   #2
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

How computer techy are you?

If you can to google a program called nod-red and load that then I probably have enough snippits of code which are easy to run in node-red to do something like that then output a feed which opencpn can read. I've that's not too daunting then I could post an overview. If you're into playing with NMEA (or anything going in or out or your computer) then node-red is really useful.

conachair is offline   Reply With Quote
Old 13-10-2017, 16:05   #3
Registered User

Join Date: Oct 2017
Posts: 7
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by conachair View Post
How computer techy are you?

If you can to google a program called nod-red and load that then I probably have enough snippits of code which are easy to run in node-red to do something like that then output a feed which opencpn can read. I've that's not too daunting then I could post an overview. If you're into playing with NMEA (or anything going in or out or your computer) then node-red is really useful.

Thanks for the reply conachair

Im no tech wiz but that doesnt sound to daunting a task, well at least hopefully haha
If you could that would be great, eager to play around with it

Thanks again!
new_to_cuiser is offline   Reply With Quote
Old 13-10-2017, 16:57   #4
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by new_to_cuiser View Post
Thanks for the reply conachair

Im no tech wiz but that doesnt sound to daunting a task, well at least hopefully haha
If you could that would be great, eager to play around with it

Thanks again!
What computer are you running Opencpn on?
Linux is really simple to get node red running on, Windows not much harder.
The extra modules are probably easier to install inside the program once it is running.
https://youtu.be/hEpeobDyj8k
conachair is offline   Reply With Quote
Old 13-10-2017, 21:17   #5
Registered User

Join Date: Aug 2015
Location: Sozopol
Boat: Riva 48
Posts: 1,394
Re: Opencpn - nmea sentence generator

The most flexible way to do this is with Python. Download the package, install, learn the basics in 2-3 hours, then you can easily write simple scripts to read from a serial port, write to a serial port, etc. For NMEA 0183, you need a script to calculate XOR checksums. It is a one line command in Python.

The fastest way is to just create a GPS track in Excel, use Excel functions to create NMEA sentences, turn off checksums, then just use a copy to serial command on the computer.

Still, if you want to play around with NMEA, I would learn basic Python. I was looking at the OpenCPN plug-in, got frustrated with it's limitations then went to Python. Everything is much easier now.
Pizzazz is offline   Reply With Quote
Old 14-10-2017, 04:10   #6
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by Pizzazz View Post
The most flexible way to do this is with Python. Download the package, install, learn the basics in 2-3 hours, then you can easily write simple scripts to read from a serial port, write to a serial port, etc. For NMEA 0183, you need a script to calculate XOR checksums. It is a one line command in Python.

The fastest way is to just create a GPS track in Excel, use Excel functions to create NMEA sentences, turn off checksums, then just use a copy to serial command on the computer.

Still, if you want to play around with NMEA, I would learn basic Python. I was looking at the OpenCPN plug-in, got frustrated with it's limitations then went to Python. Everything is much easier now.
An hour or two with node-red you might not say that....

Drag and drop a complex path in moments
conachair is offline   Reply With Quote
Old 14-10-2017, 04:23   #7
Registered User

Join Date: Jan 2011
Location: France/UK
Boat: Gib'Sea 402
Posts: 548
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by conachair View Post
An hour or two with node-red you might not say that....

Drag and drop a complex path in moments
I have node-red on my Windows lap-top but I think it's difficult to see where to start. There's lots on line but it is assumed everyone knows how it comes together ... ...

Any pointers to a beginner's tutorial?
hoolie is offline   Reply With Quote
Old 14-10-2017, 05:09   #8
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by hoolie View Post
I have node-red on my Windows lap-top but I think it's difficult to see where to start. There's lots on line but it is assumed everyone knows how it comes together ... ...

Any pointers to a beginner's tutorial?
Really quick intro -

You can think of a 'flow' as a series of guys(nodes) which do different things and a 'book' gets passed from one to another. The book(s) is usually called msg, so the payload chapter is msg.payload. The payload is used a lot to send data along but the message can contain much more.

The input nodes start writing the book from info coming in or just create something themselves.

So at the very top there is an inject node, drag one of them onto the main screen and double click on it , inside at the top next to payload click the arrow and select the "string" option, a string is just another name for some text. Then you can write "my first node red" and set it to repeat say every 2 seconds.
Next drag a debug tab from the output nodes onto the main screen and join the 2 little grey boxes. You've created your first flow! Now hit deploy and it gets saved and starts to do its stuff.
So what happens is every 2 seconds the inject node sends a book to the debug node, in the book in the chapter called payload is the text "my first node red". The debug tab reads this chapter and all this guy does is read what's in the msg.payload chapter and display the in the debug tab at the righthand side of the screen.

That's the heart of it, instead of or as well as the debug node you could send the output of the inject node to an email, or twitter, or save it to a file or a database. Same the other way round, take the output of a serial node and save it to a file, so much you can do

The function nodes are a bit more complex, they usually use the javascript language to do things to the message in the 'book', so you could strip apart a nmea message coming in from a serial input of you computer and save just the bits you want to a file.

Then there's the dashboard which can display all sorts of charts, text, dials.




Here's one page of my dashboard on a the boat raspberry pi >

conachair is offline   Reply With Quote
Old 16-10-2017, 04:56   #9
Registered User

Join Date: Oct 2017
Posts: 7
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by conachair View Post
What computer are you running Opencpn on?
Linux is really simple to get node red running on, Windows not much harder.
The extra modules are probably easier to install inside the program once it is running.
https://youtu.be/hEpeobDyj8k
Hi Conachair

Sorry for the delayed reply i was finishing up in college on friday when i was speaking to you
work nights on the weekends which has me all over the place

Ive got node-red setup on my windows PC
Is there any chance you can give me a quick tutorial to get me going with interacting with opencpn ??

Thanks
new_to_cuiser is offline   Reply With Quote
Old 16-10-2017, 05:04   #10
Registered User

Join Date: Oct 2017
Posts: 7
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by Pizzazz View Post
The most flexible way to do this is with Python. Download the package, install, learn the basics in 2-3 hours, then you can easily write simple scripts to read from a serial port, write to a serial port, etc. For NMEA 0183, you need a script to calculate XOR checksums. It is a one line command in Python.

The fastest way is to just create a GPS track in Excel, use Excel functions to create NMEA sentences, turn off checksums, then just use a copy to serial command on the computer.

Still, if you want to play around with NMEA, I would learn basic Python. I was looking at the OpenCPN plug-in, got frustrated with it's limitations then went to Python. Everything is much easier now.
Again sorry for the delayed replay i work nights on the weekends don't get much time for myself
I have a bit of knowledge on python, basics enough scripts is all that i was exposed too
Im not familiar with the nmea standards or how it interacts with opencpn
any chance of a debrief from you ?
new_to_cuiser is offline   Reply With Quote
Old 16-10-2017, 06:25   #11
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by new_to_cuiser View Post
Hi Conachair

Sorry for the delayed reply i was finishing up in college on friday when i was speaking to you
work nights on the weekends which has me all over the place

Ive got node-red setup on my windows PC
Is there any chance you can give me a quick tutorial to get me going with interacting with opencpn ??

Thanks
You could give this a go - If you copy the code below you can import it into node red, on the node red webpage you can either go into the menu top left and select import clipboard or easier just to press ctrl i, paste the code in and you should have something which looks like this -



What's going on here is, the inject node on the left in this case is just acting as a trigger, next node is a function node, it sees something coming in so does its thing which in this case makes a nmea sentence without a checksum and without the leading "$", next node is another function node, it creates a checksum and adds the leading "$", then this goes to a debug node so you can see what's going out in the debug tab and it also goes to a UDP out node. So if you set an opencpn connection to receive on that IP addresss and port you should be good.

This example is with opencpn running on the same machine as node-red, the IP address 127.0.0.1 is the local machine. (I'm not really 100% with the inner workings of IP , TCP & UDP but that address & port should work)

So now it should be really windy!

You can either look in "show nmea debug" to see if the sentence is coming in or make a dashboard looking at windspeed.

Creating some random nmea sounds fun, later on I'll have a play with that and see where the boat ends up



Edit -> That was SO easy, took about a minute on google, code now sends a random windspeed between 1 & 100Kts every 2 seconds. This is sppeded u to 5 time a second, looks like dashboard struggles to keep up..


Code:
[
    {
        "id": "12dfa652.41d6aa",
        "type": "inject",
        "z": "1febfe0b.5f6be2",
        "name": "",
        "topic": "first",
        "payload": "My first flow",
        "payloadType": "str",
        "repeat": "2",
        "crontab": "",
        "once": false,
        "x": 150,
        "y": 160,
        "wires": [
            [
                "6152a454.63eb8c"
            ]
        ]
    },
    {
        "id": "6152a454.63eb8c",
        "type": "function",
        "z": "1febfe0b.5f6be2",
        "name": "Make MWV nmea sentence",
        "func": " //      1   2 3   4 5\n //       |   | |   | |\n //$--MWV,x.x,a,x.x,a*hh<CR><LF>\n//Field Number:\n\n//1.Wind Angle, 0 to 360 degrees\n\n//2.Reference, R = Relative, T = True\n\n//3.Wind Speed\n\n//4.Wind Speed Units, K/M/N\n\n//5.Status, A = Data Valid\n\n\nvar random = Math.floor((Math.random() * 100) + 1);\n\nvar nmea=\"NRMWV,179,R,\" + random + \",N,A\";\n\n\n\n\nmsg.payload = nmea;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 340,
        "y": 260,
        "wires": [
            [
                "a502b1b2.3fadd"
            ]
        ]
    },
    {
        "id": "a502b1b2.3fadd",
        "type": "function",
        "z": "1febfe0b.5f6be2",
        "name": "calc checksum",
        "func": "var nmea = msg.payload;\nvar checksum = 0; \n\nfor(var i = 0; i < nmea.length; i++) { \n  checksum = checksum ^ nmea.charCodeAt(i); \n}\nchecksum = checksum.toString(16);    //convert to hex\nnmea = '$' + nmea + '*' + checksum;  //make the full nmea sentence again\n\nmessage = 'Full message =' + nmea + '\\r\\n' + 'Checksum = ' + checksum ;\n\nmsg.payload = nmea;\nmsg.payload = msg.payload+\"\\r\\n\"\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 460,
        "y": 160,
        "wires": [
            [
                "e1d4dae2.f67ef8",
                "28e709ba.9c6476"
            ]
        ]
    },
    {
        "id": "e1d4dae2.f67ef8",
        "type": "udp out",
        "z": "1febfe0b.5f6be2",
        "name": "",
        "addr": "127.0.0.1",
        "iface": "",
        "port": "10108",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 692.9999694824219,
        "y": 143.0000352859497,
        "wires": []
    },
    {
        "id": "28e709ba.9c6476",
        "type": "debug",
        "z": "1febfe0b.5f6be2",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "true",
        "x": 610,
        "y": 80,
        "wires": []
    }
]
conachair is offline   Reply With Quote
Old 16-10-2017, 10:16   #12
Registered User

Join Date: Oct 2017
Posts: 7
Re: Opencpn - nmea sentence generator

Hi conachair

thanks for the intro i got it up and running
im impressed with how quick it was using node red
that was too simulate the wind speeds detected on the boat? the type of sentence was mwv
your obviously up to scratch on nmea standard?
im new too nmea standard and was just wondering
what is the type of nmea sentence to update gps location
and the type to update the boats heading

my end goal is too move boat in open cpn changing the heading of the boat

thanks again
new_to_cuiser is offline   Reply With Quote
Old 16-10-2017, 12:09   #13
cruiser

Join Date: Nov 2007
Location: Probably in an anchorage or a boatyard..
Boat: Ebbtide 33' steel cutter
Posts: 5,030
Re: Opencpn - nmea sentence generator

Quote:
Originally Posted by new_to_cuiser View Post
Hi conachair

thanks for the intro i got it up and running
im impressed with how quick it was using node red
that was too simulate the wind speeds detected on the boat? the type of sentence was mwv
your obviously up to scratch on nmea standard?
im new too nmea standard and was just wondering
what is the type of nmea sentence to update gps location
and the type to update the boats heading

my end goal is too move boat in open cpn changing the heading of the boat

thanks again
Glad it worked first time!!

Yes that was windspeed, just happened to be one I was playing around with and had to hand.

Lots info on NMEA on the web,
NMEA Revealed
from memory the RMC sentence should be enough to give position. There's two types of "heading", course over ground and heading, so the direction the ship is going and the direction the ship is pointing, not always the same.
Getting into all that with random numbers might mean a bit more programming but the concept should be pretty much the same. Suppose you could have a random plus, zero or minus then add that to the lat and long after sorting out the units, ISTR nmea RMC et al use something like 3928.22 for 39deg, 28.33 minutes. Different from the normal deg we use anyway.
This might be a morning brain exercise over coffee soon
conachair is offline   Reply With Quote
Old 17-10-2017, 05:28   #14
Registered User

Join Date: Oct 2003
Posts: 125
Re: Opencpn - nmea sentence generator

If I may come in here!

I use licensed charts on a dongle from "Visit My Harbour with Open CPN, in my capacity as a professional delivery skipper. At present I use a USB type GPS and provides for what I need, on passage, but using the boat's instruments for other information. However, I want to use the VDR Plug-in, now installed, to provide me with much more detail, and to look back on after the passage.

The essence here is being on different boats. How can I collect all the NMEA data from the vessel when on passage to use integrally with Open CPN. Hard wiring is not an option, when it's not your yacht! Older yachts seldom have Wi-Fi/Bluetooth!

Any information that members can offer that can actually be used will be most welcomed, thank you.
katoema is offline   Reply With Quote
Old 17-10-2017, 06:47   #15
Registered User

Join Date: Feb 2012
Location: Austria
Posts: 320
Re: Opencpn - nmea sentence generator

I use openplotter on rpc3 for professional delivery jobs. Works great and so I have always familiar user interface including ais.
skipperearly is offline   Reply With Quote
Reply

Tags
enc, generator, nmea, opencpn


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opencpn crashes when receiving WIMDA nmea sentence, conachair OpenCPN 25 03-10-2017 03:18
Radio Ocean O.Chart 7 NMEA 0183 Sentence moteje Marine Electronics 0 23-09-2013 04:13
NMEA WPL sentence support? s/v Jedi OpenCPN 9 04-03-2013 04:29
OpenCPN and NMEA sentence dmoore OpenCPN 8 21-12-2012 12:47
MOB NMEA sentence Cavalier Marine Electronics 13 27-08-2012 10:12

Advertise Here


All times are GMT -7. The time now is 02:33.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.