Go Down

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

timolappalainen

I would prefer Teensy. Check example https://github.com/ttlappalainen/NMEA2000/tree/master/Examples/TeensyActisenseListenerSender on my NMEA2000 library and leave additional USB (small Pololu board) away. Then you have NMEA2000 bus ready board to add your own interfaces.

I have not tested library with Uno. But with it you would anyway need CAN controller, bus driver, chrystal and some capacitors or ready CAN-BUS shield.

seamaster

Timo,
thanks for the quick reply
Today I managed to buy Mega and Can Shield. I'm up and running with the CAN shield example sketch, but when i load your temperature sketch, and it compiled OK. I don't have the shield connected to NMEA2000 network yet, but I'm flying to the boat on Sunday and Monday I can test that. Will update with the next post... I'm sure I will have more questions...
Thanks again!


bgnad

Is anyone working on converting automotive CAN bus data to NMEA2000, so one could use the engine interments on a marine multifunction display while using it as an offroad chart reader?

seamaster

I'm having success outputting to my boats n2k bus after following Timo's documention.
I think it will be relatively easy to adopt the sample code to output different analog values, e.i. temperature, rpm, angle (from pot signal) etc.
One question I have is can I, or how do I combine sensors that I can use one CAN shield and one Mega board to output different class devices. For example, can I output battery monitoring/status PGNs, combined with refrigerator and freezer temperatures and engine and generator rpm, temp, etc. I hope I explained what my goal is... instead of using 3 arduino boards and 3 CAN shields, I would like to combine the functionality in one. Is that possible, or will each class device require separate hardware?

timolappalainen

First answer for your last question: as far as I know, each class does not need to be published. So I mean that you can just choose e.g. class 25 (Inter/Intranetwork Device) and 132 (Analog to NMEA 2000 Gateway). I have not yet heard MFD device, which would not show information from wrong class device. They are more interested just about data nodes will send. I have not either saw MFD device, which would show Device/Class information. Normally they just show manufacturer, ModelSerialCode and ProductCode etc. (information from SetProductInformation).

I had plans about functionality to have device separation on library. You are the first one who is asking this. You can see e.g. SetMode has DeviceIndex parameter. That was planned for handling multiple device/class on same code. But then we would also need DeviceIndex for SetProductInformation and SetDeviceInformation. You would send message with SendMsg(N2kMsg, DevIndexBatteryMonitor); So if that would be important, I could continue to develop that, but it is not mandatory by bus.

As more problematic I would see wireing all sensors from engine, refridgerator etc. to one mega board. I have added several Teeansy boards, which is rather small package (see my example https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/TeensyActisenseListenerSender/Documents/Teensy_Actisense_listener_sender.pdf) and then just wired N2kBus.

flemmingdjensen

Hi timolappalainen!

First of all - thank you very much for these libraries for Arduino.

I have a project currently where I use an ESP8266 connected with the MCP2515 shield.

I am using the ActisenceSenderListener example and the NMEA Simulator to try and output NMEA2000 packets on can-bus.

I have not connected any bus to the H / L pins of the MCP2515 shield yet.

When I start the firmware I can see the first sentences goes fine but then all following messages fails...

See my console log...

Any idea what is going wrong? Is the library compatible with ESP8266? I'm not using interrupt for the MCP2515 as I am only sending data. CS is software controlled on GPIO15 on the ESP8266 CLK, MISO, MOSI is connected to the recommended perip pins.


0x2d
csum 0x2d
v09f0c112
~ld

