Go Down

Topic: NMEA 2000 Shield (Read 391497 times) previous topic - next topic

fredda_lk

Hi Timo
First o all, thank you for your fantastic work.

I'm using a Arduino Mega with MCP2515 Can modified with a 16Mzh crystal. When I'm running your example ActisenseListener everything works great together with Actisense reader!

But when I run DataDisplay2 I get different results every time in my serial port. Sometime I only get 1 sentence, other times I get 10-20 sentences and sometimes I get 200 sentences.
When I restart the Arduino it works directly again and I get some sentences.

Do you have any idea why I'm getting different amount of data?

timolappalainen

Where you are getting the data and how much there is data? How many different PGNs and devices?

Just now I do not have idea. I have tested DataDisplay2 with MessageSender on Teensy and it still can catch all that traffic. The serial port may get stuck, if it gets data from PC to Mega direction. But this should not be the case, if you just follow the serial monitor and do not send any data to other direction. The stuck problem can be handled by adding
Code: [Select]
while ( Serial.available() ) Serial.read(); after NMEA2000.ParseMessages(); But I would be surpriced, if that would be the case.

fredda_lk

For now I only have one device connected to the NMEA 2000 network, my engine, as you can see in the attached file.

I'm not sending any data on the serial port, just watching the information send in the example code. 

As you can see in the attachment it just stops sending data in the middle of a sentences, and when I restart the serial port I will receive data from start again. 

timolappalainen

Do you use Arduino Serial monitor? Could you try same with e.g. Putty.

Since you system works fine with Actisense NMEA Reader, I think that the Mega itself handles messages right. I have time to time seen different problems with Arduinos USB-Serial drivers.

Which OS you have?

fredda_lk

I have mostly used Arduino serial monitor but also Putty both with the same result, unfortunate.
I use win 10. Maybe it's a problem with receiving in windows and not the Mega?

timolappalainen

I have W10 too, so it is difficult to say. Please confirm that with ActisenseListener - Actisense NMEA reader it runs without stopping - let it run long. In principle there is not much difference on handling between ActisenseListener and DataDisplay2. You could also try with ActisenseListener in text mode by uncommenting line
Code: [Select]
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); and then use putty or serial monitor.

fredda_lk

Yes, the ActisenseListener runs without stop for 15 min. When I uncommenting the text line so I get text-mode I only get 200 sentences again exactly as the DataDisplay2 and it works in 10 seconds….

I have tried another serial converter and connected it with wires to tx0 and Rx0 and get the same resultate as USB port. Both on Putty and Arduino serial monitor.

When I run AtisenseListener and connect it with USB to Actisense Reader and in the same time connect serial reader with wires to Tx0/Rx0 I read data there too, but nothing I can understand.

Is there any buffer in the Mega that is filling up with data when it's in text-mode?



fredda_lk

Now I have some progress!

When I set the speed of the serial port to 230400 in the arduino program ActisenseListener and DataDisplay2 it runs without any problem when connected to my computer!

I don't now why and how but it works. Any idea?

timolappalainen

No ideas. As I mentioned I have transmitted data with Messagesender and received all with Mega 115200 on DataDisplay2. And Message sender sends much more than on yours sample. One difference can be that your data had several 1 frame messages, which can be send faster. But I have not had time to simulate that.

timolappalainen

I am writing NMEA2000 -> NMEA0183 converion for Rasberry Pi for my friend. With this you just need RPi 3, PiCAN2 (or alternative) and the code for getting GPS data from N2k to e.g. OpenCPN.

Just note, if anybody is interested.

scottdube

Timo,

This looks really great.  I just stumbled onto your thread as i'm interested in using an arduino to listen on my Seatalk NG network and pull info off to transmit to an mqtt broker.  I have tried to look at the entire thread I have been unable to find if I can use your work to listen to the Seatalk network, either by native seatalk or using a NMEA 2000 converter and connecting the arduino to that?  Any direction would be very much appreciated.

Thanks

Scott

timolappalainen

Seatalk NG is actually same as NMEA2000. There is a simple adapter cable to convert Seatalk NG to NMEA2000, but as far as I know it is just cable with different connectors - so no logic on it. Do not mix Seatalk and Seatalk NG. From Seatalk to Seatalk NG you need converter or device, which supports both like I have Autopilot. Then you see at least some Seatalk data also on Seatalk NG and NMEA 2000.

Waht is mqtt broker? If you do not yet have any Arduino board, I prefer Teensy 3.2 or up.

fredda_lk

I'm interested in a raspberry Pi solution. I have checked your guide on Github to connect the MCP2515 to the Pi, do you have any code example like the Arduino example, Datadisplay2, to read the NMEA2000 sentences in text mode? Or is that what you are working on now?

timolappalainen

I added yesterday new example NMEA2000ToNMEA0183. I made it for my my friend for use with OpenCPN to get NMEA0183 data from NMEA2000 network. It also provides all NMEA2000 data to other port in Actisense format e.g. for SignalK server. The example has been tested on RPi3B with home made "PiCAN2" and also on DUE, Mega and Teensy boards.

On RPi3 I used CodeBlocks 16.01, which seem to install easily to Raspberry. The only trick was that one has to do: Plugins-Manage plugins... disable Code completition on CodeBlocks. Otherwise it will just close time to time without any save. I did not made simple makefile yet. I like IDE programming.

For "serial ports" on RPi I used tty0tty "virtual null modem cable". So my example writes data to one serial port so the other program can read it on other. You can find more about tty0tty on https://askubuntu.com/questions/588800/setup-virtual-serial-ports-linux-null-modem-emulator-using-tty0tty and download it from https://github.com/freemed/tty0tty. I am not sure would it have been possible to use pipes instead of tty0tty.

This was my first RPi solution and it took 2 days to get it up - well I spent some hours trying to get Atom for RPi. Anyway the instructions are not complete and one has to google some small tricks to get things working. I may redo everything and write simple step by step guide to get example up and running. But before that I should try to get ESP32 CAN running.

scottdube

Seatalk NG is actually same as NMEA2000. There is a simple adapter cable to convert Seatalk NG to NMEA2000, but as far as I know it is just cable with different connectors - so no logic on it. Do not mix Seatalk and Seatalk NG. From Seatalk to Seatalk NG you need converter or device, which supports both like I have Autopilot. Then you see at least some Seatalk data also on Seatalk NG and NMEA 2000.

Waht is mqtt broker? If you do not yet have any Arduino board, I prefer Teensy 3.2 or up.
Thanks Timo my install has Seatalk NG not seatalk I was not careful in my post.  So I think I can simply make up a connector and go directly to the arduino.  If I get this right though I need to put a CAN "device" like MCP2562 or similar between the Seatalk NG cable and the arduino?  I'm trying to visualize the connections.  If I do this I do not need an NGT-1 have I got that right?

MQTT is transport telemetry language developed for communication between IOT devices mqtt.org/faq  I'm looking at using the wind and gps info from the Seatalk NG bus along with sensor data that I build from mysensors.org type sensors.  Sending all that through mqtt to a database and displaying via node red.

Thanks for all of your work!

Go Up