Go Down

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

pagoda54

I found that if you enable bus listening with some of the NMEA-Master examples, Actisense NMEA Reader eventually stalls due to buffer problems. I thought it was a PC related issue. Not this time.
On subsequent examples with The NMEA2000 Listener with the LED you have inserted an serial  buffer clear .

Transplanting that to the other examples avoids the problem.

Works fine now

timolappalainen

If I remember right, it depends of device. NMEA Reader sends some initialization commands to the serial. If that data will not be cleared, some devices serial gets stuck and does not either send anymore.

jsholovitz

Thanks, Timo

Here are a few responses:


Some questions:
- Which version of Actisense Reader you run the tests? I'm using 1.5.1.7. I did see the same situation when feeding the data from the Arduino directly to my Raspberry Pi into OpenPlotter / Signal K server.
- Did you close and restart NMEA Reader between each test? Yes
- Do you have other system like Teensy for making same test? No, I think that's my next step to make a Teensy device. Need to order many parts for that.
- Can you make same test by feeding Due bus with other device and with NMEA Simulator? As above


Any other thoughts? Thanks!
Hi again - I'm back!

Just wanted to update as I've had the chance to do more testing.

First, I ordered a Teensy and built one as specified in Timo's documentation, except I did not add the extra USB interface.

Now, in bench testing at home (boat is hauled and put away for the season :( ) I find interesting results.

I'm using the Teensy as an Actisense sender, sending messages generated from Timo's NMEA Simulator program. I enabled sending of all PGNs within the simulator.  What I find in this case is that no matter which sketch (ActisenseListener, ActisenseListenerSender, ArduinoGateway) I install on the DUE, I still see 48 PGNs (exactly what I would expect) show up in the ActiSense NMEA Reader application.  Unfortunately, the NMEA Simulator does not create AIS data, so perhaps there is something related to that? Other thoughts?

Thanks in advance!

Les_Collier

timolappalainen  I am the new man in town, how do I obtain your 2000 library and hardware ??.   


Looking into the future with my crystal ball there will be a transition over from CanBus to Ethernet ( it's already started, Can Bus is not fast enough for some apps, radar for example )

   Have you chaps thought about writing your own 'Shareware Open Standard' and support Library for Ethernet so that users and manufacturer's do not have to keep paying for expensive Nema2000 licences, strikes me such a library would be very popular with end users as it would cause industry suppliers to standardise on one format therefore making their products all communicate with one another regardless of manufacture.

timolappalainen

For embedded I prefer to use either Teensy or ESP32. Both has build in CAN and so requires only tranceiver e.g. MCP2562. Download the library and install it. Also download necessary libraries NMEA2000_Teensy and FlexCAN for Teensy or NMEA2000_esp32 for ESP32. Note that if you use Teensyduino, do not install FlexCAN with it. Or if you have done it already, delete FlexCAN from "C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries".

Read the NMEA2000_library_reference.pdf. There is not much about Teensy or ESP32, but they only differs of required "driver".

RPi is also possible for bigger projects and has ethernet and WiFi ready. There is example https://github.com/ttlappalainen/NMEA0183/tree/master/Examples/NMEA2000ToNMEA0183. It works with PiCAN2 board or with my board, which has also NMEA0183 and 1-wire.

For 'Shareware Open Standard' there is already SignalK. And big manufacturers like Garmin, Raymarine, Lowrance would not go to any open standard. And Nmea is already planning OneNet and most big manufacturers are already participated.

FXVT

Hello Timo,

Thanks for your great job !

I would like to change my hardware MEGA2560+Shield for a Arduino Due + a Can Transceiver.
I'd like to chose a ready to plug transceiver does it work with a SN65HVD230 based ?

https://fr.aliexpress.com/item/SN65HVD230-CAN-bus-transceiver-communication-module-for-arduino/32686393467.html

Regards.
FX VAN THUAN

timolappalainen

Why not to Teensy? Smaller and better.

Library does not see the tranceiver, so it works.

Anyhow people have had more problems with SN65HVD230 than with MCP2562 tranceiver. I have used only that and never had any tranceiver problems.

FXVT

Bonjour Timo,

Thanks for tout advice. I am going tout dig the Teensy track.

Merci.
FX

timolappalainen

There is brakout board at http://skpang.co.uk/catalog/teensy-canbus-breakout-board-include-teensy-32-p-1507.html or just buy parts and follow https://github.com/ttlappalainen/NMEA2000/tree/master/Examples/TeensyActisenseListenerSender for basic connection. You probably do not need extra USB as on that device.

FXVT

#609
Nov 18, 2018, 09:53 am Last Edit: Nov 18, 2018, 09:59 am by FXVT
Bonjour autopilotNOR,

I use this 3 lines of code to get more stable values for the RPM:

int rpm_reel           = 0;
....
rpm_reel = rpm_reel / 10; // Pour arrondir à 10 et ainsi eviter que le nombre flucute trop
rpm_reel = rpm_reel * 10; // Pour arrondir à 10 et ainsi eviter que le nombre flucute trop

So the value is always a multiple of 10.

I don't use the FreqMesure, but I am going to try it because I have a limitation with my current sketch.
I use interrupts and I have to use a dedicated Arduino board to mesure RPM and Temperatures (Engine and Fridge), and an other one to get datas from the Victron BMV700 Battery controler.
This last app uses interrupts as well.

The project is to merge this two applications on the same Mega Board.
Today, each board works well separately , but the new sketch I am writing for the Mega is not yet reliable because of the interrupts.

Amicalement.
FX

timolappalainen

You can get very stable value by using FreqMeasureMulti library and low pass filter with it:

Code: [Select]


double ReadRPM() {
#define FilterWeight 0.005
static double Average=0;
...
 while ( FreqMeasure.available() ) {
    double PulseWidth=FreqMeasure.read();
    Average = (FilterWeight * PulseWidth + (1 - FilterWeight) * Average);
 }

 return FreqMeasureMulti::countToFrequency(Average)*60;
}


You need to poll above fast enough.

Low pass filter value FilterWeight depends of your altenator frequency. I think above value was with altenator providing pulses with factor 11. For higher frequency you have to change it even smaller.

Too small value on low pass filter make result stable, but response is slower and opposite. The problem with above is that with RPM measuring you do not get reading constantly. So above filter value may be OK with 4000 RPM, but a bit lazy below 1000 RPM. One solution is to make it adaptive as I have, but the code is a more complex.

pagoda54

Timo,
I've had good success with the NMEA 2000 libraries, so I started to take a look at your NMEA0183>NMEA2000 conversion routines.
They only seem to deal with navigation/GPS parameters?  Do any exist for converting DBT or depth sentences form NMEA0183?
I have a transducer which spits out NMEA0183 at 4800Baud which I might try to integrate into the N2K network.

Both the sounder and the plotter are at home over the winter so I can experiment.

Apologies if I haven't found the right docs on GitHub!

Cheers, Graeme

timolappalainen

I do not seem to have parsers for depth on NMEA0183 library. They are relative easy to add, but just now I am relative busy. I could add them within 2-3 weeks.

pagoda54

I do not seem to have parsers for depth on NMEA0183 library. They are relative easy to add, but just now I am relative busy. I could add them within 2-3 weeks.
If you find the time over the next few months - great - otherwise don't worry about it!

FXVT

#614
Nov 25, 2018, 07:36 pm Last Edit: Nov 25, 2018, 07:48 pm by FXVT
Bonjour Timo,

I have these messages when I compile:

Code: [Select]







[color=red]C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kMsg.h:83:7: warning: type 'struct tN2kMsg' violates one definition rule [-Wodr]

 class tN2kMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kMsg.h:83:7: note: a different type is defined in another translation unit

 class tN2kMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kMsg.h:96:8: note: the first difference of corresponding definitions is field 'TPMessage'

   bool TPMessage;

        ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kMsg.h:83:7: note: a type with different number of fields is defined in another translation unit

 class tN2kMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kCANMsg.h:28:7: warning: type 'struct tN2kCANMsg' violates one definition rule [-Wodr]

 class tN2kCANMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kCANMsg.h:28:7: note: a different type is defined in another translation unit

 class tN2kCANMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kCANMsg.h:39:11: note: the first difference of corresponding definitions is field 'N2kMsg'

   tN2kMsg N2kMsg;

           ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kCANMsg.h:39:11: note: a field of same name but different type is defined in another translation unit

   tN2kMsg N2kMsg;

           ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kMsg.h:83:7: note: type 'struct tN2kMsg' should match type 'struct tN2kMsg' that itself violate one definition rule

 class tN2kMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kMsg.h:83:7: note: the incompatible type is defined here

 class tN2kMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/NMEA2000.h:79:7: warning: type 'struct tNMEA2000' violates one definition rule [-Wodr]

 class tNMEA2000

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\NMEA2000.h:79:7: note: a different type is defined in another translation unit

 class tNMEA2000

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/NMEA2000.h:367:17: note: the first difference of corresponding definitions is field 'N2kCANMsgBuf'

     tN2kCANMsg *N2kCANMsgBuf;

                 ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\NMEA2000.h:367:17: note: a field of same name but different type is defined in another translation unit

     tN2kCANMsg *N2kCANMsgBuf;

                 ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/N2kCANMsg.h:28:7: note: type 'struct tN2kCANMsg' should match type 'struct tN2kCANMsg' that itself violate one definition rule

 class tN2kCANMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\N2kCANMsg.h:28:7: note: the incompatible type is defined here

 class tN2kCANMsg

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/NMEA2000.h:213:9: warning: type 'struct tMsgHandler' violates one definition rule [-Wodr]

   class tMsgHandler {

         ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\NMEA2000.h:213:9: note: a different type is defined in another translation unit

   class tMsgHandler {

         ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/NMEA2000.h:217:18: note: the first difference of corresponding definitions is field 'pNMEA2000'

       tNMEA2000 *pNMEA2000;

                  ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\NMEA2000.h:217:18: note: a field of same name but different type is defined in another translation unit

       tNMEA2000 *pNMEA2000;

                  ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src/NMEA2000.h:79:7: note: type 'struct tNMEA2000' should match type 'struct tNMEA2000' that itself violate one definition rule

 class tNMEA2000

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000\src\NMEA2000.h:79:7: note: the incompatible type is defined here

 class tNMEA2000

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000_mcp/NMEA2000_mcp.h:42:7: warning: type 'struct tNMEA2000_mcp' violates one definition rule [-Wodr]

 class tNMEA2000_mcp : public tNMEA2000

       ^

C:\Users\VANTHUAN\Documents\Arduino\libraries\NMEA2000_mcp\NMEA2000_mcp.h:42:7: note: a type with different bases is defined in another translation unit

 class tNMEA2000_mcp : public tNMEA2000

       ^[/color]

[color=blue]Le croquis utilise 30644 octets (12%) de l'espace de stockage de programmes. Le maximum est de 253952 octets.
Les variables globales utilisent 1093 octets (13%) de mémoire dynamique, ce qui laisse 7099 octets pour les variables locales. Le maximum est de 8192 octets.[/color]


The compilation go to the end.
At the end, I have the message in blue color, but I also have the messages in red.
What does it means ?
Anyway it seems to work well. The data I send can be read on the MFD.

Merci.
FX

Go Up