CAN device ready
Pri:6 PGN:126996 Source:13 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,47,50,53,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,35,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
Pri:6 PGN:130312 Source:17 Dest:255 Len:8 Data:0,0,0,8F,70,FF,FF,FF
Pri:6 PGN:130316 Source:17 Dest:255 Len:8 Data:0,1,D,52,81,4,8C,B
Pri:6 PGN:126996 Source:13 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,47,50,53,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,35,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:17/20 send failed
Pri:6 PGN:130312 Source:17 Dest:255 Len:8 Data:0,0,0,8F,70,FF,FF,FF
PGN 130312 send failed
Pri:6 PGN:130316 Source:17 Dest:255 Len:8 Data:0,1,D,52,81,4,8C,B
PGN 130316 send failed
Pri:6 PGN:126996 Source:13 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,47,50,53,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,35,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:126996 Source:14 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,4C,6F,67,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,35,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:126996 Source:16 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,57,69,6E,64,20,6D,65,74,65,72,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,34,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:126996 Source:17 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,6F,75,74,73,69,64,65,20,65,6E,76,69,72,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,34,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:126996 Source:18 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,65,6E,67,69,6E,65,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,34,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:126996 Source:19 Dest:255 Len:134 Data:14,5,9A,2,4E,4D,45,41,32,30,30,30,20,73,69,6D,75,6C,61,74,6F,72,20,66,6C,75,69,64,20,6C,65,76,65,6C,0,0,31,2E,32,2E,30,2E,31,30,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,2E,32,2E,30,2E,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,30,39,37,31,34,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1
PGN 126996, frame:0/20 send failed
Pri:6 PGN:130306 Source:16 Dest:255 Len:6 Data:0,F4,1,59,C4,0
PGN 130306 send failed
Pri:6 PGN:130311 Source:16 Dest:255 Len:8 Data:0,41,97,72,78,37,F5,3
PGN 130311 send failed
Pri:6 PGN:130312 Source:17 Dest:255 Len:8 Data:0,1,4,55,73,55,73,FF
PGN 130312 send failed
Pri:6 PGN:130312 Source:17 Dest:255 Len:8 Data:0,1,4,55,73,55,73,FF
PGN 130312 send failed

BR Flemming Dahlhof Jensen

flemmingdjensen

I just attached a logic analyser and can see endless loop retransmitting the following....

Pri:6 PGN:126996 Source:13 Dest:255 Len:134 Data:14,5,9A,2,4E,4D

So this retransmitting seems to prevent sending the next sentences...

timolappalainen

Do you mean example ActisenseListenerSender? That has been tested to work only on Due, since it uses two USB:s - one for sending and other for listening. I had problems with single USB that it stops responding, when you are sending and reaceiwing binary data throug it. But this should not be your case.

Are you writing with NMEA Simulator? It may be that sending buffers will overflow and it can not send all messages. You coud try add NMEA2000.SetN2kCANSendFrameBufSize(500); on beginning of setup(). Note that value 500 is frames, so this is taking 4k of memory. So you have to adjust value according to your memory. Default is 40 as documentead.

But also I am not sure that does MCP2515 chip fail to send anything, if it is not connected to the bus. Then everything will be just bufferd, until it fills out and start to give error.

Also if you using NMEA Simulator, you can disable sending product information for each device. I prefer to first test with one device and one PGN and then add PGNs.

flemmingdjensen

#158
Feb 16, 2017, 08:53 am Last Edit: Feb 16, 2017, 09:01 am by flemmingdjensen
I had to modify your sketch slightly in order for it to work on my setup.

So I am using a NodeMCU ESP8266 with 4MByte flash.
Using the std com port as programming interface and normal Serial output for debugging
I then attach one more USB serial and drive this throught the software Serial driver.
This software serial is now receiving the messages from the NMEA Simulator
Im not using interrupts

I have to modify NMEA2000_mcp.cpp because there is no SREG on the ESP8266

So I use noInterrupts() & interrupts() instead for the ESP8266.

In my logic analyser it seems like the 2515 is repeating the last frame (8 bytes) over and over again.

I have read an errata on the chip mentioning that CS should go hi within 78us after the last transmission or the chip could begin repeating.

I will try upping my transmit buffer as you suggested later today.

My sketch is looking like this:

=============================

// Demo: NMEA2000 library. Bus listener and sender.
//   Sends all bus data to serial in Actisense format.
//   Send all data received from serial in Actisense format to the N2kBus.
//   Use this e.g. with NMEA Simulator (see. http://www.kave.fi/Apps/index.html) to send simulated data to the bus.

#define USE_N2K_CAN 1
#define N2k_SPI_CS_PIN 15
#define USE_MCP_CAN_CLOCK_SET 16
//#define N2k_CAN_INT_PIN 4

#include <Arduino.h>
#include <N2kMsg.h>
#include <NMEA2000_CAN.h>
#include <ActisenseReader.h>
#include <SoftwareSerial.h>

tActisenseReader ActisenseReader;

SoftwareSerial swSer(2, 0, false, 256);

