ttlappalainen/NMEA2000_due

Can Gateway

ieb opened this issue · 3 comments

ieb commented

I have a Volvo D2-40 and would like to connect the engine NMEA2000 CanBus to a Raymarine based NMEA2000 Instrument bus. I assume its a bad idea to connect the 2 electrically without a gateway. The earth is common, but 12V is different, and CanH, CanL levels might be different. So, I was wondering if it's possible to use both of the Due Can devices, one on the engine, one on the instruments to connect the 2 with a bridge based on your libraries running on the Due.

Looking at the code, Can0 is hard coded, and the NMEA2000 object is a singleton by design. So I assume its non trivial to create a dual NMEA2000 bridge ?

I could alway buy the Volvo Penta NMEA2000 gateway, but that would be nearly as much fun.

I updated NMEA2000 library and NMEA2000_due library. Now it allows to select CAN device for due. I tested that it works as single with both CAN device, but did not test with dual port at same time. If you test, please report does it work.

NMEA2000 is not singleton. It is real class and you can have multiple instances of it. The include NMEA2000_CAN.h has been made for simple startup for rookies. So if you want to use two can on same device you can do either:

#include <NMEA2000_CAN.h> // This creates default NMEA2000 object with default settings
tNMEA2000 &NMEA2000_CAN1=*(new tNMEA2000_due(tNMEA2000_due::CANDevice1));

And then you do setup and loop call for both devices. If you do not like default naming, just do

#include <NMEA2000_due.h>
tNMEA2000 &NMEA2000_CAN0=*(new tNMEA2000_due(tNMEA2000_due::CANDevice0));
tNMEA2000 &NMEA2000_CAN1=*(new tNMEA2000_due(tNMEA2000_due::CANDevice1));

Then an other thing is that do you actually need two busses. If the other bus is really CAN, it should have same CAN levels. I heard somewhere that power for Volvo bus was 24V, better not to connect that. Also it may be better not to connect GND directly together with N2k, since it may cause ground loop. That you have to remember anyway and probably use isolated tranceiver if you do gateway.

The other problem is that as far as I know Volvo has J1939 (=CAN) - not NMEA2000. Also they do not use standard messages for data. So you may need to do reverse engineering to find each message content. Translating them to NMEA2000 is then simple with my library. If yo have time, please do that and publish messages used by Volvo - there may be others on internet who thanks you for the work!

If you do gateway, you can use simple MCP2562 tranceiver on otherside, but on NMEA2000 side it is better to use e.g. ISO1050 and power it with from NMEA2000 side with simple regulator. Then you will not have groundloop problems.

ieb commented

Thank you for the patch and detailed explanation.
I will give it a go and report back what I find. The D2-40 has a Mechanical Diesel Interface (MDI) and quite a simple set of sensors (flywheel, temp, oil pressure switch, tank level etc ... no MAF, or electronic injection) so I suspect it won't produce anything that exciting, other than perhaps the fault codes which are very proprietary, and limited to the sensors they can read.

My engine is 12V throughout, being small, but I will check the bus voltages and isolate with MCP2562 as you suggest. Thank you again.

Isolation should be done with ISO1050 on N2k side. On engine side you can use MCP2652.