void setup() {
  Serial.begin(115200);
  swSer.begin(115200);
 
  NMEA2000.SetForwardStream(&Serial);  // PC output on due programming port
  NMEA2000.SetMode(tNMEA2000::N2km_SendOnly);
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text
  NMEA2000.Open();

  // I had problem to use same Serial stream for reading and sending.
  // It worked for a while, but then stopped.
  ActisenseReader.SetReadStream(&swSer);
  ActisenseReader.SetMsgHandler(HandleStreamN2kMsg);
}

void HandleStreamN2kMsg(const tN2kMsg &N2kMsg) {
  N2kMsg.Print(&Serial);
  NMEA2000.SendMsg(N2kMsg,-1);
}

void loop() {
  NMEA2000.ParseMessages();
  ActisenseReader.ParseMessages();
}

flemmingdjensen

#159
Feb 16, 2017, 09:22 pm Last Edit: Feb 16, 2017, 09:28 pm by flemmingdjensen
SUCCESS!!!!

Now I build a complete setup!
NMEA2000 Simulator -> ESP8266 -> MCP2515 -> CAN-BUS -> MCP2515 -> ESP8266

And guess what.... It works :)

So I guess the reason for the errors in transmission was because I didn't have a complete CAN-BUS setup...


WheelSea

Kudo's to you timolappalainen,
That was a lot of work on your part.

I have my arduino (Mega + 2515) up and running and I am very impressed so far with all the coding on your part. My 2515 was 8mhz and that took a little trouble shooting.   Being able to output to the terminal and NMEA 2000 simultaneously solved a lot of problems.  I had a lot of trouble with my other NMEA devices not being able to read 130316, Temperature for EGT.  This being the Actisense NGT-1 USB and the iKommunicate and Raymarine I70.  All my work is being done at home prior to any installation on the boat.
So far I have output voltages for 3 batteries voltages  and 3 environment temperatures and 1 EGT.  Adding 3 more EGT's should be easy.  I need 4 EGT's total.  Twin engine and a turbo on each side of each engine.

It should be straight forward to apply all the other sensors to the engines now.  I will probable use a few arduino's to do so, one for temp the other pressure, resisitive etc.

Has anyone coded for a display?  Having your own helm display.

Thinking I may do just that with my 5 inch Nextion NX8048T050 TFT display.
Any advice that someone wants to share

Larry

seamaster

#161
Feb 18, 2017, 06:35 am Last Edit: Feb 18, 2017, 07:10 am by seamaster
Hi Timo,
Thanks for the response! I was occupied trying to rebuild my nav-PC as my M2 SSD in my intel NUC just decided to quit.
I'm back on the project now and I will try to source some parts to build few different units. I do agree- separate units will be cleaner to install.
On different note: Is there some PGN that reports bilge pumps cycles in the Nmea 2k? I have some n2k documentation that I can send you in email. Send me your email address so I can fwd you what I have.
 My is MVseawitch at gmail. Send me quick email and I will fwd you what I have.

timolappalainen

SUCCESS!!!!

Now I build a complete setup!
NMEA2000 Simulator -> ESP8266 -> MCP2515 -> CAN-BUS -> MCP2515 -> ESP8266

And guess what.... It works :)

So I guess the reason for the errors in transmission was because I didn't have a complete CAN-BUS setup...


Good that you got it running. I have to design a way for NMEA2000_mcp to avoid SREG problem.

timolappalainen

It should be straight forward to apply all the other sensors to the engines now.  I will probable use a few arduino's to do so, one for temp the other pressure, resisitive etc.

Has anyone coded for a display?  Having your own helm display.

Thinking I may do just that with my 5 inch Nextion NX8048T050 TFT display.
Any advice that someone wants to share

Larry
[/quote]
Hi Larry and all,

I quickly looked in to the Nextion and it has same problem as with all these cheap displays - only max 250 nits. I think that for outside you need 600 nits or even more. Sunlight readable systems are normally providing 800-1300 nits.

For more devices I prefer to look Teensy 3.2 board. That draws less current than Mega or Due boards. You can find link to schemas on my earlier post.

WheelSea


Thanks for the reply,
I am going to abort doing a display.  This was purchased for use inside the boat on the watermaker.  Instead I will find a sunlight readable monitor and use a windows based machine.  Actisense will be coming out with an update to NMEA 2000, soon I hope.  Going to look at building the arduino actisense reader, I have not looked at the code to see what it may output.  Starting to read up on OpenSkipper?

Go Up