Arduino Forum

Development => Other Hardware Development => Topic started by: svDeepPlaya on Feb 03, 2011, 12:05 am

Title: NMEA 2000 Shield
Post by: svDeepPlaya on Feb 03, 2011, 12:05 am
NMEA 2000 is a closed CAN-BUS standard for marine electronics. It would be awesome to have a shield that can accept the standard NMEA 2000 or that has a screw down terminal to accept bare wires.

NMEA 2000 supplies both power and data in it's cable. Not sure if it's adequate to power the ardunio.
http://en.wikipedia.org/wiki/NMEA_2000

If someone out there can handle the hardware and board side of things, I could help do the research.

Thanks,
-p
Title: Re: NMEA 2000 Shield
Post by: estratos on Feb 03, 2011, 11:17 am
Hi,

Building a CAN shield for the Arduino is quite simple. You just need a SPI-based CAN controller (ex: MCP2515) and a CAN interface (ex: MCP2551). The N2K bus typically provides 12VDC so you will need a regulator in order to power the arduino and the shield, and some kind of optical isolation between CAN interface and CAN controller if you want to stay clean. This is just for the physical side of the engine. Then you'll need to implement all the N2K protocol into the Arduino, but remember the following:

1. NMEA 2000 is a proprietary protocol. You'll surely need to purchase the specification from the NMEA association (several $1000's if I remember well).
2. If you want to certify the product, you'll need to pay for a N2K ID to the NMEA association and later you'll need to pay for the certification process.

I've worked with NMEA 2000 in the past so feel free to drop more questions if you need.

Daniel.
Title: Re: NMEA 2000 Shield
Post by: svDeepPlaya on Feb 07, 2011, 08:01 am
Thanks for the tips!

I hear you on the NMEA 2000 proprietary thing, but many are reverse engineering it... so I'm guessing it's not too difficult.

-p
Title: Re: NMEA 2000 Shield
Post by: estratos on Feb 17, 2011, 04:34 pm
Depending on the amount of N2K nodes available on the bus and their outgoing traffic load (some N2K devices are programmed to drop CAN messages every 100 ms), you could find that your Arduino-based node is not capable to accept all the traffic load without loosing packets so If you're thinking in using the Arduino as a kind of PC gateway this could be an issue. For end-device applications the AVR should be fine.
Title: Re: NMEA 2000 Shield
Post by: rjason on Oct 04, 2011, 04:13 pm
Hello,

Did you ever get anywhere with NMEA 2k -> Arduino? I'm considering the CAN shield to start playing with it.. don't want to recreate the wheel if you've made progress.

Thanks,
Jason
Title: Re: NMEA 2000 Shield
Post by: svDeepPlaya on Oct 04, 2011, 07:54 pm
I've not heard anything more about anyone working on this...
Title: Re: NMEA 2000 Shield
Post by: terryking228 on Oct 07, 2011, 03:24 pm
I just saw several NMEA2000 installations yesterday at the Genoa, Italy Boat Show. Immense. Many 100 foot yachts.  All NMEA2000 setups were on carpeted booths and high-end graphics.

The only DIY that crowd seemed to do was mixing drinks  :smiley-mr-green:

If anyone gets into NMEA-Anything start a thread on the forum... I've done a little.
Title: Re: NMEA 2000 Shield
Post by: androrossi on Jul 23, 2012, 02:03 pm
Hi all,

I want to send data over NMEA 2000 bus using Arduino UNO + Sparkfun Can-Bus (http://www.sparkfun.com/products/10039).

I have some questions on NMEA 2000:

1) Is correct to use that Can-Bus board to send data??? The structure of can bus message is the same of NMEA2000 message???
2) Is there any library that I can use???

Any suggestion on NMEA 2000 would be appreciated.

Thanks a lot!

:D
Title: Re: NMEA 2000 Shield
Post by: estratos on Jul 23, 2012, 04:23 pm

1) Is correct to use that Can-Bus board to send data??? The structure of can bus message is the same of NMEA2000 message???


Yes, you should be able to connect an Arduino to a CAN bus through this board. However, bear in mind the actual traffic load in the bus and the limited computing power of an Arduino. If you just want to develop a "sender" application it's should be OK.

Quote

2) Is there any library that I can use???


No free or open source library if I remember well. Working with NMEA2000 typically requires you to buy their specs.

Hope this helps,

Daniel.
Title: Re: NMEA 2000 Shield
Post by: androrossi on Jul 23, 2012, 08:50 pm
Thanks a lot Daniel.

I just want to develop a Sender application on Arduino.

I have another question:
is the structure of CanBus messages (2.0b) the same of Nmea2000 messages???

:D
Title: Re: NMEA 2000 Shield
Post by: estratos on Jul 23, 2012, 11:43 pm
Yes, NMEA2000 sits on top of CAN (extended address schema).
Title: Re: NMEA 2000 Shield
Post by: androrossi on Jul 25, 2012, 02:09 pm
Thanks a lot Daniel.

Is the message format for NMEA2000 this http://www.can-cia.org/index.php?id=496 ???
But it is bit different from CAN (2.0B) message format http://it.wikipedia.org/wiki/Controller_Area_Network#Formato_dell.27Extended_frame .

I'm wrong???

:D
Title: Re: NMEA 2000 Shield
Post by: estratos on Jul 25, 2012, 03:36 pm
ID A + ID B makes 29 bits. Yes, NMEA2000 is somehow a subclass of J1939 and inherits some PGN's from it in fact.
Title: Re: NMEA 2000 Shield
Post by: androrossi on Jul 29, 2012, 07:01 pm
Hi Daniel,

I found this forum http://www.mikrocontroller.net/topic/143234 and on this forum I found this library http://www.mikrocontroller.net/attachment/53861/NMEA2000ToNMEA183.rar .

I think it is what I need...

Can you help me with it?


Thanks a lot.

:)
Title: Re: NMEA 2000 Shield
Post by: dpharris on Jul 29, 2012, 07:15 pm
What do you need help with exactly?  My boat has a Volvo engine that sends their variant of this -- would be nice to interface to it. 

David
Title: Re: NMEA 2000 Shield
Post by: androrossi on Jul 30, 2012, 02:10 pm
Hello David,

Did you already use that library ( http://www.mikrocontroller.net/attachment/53861/NMEA2000ToNMEA183.rar )?
If yes, what hardware are you using? I have an Arduino UNO + Sparkfun Can-Bus ( http://www.sparkfun.com/products/10039 ).
I want to send some data over NMEA2000 bus to all node (broadcast).
I'd like to have a code example to send data using that library (if possible) or a brief guide to using the library.

Thanks a lot

:)
Title: Re: NMEA 2000 Shield
Post by: skyjumper on Aug 07, 2012, 07:54 am
I also have an N2K project I need to work on, but the expense of the protocol and certification is holding me up. Have you had any luck so far?
Title: Re: NMEA 2000 Shield
Post by: southern_cross on Oct 08, 2012, 08:45 pm
I have just started with embedded programming but been writing enterprise software for many years.

I have just pulled together a base NMEA 2000 / J1939 protocol stack. Currently I have support for a limited number of PGNs but I do have  support for single and fast frame NMEA2000 messages. The current project is to create NMEA 2000 transducer that will read analog engine data and broadcast PGNs 127488 (engine Rapid), 127489 (engine dynamic), 127505 (fuel level). The protocol stack is built to quick add additional PGNs with minimal amount of code.

Also I'm finishing up support for address claim and other NMEA 2000 group functions. If you are interested in working with me on adding additional capabilities and functions let me know. The current implementation runs on Arduino Uno with Sparkfun CAN-bus that uses MCP2515 CAN controller.

Title: Re: NMEA 2000 Shield
Post by: JayEmell on Oct 15, 2012, 12:19 pm
Hi, @southern_cross: I'm most interested in your work. Myself looking at the possibilities to use Arduino + shield to prototype a marine monitoring interface. Basically I would want to monitor and convert to NMEA2000 the engine data you mention plus some additional ones, like PGN 127508 - Battery Status. Possibly also some environmental data and in future also read and parse the AIS PGNs. I've previously only been working in the NMEA0183 domain though now believe that the transition to 2000 is inevitable. If you are willing to share your progress and also specify how you would want to co-operate I'd be very happy to join.
Title: Re: NMEA 2000 Shield
Post by: scruzin on Dec 04, 2012, 08:33 am
Hi, I'm new to this forum.  Just wondering if there has been anything more on the subject of interfacing Arduino and NMEA2000?
Title: Re: NMEA 2000 Shield
Post by: scruzin on Dec 04, 2012, 08:50 am
BTW, there is an open-source NMEA 2000 decoder project over at https://github.com/canboat that looks useful.
Title: Re: NMEA 2000 Shield
Post by: coryjfowler on Jan 29, 2014, 02:15 am
I've just spent the weekend decoding a NMEA 2000 GPS sensor.  Garmin's manual specified the PGNs the unit transmits and accepts but no detail on any of the payload.  I've managed to come across documents which have been helpful, but whats been most helpful is Maretron's product manual.  They get into detail, at least with their GPS sensor, almost as heavily as most NMEA0183 devices I've had the pleasure to use.  Only problem is, I need to figure out how to configure my Garmin sensor since differential corrections are disabled be default...  I've been talking with a Garmin representative about the lack of technical documentation and am waiting for a follow-up.

When it comes to standards, the manufacture might be the entity who purchases the standard, but we, the customer, are actually paying for it. 

http://www.nmea.org/Assets/july%202010%20nmea2000_v1-301_app_b_pgn_field_list.pdf

I've been active over at Seeed studio's forums.  I've been actively developing and ironing out the MCP2515 library.  I would recommend checking out my github if you end up using the MCP2515 with an Arduino.
Title: Re: NMEA 2000 Shield
Post by: allen652 on Feb 10, 2014, 11:22 pm
Cory would you be able to provide an example of writing a broadcast of engine data PGN 127489 using your library?

I am working on receiving these values from my boat's computer (delphi ecm MEFI3) and I would now like to have them appear on my NMEA 2000 network.

I'll be releasing my full project's source code and hardware when completed (for now: by request).
Title: Re: NMEA 2000 Shield
Post by: allen652 on Mar 05, 2014, 04:21 am
Nevermind Cory.

I have successfully broadcasted engine data (PGN 127488 + PGN 127489) to my raymarine MFD.
Title: Re: NMEA 2000 Shield
Post by: Fishstretcher on Mar 21, 2014, 02:22 am
I am very interested in doing just this. If you are willing to share what you have done, I would very much appreciate it. Not sure if if want PGN 127489 or 130311 for my task. There doesn't seem to be an appropriate PGN for engine vacuum (not boost).

Thanks!


Nevermind Cory.

I have successfully broadcasted engine data (PGN 127488 + PGN 127489) to my raymarine MFD.
Title: Re: NMEA 2000 Shield
Post by: allen652 on Mar 22, 2014, 01:13 pm
I'd be happy to help. PM sent.
Title: Re: NMEA 2000 Shield
Post by: Fishstretcher on Mar 22, 2014, 03:40 pm
I replied. Thanks very much! I don't have much to offer in kind, other than a parts list and schematic for what I plan to do with it.
Title: Re: NMEA 2000 Shield
Post by: FPeter on May 11, 2014, 04:44 am

Nevermind Cory.

I have successfully broadcasted engine data (PGN 127488 + PGN 127489) to my raymarine MFD.

Hello Allen!

How did You manage to broadcast PGN 127489? It isnt covered by standard or extended CAN formats due to more than 8 databyte (=26) in it - I found that its only supported by CAN FD devices - MCP2515, AT90CAN128 family and all PICs are supports only the 8 databyte mode... Im really interested in it, can You please share Your findings?

Best regards,
Peter
Title: Re: NMEA 2000 Shield
Post by: coryjfowler on Jun 03, 2014, 06:52 am
The way more than 8 data bytes is sent is a little confusing.  They send it 7 bytes at a time with the first byte of every message incrementing by 1, which is called the sequence identifier.  So to send more than 8 data bytes, you would essentially be sending multiple messages, each having the sequence identifier one greater than the previous.  Three such messages would give you 21 bytes and four would give you 28.  I think the simplest way to do this would be with a 'for' loop, putting the data bytes in an array, using the the loop count variable as the sequence ID, and multiplying the loop variable by seven for the offset needed by the array.

Sorry, its been a while since I've been around and active.  I've been busy with life things and not had any time for my toys.
Title: Re: NMEA 2000 Shield
Post by: JayEmell on Jul 09, 2014, 12:53 pm
@allen652:
I'm very impressed you managed to generate engine data on NMEA 2000 so the Raytheon MFD could display it. Is there a way you could share your results or can I approach you via a PM? /Jay
Title: Re: NMEA 2000 Shield
Post by: hobi on Aug 29, 2014, 06:46 pm
@allen652: I also look to broadcast information to a Triton T41 MFD.

I have been crawling on the web to find out some raw binary file, that I could use to check my code but no luck.
Therefore, what I have is the NMEA decoder ( Good that this was made open, really a huge piece of work)  that will help me to understand what the Triton sends out initially when powered up, but I will have to reverse the decoder, and assemble some PGNs ( like boat COG , wind direction) and send that to the Triton.

It would be of great help if you could accept to share the piece of SW you did to boradcast PGNs... Please.

What I am concerned about is the address claim, and also device capabilities / ISO aCK stuff.

Thanks in advance.

Title: Re: NMEA 2000 Shield
Post by: jpjcb66 on Oct 09, 2014, 12:36 pm
Hello everyone,
I have trouble with PGN 127489 + MFDe7 Raymarine and I have not response from "allen652" .
Can not display engine temperature water.
Can someone please help me?
thank you
jp
(http://jp-jacobee.fr/BATEAU/MFDe7_1014.png)
Title: Re: NMEA 2000 Shield
Post by: allen652 on Oct 09, 2014, 04:32 pm
I am using an arduino MEGA and the MCP2515 library as mentioned and worked on by coryjfowler https://github.com/coryjfowler/MCP2515_lib (https://github.com/coryjfowler/MCP2515_lib).

I built my own shield for a few dollars by purchasing the components from digikey.com (http://digikey.com). The design is based on seeedstudio's canbus http://www.seeedstudio.com/wiki/images/7/78/CAN-BUS_Shield_v0.9b.pdf (http://www.seeedstudio.com/wiki/images/7/78/CAN-BUS_Shield_v0.9b.pdf).

IC CAN Transceiver: MCP2551-I/P-ND
IC CAN Controller: MCP2515-I/P-ND
16 MHZ Crystal: XC1748-ND
Resistors: 10kohm & 4.7kohm
Capacitors: (2) 22pf & (2) 100nf

I am using non-certified NMEA2000 cabling products that I had manufactured for my current project. I have several available for sale below if interested. See images.
2 meter cable (Male to Female) - $7.5 each
T adapter - $7 each
Male rear panel mount connector - $5 each

I'll put some sample code in my next post.
Title: Re: NMEA 2000 Shield
Post by: allen652 on Oct 09, 2014, 04:53 pm
Code: [Select]

#include <mcp_can.h>
#include <SPI.h>

MCP_CAN CAN0(53);                                      // Set CS to pin 53
//MCP_CAN CAN0(2); //for my new prototype shield
unsigned char stmp[8] = {0, 0xA0, 0x41, 0, 0, 0, 0, 0};
unsigned char extpgn[26] = {0, 0xA0, 0x41, 0, 0, 0, 0, 0};
void setup(){
  Serial.begin(115200);
  // init can bus, baudrate: 250k
  if(CAN0.begin(CAN_250KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
  else Serial.print("Can init fail!!\r\n");
  //testPGN127489();
  //transmitPGN127489(0,55.5,164,171,13.54,15.8,221,11.2,32.1,38,44,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  testRPM();
}

void loop(){ 
  //PGN 127488 binary 011111001000000000
  //for id try 110 + above + 00000000 = 11001111100100000000000000000 = hex 19F20000
  //highest priority = 000 try 00001111100100000000000000000 = hex 1F20000 = dec 32636928
 
  //PGN 127489 binary 011111001000000001
  //for id try 00001111100100000000100000000 = hex 1F20100 = dec 32637184
 
  // send data:  id = 0x00, extended frame, data len = 8, stmp: data buf
  CAN0.sendMsgBuf(32636928L, 1, 8, stmp); 
 
  //testPGN127489();
  //transmitPGN127489(0,55.5,164,171,13.54,15.8,221,11.2,32.1,38,44,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);  //with checkEngine flag set to true
  transmitPGN127489(0,55.5,164,171,13.54,15.8,221,11.2,32.1,38,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);  //with checkEngine flag set to false
 
  delay(1000);                       
}
void testPGN127489(){
  //if an engine parameter is not available, set it to 255
  unsigned char extpgn[26] = {0, 208, 14, 170, 13, 151, 136, 236, 4, 37, 2, 112, 207, 11, 0, 255, 255, 255, 255, 1, 0, 0, 0, 0, 255, 255};  //decimal values
  unsigned char temp[8] = {0,0,0,0,0,0,0,0};
  //
 
  int cur=0;
  for(int i = 0; i<=3; i++){
      temp[0] = i; //frame counter
      if (i==0){
          temp[1] = 26; //total bytes in fast packet
          //send the first 6 bytes
          for(int j = 2; j<8; j++){ 
               temp[j]=extpgn[cur];
               cur++;   
           }
      } else{
           for(int j = 1; j<8; j++){ 
               temp[j]=255;
           }
           //send the next 7 data bytes
           for(int j = 1; j<8; j++){ 
               temp[j]=extpgn[cur];
               cur++;   
           }
      }
      CAN0.sendMsgBuf(32637184L, 1, 8, temp); 
      delay(1);
  }
}
void testRPM(){
  unsigned char stmp[8] = {0, 0xA0, 0x41, 0, 0, 0, 0, 0};
  int rpm;
  for(int i = 0; i<=4200; i=i+100){
      rpm=(i*4);
      stmp[2]=rpm/256;
      stmp[1]=rpm-(stmp[2]*256);
      CAN0.sendMsgBuf(32636928L, 1, 8, stmp); 
      delay(100);
  }
}
void transmitPGN127489(int engineInstance, float engineOilPress, float engineOilTemp, float engineCoolantTemp, float battery,
  float fuelRate, float engineHours, float engineCoolantPress, float engineFuelPress, float engineLoad, float engineTorque, bool flagCheckEngine,
  bool flagOverTemp, bool flagLowOilPress, bool flagLowOilLevel, bool flagLowFuelPress, bool flagLowSystemVoltage, bool flagLowCoolantLevel,
  bool flagWaterFlow, bool flagWaterInFuel, bool flagChargeIndicator, bool flagPreheatIndicator, bool flagHighBoostPress, bool flagRevLimitExceeded,
  bool flagEgrSystem, bool flagTPS, bool flagEmergencyStopMode, bool flagWarning1, bool flagWarning2, bool flagPowerReduction,
  bool flagMaintenanceNeeded, bool flagEngineCommError, bool flagSubThrottle, bool flagNeutralStartProtect, bool flagEngineShuttingDown){
  //if an engine parameter is not available, set it to 255
  unsigned int extpgn[26]; // {0, 208, 14, 170, 13, 151, 136, 236, 4, 37, 2, 112, 207, 11, 0, 255, 255, 255, 255, 1, 0, 0, 0, 0, 255, 255};  //decimal values
  unsigned char temp[8]; // {0,0,0,0,0,0,0,0};
  float v;
  extpgn[0]=engineInstance;
 
  v=engineOilPress;
  v=v*68.94757;
  //extpgn[2]=v/256;
  //extpgn[1]=v-(extpgn[2]*256);
  extpgn[2]=highByte((int) v);
  extpgn[1]=lowByte((int) v);  //this works well. I should change the code below to use this format.
 
  v=engineOilTemp;
  v=(((v-32)*5/9)+273)*100;
  extpgn[4]=v/256;
  extpgn[3]=v-(extpgn[4]*256);
 
  v=engineCoolantTemp;
  v=(((v-32)*5/9)+273)*100;
  extpgn[6]=v/256;
  extpgn[5]=v-(extpgn[6]*256);
 
  v=battery;
  v=v*100;
  extpgn[8]=v/256;
  extpgn[7]=v-(extpgn[8]*256);
 
  v=fuelRate;
  v=v*37.8541;
  extpgn[10]=v/256;
  extpgn[9]=v-(extpgn[10]*256);
 
  v=engineHours;
  v=v*3600;
  //extpgn[14]=v/16777216;
  //extpgn[13]=(v-(extpgn[14]*16777216))/65536;
  //extpgn[12]=(v-((extpgn[14]*16777216)+(extpgn[13]*65536)))/256;
  //extpgn[11]=v-((extpgn[14]*16777216)+(extpgn[13]*65536)+(extpgn[12]*256));
  int tempVar = (long) v >> 16;
  extpgn[14]=highByte(tempVar);
  extpgn[13]=lowByte(tempVar);
  tempVar = (long) v & 0xFFFF;
  extpgn[12]=highByte(tempVar);
  extpgn[11]=lowByte(tempVar);
 
  v=engineCoolantPress;
  v=v*68.94757;
  extpgn[16]=v/256;
  extpgn[15]=v-(extpgn[16]*256);
 
  v=engineFuelPress;
  v=v*689.4757;
  extpgn[18]=v/256;
  extpgn[17]=v-(extpgn[18]*256);
 
  extpgn[19] = 255; //nmea2000 reserved byte
 
  int engineStatus1P1 = B00000000;
  int engineStatus1P2 = B00000000;
  int engineStatus2 = B00000000;
  if (flagCheckEngine) engineStatus1P1 |= B00000001;
  if (flagOverTemp) engineStatus1P1 |= B00000010;
  if (flagLowOilPress) engineStatus1P1 |= B00000100;
  if (flagLowOilLevel) engineStatus1P1 |= B00001000;
  if (flagLowFuelPress) engineStatus1P1 |= B00010000;
  if (flagLowSystemVoltage) engineStatus1P1 |= B00100000;
  if (flagLowCoolantLevel) engineStatus1P1 |= B01000000;
  if (flagWaterFlow) engineStatus1P1 |= B10000000;
 
  if (flagWaterInFuel) engineStatus1P2 |= B00000001;
  if (flagChargeIndicator) engineStatus1P2 |= B00000010;
  if (flagPreheatIndicator) engineStatus1P2 |= B00000100;
  if (flagHighBoostPress) engineStatus1P2 |= B00001000;
  if (flagRevLimitExceeded) engineStatus1P2 |= B00010000;
  if (flagEgrSystem) engineStatus1P2 |= B00100000;
  if (flagTPS) engineStatus1P2 |= B01000000;
  if (flagEmergencyStopMode) engineStatus1P2 |= B10000000;
 
  if (flagWarning1) engineStatus2 |= B00000001;
  if (flagWarning2) engineStatus2 |= B00000010;
  if (flagPowerReduction) engineStatus2 |= B00000100;
  if (flagMaintenanceNeeded) engineStatus2 |= B00001000;
  if (flagEngineCommError) engineStatus2 |= B00010000;
  if (flagSubThrottle) engineStatus2 |= B00100000;
  if (flagNeutralStartProtect) engineStatus2 |= B01000000;
  if (flagEngineShuttingDown) engineStatus2 |= B10000000;
 
  extpgn[20]=engineStatus1P1;
  extpgn[21]=engineStatus1P2;
  extpgn[22]=engineStatus2;
  extpgn[23]=0;
 
  extpgn[24]=engineLoad;
 
  extpgn[25]=engineTorque;
 
  int cur=0;
  for(int i = 0; i<=3; i++){
      temp[0] = i; //frame counter
      if (i==0){
          temp[1] = 26; //total bytes in fast packet
          //send the first 6 bytes
          for(int j = 2; j<8; j++){ 
               temp[j]=extpgn[cur];
               cur++;   
           }
      } else{
           for(int j = 1; j<8; j++){ 
               temp[j]=255;
           }
           //send the next 7 data bytes
           for(int j = 1; j<8; j++){ 
               temp[j]=extpgn[cur];
               cur++;   
           }
      }
      CAN0.sendMsgBuf(32637184L, 1, 8, temp); 
      delay(1);
  }
  //for debugging
  /*
  Serial.println();
  Serial.print("Data = ");
  for(int j = 0; j<26; j++){ 
    if (j<25){
      Serial.print(extpgn[j]);
      Serial.print(", ");
    } else {
      Serial.println(extpgn[j]);
    }
  }
  Serial.print("HexData = ");
  for(int j = 0; j<26; j++){ 
    if (j<25){
      Serial.print(extpgn[j],HEX);
      Serial.print(", ");
    } else {
      Serial.println(extpgn[j],HEX);
    }
  }
  */
}
Title: Re: NMEA 2000 Shield
Post by: jpjcb66 on Oct 09, 2014, 04:55 pm
Thank you for your reply.
Here is my current code for this part :

Code: [Select]
// ++++++++++++++++++++++++++++++++++++ Engine Parameters, Dynamic ++++++++++++++++++++++++++++++++++++
  updateRate = 500; // 2 * / s
  priorite = 5;
  PGN = 127489;  // Paramètres environnementaux bus NMEA 2000 (N2K)
  source = 35;   // Airmar = 35
  adresse = priorite * 67108864 + PGN * 256 + source;
  float tempwc =  95; //TWEng;  // Celsius  Engine Water Temp
  long tempwk =  100 * ( tempwc + 273.15 );
  long tempw1 = ( tempwk & 0b1111111100000000 ) >> 8;  // mise en forme format CAN 16bits
  long tempw2 =   tempwk & 0b0000000011111111;

  float PressEng = 200;  // Lecture capteur pression resolution = 8 bits pour essai.
  long PressEng_ = 20 * PressEng;
  long PressEng1 = ( PressEng_ & 0b1111111100000000 ) >> 8;  // mise en forme format CAN 16bits
  long PressEng2 =   PressEng_ & 0b0000000011111111;

  message.id = adresse;
  message.ide = 1;
  message.rtr = 0;
  message.dlc = 8;
  message.data[0] = 0;   //  SID
  message.data[1] = 0;   //  Engine instance  8bits    0=Single Engine
  message.data[2] = 0;   //  doit etre  à 0 pour lecture 2 octets plus bas. Oil press = 0 si 255
  message.data[3] = PressEng2; //PressEng2;   
  message.data[4] = PressEng1; //PressEng1;   //  Oil   Press huile 1=0,3  2=0,5  3=0,8  4=1b  28=7,2b
  message.data[5] = 255;   //  ????
  message.data[6] = tempw2;   //  Temperature eau moteur - 16 bits (sonde DS18B20)
  message.data[7] = tempw1;   //  Temperature eau
/* Serial.print("TEMPERATURE EAU MOTEUR : ");
Serial.print(tempw2);  Serial.print(" - ");
Serial.println(tempw1);
*/
  SendPaquet();

  message.data[1] = 1;  // 1 paquet supplémentaire
  message.data[2] = 0;  // Alternateur
  message.data[3] = 0;  // Alt
  message.data[4] = 0;  // Fuel rate
  message.data[5] = 0;  // Fuel rate
  message.data[6] = 1;  // Hour
  message.data[7] = 0;  // Hour
  message.data[8] = 0;  // Hour

  SendPaquet();

  message.data[1] = 2;  // 1 paquet supplémentaire
  message.data[2] = 4;  // Hour
  message.data[3] = 0;  // Coolant press
  message.data[4] = 0;  // Coolant press
  message.data[5] = 0;  // Fuel press
  message.data[6] = 0;  // Fuel press
  message.data[7] = 0;  // reserved
  message.data[8] = 0;  // Discrete Status 1

  SendPaquet();

  message.data[1] = 3;  // 1 paquet supplémentaire
  message.data[2] = 0;  // Discrete Status 1
  message.data[3] = 0;  // Discrete Status 2
  message.data[4] = 0;  // Discrete Status 2
  message.data[5] = 0;  // Percent Engine Load
  message.data[6] = 0;  // Percent Engine Torque

  SendPaquet();

  delay(updateRate);
Title: Re: NMEA 2000 Shield
Post by: spicetraders on Oct 09, 2014, 05:13 pm


I am using non-certified NMEA2000 cabling products that I had manufactured for my current project. I have several available for sale below if interested. See images.
2 meter cable (Male to Female) - $7.5 each
T adapter - $7 each
Male rear panel mount connector - $5 each


I have found that NEMA2000 is hardware wise follows the older DEVICENET so many parts interchange with out issues. 
Title: Re: NMEA 2000 Shield
Post by: jpjcb66 on Oct 09, 2014, 05:14 pm
Compliments, Beautiful Code.
But I have to try to translate Arduino uno.

I did not see how you code:
address = priority * 67108864 * 256 + PGN + source;
Title: Re: NMEA 2000 Shield
Post by: allen652 on Oct 09, 2014, 06:04 pm
I should probably comment my code better (and more often).

jpjcb66: The first 3 bits of the id is the priority, the next 18 bits are the PGN, and the last 8 bits are the source address.
See the comments in my code above in void loop().

priority = 000
PGN = 011111001000000000
source = 00000000

00001111100100000000000000000 binary = 32636928 decimal

Code: [Select]
// send data:  id , extended frame, data length = 8, data buffer
  CAN0.sendMsgBuf(32636928L, 1, 8, stmp);
Title: Re: NMEA 2000 Shield
Post by: jpjcb66 on Oct 09, 2014, 06:45 pm
@allen652

I understand !
You put "source" = 0x0
Code Airmar = 0x25 (35dec).
There exists an array of manufacturer codes ?
For example what is the Volvo Penta code ?


Your code is perfect, thank you infinitely.
jp
Title: Re: NMEA 2000 Shield
Post by: farabin on Jan 21, 2015, 07:36 pm
Hi friends
I want to read 2 periodic data from maretron WSO100 module. PGN #130306 for wind data & #130310 for environmental parameters. As I read this PGNs send periodically every 100 ms &  500 ms...
I use LPC1768 controller and do this steps to read wind data:
1) set CAN Controller baud rate to 250 kbit/sec
2) set ID to 130306(0x01FD02) in extended format
3) read can receive buff...
But I don't receive any data on bus!!!
what should I do??? what's wrong???
please help me...
Thanks a lot
Title: Re: NMEA 2000 Shield
Post by: Prof67 on Feb 20, 2015, 01:41 am
Hi,

Want to read NEMA2000 stream from a Garmin Depth founder with a Arduino Due.

Just this device on NEMA network.

Did someone have code reference ?

  :D
Title: Re: NMEA 2000 Shield
Post by: elgui on Mar 30, 2015, 08:57 pm
Hi,

I'm about to buy a "triducer", the Airmar DST800. It's going to send depth/temp/speed via NMEA2000.
As a java programmer with zero experience with Arduinos (but lot of time to spend on it), do you think I have a chance, using existing resources, to decode these informations and display it on a e-ink display shield ?
I don't absolutely need a ready-to-use solution, and a simple "yes you can" would be much appreciated to preserve my motivation ^^
Of course, I'll be back later with more accurate questions ;)
Title: Re: NMEA 2000 Shield
Post by: CrossRoads on Mar 30, 2015, 09:04 pm
Yes you can.
Only challenge is parsing the NMEA data stream to pick out the pertinent info.
And then sorting out the e-ink interface. Probably just another serial data stream?
Title: Re: NMEA 2000 Shield
Post by: elgui on Apr 01, 2015, 01:21 am
Thank you CrossRoads,
I have an idea about the parsing challenge, and I guess I can use some existing code that parse GPS datas and adapt it. The e-ink display does not scares me that much, because if I don't succeed, I still have other display options.
I'll put my code somewhere on this forum if I reach my goal =)
See you !
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 31, 2015, 10:08 am
Hi All,

I have been trying to find NMEA2000 shield without success, so I wrote my own. It can act as listener only and forward data to PC in Actisense or clear text format. Or it can act as Termperature sensor node with automatic address claiming. Or as I am making it as a NMEA0183 combiner/ NMEA200 converter and sensor node.

Library works with Mega board with MCP2551 chip or with Due board with its internal CAN controller.

Anybody interested?
Title: Re: NMEA 2000 Shield
Post by: rickbase1 on Aug 13, 2015, 09:41 pm
Great timing, I just signed up to this forum and started looking for a library today ! 

Please count me in. 

I am building a LiFePo4 alternator regulator and an active charge/monitor BMS and would love to have a full NMEA2k interface to connect my Maretron/Raymarine network.

Thanks,

Rick

Title: Re: NMEA 2000 Shield
Post by: FXVT on Aug 16, 2015, 11:24 pm
Bonjour

Here is the sketch I have written to display the battery voltage on my boat.
It sends the PGN 127508 thru the NMEA 2000 network.
The voltage (Only one battery, Battery number 1= instance 0) can be read on:
- Raymarine A78 MFD
- B&G Triton


The Arduino+Shield (Seeedunio) pack is directly powered by the 12v supply

The voltage is read by the A0 pin through a voltage divider made with 2 resistors

It works well and seems to be reliable, but sometime the INT red led turns on solid. However it keeps on running, the network does'nt hang up.

Amicalement.
François-Xavier
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 17, 2015, 08:00 am
Hi,

You can find NMEA2000 library and samples on https://github.com/ttlappalainen. The best would be to use Arduino Due, since it needs only MCP2562 tranceiver for connecting to the bus. It also has 8 byte double for better calculations.

My own setup is running and it has also 3 NMEA0183 inputs for combiner and tranfer data to N2kBus. So with Arduino Due and 4 extra chips this replaces 4 devices: NMEA0183 combiner (e.g. Brookhouse), NME0183->N2k (Actisense), N2k->PC  (Actisense), MOB device.
Title: Re: NMEA 2000 Shield
Post by: FXVT on Aug 17, 2015, 08:47 pm
Bonjour,

Good job Timo.

I have not understood everything but it is very interesting.

Amicalement.
François
Title: Re: NMEA 2000 Shield
Post by: pogcarr on Sep 09, 2015, 05:13 pm
Timo,

Can you provide any pictures or other details of your hardware setup?  How you hooked everything together.  VERY interested!

Paul
Title: Re: NMEA 2000 Shield
Post by: thomasow on Sep 11, 2015, 06:17 pm
Hi All,

I have been trying to find NMEA2000 shield without success, so I wrote my own. It can act as listener only and forward data to PC in Actisense or clear text format. Or it can act as Termperature sensor node with automatic address claiming. Or as I am making it as a NMEA0183 combiner/ NMEA200 converter and sensor node.

Library works with Mega board with MCP2551 chip or with Due board with its internal CAN controller.

Anybody interested?
Timo,

Hello.  Wanted to let you know I have just posted up a very rough cut of a NMEA-2000 / Alternator regulator bridge based on your lib.  I made some extensions to include some additional PGNs - and once proofed out a bit will submit a pull back to your get-hub lib.

This bridge is intended to run on a Due, and takes the ASCII status strings from my Arduino based Alternator Regulator and send them out to the NMEA-2000 bus.  At this point is is rather unproven as I lack some additional hardware (specifically, the NEMA-2000 display side), am not settled on which PGNs should be broadcasted, and I am not totally sure I have extended your libs correctly  :o

Source, extended libs (draft form), as well as a bit more details here:
http://arduinoalternatorregulator.blogspot.com/2015/09/very-rough-nmea-2000-bridge-source.html (http://arduinoalternatorregulator.blogspot.com/2015/09/very-rough-nmea-2000-bridge-source.html)

Looking forward to perhaps getting this a bit more settled.


Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Sep 25, 2015, 08:28 am
Hi PogCarr and thomasow,

I'll try to upgrade GitHub with pictures and extension as soon as possible. I have been a bit busy with othe project.

Timo
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Sep 27, 2015, 08:41 am
Hi all,

Now there is upgraded version of NMEA2000 library and some drawings under Documents in https://github.com/ttlappalainen/NMEA2000
Title: Re: NMEA 2000 Shield
Post by: skyflyer on Nov 09, 2015, 03:23 pm
I have to laugh when I see some of your posts describing yourselves as 'beginners'. To me a lot of this is like a foreign language and you are experts compared to me!

Perhaps someone can help me if I describe where I am at and where I am trying to go

I have managed to set up an Arduino to create NMEA0183 sentences from analogue data, combine with NMEA0183 sentences from other instruments and transmit in NMEA0183 format.

I need to now translate that to NMEA2000 to feed a different network

From this thread I have managed to understand that I will need to buy or make a Canbus shield, to attach to the Arduino.  Also that I will need to download and include various Libraries.

What i do not understand, nor can I find any obvious reference, is what I then have to do to convert the data obtained via N0183 to N2000?

Where is this step? Is it proprietary? Is everyone having to do their own reverse engineering, or is this staring me in the face somewhere that I have missed?

Unfortunately my knowledge of electronics is zero. I can connect one terminal to another, I can solder, I can construct but I have no understanding at all of what is happening inside the device! I struggle with simple concepts like transmission speed, capacitors, diodes, transistors etc.

I' just want an idiots guide to try and get this working. It sounds like many of you have managed but I cannot make the jump from the sample sketches to the real thing.

For example if I have a simple wind sentence from NMEA0183

$WIMWV,059,R,5.04,N,A*0

How do I get that data or part of that data, broadcast to N2000?

Thanks if anyone can help
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 09, 2015, 04:15 pm
Hi,

Well I am beginner with Arduino, but did my first digital telecope control system on 1980 with 2 A4 sized boards full of logic chips.

I prefer you buy a Arduino Due and MCP2562 chip for NMEA2000 tranceiver. Due is better for your task, since it has more power.

If you like to convert data from NMEA0183 to NMEA2000 you also need e.g. MAX3483 for NMEA0183 bus tranceiver. On Arduino Due you can have max. 3 MAX3483 and so 3 channels for NMEA0183.

I can then send you ready drawing for converter. If you get data to Arduino as in analog format, then you do not need MAX3483 tranceivers.

So now actually there are almost everything ready. I have to update NMEA2000 library, which now also have functions fo sending wind data. I have not done that yet, since other guy has developed wind data handling and I have not yet proved it ok.

On my library there is sample TemperatureMonitor, which does your task but with temperature. Post your contact to me, so I can guide you how to  continue.
Title: Re: NMEA 2000 Shield
Post by: skyflyer on Nov 09, 2015, 04:57 pm
thanks for that, its a good start; I am contactable at gc9876 (at) hotmail dot com

I should explain that I need some data in NMEA0183 format also (to feed to chart plotter) so it needs to be done in two steps, even if actually it would be possible to go straight from analogue to N2000.

My set up will require the combining (multiplexing) of N183 GPS, Wind and Depth sentences which is then both transmitted to N183 chart plotter and also converted to N2000 for autopilot.


Thanks again
GC
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 09, 2015, 05:13 pm
You setup is rather same I have. So I'll contact directly to you.
Title: Re: NMEA 2000 Shield
Post by: mcnobby on Nov 13, 2015, 02:35 pm
I used to work for Simrad/Navico and worked on some of the earliest versions of NMEA2000, I even had a bit of a hand in some of the original PGNs !! Simrad/Navico adopted CAN@250kbps on thier Corus instrument system well before NMEA2k was published. We mainly used Philips devices (one of the earliest companies to embed CAN into their microcontrollers), then moved to Renesas devices.

Its come a long way

A tiny bit off-topic, but this is a very interesting venture :
https://www.kickstarter.com/projects/1689846268/ikommunicate-gateway-enabling-the-internet-of-thin (https://www.kickstarter.com/projects/1689846268/ikommunicate-gateway-enabling-the-internet-of-thin)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 14, 2015, 05:17 am
Hi,

I also know signal-K, but there is no MFD with support for that - at least I have not heard any. And with MFD I mean waterproof and sunlight readable display, which can be installed on steering pole. So the point for NMEA library is the way to provide tools to add e.g. temperature or tank sensors to existing bus. It also provides way to read data to PC.

Check also NMEA-Simulator (http://www.kave.fi/Apps/), which next version (coming withing few days) also offers way to simulate devices on N2k bus.
Title: Re: NMEA 2000 Shield
Post by: zyabba on Nov 23, 2015, 11:06 am
hi, Timolappalainen.
it is a great project ! I am trying to make my own wind sensor . the hardware is working fine. It send nmea 0183 mwv message to com port. now I am trying to connect it to pc-to n2k converter. I use arduino due with internal can and max 232cpe. I have sucsess to read depth data from n2k . and I see some data in actisense listener but cannot read it . I also see pcton2k in list of devises on my lowrance and garmin , but when I try to send some data from comport or nmea 0183 out of garmin Isee nothing ! I tyied different baud rate of ports , connected to native and programming ports of arduino ,used max 232cpe  and arduino serial port but fail ! I see led blinking when data comes from n2k and from nmea simulator but nohing in n2k . what is wrong in my setup ? is it possible to read actissence format ? thanks !
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 23, 2015, 11:50 am
Hi,

I did not understood you setup.
- What is your pc-to-n2k converter
- Where do you have MAX232CPE? For CAN you should use CAN tranceivers
- What do you mean  "...see some data in actisense listener"? Are you using my Arduino example ActisenseListener with Actisense "NMEA Reader" PC sw?

There is new Arduino example ActisenseListenerSender, which can read and send data. With that you:
- Connect Arduino CAN to N2k bus.
- Open Actisense "NMEA Reader" to the programming port.
- Open "NMEA Simulator" to native port.

Now if you enable PGN:s for sending on "NMEA Simulator", you should see them on "NMEA Reader" and also simulated devices on your Garmin or Lowrance. Note that on "NMEA Simulator" you must set device source addresses different than devices you have on N2k bus. "NMEA Simulator" can not yet do Address Claiming.

If you want to send wind data to the N2k bus, take first the example WindMonitor. There you need only to write your code for functions double ReadWindAngle() and ReadWindSpeed() and it will send wind data to the bus. Not that to write N2k, you do not write any NMEA0183 messages to com port. You have to create N2k message and send it as in example void SendN2kWind().

Download newest version of NMEA2000 library and "NMEA Simulator". I have done several fixes within few days.
Title: Re: NMEA 2000 Shield
Post by: zyabba on Nov 24, 2015, 08:17 am
my hardware is arduino due internal can and can tranceiver tja1050 .
max232cpe is used to connect arduinos serial with rs232 on laptop or garmin in some cases.
yes I am  using your Arduino example ActisenseListener with Actisense "NMEA Reader" .my last attempt was sucsessful.
I could read data from can bus ,see list of nmea2000 devises , but I did not see ActisenseListener in this list. but
your another example FromPCToN2k is shown .I have downloaded your new ActisenseListenerSender example and I will try it today.
I think I need to smoke a lot of manuals before I could create N2k message and send it to bus :)  . thank you for your answer .









Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 24, 2015, 08:57 am
Hi,

Example ActisenseListener and ActisenseListenerSender are blind to N2k bus. If you instead take as I mentined example WindMonitor, it will be shown on the bus. If on WindMonitor you uncomment line
  // Serial.begin(115200);
and change line:
NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,23);
to
NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,23);

Your wind monitor will act as N2k node, but also lintens and forwards all traffic to the Serial.

I have spent too much time with N2k, so I hope you do not need to. For that there are several ready N2k messages to create for sending with library. You will find these on file N2kMessages.h. If you need some new message (PGN) to be send, contact me so I'll add it to the library for available to everyone. I take few minutes for me to add new PGN, while you may need to dig internet for hours.

Note that WindMonitor uses those predefined functions from N2kMessages.h within its function "void SendN2kWind() {...}

And if you like to visualize N2k data on PC or have webserver for them, check also OpenSkipper. The lates beta is on http://www.kave.fi/Apps The other way for visualizing is to use SignalK (http://signalk.org/)
Title: Re: NMEA 2000 Shield
Post by: zyabba on Nov 24, 2015, 05:51 pm
hello ,
windmonitor is working great ! I see speed and direction of the wind and WindMonitor is shown in device list (exept raymarine i70 but data is shown)
I also try it as ListenAndNode - the bus data is shown in Openskipper .the example "fromPCToN2k" is also seen in the bus .if I turn ListenAndNode I see bus trafic but I cannot send message to n2k even in NodeOnly .I try to send some n2k pgn using nmea simulator but no data is shown on mfd
(lowrance and raymarine) may be I am doing something wrong .I dont anderstand what . but it is a progress . next I wil try to connect wind sensors
to windmonitor . first I will connect potentiometer to analog if sucsess- digital out of sensors .It would be great to connect rudder sensor, so adding
rudder pgn would be great ! I hope this topic would progress !
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 24, 2015, 08:30 pm
Hi,

Note that sending data from PC to N2k bus is not build in the library. It is an other module ActisenseReader. That has been used on both examples fromPCToN2k and ActisenseListenerSender. Note that on ActisenseListenerSender I have used Arduino programming port for data to PC and native port for data from PC to N2k bus. This is because I did not found the reason why stream get jammed, if I used same port for both directions. It worked for some time but on long period it always stopped and nothing went to any direction any more. Maybe there is explanation somewhere, but it was not critical for me at that time.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 25, 2015, 08:49 am
Hi,

I updated NMEA Simulator with rudder PGN (see Tools-Options...-NMEA2000-"Engine, other") and function void SetN2kRudder(...) to N2kMessages module on NMEA2000 library.

Timo
Title: Re: NMEA 2000 Shield
Post by: zyabba on Nov 25, 2015, 10:55 am
thank you Timo ! I'll try. So I anderstand that if I have a compass in n2k bus , it is possible to calculate true wind direction (listenAndNode) Am I wright ? openskipper dont want to work when I plug n2k compass to the bus.I think it doesn't like high data refresh.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 25, 2015, 11:34 am
Yes. Then you need tom make similar message handler as in example DataDisplay. I need to add heading parser function to N2kMessages module. Which PGN your compass is sending - PGN 127250? Which GPS compass you have?

I have 10Hz compass and lot of other data coming to OpenSkipper, so I do not think this is the problem with it. Other possibility is that some definition is wrong.
Title: Re: NMEA 2000 Shield
Post by: zyabba on Dec 02, 2015, 07:58 am
WoW ! It's working !
I connected magnetic encoder as5040 as wind direction sensor , IR couple from old mouse as wind speed sensor , potentiometer as rudder sensor. I have edded rudder to simple wind monitor .
Everything working great . now I am trying to edd tft lcd with beautifull graphics. Need some more time and alcohol to solve bugs , but already it is a greate step. thank you Timo!































































i
Title: Re: NMEA 2000 Shield
Post by: skyflyer on Dec 20, 2015, 09:24 pm
Another newbie question has arisen as my own project develops. The Due I am using to output the data, transmits the 0183 sentences down the serial port, but I guess this is RS232 protocol.

I believe NMEA0183 is TTL or at least different; at the moment my instrumentation will not read what the due is outputting.  How do I convert it, invert it, change it?

Thanks
Title: Re: NMEA 2000 Shield
Post by: virtuvas on Jan 14, 2016, 08:24 pm
Hi,

You can find NMEA2000 library and samples on https://github.com/ttlappalainen. The best would be to use Arduino Due, since it needs only MCP2562 tranceiver for connecting to the bus. It also has 8 byte double for better calculations.

My own setup is running and it has also 3 NMEA0183 inputs for combiner and tranfer data to N2kBus. So with Arduino Due and 4 extra chips this replaces 4 devices: NMEA0183 combiner (e.g. Brookhouse), NME0183->N2k (Actisense), N2k->PC  (Actisense), MOB device.
hello,

my first post here, but have being working on arduino Uno -> NMEA0183 and have a few sketches working for specific things already posted in the YBW forum. One is for rudder angle (IIRSA) which I now have to convert to NMEA2000 (should be 127245) as my Garmin GMI10 doesn't support this sentence.

Have a few bits of kit, 3 Uno's relay/wifi/ethernet/Serial->TTL, etc shields but NOT a Due, nor a CAN BUS gate/shield.

Could you please recommend a setup that will work with minimum effort and debugging?
I'm ok with a soldering gun, but not particularly good in reading graphs (talking about building the CAN BUS interface in hardware using the MCP2562 tranceiver you mention).
Are there any readymade shields that would plug on the Due that will work with your code? Planning to order tonight so that I can get the N2K project moving using your notes and code.
I can see the CAN BUS Seeed  and the SparkFun one, are they any good?

thank you very much!

cheers

Vassilis
Title: Re: NMEA 2000 Shield
Post by: virtuvas on Jan 14, 2016, 08:29 pm
Another newbie question has arisen as my own project develops. The Due I am using to output the data, transmits the 0183 sentences down the serial port, but I guess this is RS232 protocol.

I believe NMEA0183 is TTL or at least different; at the moment my instrumentation will not read what the due is outputting.  How do I convert it, invert it, change it?

Thanks
hi there,
I know it's a month old question, just in case you haven't figured it out you need an RS232 - > TTL converter, a few on ebay for 1-2euro each.
In theory (haven't tried it) the new IDE supports software serial and it should work without h/w will try (maybe later on tonight and can report back)

cheers

V.
Title: Re: NMEA 2000 Shield
Post by: R_P_Ryan on Jan 19, 2016, 08:37 pm
I have built and published an Arduino-based marine engine monitoring system at https://bitbucket.org/R_P_Ryan/enginemonitor/wiki/Home.

It reads nine sensors and displays the data on 16 X 2 LCD, with a "next" button to display the next sensor:
1. Raw water in temp
2. Raw water out temp
3. Coolant entering the heat exchanger temp
4. Coolant exiting the heat exchanger temp
5. Cylinder head temp
6. Engine room temp
7. Oil temp
8. Exhaust gas temp
9. RPM


There is demand to publish the data to NMEA 2000 displays.

What is the best way to approach this?

Thanks,
Robert
Title: Re: NMEA 2000 Shield
Post by: Heatz on Feb 10, 2016, 04:21 pm
HI ttlappalainen,
your work on this project is very much appreciated and impressively done. I have a Mega and a CANbus shield but am having problems with sending data on my n2k network to a Raymarine a98. The arduino code (your tempmonitor) initializes the canbus shield correctly (though I had to change the CSpin to 10), but i get Write Failed messages when it runs. Does the code need to get a response form the n2k network or should it just be writing out the data? My TX and RX LEDs on the CANbus shield remain constantly lit. I am able to see the correct data when using the Actisense reader s/w and uncommenting the appropriate lines of code. I see nothing on the Raymarine MFD.
Thanks for any help you can provide.
Title: Re: NMEA 2000 Shield
Post by: Heatz on Feb 15, 2016, 10:50 pm
Timo,
Your code is fantastic and all working great as you documented. Thanks for the tremendous effort. I am using a Mega with CANBus shield. I had to connect Pin 53 of mega to pin 9 of Canbus shield to make it work. I am displaying RPM, OIl Pressure, Coolant Temp and Battery V on a Raymarine a98 MFD. I am curious about the SetN2kPGN127489 function as it appears not to make use of the boolean alarm flags. Your N2kMESSAGES.CPP code seems to not assign the enginesStatus1 and 2 messages into PGN messages.

I would have expected to see:

  N2kMsg.AddByte(engineStatus1P2);  // Discrete Status1
  N2kMsg.AddByte(engineStatus1P2);  // Discrete Status1
  N2kMsg.AddByte(engineStatus2);    // Discrete Status 2
  N2kMsg.AddByte(0);

right after the building of the engineStatus1x bytes. Is this correct?
Thanks, Heatz
Title: Re: NMEA 2000 Shield
Post by: Dick3 on Feb 22, 2016, 02:08 pm
Hi,

I'm looking for the NMEA PGN 127245 Rudder field format for SW programming.
Can anyone help me, please?

Thanks!

Jan Richard
Title: Re: NMEA 2000 Shield
Post by: Enzycal on Mar 04, 2016, 05:05 pm
Hi, is it possible to use this module http://www.14core.com/wiring-the-mcp2515-controller-area-network-can-bus-diagnostics/ (http://www.14core.com/wiring-the-mcp2515-controller-area-network-can-bus-diagnostics/) with NMEA2000 library?
Title: Re: NMEA 2000 Shield
Post by: maxik on Mar 13, 2016, 12:56 pm
Do I understand correctly that for use of the library to Maple Minnie I need additional Shield?
Title: Re: NMEA 2000 Shield
Post by: Hobbe1979 on Mar 15, 2016, 05:06 pm
Hi,
Great work you have done. I have managd to setup an Arduino due with a mcp2562 as described in the documentation from timolappalainen. I'm trying to communicate with a Garmin 721xs but I experience several problems.

It works if I use ActisenseListenerSender and run it with the nmea simulator by timolappalainen from openskipper. I do not receive all info sent. The wind data, tank and RPM does not show on the garmin unit. However fuel rate, engine temp, oil temp works among others. All simulated devices  appears in the list of devices on the garmin unit.

So now to the real trouble
If I use some of the other exampels as message sender or temp monitor. It shows up in the list and I receive data. Not complete but some of the data works. Then after 30-60 seconds it stops and the unit disappears from the list of devices. If I look on the traffic on the serial bus (usb), I still receive data from the garmin unit and the arduino seams to still send data. So I guess that its been kicked out by the garmin unit of some reason.
If I just initiate the Arduino and disable it from sending messages, then its stays in the list on the garmin unit.

I guess that I probably missed something important….   I have been reading through most of the documentation and libraries. I have to say that I'm impressed even if I do not understand even half.

I'm happy for all kind of support to get this to work.
Title: Re: NMEA 2000 Shield
Post by: The4thzeke on Mar 16, 2016, 12:06 am
Hello everyone, I am a complete Noob to Arduino and forums in general so I hope I do not insult anyone with my first post.  I would like to use the Arduino to receive depth data from my Raymarine NMEA 2000 depth sounder to control a fishing downrigger.  The Arduino would adjust the depth of my fishing gear based on the information sent from my depth sounder.  I'm okay with the mechanical aspects but have really no idea about the programming end of things.  I would appeciate any oppinion on the "do-ability" of this project as well as the level of programming complexity (ie. Likelihood of existing libraries for the programming).  I have spent some time searching the forum and the web for similar projects and I think others have done similar things but have not found anyone who has taken depth information from a NMEA 2000 system.  Thank you in advance and forgive me if I posted this in the wrong place.
Title: Re: NMEA 2000 Shield
Post by: Hobbe1979 on Mar 16, 2016, 06:15 pm
Hello,
I´ve been keeping on trying to find out why I get kicked out from the Garmin unit. I have made some interesting observations.  When I watch the traffic sent from the Arduino with the temature monitor program.

If I  comment: " // SendN2kTemperature();"  so it doesn't send any messages. it will stay in the list in the Garmin unit.

The traffic looks as follows:
--------------------------------------
CAN device ready
Start address claim
Pri:6 PGN:60928 Source:22 Dest:255 Len:8 Data:FB,FF,5F,2E,0,A0,64,40
Pri:6 PGN:126996 Source:22 Dest:255 Len:134 Data:FF,FF,9A,2,45,78,63,61,6C,69,62,75,72,20,58,2D,31,31,39,0,0,0,0,0,0,0,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,30,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,FF,FF
Pri:6 PGN:60928 Source:22 Dest:0 Len:8 Data:FB,FF,5F,2E,0,A0,64,40
Pri:6 PGN:60928 Source:22 Dest:0 Len:8 Data:FB,FF,5F,2E,0,A0,64,40
-------------------------------------

And there after keep on sending PGN:60928 with a few seconds interval.
However when uncomment: " // SendN2kTemperature();" and I send a message, the traffic looks as follows. I Have noticed that it stops sending PGN:60928. Instead it send only PGN:13031.  See under.
I guess that this could be the reason? Are there any way of getting it to send PGN:60928 frequently?

------------------------------------------
CAN device ready
Start address claim
Pri:6 PGN:60928 Source:22 Dest:255 Len:8 Data:FB,FF,5F,2E,0,A0,64,40
Pri:6 PGN:126996 Source:22 Dest:255 Len:134 Data:FF,FF,9A,2,45,78,63,61,6C,69,62,75,72,20,58,2D,31,31,39,0,0,0,0,0,0,0,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,30,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,FF,FF
Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:16,C1,70,FF,FF,FF,FF,FF
Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:16,C1,70,FF,FF,FF,FF,FF
------------------------------
Title: Re: NMEA 2000 Shield
Post by: Hobbe1979 on Mar 17, 2016, 01:14 pm
I have figured out that, if I do send an address claim by using "NMEA2000.SendIsoAddressClaim();" every 2000 milliseconds,  It works well with the Garmin 721xs.  Then everything seems stable. The RPM data works now. It seems to be just a setting in the garmin that was the issue.

Is this the correct way of solving my issue?
Title: Re: NMEA 2000 Shield
Post by: heryoon on Mar 19, 2016, 01:48 am
Hello, I'm trying to use the Mega and the Can-Bus shield in order to get readings from my NMEA 2000 "Intelliducer" from Garmin.
When I was attempting to use the temperature monitor sample code,
"CAN device failed to open"
from the
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); part of the code.
Even though on my Can-Bus shield, the RX led is flashing.

Any idea why it's failing to "open" to the device which I'm assuming it's not communicating with it???
Title: Re: NMEA 2000 Shield
Post by: Hobbe1979 on Mar 21, 2016, 09:49 am
Hello, I'm trying to use the Mega and the Can-Bus shield in order to get readings from my NMEA 2000 "Intelliducer" from Garmin.
When I was attempting to use the temperature monitor sample code,
"CAN device failed to open"
from the
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); part of the code.
Even though on my Can-Bus shield, the RX led is flashing.

Any idea why it's failing to "open" to the device which I'm assuming it's not communicating with it???
I got the same issue with my mega when the MCP2515 where not hooked up correctly. So I think that its caused when there are no working communication to the can controller.
Title: Re: NMEA 2000 Shield
Post by: Heatz on May 06, 2016, 02:11 am
Hello, I'm trying to use the Mega and the Can-Bus shield in order to get readings from my NMEA 2000 "Intelliducer" from Garmin.
When I was attempting to use the temperature monitor sample code,
"CAN device failed to open"
from the
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); part of the code.
Even though on my Can-Bus shield, the RX led is flashing.

Any idea why it's failing to "open" to the device which I'm assuming it's not communicating with it???
I had issues getting my mega to work with the Canbus shield. Turned out I had the wrong MISO pin selected (or something like that). I posted about this somewhere, but can't seem to remember at this time.
Title: Re: NMEA 2000 Shield
Post by: Adrculda on May 11, 2016, 04:07 am
Hey guys...
My plan is to use a Garmin GFS10 for fuel consumption and level alongside an Arduino DUE faced with Engine Data Acquisition ( It's and older boat, not fuel injected ) and everything is analog. With that being said I would like to use this as an performance tracking tool and as backup if one of those gauges start to "lie".

Would like to add the following items into the NMEA2000 Stream with the DUE.
- Engine RPM ( I will have to devise a simple circuit as the only signal I have is from the coil )
- Engine Water Temp
- Port Exhaust Temp
- Starboard Exhaust Temp
- Water Temp / Speed ( Using Mercruiser 859223 Unit )
- Heading / Compass
- Trim / Tilt


 I'm going to be using an Lowrance Elite 7Ti as an display unit.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 11, 2016, 05:03 am
Hi Guys,

I have not followed this forum for a while, since I should get messages by email and I have not got any until now. So I have thought this has been dead. Here are some late answers.

Please check arduino library on https://github.com/ttlappalainen/NMEA2000 . It has been developed more and used by several projects. Under documents there are drawings to make own devices and how to start with library. Under examples there are ready code e.g. for sending some temperatures.

Adrculda:
So for sending engine RPM you just use:
    SetN2kEngineParamRapid(N2kMsg, EngineInstance, RPM);
    NMEA2000.SendMsg(N2kMsg);

For engine water temp you need to use
    SetN2kEngineDynamicParam(N2kMsg, 1,N2kDoubleNA,N2kDoubleNA,EngineWaterTemp,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA);
    NMEA2000.SendMsg(N2kMsg);

And for temperatures as in example TemperatureMonitor.ino
    SetN2kTemperature(N2kMsg, 1, 1, N2kts_ExhaustGasTemperature, ExhaustTempPort);
    NMEA2000.SendMsg(N2kMsg);
    SetN2kTemperature(N2kMsg, 1, 2, N2kts_ExhaustGasTemperature, ExhaustTempStarboard);
    NMEA2000.SendMsg(N2kMsg);

Hobbe1979:
PGN 60928 is only for address claiming and it will be done only when requested. So that should ne be sent frequently. Unfortunately some units expects it. E.g. my Garmin GMI 20 does not.

Dick3:
In NMEA2000 library there is ready function SetN2kRudder. If you need to know how data is build, read code on N2kMessages.cpp.

Enzycal:
Yes you can. It is almost the same as my sample schematic: https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoMega_CAN_with_MCP2515_MCP2551.pdf
Title: Re: NMEA 2000 Shield
Post by: jukkap on May 11, 2016, 07:26 pm
Hello,

My goal is to get speed information from Raymarine a67 and display it in another display/meter.

Problem is that when Raymarine contacts satellites, NMEA messages ends from Raymarine and Raymarine don´t receve any messages from AT90CAN128.
 
When Raymarine is tested indoors and it can´t get satellites, system shows work  just fine.
For example it ansewers ISO reguest speed IDE: 59904 Data: 128259 (speed), even without address claim.

What would be the solution?

1. Should i pay attension something in address claim?
            (Field informations, Device instance, Manufacturercode etc.)

2. Should Product Information(126996) be send, even Raymarine or ohter nodes don´t request it?
             (Tryed to send, but Raymarine not seems to understand message)

3. Or should i give up and by Actisense NGT-1 ISO? Could it be the solution of this project. Any experiences  from Actisence?


Harware setup:
-AT90CAN128
-MCP2551
-Raymarine a67


Thanks,

Jukka Penttinen

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 11, 2016, 09:17 pm
Hi jukkap,

First do you use my NMEA2000 library with NMEA2000_avr?
Have you tested just listen traffic on bus by using example ActisenseListener and do you get it right?
What is your other display?

1. I have tested a lot with Garmin GMI 20 and it seem to be rather flexible. With my current address claiming code it works fine. But some other system required that address claiming should be sent every 2 sec. So who can say about Raymarine does it accept only registered manufacturer instead my default 2046, which is the highest possible value.

2. In principle there is no need to send product information without request. Devices should register devices on the bus by address claiming and if they are interested about sender, then they should request product information.

3. I have NGT-1 ISO and it is good. After writing NMEA2000 library I have done everything with with it and NGT is just as a spare on boat.

If you are located in near Turku I would be interested to test your MFD with Arduinos.
Title: Re: NMEA 2000 Shield
Post by: Adrculda on May 12, 2016, 03:42 pm
So...

Went Ahead and Ordered a waterproof enclosure (http://www.ebay.com/itm/252101965244?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT) and will be using an AMP seal connector for the sensor inputs from the engine.

Does anyone know what the part number for the NMEA2000 connectors are ??
I'm almost sure TE / AMP would be the one to supply them...
Title: Re: NMEA 2000 Shield
Post by: Rfritz on May 12, 2016, 09:14 pm
Look at these from digikey:

APC1760-ND $4.24

waterproof O-ring and mounting nut included.
Title: Re: NMEA 2000 Shield
Post by: Adrculda on May 13, 2016, 04:04 am
Look at these from digikey:

APC1760-ND $4.24

waterproof O-ring and mounting nut included.
Thank you :)
Title: Re: NMEA 2000 Shield
Post by: nilsal on May 14, 2016, 10:38 pm
I've tried to build the TemperatureMonitor program for mega it gives the error message:

C:\Users\Nils\Documents\Arduino\libraries\NMEA2000_mcp-master/NMEA2000_mcp.h:62:84: error: 'MCP_16MHz' was not declared in this scope ...


If I build it with due settings it works. Unfortunately I don't have a duo board.
If I try to define MCP_16MHz

#ifndef MCP_16MHz
#define MCP_16MHz 1
#endif


 I get:
C:\Users\Nils\Documents\Arduino\libraries\NMEA2000_mcp-master\NMEA2000_mcp.cpp:60:148: error: no matching function for call to 'MCP_CAN::MCP_CAN()'...

I think I have followed the instruction in Arduino NMEA2000 library
02.02.2016 pdf file
Does anybody know what can be wrong?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 15, 2016, 06:08 am
I tested with latest libraries and seem to work.

Note that you should not use original Seed studio can bus shield library. MCP_16MHz has been defined in developed version of CAN_BUS_Shield library in file mcp_can_dfs.h on line 250. If you do not have that, delete your Arduino\libraries\CAN_BUS_Shield-master and download it from https://github.com/peppeve/CAN_BUS_Shield and install it.
Title: Re: NMEA 2000 Shield
Post by: jukkap on May 15, 2016, 08:19 am
Hi Timo,

Here is some deteails what I forgot mention.

First do you use my NMEA2000 library with NMEA2000_avr?
No. When I start this project I found some C CAN example from AvrFreaks harwared with AT90CAN128.
For me Adruino isn´t so familar yet, but maybe I should exlore it.

Have you tested just listen traffic on bus by using example ActisenseListener and do you get it right?
I have´n test bus any other device but follow bus traffic from Raymerine. Raymarine stops sending messages when it reachs satellites.
Now I´m gonna order Actisence so I can listen bus traffic and maybe get proceed this project by that.

What is your other display?
My plan is to get old Sumlog knotmeter to display speed from Raymarine == Retrometer ;)


Here is some tests what  I´m done whit my devices.

Raymerine gets           AddClaim        SpeedReguest         Traffic on bus
Satellites                      done               Tx + Rx              (checked from Raymarine)

   F                                F                     F                         T
   F                                T                     T                         T
   T                                T                     F                         F
And correction my previous message: I have to AddressClaim before can get or send any messages on bus.
So, thats seems to be OK.


Summary: I get that Actisense and see how does it works then.
Tanks for all so far. I raport results when I get that Actisense.

PS: Timo, I live in Vaasa and sail under WSF. Let me know if you are sailing here Kvarken.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 15, 2016, 08:41 am
You could try with my library before ordering NGT-1. If you just load my library, stuff for avr and try with example ActisenseListener, you should be able to see all traffic on bus with Actisense NMEA Reader.
Title: Re: NMEA 2000 Shield
Post by: jukkap on May 15, 2016, 08:50 am
Ok.

Maybe i should test it. Do I have to do some modifications to code when i use AT90CAN128 prosessor?
Title: Re: NMEA 2000 Shield
Post by: nilsal on May 15, 2016, 11:12 am
I tested with latest libraries and seem to work.

Note that you should not use original Seed studio can bus shield library. MCP_16MHz has been defined in developed version of CAN_BUS_Shield library in file mcp_can_dfs.h on line 250. If you do not have that, delete your Arduino\libraries\CAN_BUS_Shield-master and download it from https://github.com/peppeve/CAN_BUS_Shield and install it.
Thanks, change of library did the trick!
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 15, 2016, 08:20 pm
JukkaP. I have not tested avr chips, but thomasonw used them and made the code. On library readme it says: "To use avr processors internal CAN you need also NMEA2000_avr library and avr_can library, which you can download from https://github.com/thomasonw/avr_can". So if you have selected avr board, the #include <NMEA2000_CAN.h> in example ActisenseListener should automatically select right libraries for you - you must have installed them ofcoarse.

Example ActisenseListener does not show itself on bus at all - it simply listens. To send some data e.g. temperatures, there is example TemperatureMonitor, which should work as well. I have tested all examples with DUe and Mega boards by using both Garmin GMI20 and NMEAReader. Some examples has been also tested with Teensy boards. I do not have avr boards, but thomasonw developed something by using my library.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 16, 2016, 08:33 am
Hi all,

For building NMEA2000 devices, check this link: https://hackaday.io/project/11055-kbox
It has build in several hw components for boating solutions. Available code has been build by using my NMEA2000 library.
Title: Re: NMEA 2000 Shield
Post by: gibas on May 16, 2016, 01:53 pm
Hi,

I'm new to these foruns. First of all thanks to everyone for sharing the information. I'm trying to send data from Arduino battery monitor example sketch to my N2k bus consisting of Garmin 720, 2 GMI10, one VHF 300i and 1 Airmar Intelliducer. I have one MCP2515 controller with TJA1050 transceiver working at 8 Mhz. From what I've realized the library is set for 16 Mhz as default. How can I change it to 8Mhz?

Thanks for your answers,

Gibas
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 16, 2016, 02:10 pm
Hi,

You should edit beginning of you BatteryMonitor sample with #define USE_MCP_CAN_CLOCK_SET 8:
...
#include <Arduino.h>
//#define N2k_CAN_INT_PIN 21
#define USE_MCP_CAN_CLOCK_SET 8
#include <NMEA2000_CAN.h>       // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <N2kMessages.h>
...
Title: Re: NMEA 2000 Shield
Post by: gibas on May 16, 2016, 02:25 pm
Hi,

As described in the begining of NMEA200_Can.h file.... I don't know how I've missed it. Thanks for your fast reply.

Regards,

Pedro
Title: Re: NMEA 2000 Shield
Post by: Tlam on Jun 21, 2016, 08:21 am
Hi!


I have trouble with 127506 PGN DC Detailed status.

I write any value of field 3 and display - "0%" !!!

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 21, 2016, 09:11 am
Hi,

Which display you use? Do you have right type for value?

There is example MessageSender, which also sends that message as sample. I just tested that with NMEA Reader and it shows values as they have been set on sample code. One can test MessageSender code with single board by setting NMEA2000.EnableForward(true); on setup and then opening NMEA Reader to board port. You can test your code in this way too.
Title: Re: NMEA 2000 Shield
Post by: Tlam on Jun 23, 2016, 09:51 am
Thank you for you answer, problem is out)


I need another little help.

I try coding PGN 127505 and problem with field of capacity in liters.

Field is 8 byte , I don't know how to translate simple value (ex. 100) into 8 byte field ....
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 23, 2016, 10:28 am
Are you using NMEA2000 library and N2kMessages.h/.cpp? In N2kMessages.h there is simple definition for call: SetN2kPGN127505 or
SetN2kFluidLevel(tN2kMsg &N2kMsg, unsigned char Instance, tN2kFluidType FluidType, double Level, double Capacity);
, where you simply set Capacity as 100 e.g.

SetN2kFluidLevel(N2kMsg,1,N2kft_Fuel,51.2,100);
NMEA2000.SendMsg(N2kMsg);

This will set current fuel level to 51.5% of 100 l capacity.
Title: Re: NMEA 2000 Shield
Post by: Tlam on Jun 23, 2016, 09:38 pm
another question. I try to use your library with arduino nano and can bus shield 8MHz.

"
Arduino: 1.6.7 (Windows XP), Плата:"Arduino Nano, ATmega328"

In file included from C:\Documents and Settings\Admin\Мои документы\Arduino\libraries\NMEA2000-master/NMEA2000_CAN.h:85:0,

                 from C:\Documents and Settings\Admin\РњРѕРё документы\Arduino\Nmeatest\Nmeatest.ino:19:

C:\Documents and Settings\Admin\Мои документы\Arduino\libraries\NMEA2000_mcp-master/NMEA2000_mcp.h:58:84: error: 'MCP_16MHz' was not declared in this scope

     tNMEA2000_mcp(unsigned char _N2k_CAN_CS_pin, unsigned char _N2k_CAN_clockset = MCP_16MHz, unsigned char _N2k_CAN_int_pin = 0xff);

                                                                                    ^

In file included from C:\Documents and Settings\Admin\Мои документы\Arduino\Nmeatest\Nmeatest.ino:19:0:

C:\Documents and Settings\Admin\Мои документы\Arduino\libraries\NMEA2000-master/NMEA2000_CAN.h:95:27: error: 'MCP_8MHz' was not declared in this scope

 #define MCP_CAN_CLOCK_SET MCP_8MHz

                           ^

C:\Documents and Settings\Admin\Мои документы\Arduino\libraries\NMEA2000-master/NMEA2000_CAN.h:105:39: note: in expansion of macro 'MCP_CAN_CLOCK_SET'

 tNMEA2000_mcp NMEA2000(N2k_SPI_CS_PIN,MCP_CAN_CLOCK_SET,N2k_CAN_INT_PIN);

                                       ^

exit status 1

?
 
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 24, 2016, 09:22 am
Hi,

You have the same problem as nilsal on this forum message #92. I responded on #93 that you should not use original seed studio library. Instead use https://github.com/peppeve/CAN_BUS_Shield. That has been also mentioned on my library documents.

Timo
Title: Re: NMEA 2000 Shield
Post by: fred3 on Jun 29, 2016, 07:38 pm
Hi Timo and all !

This is my first post but I have been reading everything you did with N2k and all about boats !
Thank you very much for sharing all your work. I appreciate it very much !

I am retired in electronics but have been living the computer age since the day of the 80 series (and even the 40 !) did some assembler with the 6502 but I am new in Arduino and programming. I have been interested in the N2k CAN since my friend has a boat using this network. So I need to help him with electronics.

However I have 2 due's working with CAN in a closed N2k network. All is working FB including a short program I  put together from bits and pieces of programs including your work that sends waterspeed to N2kbus from a paddle speed sensor. It works OK including the Product and Device information but I am shy to share it as it probably would not survive experts opinion,hi.

Anyway I am able now to inspect my friends N2k network and perhaps do some work in the future.
I would like to look at the Address Claiming in the near future. I hope to be able to learn more about this N2k with the Arduino due and have some NMEA0183 devices connected too.
Please continue your work !

Thank you

Fred




 
Title: Re: NMEA 2000 Shield
Post by: syntaxio on Aug 30, 2016, 04:42 pm
Just found this as I am starting a project on a new wake sport boat. I have been long time electronics guy but mostly in the analog realm until the last few years. That said I have been coding for a very long time and do it for a living. It is all just syntax and IO so I figure with enough time I will be able to figure out N2K.

My intent is to automate a few things that I normally could have done without the need for N2K. The issue is that the newer wake sport and day boats are moving to custom built in MFD with joystick control knob and button devices for the human interface that all communicate of N2K. Boats in this class are getting far more complex as they are including features from the factory that use to be add ons. The custom MFD in my boat handles the task of communicating over the engine can bus, the radio can bus, NMEA 0183, and NMEA 2000. The MFD also communicates with a gateway over N2K in order control things such as lights, bilge, horn, etc. The only things I need to decipher for my current project are GPS and all of the joystick/button commands. Obviously there will be a few undocumented PGNs but I hope to be able to figure them out. I am first going to attempt to use the actisense listener sketch to see what is being broadcasted but from there I may need a hand as I am new to N2K. The upside is I may discover and help document a few PGN on the HID side of things which are becoming more common.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 30, 2016, 07:22 pm
Hi syntaxio,

You have interesting job to discover undocumented PGN:s. Note that there are pgn.h under SignalK project and PGNDefs.N2kdfn.xml (latest version under www.kave.fi/Apps) under OpenSkipper, which already has a lot PGN information. Also it is easiest for reverse engineering to minimize bus data by switching devices off.

Anyway do not hesitate to ask help.
Title: Re: NMEA 2000 Shield
Post by: syntaxio on Sep 14, 2016, 10:13 pm
I have tried sending a private message a few days ago but not sure if it worked. Long story short is I have isolated the proprietary PGN and values that I need to be able to read and write. Just need to get them added to the library and having just a bit of brain fart trying to do that. Could certainly use a hand at this point.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Sep 15, 2016, 05:57 am
Hi,

I do not know, why I did not receive notify for private message.

Since these are proprietary, it is best to create own message files for these. So if you have device manufacturer B&G, you could create message files N2kBandGProprietaryMessages.cpp and .h. Then you create message creation and parsing messages similar as they are on N2kMessages.cpp and .h. Note also that since different manufacturers can use same PGN:s for proprietary messages, it may be that there is no sense name functions as they are on N2kMessages e.g. SetN2kPGN127489. Instead just use informative name e.g.
// Sonic hub proprietary PGN 130816
void ParseN2kSonicHubInfo(...)

So you do not need to add your PGNs at this point to library. When you have tested handling functions for then, it would be greate to get them published for possible other users.

Without information about you PGN structure I can not say more for now.
Title: Re: NMEA 2000 Shield
Post by: coryjfowler on Oct 06, 2016, 09:20 pm
Does anyone have a Garmin chart plotter that uses a NMEA 2k GPS?  I can decode all the GPS PGNs, but I can't turn on WAAS and GLONASS.  Garmin is no help at all, and I do not suggest using their NMEA 2k products as a result since they wont support them outside of their own products which violates the whole point of NMEA 2k.

By the way, Maretron manuals are a good source for NMEA 2k PGN information.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Oct 07, 2016, 06:17 pm
I prefer also to look CanBoat project pgn.h (https://github.com/canboat/canboat/blob/master/analyzer/pgn.h) and derived OpenSkipper PGNDefns.N2kDfn.xml (see http://openskipper.org/). Both has better description of data than Maretron Manuals. I have some fixes for OpenSkipper PGN definitions, which has not yet been published, but I'll do it within some weeks.
Title: Re: NMEA 2000 Shield
Post by: mespelosin on Nov 08, 2016, 01:25 pm
I am working with Maretron products (FFM100 and FPM100 sensors), reading data in NMEA2k and sending in RS232 port. I have decoded FPM100 sentences, but i faced difficulties in FFM100 65286 / 65287 propietary sentences.
I would need information about those fields, to decode info and later send it.
I would appreaciate if you could provide any kind of information.
Title: Re: NMEA 2000 Shield
Post by: Heatz on Nov 29, 2016, 07:31 pm
I am using a Arduino Mega and CANbus shield for sending data through to a NMEA 2k network. I am successfully sending the following PGNs and displaying on an a98 Raymarine MFD

SetN2kEngineDynamicParam
SetN2kEngineParamRapid
SetN2kDCBatStatus
SetN2kEnvironmentalParameters

However, I am trying to construct my own AIS messages and send SetN2kAISClassAPosition but it is not being displayed on a98 Raymarine MFD even though it does appear to be 'read' on the actisense nmea reader.

  SetN2kAISClassAPosition(N2kMsg, 1, Repeat, 123456789, 26.396, -80.075, 1, 1, 1, 20, 20, 30, 0, NavStatus);


has anyone successfully sent AIS messages?

Eric
Title: Re: NMEA 2000 Shield
Post by: mechand on Dec 08, 2016, 08:29 am
Dear colleagues, we are producing fuel flow meters. And now making Nmea2k version of differential type fuel flow meter (can be easy installed for supply-return flow engine).

Would be fine to have some cooperation with other NMEA2k investigators.

We now can send messages to Lowrance display:

http://imgur.com/a/PWNBU
http://imgur.com/a/PWNBU

but I understand it is point-point communication, in real big NMEa2k network it will create problems

We are lacking address claiming support.
And PGN list report.

SO if any can share this docs with us we can send our products for example as X-mas gift :)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 08, 2016, 08:37 am
Hi,


Are you using my NMEA2000 library (https://github.com/ttlappalainen/NMEA2000). It has automatic address claiming support etc.

There is also progress with "Remove Arduino dependencies" under issue with that name.

Funny that I am also building fuel flow/engine monitor just for my own.
Title: Re: NMEA 2000 Shield
Post by: lundpetersen on Dec 13, 2016, 06:38 pm
Hi All,

I have used timolappalainen's great project and have it working on my Arduino Due. I have created a simple circuit that measures the voltage of my batteri and outputs it on NMEA2000 to my Lawrence HDS 9 Gen3 MFD. It works like a charm.

My plan is to transfer my analogue gauges to my MFD - the first was the voltage. I also need to transfer Fuel Level, Tachometer (RPM's), and Speedometer. Ultimately I also want to use the DUE as NMEA0183 to NMEA2000 for my Furuno 4800 Radio with AIS so I don't need to have any NMEA0183 connected to my MFD's.

My question is, do anyone have a good link to a circuit I can studdy to figure out how to make my DUE read the input from the Tachometer from my engine? Its an old Mercury engine - and it is definitely analogue. Any good ideas/links to articles about others that has done this on Arduino?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 14, 2016, 07:07 am
Hi,

Have you checked e.g. http://cr4.globalspec.com/thread/53842/Getting-a-RPM-Signal-From-the-Alternator ?

Alternative way is to use e.g. reflective sensor e.g. http://fi.farnell.com/omron-electronic-components/eesy313/photomicrosensor-reflect-4-4mm/dp/2301884?ost=eesy313&selectedCategoryId=&categoryNameResp=Kaikki%2Bluokat&searchView=table&iscrfnonsku=false

That of coarse requires that you need to build support forsensor to engine. But with it you will allways get true RPM, which does not need calibration like using W.

I am building fuel flow meter, where I would include reflective sensor for RPM and other engine information.

I have also ready NMEA0183->NMEA2000 converter for GPS. By modifying selected messages, you could easily modify that for your own purposes.

I also prefere to have several boxes instead of trying to put all functionalities to same. I have started to use Teensy 3.2 or up in most my devices. Teensy 3.2 is smaller and requires less power that DUE. You can find some documents on example https://github.com/ttlappalainen/NMEA2000/tree/master/Examples/TeensyActisenseListenerSender
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 16, 2016, 02:25 pm
Hi,

I have develope FUSION LINK server

Please help me construct CAN message for CAN.sendMsgBuf() function.

PGN 130820

The first two data bytes of any message will contain Proprietary Parameter Group Structure with the
following format

11 bit - value of 419
2 bit - value of 3
3 bit - value of 4

These fields combine to give the value 0x99A3
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 16, 2016, 06:05 pm
Are you using NMEA2000 library or do you really want to use directly mcp_can library?
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 16, 2016, 06:53 pm
I successfully use your library, thank you very much.


But it useless for FUSION LINK PGNs. I want use directly mcp_can.

But I can't construct right message.
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 16, 2016, 07:28 pm
And , are you have any information about PGN 130820 ? )
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 16, 2016, 08:19 pm
Why it is useless? You can send or parse any message with library. You just need to write message build or parser program to your own file. N2kMessages contains most used messages, but nothing prevents you write you own messages.

130830 is proprietary message and its contents depends of manufacturer and I do not have any other information of it execpt that first two bytes contains manufacturer code and and industry code (4=maritime).

But for library you can have message builder function like others in N2kMessages:
void SetN2kPGN130830FusionLink(tN2kMsg &N2kMsg, ???) {
    N2kMsg.SetPGN(130830L);
    N2kMsg.Priority=3;
    N2kMsg.Add2ByteUInt(0x99A3); // Fusion link
    N2kMsg.Add???
}

But there is no way to write more, if you do not know the content os Fusion Link message.

Note that 0x99A3 can be also constructed  4 << 13 || 3 << 11 || 419
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 16, 2016, 08:36 pm
Thank you for help and idea ! ))

But very difficult for me...
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 17, 2016, 05:31 am
With library you can make much more easily any N2k system, since it takes care of several things required on communication on N2k bus. In N2kMessages you will find common PGN build and parser routines, which you can use as sample to build your own. In examples MessageSender, WindMonitor or Temperature monitor you find how to send data to the bus. And e.g. example DataDisplay2 shows how to read PGNs.

If you do not have description for PGN 130830 data content, you have to spy it by recording data on bus and mark changes made on sender side. You can not do that "reverse engineering" if you do not have devices from original manufacturer.
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 17, 2016, 09:42 am
I successfully use library for many selfmaid devices. Engine monitor, fuel level and battery monitor.

Now I have idea to make audio server on arduino that controlled from raymarine mfd.

I don't have device for reverse engineering and fully information about proprietary PGNs(

But some pieces of information looks are possible for some experiments.

Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 17, 2016, 01:13 pm
May be somebody have information about proprietary entertainment PGNs ?
Title: Re: NMEA 2000 Shield
Post by: Tlam on Dec 18, 2016, 12:28 pm
Hi Timo,


I have a question about NMEA2000.SetN2kCANMsgBufSize();

When I provide argument value more than 2 , device hold. What happened ?


1 or 2 work correctly
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 18, 2016, 05:39 pm
What device you use and how much memory used it says after compilation?

I tested example ActisenseListener on Arduino Mega with 20 and it works. 30 does not. Note that this allocates memory dynamically and one tN2kCANMsg eats about 243 bytes memory. So 5 will eat 1.2 kB. For Mega my test says 7.8 kB free after compilation. So 30 takes 7.3 kB and remaining 0.5 kB is not enough for other local variables and also Mega hangs. So I would expect that you have device where even 3 is too much.
Title: Re: NMEA 2000 Shield
Post by: Dazzler on Dec 30, 2016, 08:07 pm
I'm struggling with the basics.  I have a Due connected to the W7 PC running Arduino IDE 1.6.12, as per Timo's instructions for the NMEA 2000 library. I have edited the temperature sketch, uploaded it to the Due and started Actisense NMEAReader and selected the com port, all as per instructions.
But I see nothing in NMEA reader.  The only output I can see is if I uncomment the serial.print line in SendN2kTemperature and start the Serial monitor.
I've followed Timo's instructions to the letter but have failed at the first hurdle.  Is there any other config  I should have done?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 30, 2016, 08:45 pm
Hi,

Due to library portability changes we had to remove Serial as default output stream. This is documented on Readme Changes section. So it should start to work, if you add line
  NMEA2000.SetForwardStream(&Serial);
after
Serial.begin(115200);

I'll add this to example for next release.
Title: Re: NMEA 2000 Shield
Post by: Dazzler on Dec 31, 2016, 05:03 pm
Thanks Timo. Laziness on my part - RTFM, as they say.
And thanks for all the work you've put into this. I'm sure there are many more people who have benefited from all your effort.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 04, 2017, 09:41 am
As my opinion RTFM is not good attitude, since things may be written unclear or specially when you start to work with new things, it may be difficult to understand or find. Also even for simple things manuals may be so long, that who has time to read them from word to word. So if I know the answer, I'll never respond with RTFM. Instead as this case I'll answer to the question and point to the place, where it has been explained. This may help user next time to find answers for similar questions first from manual.

So please at least about my NMEA 2000 library do not hesitate to ask, if you do not find solution easily from manual. Asking may save you several hours instead of trying to understand my manual.
Title: Re: NMEA 2000 Shield
Post by: jrmdive on Jan 24, 2017, 07:47 pm
Hi all,

A million thanks for Timo and the others who have contributed code.  Life is good.

I'm working on building out an array of marine electronics for my boat.  I have an existing N2K network that I installed previously, and wanted to push my data onto it to make it available to my consumer electronics.

Just a quick note for those who are contemplating this path:

DO NOT USE THE ARDUINO TOOLCHAIN PRE-PACKAGED WITH YOUR LINUX DISTRO.

I wasted (although I've learned tons, so it's probably not wasted) about a week working on getting the NMEA stuff to compile.  I could not figure out why I was having cascading dependency problems.  I even deleted my entire IDE and started again.  Then I snagged a Due and transceiver to try and follow as closely to the original project as possible, which is when I discovered that the version of the Arduino IDE that I had installed was a mess (no option for additional boards.)  I dumped it, downloaded the one from arduino.cc, and installed the library chain.  And it compiles first time.  Aaarrrrggghhhhh!

You'd think as someone who's been using Linux since 1994, and various UNIX flavors for much longer, I would have known not to trust a pre-compiled package.  But since that issue didn't pop up in a lot of searching, I thought I'd memorialize my issue and solution here for the next person.

At any rate, many thanks again to all those contributors.  I'm sure there'll be questions in the future, as I'm planning on putting together a network of low-cost low-power sensors based on the Nano and tying them in to my existing N2K network.

Josh
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 24, 2017, 08:49 pm
Just want to remind about KBox project, which has nice package for N2k bus with WiFi output etc. Check it at https://hackaday.io/project/11055-kbox
Title: Re: NMEA 2000 Shield
Post by: jrmdive on Jan 25, 2017, 01:30 am
Also, there's a typo on line 58 of NMEA2000_mcp.h

   tNMEA2000_mcp(unsigned char _N2k_CAN_CS_pin, unsigned char _N2k_CAN_clockset = MCP_16MHz
                                                                                                                                                                         

should be:

   tNMEA2000_mcp(unsigned char _N2k_CAN_CS_pin, unsigned char _N2k_CAN_clockset = MCP_16MHZ



Josh
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 25, 2017, 07:56 am
Why? See mcp_can_dfs.h ... line 255: #define MCP_16MHz   1
Title: Re: NMEA 2000 Shield
Post by: jrmdive on Jan 25, 2017, 07:55 pm
This is why the boss at my first sysadmin job insisted that we compile everything from source ourselves.  Because package managers only complicate things.  Turns out that even though I stripped out the packages and reinstalled the new IDE in my home directory (may the aforementioned BOFH forgive me for ever installing in my home directory) I hadn't actually checked to make sure that ALL the files were deleted.  Turns out that there was a copy of the seed version installed in /usr/share/arduino/libraries/.  Which wouldn't be a problem, except that even though I installed in my home directory (a thousand pardons sir), the IDE decided to default to the shared library location and was using that library, which has it capitalized.  Which is why nothing would compile without the change.

So I deleted them, quit all IDE sessions, reloaded, and tried again.  I still required the "MHZ" in my trial program.  Rebooting didn't help.  Somewhere the IDE was hiding that define with the capital Z, and I couldn't find it.

So I got medieval on it.  Removed everything, from everywhere.  Downloads, folders, everything.  "sudo find /* | grep mcp" found a bunch of stuff hiding in /tmp.  Stripped it all.  Started over from scratch, redownloading and reinstalling.  Deleted all my CAN test sketches (OK, that may have been a bit much, but I was frustrated).  Which was a bummer as I had a working three node setup (two nanos and a due) all talking even with all this namespace clashing.

So, after the complete nuke drop and reinstall, I've got the three nodes talking again, without the capital "Z" but this is crazy.  I have no idea which of my other projects I've broken by doing this.

I once worked in a shop where the suits decided that Silicon Graphics was the next Sun, and dropped a bunch of IRIX machines on us and told us to use them.  We had to port everything.  This feels a lot like that, except that was the early 1990's and I was getting paid...

Josh

-- I think the moral of this story is "If you've ever done anything with CAN in the arduino environment before attempting the NMEA2000 stuff, delete it ALL and start from scratch."
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 26, 2017, 06:54 am
I am sorry, but I do not understand. On original SeedStudio CAN bus code I could not find that definition at all. See. https://github.com/Seeed-Studio/CAN_BUS_Shield . As far as I know peppeve (https://github.com/peppeve/CAN_BUS_Shield) implemented that, when he added support for Maple Mini 8MHz.
Title: Re: NMEA 2000 Shield
Post by: jrmdive on Jan 26, 2017, 04:53 pm
Not that it overly matters now, I've got it all working.  But in the interest of my own curiosity, here's what I've found.

In the version of the library that was initially installed, this was the header:
Code: [Select]
mcp_can_dfs.h
  2012 Copyright (c) Seeed Technology Inc.  All right reserved.
  2014 Copyright (c) Cory J. Fowler  All Rights Reserved.

  Author:Loovee
  Contributor: Cory J. Fowler
  2014-1-16

When you peruse the file, starting in line 439 you get:
Code: [Select]
#define MCP_20MHZ    0
#define MCP_16MHZ    1
#define MCP_8MHZ     2

Which obviously translates over to the .cpp file, yet those are the only instances.  All the rest of the times the "Z" appears lower case, as in lines 241-:
Code: [Select]
/*
 *  Speed 8M
 */
#define MCP_8MHz_1000kBPS_CFG1 (0x00)
#define MCP_8MHz_1000kBPS_CFG2 (0x80)
#define MCP_8MHz_1000kBPS_CFG3 (0x80)

#define MCP_8MHz_500kBPS_CFG1 (0x00)

In fact, in the entire library folder, there are only these instances:
Code: [Select]
     ./grep MHZ *
keywords.txt:MCP_16MHZ           LITERAL1
keywords.txt:MCP_20MHZ           LITERAL1
mcp_can.cpp:        case (MCP_8MHZ):
mcp_can.cpp:        case (MCP_16MHZ):
mcp_can.cpp:        case (MCP_20MHZ):
mcp_can_dfs.h:#define MCP_20MHZ    0
mcp_can_dfs.h:#define MCP_16MHZ    1
mcp_can_dfs.h:#define MCP_8MHZ     2

I think the only reason I even ran into it, beyond the "broken not broken" nature of the library caching system in the arduino IDE, is that the cheap Aliexpress breakout boards I got came with 8MHz crystals instead of 16MHz.  So in using the #define to allow for the different speeds, I got caught out with conflicting libraries.

At any rate, a million thanks again for the N2k code.  I've got my sensors up and talking and it's great. 

Josh
Title: Re: NMEA 2000 Shield
Post by: Pelle8879 on Jan 28, 2017, 01:40 pm
Hi Timo!
I would like to send compass direction in degrees to NMEA2000 and would like to know how to do that.
I do not like the way GPS is determining compass direction when standing still.
A have a compass solution using two GPS-es. I am reading NMEA0183 from each and then I calculate Compass direction (0-360) with an arduino DUE.

The problem I have is to send degrees to NMEA2000 (If there are any message type for that).
How do external compasses send compass direction on NMEA2000?

I can send NMEA0183 message but would like to send similar to NMEA2000 bus.
This is the spec. for xxHDT in NMEA0183.
$--HDT,x.x,T*hh
1) Heading Degrees, true
2) T = True
3) Checksum
Could you please help me?
/Pelle
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 28, 2017, 03:11 pm
Heading will be provided with NMEA 2000 PGN 127250.

Have you looked in e.g. WindMonitor example in my NMEA2000 library? So instead of call SetN2kWindSpeed(...) in WindMonitor use call SetN2kTrueHeading(N2kMsg,0,DegToRad(HeadingInDegrees));

Remember also change SetProductInformation(...) and SetDeviceInformation(...) in setup() to match your device.

You can find message creating functions in N2kMessages.h.

How accurate heading you can get with two GPS? I have Vector GPS compass, which is accurate, but expensive.
Title: Re: NMEA 2000 Shield
Post by: Pelle8879 on Jan 28, 2017, 04:42 pm
Thank you Timo!
I plan to use two RTK-recievers fetching Base station data over TCP and therefore I will get position within dm accuracy (at clear sky), that means... very good GPS-accuracy. I have not calculated the accuracy but it depends of course of the distance from front to rear antennas.
I will immediatly try to setup your suggested solution.
Thanks a lot for your info!
If I have further questions regarding connections for CAN-Bus I hope you will be helpful also.
Thanks again!
/Pelle
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jan 28, 2017, 05:36 pm
Please check the documents folder, there are sample schemas. With due I prefer to use MCP2562, which has ability to use 3.3 V IO as required with DUE.
Title: Re: NMEA 2000 Shield
Post by: Pelle8879 on Jan 29, 2017, 08:31 am
Thanks Timo, I really appreciate your help! :)
/Pelle
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 03, 2017, 07:53 am
I read that most people are using arduino duo or mega. I'm not quite clear if it is possible to create low cost engine monitoring system and output to n2k with arduino uno and some kind of can driver?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 03, 2017, 10:45 am
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.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 04, 2017, 09:31 am
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!

Title: Re: NMEA 2000 Shield
Post by: bgnad on Feb 07, 2017, 11:19 pm
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?
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 09, 2017, 12:03 am
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?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 09, 2017, 02:59 pm
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.
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Feb 15, 2017, 09:04 pm
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
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Feb 15, 2017, 09:33 pm
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...
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 16, 2017, 06:19 am
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.
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Feb 16, 2017, 08:53 am
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();
}
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Feb 16, 2017, 09:22 pm
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...

Title: Re: NMEA 2000 Shield
Post by: WheelSea on Feb 17, 2017, 11:32 pm
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
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 18, 2017, 06:35 am
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.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 18, 2017, 08:34 am
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.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 18, 2017, 09:09 am
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.
Title: Re: NMEA 2000 Shield
Post by: WheelSea on Feb 19, 2017, 08:22 pm

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?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 20, 2017, 06:47 am
If you find reasonable priced sunlight monitor, please inform - I have tried to find one and they allways starts over several hundred euros. I found http://www.hantronix.com/page/index/products/tft having some nice displays, but don't know has anybody used them with Arduinos. Then I just bought Garmin GMI 20 for showing data outside.

Since I have PC as navigator I also thought to use e.g. tablet with VNC outside and OpenSkipper as web server. But I have not yet found bright enough tablet either. See my OpenSkipper webserver sample running on kavettl.dynalias.com:2222 - menu icons does not work over internet for some reason.

Other option would be to use SignalK server. See e.g. https://github.com/signalk/specification/wiki/Raspberry-Pi-Installation-(Java-Server)
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 21, 2017, 05:30 am
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.
Hi Timo,
I don't mind ordering the Teensy 3.2, but it is very hard to ship stuff to Mexico, and I'm not going back to Canada for a while so getting parts is hard and I will try to make it with what I have...

I have few UNO and few NANO boards kicking around in my bag of goodies here on the boat.  As I managed to get the MEGA + Can shield working perfect without any issues, I decided to try with UNO + CAN shield.
I figured that the CAN Shield is designed to fit on the Uno, so I did not need to bend pin 10,11,12,13 as I needed to do on the MEGA setup in order to get it working

MEGA setup with patch wires
10->53
11->51
12->50
13->52
UNO straight through
10->10
11->11
12->12
13->13

I switched the board type in IDE and the code that ran well on MEGA compiles fine for UNO.
I did not see any error messages but with the UNO, I don't see the new node on my N2K network via NGT-1 that I use for monitoring. I see the PWR, Rx, Tx and Int flashing when its all working with the MEGA, but with the UNO only the receive LED on the CAN blinking.
I'm not sure if what i need to adopt in which files to get it working with the UNO boards.
I hope you can point me in the right direction?
 
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 21, 2017, 07:46 am
NMEA2000_CAN.h tries to automatically select suitable libraries and settings for you according to board. Now it selects mcp_can for your Uno board, but on 105 line it uses default #define N2k_SPI_CS_PIN 53. So in the beginning of your .ino file before #include <NMEA2000_CAN.h> add line #define N2k_SPI_CS_PIN 10 so it will use pin 10 for SPI chip select.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 21, 2017, 08:06 am
Timo,
I just did add #define N2k_SPI_CS_PIN 10 and uploaded to the board. The Int LED on the CAN shield starts blinking for a while, then goes ON solid, but  the Tx LED is not blinking and the node is not found on the N2K bus. I think this is better, but still something missing... is there something to do with the interrupt pin? I just noticed in NMEA2000_CAN.h the next line after 
#define N2k_SPI_CS_PIN 53
is
#define N2k_CAN_INT_PIN 21
as far as I'm aware the interrupt pins for uno are D2 and D3
does it have to be changed fro 21 to 2 and do I need to rewire to diferent pin on the Can Shield?
Any thoughts?

Another thing that i just noticed is that with that edit, the serial monitor starts outputting normal and then in few seconds it stops to output (I'm using the "BatteryMonitor" example)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 21, 2017, 08:11 am
On different note: Is there some PGN that reports bilge pumps cycles in the Nmea 2k?

There is no PGN for that. For your own system you can use e.g. PRN 127489 "Engine Parameters, Dynamic" and show it as second engine instance and use "Engine hours" parameter. That PGN is so common that MDF:s can show it. But this is of coarse very confusing way.

Right way would be to use some of reserved proprietary PGNs (like 61184 - 61439), but then you have to also build display, which can parse and show that PGN content. On single frame proprietary PGNs you have 6 bytes data, which you can freely define.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 21, 2017, 08:26 pm
Timo,
I just did add #define N2k_SPI_CS_PIN 10 and uploaded to the board. The Int LED on the CAN shield starts blinking for a while, then goes ON solid, but  the Tx LED is not blinking and the node is not found on the N2K bus. I think this is better, but still something missing... is there something to do with the interrupt pin? I just noticed in NMEA2000_CAN.h the next line after  
#define N2k_SPI_CS_PIN 53
is
#define N2k_CAN_INT_PIN 21
as far as I'm aware the interrupt pins for uno are D2 and D3
does it have to be changed fro 21 to 2 and do I need to rewire to diferent pin on the Can Shield?
Any thoughts?


Another thing that i just noticed is that with that edit, the serial monitor starts outputting normal and then in few seconds it stops to output (I'm using the "BatteryMonitor" example)
Hi,
I had success, but regardless, I'm not quite happy with that as i have no idea why it works now  :smiley-confuse:

After long struggle, I finally got it working on UNO. I'm not sure if I did the right thing, but it seems to be working.
It ended up that I needed to add another line after the line Timo  instructed me to add in my .ino file
Here is what I added in my .ino file:

#define N2k_SPI_CS_PIN 10       // as per Timo's instructions
#define N2k_CAN_INT_PIN 21    // lucky guess?

I'm not sure exactly why it works, because as far as I know the interrupt pins for UNO are 2 and 3.
Can someone explain as I'm trying to understand?


Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 21, 2017, 09:04 pm
There is no definition for interrupt as default on NMEA2000_CAN.h. If you want to use interrupt, you have to define it before including NMEA2000_CAN.h. And if you define wrong pin, it won't work at all.

If you have interrupt definition on NMEA2000_CAN.h, check that you have downloaded the sources from my githup.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Feb 26, 2017, 06:42 am
Hi Timo,
Excuse my ignorance but I'm not exactly clear what sources I need to download?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Feb 27, 2017, 06:39 am
In my original, updated and "official" version of NMEA2000_CAN.h there is no definition for interrupt as default. So if you look NMEA2000_CAN.h on my Github (https://github.com/ttlappalainen/NMEA2000/blob/master/NMEA2000_CAN.h) there is not #define N2k_CAN_INT_PIN 21 after #define N2k_SPI_CS_PIN 53 exept as informative. So I was just wondering, where you had downloaded that version and will it have other changes related to some system.
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Mar 19, 2017, 08:44 pm
Hi Again,

Today I went down to my boat in order to try and get my ESP8266 with MCP2515 NMEA2000 logger up and running.

So I experience the following... All boat electronics is up and running, I can see fx Wind Speed in my ChartPlotter and the MCP2515 is attached to the Simnet network but not turned on yet.

All works!

Then I turn on the Canbus controller and ESP8266 with just opens the NMEA2000 for listening.

I watch the updates from the Wind speed indicator on the chart plotter AND after 5 secs the communication on the BUS halts completely.

If I then turn off the 2515 and ESP8266 the BUS runs again....

I can see that I have configured the MCP2515 as 16 Mhz but there is only 8 Mhz crystal on the board.

So maybe that is the problem?
So maybe using this define is the way forward?

#define USE_MCP_CAN_CLOCK_SET 8

But why the bus stops with wrong clock is beyond me

If i measure the voltages on L / H with 2515 off the voltages is: 2.5 V and 2.5V

With 2515 on:  2.7V and 3V only measured with a digital voltage meter...

Any suggestions?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Mar 20, 2017, 06:40 am
If you e.g. shortcut the L/H, communication will stop. So either you 2515 is failing (or driver after 2515) or wrong clock set will cause the failure.
Title: Re: NMEA 2000 Shield
Post by: flemmingdjensen on Mar 20, 2017, 08:57 pm
Hi Timo (and others)

The problem was indeed the faulty clock setup. After I changed to 8Mhz - the same as the xtal - everything works and the bus continues...

Success....

So now I am logging some different parameters and fetching Wind speed / direction from the NMEA 2000 BUS.

See my logger here:
https://thingspeak.com/channels/198625/


The depth is not correct yes. This I have to investigate

// BR Flemming
Title: Re: NMEA 2000 Shield
Post by: r2d290 on Apr 12, 2017, 10:51 pm
Alright, my turn to try to get this working. Some struggles, so any help would be highly appreciated.

Hardware Setup:

Note: I have not connected any interrupt. Also, I have not connected digital pin 0-7 on the CAN-BUS shield to the Arduino, since one of the 8-pin sockets were missing when I got it.



From my MFD I select settings for my Water temp. I can then select "Data sources" and then I can select between getting this from one of the two MFDs. When I turn of the aft MFD, I'm only allowed to select "This equipment". When I turn off the aft MFD, and then connected my NGT-1 Iso's DB-9 plug to the CAN-BUS Shield, I would expect the arduino to appear as one of the Data sources, but does not. Also, only one of the LEDs on the NGT-1 is blinking.

Also, I'm not abel to get the NMEA-simulator to work. Connecting the NGT-1 to computer via the Serial-to-USB cabel, and with the settings as you can see attached. Still no device available on the MFD.
With the NMEA-simulator (as well as with the NMEA-reader) two LEDs are blinking on the NGT-1.

Any further suggestions for troubleshooting?

And by the way - Thanks for a great job creating and supporting this! :)

Code: [Select]

// Demo: NMEA2000 library. Send main cabin temperature to the bus.

#include <Arduino.h>
#define N2k_SPI_CS_PIN 10
#include <NMEA2000_CAN.h>  // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <N2kMessages.h>

// List here messages your device will transmit.
const unsigned long TransmitMessages[] PROGMEM={130310L,130311L,130312L,0};

void setup() {
  // Set Product information
  NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
                                 100, // Manufacturer's product code
                                 "Simple temp monitor",  // Manufacturer's Model ID
                                 "1.1.0.21 (2016-12-31)",  // Manufacturer's Software version code
                                 "1.1.0.0 (2016-12-31)" // Manufacturer's Model version
                                 );
  // Set device information
  NMEA2000.SetDeviceInformation(112233, // Unique number. Use e.g. Serial number.
                                130, // Device function=Temperature. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                75, // Device class=Sensor Communication Interface. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                2040 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                              
                               );
  // Uncomment 2 rows below to see, what device will send to bus. Use e.g. OpenSkipper or Actisense NMEA Reader                          
  Serial.begin(115200);
  NMEA2000.SetForwardStream(&Serial);
  Serial.println("1");
  Serial.println("2");
  Serial.println("3");
  Serial.println("4");
  // If you want to use simple ascii monitor like Arduino Serial Monitor, uncomment next line
  //NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.

  // If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
  NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,3);
  //NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
  //NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
  // Here we tell library, which PGNs we transmit
  NMEA2000.ExtendTransmitMessages(TransmitMessages);
  NMEA2000.Open();
}


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

double ReadCabinTemp() {
  return CToKelvin(22.5); // Read here the true temperature e.g. from analog input
}

double ReadWaterTemp() {
  return CToKelvin(15.5); // Read here the true temperature e.g. from analog input
}

#define TempUpdatePeriod 2000

void SendN2kTemperature() {
  static unsigned long TempUpdated=millis();
  tN2kMsg N2kMsg;

  if ( TempUpdated+TempUpdatePeriod<millis() ) {
    TempUpdated=millis();
    SetN2kTemperature(N2kMsg, 1, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kEnvironmentalParameters(N2kMsg, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kOutsideEnvironmentalParameters(N2kMsg, 1, ReadWaterTemp());
    NMEA2000.SendMsg(N2kMsg);
    // Serial.print(millis()); Serial.println(", Temperature send ready");
  }
}


Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Apr 13, 2017, 07:37 am
Hi,

First. Unfortunately NMEA-Simulator does not currenty send through any NGT. It reaquires some initialization message, which I have not yet done. I have the work on table but too much to do. There is example code ActisenseSender, which I use with simulator, but it requires at least Mega board. With DUE you can use ActisenseListenerSender - one USB for receiving and other for sending.

With Arduino Uno there is some unsolved problem. There is e.g. issue https://github.com/ttlappalainen/NMEA2000/issues/20 , where user finally gave up. I have only Due, Mega and Teensy boards for testing. Since Teensy size I like it most.

I do not see any reason why Uno should not work. You could first try some things:
- Comment  #define N2k_SPI_CS_PIN 10 -> // #define N2k_SPI_CS_PIN 10 . If you interrupt wire is not connected or right, it won't work, if interrupt pin has been defined. Without definition library will not use interrupt.

- Is there enough memory as default? Uno has only 2kB and library has been tested with Mega 8kB ram. Add next lines before NMEA2000.Open();
  NMEA2000.EnableForward(false); /this disables message forwarding and save some memory.
  NMEA2000.SetN2kCANMsgBufSize(2);
  NMEA2000.SetN2kCANSendFrameBufSize(30);
This will reduce reseved memory for message buffers.

- To check free memory I used library on http://playground.arduino.cc/Code/AvailableMemory. Add e.g. after TempUpdated=millis(); lines
    Serial.print("freeMemory()=");
    Serial.println(freeMemory());
Remember to include #include <MemoryFree.h> at beginning of the code.

Timo
Title: Re: NMEA 2000 Shield
Post by: r2d290 on Apr 13, 2017, 11:47 am
Thank you for your fast reply :)

I don't quite understand the part with commenting out #define N2k_SPI_CS_PIN 10
I thought I did this to overwrite the CS_PIN 53 that is used by Mega, to instead use the CS_PIN10 for the UNO?

When I comment out this line, I can no longer see the light on TX or RX. I also tried to change the number from 10 to 9 (as you suggested in the issue you linked to), but also then, the light on TX and RX is gone. I used my multimeter on the CAN-BUS shield to confirm that Arduino UNO pin 10 (SS), 11(MOSI), 12(MISO) and 13(SCK) goes  to MCP2515 pins 16 (CS), 14(MOSI), 15(MISO) and 13(SCK).
I find it a bit strange, though, that both RX and TX is lit, even when nothing is connected to the DB9-connector on the CAN-BUS shield.

Is it necessary to have the interrupt-cabel to get the communication to work? According to your schema, the MCP2515 INT, pin 12, should be connected to Arduino pin SCL, but the CAN-BUS shield has this on digital pin 2 instead. So, since I have not yet connected it - do I need it? And if so - what changes should I do to change Arduino pin SCL to Arduino pin 2? And - what changes can I do to drop/skip using the interrupt?

Quote
Is there enough memory as default?
Code: [Select]
freeMemory()=483
freeMemory()=483

Also, thanks to the "NMEA2000.SetN2kCANMsgBufSize(2);", I no longer need to have those Serial.println(1,2,3,4) lines that I had in the beginning. So, that part seems a little better.
However, when I run in debug-mode now, I no longer see the "ISO Address claim", only the three other. Not sure how important that is, though.


So, to summarize - I'm still unable to get det arduino to display on the MFD. I have not connected the Interrupt-signal to the CAN-BUS shield. The TX and RX on the CAN-BUS shield is blinking verry fast (previously I think it was constantly lit). The NGT-1 is only blinking on that one led that is always blinking when connected to the gate (on the boat).

Any further troubleshooting suggestions?

This is my code now:

Code: [Select]

// Demo: NMEA2000 library. Send main cabin temperature to the bus.

#include <Arduino.h>
#include <MemoryFree.h>
#define N2k_SPI_CS_PIN 10
#include <NMEA2000_CAN.h>  // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <N2kMessages.h>

// List here messages your device will transmit.
const unsigned long TransmitMessages[] PROGMEM={130310L,130311L,130312L,0};

void setup() {
  // Set Product information
  NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
                                 100, // Manufacturer's product code
                                 "Simple temp monitor",  // Manufacturer's Model ID
                                 "1.1.0.21 (2016-12-31)",  // Manufacturer's Software version code
                                 "1.1.0.0 (2016-12-31)" // Manufacturer's Model version
                                 );
  // Set device information
  NMEA2000.SetDeviceInformation(112233, // Unique number. Use e.g. Serial number.
                                130, // Device function=Temperature. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                75, // Device class=Sensor Communication Interface. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                2040 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                               
                               );
  // Uncomment 2 rows below to see, what device will send to bus. Use e.g. OpenSkipper or Actisense NMEA Reader                           
  Serial.begin(115200);
  NMEA2000.SetForwardStream(&Serial);
  // If you want to use simple ascii monitor like Arduino Serial Monitor, uncomment next line
  //NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.

  // If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
  NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,3);
  //NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
  NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
  NMEA2000.SetN2kCANMsgBufSize(2);
  NMEA2000.SetN2kCANSendFrameBufSize(30);
  // Here we tell library, which PGNs we transmit
  NMEA2000.ExtendTransmitMessages(TransmitMessages);
  NMEA2000.Open();
}


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

double ReadCabinTemp() {
  return CToKelvin(22.5); // Read here the true temperature e.g. from analog input
}

double ReadWaterTemp() {
  return CToKelvin(15.5); // Read here the true temperature e.g. from analog input
}

#define TempUpdatePeriod 2000

void SendN2kTemperature() {
  static unsigned long TempUpdated=millis();
  tN2kMsg N2kMsg;

  if ( TempUpdated+TempUpdatePeriod<millis() ) {
    TempUpdated=millis();
    //Serial.print("freeMemory()=");
    //Serial.println(freeMemory());
    SetN2kTemperature(N2kMsg, 1, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kEnvironmentalParameters(N2kMsg, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kOutsideEnvironmentalParameters(N2kMsg, 1, ReadWaterTemp());
    NMEA2000.SendMsg(N2kMsg);
    // Serial.print(millis()); Serial.println(", Temperature send ready");
  }
}


Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Apr 13, 2017, 01:07 pm
Sorry I did not read it carefully. I read that it was #define N2k_CAN_INT_PIN 10, which would define that pin 10 will be used for interrupt. You must have #define N2k_SPI_CS_PIN 10 (or 9) for UNO.

You do not need interrupt wire for communication. In tha case you must not have #define N2k_CAN_INT_PIN xx as you do not. Interrupt is critical, if you read bus data, because otherwise you will easily loose data.

Do you have UNO connected to the bus? Since you have NGT, I'll prefer to connect UNO and NGT to the bus with right terminator resistor. Leave MFD out at this moment. Then you can read bus traffic via NGT. I also prefer to change NGT to read oll messages instead of filtering anything. This you select on NMEA Reader. Since you now have:
NMEA2000.EnableForward(false);
That disables all message forwarding to USB. So it won't print any messages anymore.
You could also uncomment
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
So it will show something as clear text.

So if you do not see any messages sent by UNO on NMEA Reader, then you have to really debug, what goes wrong with UNO. You can search println on NMEA2000.cpp and uncomment those in some places and see, if you find place, where it stops. As I mentioned I do not have UNO, you have to do the tests.
Title: Re: NMEA 2000 Shield
Post by: r2d290 on Apr 13, 2017, 09:07 pm
Hello

Thanks for the reply and clarification regarding interrupt. I've left the boat now, but I'm eager to get back with more information within a few days.

Quote
Do you have UNO connected to the bus?
I'm not totally clear on this question. If the "bus" is defined by the thing on the boat that looks like:
TTTTT (the thing that the MDF, the CD-player and my NGT is connected to), then yes - the Arduino is connected to the bus, but via the NGT. Or did you mean the MOD-bus shield? Then yes, the Modbus-shield is connected to the pins in the UNO.

So: MFD<-->TTTT <--NGTcabel--NGT--NGTcabel(with DB9-connector)-->Modbus-shield <--> Arduino <--> USBcabel --> PC.

And when I was reading from the entire system with NGT, it was like:
MFD<-->TTTT <--NGTcabel--NGT--NGTcabel(with DB9-connector)--> <--DB9toUSB-cabel--> PC.

Hope this made sense. If not, please ask for clarification :)

Quote
Since you have NGT, I'll prefer to connect UNO and NGT to the bus with right terminator resistor. Leave MFD out at this moment. Then you can read bus traffic via NGT
Do you mean that I can connect my UNO (or do you mean the MOD-BUS DB9-connector?) to to the TTTTT in the boat, without using the NGT in between? That would be too awesome. How is that done? Do I need a special cabel or something, since the Mod-Bus shield has a DB9-connector, and the TTTTT has a circular connector with 5 pins. What does the NGT-1 even do, btw? I thought it was kind of "decrypting" the NMEA-2000 signal to a serial-signal.

Btw: What is the "right" terminator resistor, and where is this supposed to be placed?
If I don't remember totaly wrong, there is already a resistor at the end of the TTTTT. Does this have anything to do with it?

I have TeamViewer to the computer on the boat, so I tried what you said regarding changing filtering in NMEA Reader. I could not find this option. The closest I found was Edit -> Preferences -> Transfer: Receive All, but this option was disabeled by a reason? See attached pic.

Code: [Select]
NMEA2000.EnableForward(false);
That disables all message forwarding to USB. So it won't print any messages anymore.

The only thing it prints to the Serial monitor is my Serial.println()-lines. But (and this might be important?) before I added this line, it only printed rubbish - mostly squares without line break. I have tried all the baude-rates on the serial-monitor, but I assume the correct is 115200. Is it supposed to print anything else than rubish to the Serial-monitor?
But - even with that line, I'm still abel to read things on the NMEA-reader through the USB-cabel when the Arduino is set to debug-mode..

Quote
You could also uncomment
NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
So it will show something as clear text.
Well, yes - it returned "something" as clear text now, but still a lot of rubbish. See attached picture.
Actually - I think the rubish is printed regardless of the EnableForward(false)-line.

Quote
As I mentioned I do not have UNO, you have to do the tests.
I will be more than happy to do some troubleshooting with this - If you can only get me started with the part with connecting the Arduino to the bus without the NGT, so that I can use the NGT to troubleshoot with.

Again, thanks a lot!
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Apr 14, 2017, 06:57 am
I am sorry to tell you that you have understood this a bit (or maybe a lot) wrong. The bus means NMEA 2000 bus - see e.g. image on bottom of page http://www.actisense.com/products/nmea-2000/ngt-1/ngt-1. Devices on bus we can call just device or also as node sometimes. Each device on bus will get own address or also called source on code. Bus is similar as street, which has houses each with own number so that post knows where to deal messages (=letters).

So now you have MDF. This is one device. NGT is an other device. On picture there are also wind and log sensors. They both are own devices. All has been connected together with bus cable, which actually has two communication wires CAN L (blue wire) and CAN H (white wire) Other three wires on bus cable are shield (gray), 0 V (black) and 12 V (red). There is no magic with this cable. If you like to save expensive  NMEA2000 connectors, you can search DeviceNet connectors and you will find same stuff. Or you can even just cut the cable and use screw terminals.

The point of my NMEA 2000 library is to make device that connects directly to the bus (CAN L and CAN H). And if you like you can also take power for the board from the bus, if you have right voltage converter like UNO has. So to connect UNO to the bus is similar as my schema https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoMega_CAN_with_MCP2515_MCP2551.pdf. And if you do not want to glue MCP2515, MCP 2551 and other stuff yourself, you should buy http://wiki.seeed.cc/CAN-BUS_Shield_V1.2/.

So you configuration, where you have UNO with MODBUS shield can not work at all, since the communication on N2k bus (=NMEA 2000 bus) is different than on serial on the other side of NGT. No I do not actually understand, why lower level library mcp_can even reports that communication opens, if you have wrong shield!

When you have right shield, you connect your UNO just an other device as in picture I mentioned above. And the termination resistors marked by A2K-TER-F on picture are just 120 ohm resistors on nice (and expensive) package.

If your NGT id not tightly srewed to the boat, take it with you to home and you can start to develop system at home. Then buy CAN bus shield and connect it to NGT on N2k side. Also connect termination resistors to your short bus - for short test bus one is enough. Then connect NGT ont the serial side to PC with serial to USB as you had. And finally connect UNO USB to PC. Now with TemperatureMonitor example you have bus system with two devices - UNO and NGT. With NMEA Monitor you should see what your TempertureMonitor (UNO) sends to the bus. When taht works, you can go to the boat and connect them to same bus with MFD, and you should see TemperatureMonitor as a device on MFD device list.

And some answers:
- Yes, you can connect UNO to TTTTT with CAN bus shield.
- You do not need special cable. As I mentioned, you just need to connect CAN L and CAN H on shield to related wires on the bus. Or you can by NMEA 2000 T-bone and suitable connectors.
- Yes, NGT converts NMEA 2000 to Actisense serial format, which I also use in my library on PC side communication. E.g. Maretron uses a bit different encoding. You need NGT to get data to PC. You you can use Arduino DUE or Mega or Teensy with my example ActisenseReader.
- Terminal resistors has to be on both end of the bus. So you can have bus through the boat from aft to bow and devices connected on the middle (as in picture) with some T-connector. Terminals should then be on the aft and bow ends of the cable. Each cable from T-connector to device must not exceed 6 meters.

Have a nice eastern!
Title: Re: NMEA 2000 Shield
Post by: r2d290 on Apr 14, 2017, 10:09 am
Hello.
Thanks for your great reply. Now, things is starting to be a bit more clear.

Quote
So you configuration, where you have UNO with MODBUS shield can not work at all, since the communication on N2k bus (=NMEA 2000 bus) is different than on serial on the other side of NGT. No I do not actually understand, why lower level library mcp_can even reports that communication opens, if you have wrong shield!
I'm so sorry for the confusion. I don't know why I was suddenly start talking about Modbus-shield. I don't have a modbus-shield, I have - as you link to - a CAN-BUS Shield V1.2 :)

Actually, I think I will go back to the boat now, bring back a few NMEA2000 Connectors, the two terminal resistors, the ngt and the UNO with CAN-bus shield, and see what more I can do :)
Title: Re: NMEA 2000 Shield
Post by: r2d290 on Apr 14, 2017, 04:23 pm
Wohoo, I made it :) The MFD is now showing a water temperature of 15.5 degrees (Wished it was so well).
It was a bit easier when I did not have the NGT between the bus and the CAN-bus shield :)

Now, time to start experimenting with some real data. Thank you so much for your help :)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Apr 15, 2017, 05:57 am
Great you got it running. You could also test does it work with interrupt by defining right line with
#define N2k_CAN_INT_PIN xx
Since system has to handle all messages, without interrupt it may loose address claiming or ISO request messages, which MDF:s use time to time to check are devices alive. If you look MFD device list, your device may time to time disappear, if those messages has been missed. This is not critical for information like temperature, but like I have my Arduino as NMEA0183->NMEA2000 converter for GPS, my MFD start to alarm, if it looses device.

Please report, if you get your UNO system working and what exeptions there may be. With execptions I mean e.g. those buffer definitios etc.
Title: Re: NMEA 2000 Shield
Post by: xotet on May 07, 2017, 11:14 am
Hi Timo, first of all thanks for your work and thanks to share with all the comunity.

 It´s possible to adapt the library to work with arduino ZERO + CAN BUS shield? since is the same size factor than UNO and more powerfull??

 I´m planing my project wich consisit of a simple Tanks and Battery Monitor with an LCD on the main cabin.

 Thanks in advance



 
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 08, 2017, 05:25 am
Hi,

I do not see why not. The main problem with Uno was low memory, which could be fixed with buffer settings. So with Zero board you do not need to define smaller buffers.

I could not find information is CAN BUS shield compatible with Zero board. Please note that Zero uses 3.3 V IO. Also you need to check, which IOs are CS and int.

Have you checked https://hackaday.io/project/11055-kbox? It's nice hw with lot of ready functions.
Title: Re: NMEA 2000 Shield
Post by: xotet on May 11, 2017, 01:46 pm
Hi,

I do not see why not. The main problem with Uno was low memory, which could be fixed with buffer settings. So with Zero board you do not need to define smaller buffers.

I could not find information is CAN BUS shield compatible with Zero board. Please note that Zero uses 3.3 V IO. Also you need to check, which IOs are CS and int.

Have you checked https://hackaday.io/project/11055-kbox? It's nice hw with lot of ready functions.
Thanks Timo

 I found Kbox very interesting since include also a bridge to nmea0183 to nmea2000 and wifi hotspot, hopefully I can use with my AIS nmea0183.

Title: Re: NMEA 2000 Shield
Post by: seamaster on May 13, 2017, 09:11 am
Hi again guys!
after couple of months of other tasks I'm back on my project. everithing went well until i ran into problem, so i need your help to resolve it.
Here is my setup:
Simple bus with 2 devices made by me. each device is terminated with 120ohm resitor between Net-L and Net-H.
on the receiving side, Arduino Uno with CanBus shield running the Actisense_listener example code:
Code: [Select]

#define N2k_SPI_CS_PIN 10
//#define N2k_CAN_INT_PIN 21
#include <SoftwareSerial.h>
#include <Arduino.h>
#include <NMEA2000_CAN.h>
//SoftwareSerial mySerial(3, 4); // RX, TX
void setup() {
  Serial.begin(4800);
 //  mySerial.begin(38400);
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text
  NMEA2000.SetForwardStream(&Serial);  // PC output on due native port
 
  NMEA2000.Open();
}

void loop() {
  NMEA2000.ParseMessages();
// if (Serial.available()) {
 //   mySerial.write(Serial.read());

}




on the transmitting side Teensy 3.2 with MCP2551 running the Temperature monitor example code:

Code: [Select]


// Demo: NMEA2000 library. Send main cabin temperature to the bus.

#include <Arduino.h>
#include <NMEA2000_CAN.h>  // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <N2kMessages.h>

// List here messages your device will transmit.
const unsigned long TransmitMessages[] PROGMEM={130310L,130311L,130312L,0};

void setup() {
  // Set Product information
  NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
                                 100, // Manufacturer's product code
                                 "Simple temp monitor",  // Manufacturer's Model ID
                                 "1.1.0.21 (2016-12-31)",  // Manufacturer's Software version code
                                 "1.1.0.0 (2016-12-31)" // Manufacturer's Model version
                                 );
  // Set device information
  NMEA2000.SetDeviceInformation(112233, // Unique number. Use e.g. Serial number.
                                130, // Device function=Temperature. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                75, // Device class=Sensor Communication Interface. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                2040 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                              
                               );
  // Uncomment 2 rows below to see, what device will send to bus. Use e.g. OpenSkipper or Actisense NMEA Reader                          
  Serial.begin(115200);
  NMEA2000.SetForwardStream(&Serial);
  // If you want to use simple ascii monitor like Arduino Serial Monitor, uncomment next line
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.

  // If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
  NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);
  //NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
  //NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
  // Here we tell library, which PGNs we transmit
  NMEA2000.ExtendTransmitMessages(TransmitMessages);
  NMEA2000.Open();
}


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

double ReadCabinTemp() {
  return CToKelvin(22.5); // Read here the true temperature e.g. from analog input
}

double ReadWaterTemp() {
  return CToKelvin(15.5); // Read here the true temperature e.g. from analog input
}

#define TempUpdatePeriod 1500

void SendN2kTemperature() {
  static unsigned long TempUpdated=millis();
  tN2kMsg N2kMsg;

  if ( TempUpdated+TempUpdatePeriod<millis() ) {
    TempUpdated=millis();
    SetN2kTemperature(N2kMsg, 1, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kEnvironmentalParameters(N2kMsg, 1, N2kts_MainCabinTemperature, ReadCabinTemp());
    NMEA2000.SendMsg(N2kMsg);
    SetN2kOutsideEnvironmentalParameters(N2kMsg, 1, ReadWaterTemp());
    NMEA2000.SendMsg(N2kMsg);
    // Serial.print(millis()); Serial.println(", Temperature send ready");
  }
}



I have terminal program (CoolTerm) connected to the USB/Serial port on the Arduino Uno (listener) to monitor what will be coming over the N2K bus. When I connect to the port it shows me that:
See attachment called Coolterm1.png
(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=211714)
when I start the Teensy 3.2
and open the Serial Monitor to the Teensy USB/Serial port I get this

See attachment called Teensy_Monitor1.png
(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=211716)

on the receiving side (Arduino Uno board)  get this:
See attachment called Coolterm2.png
(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=211718)

unfortunately the reception stops right a way after few lines are received.
if i reset the Teensy board, it reboots and i receive few lines again on the Uno board. Please note I do not need to do, touch/reset/restart/disconnect-reconnect or any of this sort  to the uno board. I just leave it alone to wait for the next transmission from the Teensy board.

If i look at the serial monitor on the teensy side, i notice that it continue to send PGNs (or at-least looks that way for about a 30-45sec:

See attachment call Teensy_Monitor2.png

(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=211720)
and then it comes up with the message that one of the PGNs has failed to send.

I'm lost here... Im not sure if this is HW or software issue. Im thinking the HW is fine as few messages go through with no problem but then the translissin to the N2K buss seams to stop (no more bl=inks on the receive and transmit LEDs) while the serial monitor keep shows the PGNs being generated and flying by...

Is it a buffer of some kind that gets filled/blocked? I'm willing to run any tests to troubleshoot that issue but i have to admit, I think I'm way better with HW than with SW (please note i said "better", not "good"  :smiley-confuse: )  

Any help or any ideas how to fix that are appreciated!
 
I receive some PGN, but then it stops.. Why, oh why?

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 14, 2017, 07:40 am
First I prefer to switch Uno and Teensy sketches. Uno does not have not enough memory with default buffers. Read library issue https://github.com/ttlappalainen/NMEA2000/issues/20 and at least start from my post on 15.4.2017. Also use Serial.begin(115200); instead Serial.begin(4800); despite this is not the problem in this case.

As you see on your first two pictures sent and received PGN:s 60928 and 130312 messgaes does not match. So I expect there is already some memory overflow on Uno.

On your last picture I expect that Teensy will not actually send anything at all. As default library has 40 frame send buffer. So it can buffer 40 single frame messages like PGN 130312 and when this buffer becomes full, it will cause error "... send failed". Note that as default library will forward own messages to stream (=USB in your case), when they have been tried to send. It does not mean that they have been actually sent to bus. So now in your last case on Teensy CAN bus control logic tries to send messages without success. It is probably trying to wait bus as become free, but it is blocked for some reason.

Note also that library does not work with latest Teensy FlexCan library. See issue https://github.com/sarfata/NMEA2000_teensy/issues/5. But as you have managed to receive something on Uno, I expect that you do not have 1.35 or newer Teensyduino.
Title: Re: NMEA 2000 Shield
Post by: seamaster on May 16, 2017, 08:34 pm
Hi Timo,
Thanks for the reply and recommendations. One remark only for clarification - I did not take the screen grabs simultaneously, therefore there could be difference in the transmit and received PGNs captured. It doesn't necessary means that we have the data corruption on the UNO board.

After reading your post, here is what i did:

I made a new Teensy3.2 board with MCP2551 which I will call NEW TEENSY for the purpose of that post. it has the same connections as the original one I made.
The first teensy board that I made I will be calling ORIGINAL TEENSY
and the Arduino UNO with CAN shield I will be calling UNO
Test cases:
1. Benchmark
 a. UNO on the receiving side,
 b.  ORIGINAL TEENSY on the transmit side
Result 1: when i run the listener code on the UNO I get "CAN ready" on the serial monitor of the UNO. When I run "Battery monitor" example on the ORIGINAL TEENSY, I receive couple of PGNs on the UNO serial monitor, then it stoppes (as i explained in my previous post)
2. Test with the NEW TEENSY
 a. UNO on the receiving side,
 b.  NEW TEENSY on the transmit side
Result 2: when i run the listener code on the UNO I get "CAN ready" on the serial monitor of the UNO. When I run "Battery monitor" example on the NEW TEENSY, I receive couple of PGNs on the UNO serial monitor, then it stoppes. in my opinion both teensy boards behave identical..
3. Test TEENSY only boards as recommended by you:
 a. NEW TEENSY on the receiving side
 b. ORIGINAL TEENSY on the transmit side (same SW that successfully sens few PGNs to the UNO in the BEnchmark case)
Result 3:
the NEW TEENSY does not get anything on the serial monitor when i run the listener SW. I do not get the "CAN ready" message :(
When i run the The Battery Monitor on the ORIGINAL TEENSY, there is nothing showing up on the NEW TEENSY serial monitor
4. Test two TEENSY only boards (same as Test 3 but reversed board functions)
 a. ORIGINAL TEENSY receiving
 b. NEW TEENSY transminting
Result 4:
Same as Result 3 nothing on the receiving board serial monitor


So after doing all that I think that there is some problem either with the listener code, or with the HW receiving portion on the Teensy boards (both of them).
But what bugs me is that I'm not getting the "CAN ready" message... so it makes me think that its the SW implementation on the Teensy
Any comments?

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 17, 2017, 07:05 am
The examples I have published has been cross tested with Mega and Teensy boards with Arduino 1.81 and Teensyduino 1.35 except FlexCAN library has been from Teensyduino 1.33.

So I made cross test again but also updated Arduino IDE to 1.82 and Teensyduino 1.36. ActisenseListener on Mega and TemperatureMonitor on Teensy.
-> Listener works and listens messages from my Garmin MFD. Monitor does not send anything.

So I replaced "C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FlexCAN" with http://www.kave.fi/Apps/Arduino/Teensy/FlexCAN.zip and rebuild all - !!NOTE!! rebuild all is important!
-> TemperatureMonitor now appears on Garmin and also messages appears on ActisenseListener in clear text.

Then I swithed ActisenseListener to Teensy and TemperatureMonitor to Mega. Again everything works fine.

So this proofs that both code works on Teensy and Mega. Important is  - what I mentioned earlier post - that you need old version of FlexCAN library.
Title: Re: NMEA 2000 Shield
Post by: seamaster on May 17, 2017, 06:14 pm
Hi Timo,
thanks for the help!
I'm glad to report that the problem is solved. After i read your latest post i went to "manage my libraries" checked my installed libraries. I found two instances of FlexiCAN. One was listed under legacy in the application container (MAC) and the other one under mydocuments\ARDUINO\libraries.
I did remove both and then added zip file FlexiCAN library.
Success!
Off I go to the next step - buy my new Simrad EVO3 display to replace my failed Furuno depth-sounder, so I can continue my pet project :)
Thanks a lot again!
(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=212263)
Title: Re: NMEA 2000 Shield
Post by: seamaster on May 26, 2017, 02:35 am
Hi all,
here is a brief update:
yesterday I received my Simrad NSS9 EVO3 display. Last night i hooked up the teensy 3.2 and MCP2551 to it and ran some battery monitor code on it and it works! it's great that all proof of concept worked well, with little hiccups... now the real work should start.

Next is to design the proper schematic, board layout, and of course write the software.
I'm planning to have at least 4 temp probes inputs (TMP36), 6X 0V-30V  inputs and 2X 16bit 0V-3.3V inputs to measure current with 500uV shunts
One issue that I noticed is that simple resistor divider does not work that great as i get some noise on the readings. Someone helped me write some code for running average and the readings are much smoother now, but i would prefer to add some RC filtering on the input pins as well.

I noticed also that the MFD will not display what I put in the manufacturer information. it always states "Manufacturer: Unknown"
shouldn't it display
"Manufacturer: SeaNav"
based on the example code below?
Code: [Select]

const tNMEA2000::tProgmemConfigurationInformation BatteryMonitorConfigurationInformation PROGMEM={
                                       "SeaNav, john.doe@unknown.com", // Manufacturer information
                                       "First attempt", // Installation description1
                                       "No real information send to bus" // Installation description2
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on May 26, 2017, 05:28 am
Unfortunately NMEA 2000 devices rely only manufacturer code set by last parameter of SetDeviceInformation. List of codes can be found by googling e.g. "NMEA 2000 Manufacturer Code - Product Code" So the code 2046 I have in examples is the biggest possible value. Note also that if you have old NMEA 2000 device, which can not be updated anymore, it will also show "unknown manufacturer" for newer manufacturers. This is one (of many) stupid thing on closed NMEA 2000 standard.

So you have 3 choices:
1. Do not care.
2. Use some registered code on list and it will show you that manufacturer.
3. Register youself as manufacturer and your device. The costs are only something like 9000-15000 dollars.
Title: Re: NMEA 2000 Shield
Post by: bwz0 on Jun 13, 2017, 01:08 pm
Is a CAN-shield with MCP2515 & MCP2551 the recommended way to go or should I look for something else? Any opinions on which one has the best quality?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 13, 2017, 01:55 pm
If you will use my NMEA 2000 library, I prefer to system with at least 8 kB RAM. You can use Arduino Mega with CAN-shield. Arduino Due and Teensy 3.2 has more RAM to use. Also Teensy uses less power. For Teensy check issue 50 under my library. If you are handy and can make your own soldering, you can use schemas under library documentation. For easy way to use teensy there is "Teensy CAN-Bus Breakout Board Include Teensy 3.2".
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 13, 2017, 07:11 pm
I'm just finishing new PCB with teensy 3.2, 8 analog 0-30V DC inputs and 4 temp inputs for TMP36 sensors providing GND, 3.3VDC and signal connection. It also have protected CAN interface mcp2551 and m12 n2k connector to directly plug into N2K network with or without termination. My prototype is working very well and I can't wait to get the first 3 boards. On the weekend I also added a compass module to the prototype, but did not have the properly tilt compensated board so it was just proof of concept. It worked well, at least as well as not tilt compensated compass could work. I ordered some 10 DOF boards and maybe in the future will have inexpensive rate compass with N2K output as well.
After the first boards are done I'm planing to develop different version with analog amplifier for measuring thermocouple to measure EGT.
I also need to figure out how to measure 0-1V positive as well as negative voltage to have an implementation for measuring battery shunt.
If there is an interest for these boards I will plan for larger run in the future.
If there is other ideas of what other interfaces are needed, please let me know.
Timo,
as soon as I have the hardware made, I will send you one of my first 3 populated boards as a tocken of appreciation for he hard work you've done to make that project possible.
Cheers!
Title: Re: NMEA 2000 Shield
Post by: bwz0 on Jun 13, 2017, 08:28 pm
If you will use my NMEA 2000 library, I prefer to system with at least 8 kB RAM. You can use Arduino Mega with CAN-shield. Arduino Due and Teensy 3.2 has more RAM to use. Also Teensy uses less power. For Teensy check issue 50 under my library. If you are handy and can make your own soldering, you can use schemas under library documentation. For easy way to use teensy there is "Teensy CAN-Bus Breakout Board Include Teensy 3.2".
Thank you! Will your library also work with the Teensy 3.6 and the "Dual CAN-Bus adapter for Teensy 3.5, 3.6" https://www.tindie.com/products/Fusion/dual-can-bus-adapter-for-teensy-35-36/ ?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 13, 2017, 09:08 pm
Thanks. It is really nice to see that people has started to use library for real devices. Maybe we could in future have simple and cheap NMEA 2000 devices available.

I personally prefer small sized simple devices spreaded around. It is rather hard to organize centralize cabling to one point for everything. With the central cabling there is also problem with noise specially with analog signals. So instead use idea of NMEA 2000 bus so that you would have bus cable through the boat and then e.g. one "sensor device" on each tank or battery. E.g. Maretron already have small tank sensor.

Also I like more simple header connector as used in DeviceNET (see on Farnell codes 1717025 and 1717013) instead of expensive NMEA 2000 connector, which also takes a lot of space. I have made several split boxes with those for price of one "real" connector. My 5 connector splitbox requires only about 45x100x40 box.

Then if you are sailor, you may think that 10 small Teensy will take too much power. For slow data like tank and battery sensors they could measure value e.g. every minute and send it to the bus and then goto low power sleep. To arrange that one needs one master, which collects data and forwards it to bus every second or two to keep MFD happy. When I have time, I'll make sample for that.

Hopefully you got ideas of my opinions.

And I'll be happy, If I will get one board. I could replace my "Alba Combi" with it. You can send me private post for further information.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 13, 2017, 09:28 pm
Thank you! Will your library also work with the Teensy 3.6 and the "Dual CAN-Bus adapter for Teensy 3.5, 3.6" https://www.tindie.com/products/Fusion/dual-can-bus-adapter-for-teensy-35-36/ ?
It may require new class instead of old NMEA2000_Teensy. I'll try to study it.
Title: Re: NMEA 2000 Shield
Post by: bwz0 on Jun 14, 2017, 12:24 am
It may require new class instead of old NMEA2000_Teensy. I'll try to study it.
I ordered it, so I'll try to let you know when I get around to try it in a few weeks time.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 16, 2017, 10:40 am
Hi Timo,
I have one NSS9 Evo3 Simrad MFD and i just got from Ebay AC42 simrad autopilot computer that i interfaced to the MFD. I added Heading and Rudder Angle output from the Teensy prototype board and at first it all appears good. I can read the heading and the rudder angle on the MFD. then I tried to commission the autopilot and as a part to the there is a sequence that one needs to perform to set the hard over to hard over limits. With my little cheat board with potentiometer on one of the analog inputs i could perfectly simulate rudder movement. the MFD shows me the rudder going to port and then to Starboard, then I center it as the calibration routine for the AP requires, but unfortunately the rudder calibration never completes, therefore I cant continue with the AP commissioning. Im sure you are wondering why i am asking you that, as you probably don't have the same AP and the chances are you don't know what the issue is, but I wanted to pick your brain on rudder PGN.
I did some digging and i found out that the MFD that controls the AP could be seeing the rudder angle but the PGN overall is not what it expects to see, and that's why the rudder calibration fails.
The way I understand your code, for rudder angle in N2kMessages.h you have:

Code: [Select]

// Rudder
// Input:
// - RudderPosition         Current rudder postion in radians.
// - Instance               Rudder instance.
// - RudderDirectionOrder   See tN2kRudderDirectionOrder. Direction, where rudder should be turned.
// - AngleOrder             In radians angle where rudder should be turned.
// Output:
//  - N2kMsg                NMEA2000 message ready to be send.
void SetN2kPGN127245(tN2kMsg &N2kMsg, double RudderPosition, unsigned char Instance=0,
                     tN2kRudderDirectionOrder RudderDirectionOrder=N2kRDO_NoDirectioOrder, double AngleOrder=N2kDoubleNA);

inline void SetN2kRudder(tN2kMsg &N2kMsg, double RudderPosition, unsigned char Instance=0,
                     tN2kRudderDirectionOrder RudderDirectionOrder=N2kRDO_NoDirectioOrder, double AngleOrder=N2kDoubleNA) {
  SetN2kPGN127245(N2kMsg,RudderPosition,Instance,RudderDirectionOrder,Angle Order);
}



so my conclusion was to write something like:

Code: [Select]



void SendN2KRudder() {
#define rudderUpdatePeriod 100
  static unsigned long RudderUpdated = millis();
  tN2kMsg N2kMsg;

  if ( RudderUpdated + rudderUpdatePeriod < millis() ) {
    RudderUpdated = millis();


    SetN2kRudder(N2kMsg, (avg2 / 2 - 280) / 3.14 / 18), 0); //avg2 is just function to read the pot and some random math to get my reading convert to rad angle that represents -40 to +40 deg


    NMEA2000.SendMsg(N2kMsg);
    delay (10);

  }
}


as I mentioned earlier it kind of works but can't complete the rudder calibration sequence. I called simrad tech support and they ask me to reset the AP settings and the MFD setting which i did later on, but it did not help.


then I start doubting the validity of the PGN I was  outputting and experimented with passing more to the function (as you see fro my code I am passing only the rudder angle in rad and the instance number). once i added more then these two parameters, I got en error compiling.  Regardless I continued digging and found something that really got me to write you this message. In your code the first parameter  to output is the rudder angle followed by the instance number, etc, ets,
I did find the string for PGN127245 here:
http://www.nmea.org/Assets/july%202010%20nmea2000_v1-301_app_b_pgn_field_list.pdf (http://www.nmea.org/Assets/july%202010%20nmea2000_v1-301_app_b_pgn_field_list.pdf)

and at least to me looks that it has different order the definition in your code:

PGN 127245   Field Field Description
Rudder order command in direction or angle with current rudder angle reading.
1 Rudder Instance
2 Direction Order
3 Reserved Bits
4 Angle Order
5 Position
6 Reserved Bits

Do you have an example outputting
PGN 127245, while passing all parameters such as RudderDirectionOrder and RudderDirectionOrder?
just in case here is the link to the AP manual http://www.simrad-yachting.com/Root/Installation%20Manual/SimradYachting/English/AC12_AC42_IM_EN_20222568_E_w.pdf (http://www.simrad-yachting.com/Root/Installation%20Manual/SimradYachting/English/AC12_AC42_IM_EN_20222568_E_w.pdf)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 16, 2017, 11:49 am
First do not compare order of c++ function parameter list and the order of PGN definition. The point is that since you normally do not need all parameters, why you should have them in that order on function? If you want to compare, you have to goto look into the function code. But I think you do not need to, since I have tested rudder PGN against Actisense NMEA Reader as I allways do with new PGNs. Also, if data would be wrong, you would not see any rudder angle on your MFD.

Then about calibration. There are two possibilities:
1. AP expects also direction order (and order angle) parameter set right.
2. AP expects specific Simrad rudder sensor and tries to calibrate that with proprietary command, which we do not have any information.

Case 1 you can test, if you calculate from changes right value for the direction order and put some value for direction angle.

Case 2 is complicate, since you should do reverse engineering with full Simrad system. Can be time consuming.

It is also possible that AP uses standard Group Function commands to set direction order fields for you Teensy. If you have latest library version, it will automatically respond for that command with "no support". But it may be that AP is not either happy for that. You can listen data with some device - even with your Teensy by using mode N2km_ListenAndNode and enable forwarding. Then you look does AP send any 126208 PGN:s (Group Function PGN) to your device.

Offset you can easily program to your Teensy, but can you manually set hard limits. If you can, then you could forget automatic calibration.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 17, 2017, 11:59 am
Hi Timo,
thanks for the reply.
I did spend all night again looking at the possible solution
I noticed that the the new library required me to change 
Code: [Select]


const tProductInformation BatteryMonitorProductInformation PROGMEM={
                                       1300,                        // N2kVersion
                                       192,                         // Manufacturer's product code
                                       "SeaWitch_Monitor",    // Manufacturer's Model ID
                                       "1.0.0.13 (2016-09-19)",     // Manufacturer's Software version code
                                       "1.0.0.0 (2015-08-03)",      // Manufacturer's Model version
                                       "12340002",                  // Manufacturer's Model serial code
                                       1,                           // SertificationLevel
                                       1                            // LoadEquivalency
                                      };                       

to
Code: [Select]

const tNMEA2000::tProductInformation BatteryMonitorProductInformation PROGMEM={
                                       1300,                        // N2kVersion
                                       192,                         // Manufacturer's product code
                                       "SeaWitch_Monitor",    // Manufacturer's Model ID
                                       "1.0.0.13 (2016-09-19)",     // Manufacturer's Software version code
                                       "1.0.0.0 (2015-08-03)",      // Manufacturer's Model version
                                       "12340002",                  // Manufacturer's Model serial code
                                       1,                           // SertificationLevel
                                       1                            // LoadEquivalency
                                      };                       


and

Code: [Select]

const tNMEA2000::tProgmemConfigurationInformation BatteryMonitorConfigurationInformation PROGMEM={
                                       "SeaNav, john.doe@unknown.com", // Manufacturer information
                                       "First attempt", // Installation description1
                                       "No real information send to bus" // Installation description2
                                      };


to
Code: [Select]

const char BatteryMonitorManufacturerInformation [] PROGMEM = "John Doe, john.doe@unknown.com";
const char BatteryMonitorInstallationDescription1 [] PROGMEM = "Just for sample";
const char BatteryMonitorInstallationDescription2 [] PROGMEM = "No real information send to bus";



in order to compile properly. I'm not saying that's wrong :) I'm just beginner in programing and i have no idea most of the time why I'm making changes. I just compare the new examples to my code and try to make it work :)

Once it start working I also noticed that the device name is not showing up anymore on my MFD but rather show "???". I bet this is a result of my attempt to get my code running with the new library and the changes I did above.




(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=215695)

Then I noticed something else -  the "rudder angle" is shown as (Simrad) group, while the "commanded rudder direction" is shown as (Global) group. All the rest of the devices on the bus are part of the Simrad group. I have no idea why "commanded rudder direction" is shown as (Global) group and it can't be changed as there is no Simrad selection in the dropdown menu as there is on the "rudder angle" (see the first picture).

(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=215699)

(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=215701)

Then I tried to change the instance from 000 to 001 and the device will not take it. I don't think this was something I was successful of doing before upgrading the library either.

(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=215697)


Let's go back to the problem at hand. My rudder angle simulator is not being liked by Simrad AP calibration procedures so im trying to understand why and possibly fix it. I did read your email carefully and some parts I understood, but for other parts my programing experience is not enough to make the right conclusions from your email.
I did program another Teensy as listener and captured the bus during my attempt to calibrate the rudder angle on the AP from the MFD. Then I searched for PGN 126208  but it wasn't there. I have attached the capture to this post. Just for clarification, I have the following devices on the N2K bus: Simrad NSS EVO3 MFD, Teensy rudder angle simulator, Simrad AC42 AP computer and another Teensy that is setup with the listener only code. I see more devices showing up in the log file, but I believe that the MFD separates the chart-ploter, the depth-sounder, the AP controller, etc.etc.

One think I would really like if you can help me with is what is the syntax of the parameters of the rudder message. I could make it compile only with passing 2 parameters. if I attempted to pass more than 2 i got errors compiling (from looking at your code i think they should be 4). Very frustrating as my abilities to understand the code are not that great. can you tell me what  parameters I pass to the rudder function, what is the syntax and what each one does?

I see "SetN2kPGN127245(N2kMsg,RudderPosition,Instance,RudderDirectionOrder,AngleOrder)" in your library
and I tried many different combinations in my code, but again it was only successful with 2 parameters
e.i.
Code: [Select]

SetN2kRudder(N2kMsg,((avg2-512)/3.1415926535897932384626433832795/180),1);
    //avg2 is just function to read the pot and some random math to get my reading convert to rad angle that represents -40 to +40 deg



Thanks in advance for spending time to look at my problems.


PS
I just received email that they are parting the big production PCB boards and my PCBs will be send in the mail to me in 48hrs! How exciting! I will post some pic immediately when I get them.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 17, 2017, 02:25 pm
Have you noticed that on the library main page, if you scroll down there is "Changes" section, where specially compitibility changes has been notified. Time to time I unfortunately find something, which is not good for some reason, so I have to change library compatibility. So please read "Changes" section allways carefully.

I also prefer not to copy from examples totally as they are. So. e.g. change name BatteryMonitorProductInformation for e.g. SeaSwitchRudderAngleProductInformation. Also change contents like versions, dates, etc. to match your code. Also remember to define LoadEquivalency to right value. This is n on formula n * 0.050 mA, which tells how much power your device takes from the bus.

You can not change instance of "Rudder Angle"-device, because currently it requires to write specific "Command Group Function" handler for rudder PGN. Currently default handler responds that change is not supported.

You can call it e.g.:
SetN2kRudder(N2kMsg,DegToRad(RudderAngle),1,N2kRDO_MoveToStarboard,DegToRad(RudderCommandedAngle));

Note that you can use library function DegToRad() for conversion.

I'll recheck that product information should be send right to the bus. I'll inform later.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 18, 2017, 09:01 am
I tested product information sending and it seem to work. But I have to test it also with MFD. Your MFD should query product information from your device. I have to check could support for Comand Group Function cause that some MFD:s could query product information by using it instead of ISO request.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 18, 2017, 10:43 am
Hi Timo,
Thank you for your instructions. After I received your reply I managed to output completely
PGN127245 string, I think... and read the compatibility section in your library so now I see the proper name, but stiill struggling outputting rudder angle on the top of the other two with your multi  device sample.
Back to the problem on hand: On the Simrad display I still see difference in the groups. The rudder angle Bellingham nags to the simrad group and the rudder commanded angle belongs to the global group. The AP rudder angle calibration still does not work. :( at this point I am almost positive that maybe the AP needs some response from the Rudder angle sensor, but not too sure as I couldnt not find anything like that in my data capture during an attempt to calibrate the rudder portion of the AP dock setup.
The datasheet for the Simrad N2K rudder angle sensor refers output only PGN127245.
http://www.simrad-yachting.com/Root/Simrad-Documents/RF25_Instruction_Rev.A.pdf (http://www.simrad-yachting.com/Root/Simrad-Documents/RF25_Instruction_Rev.A.pdf)
So I will still try to concentrate providing the proper output from my simulated sensor. With your help I got the sintax ok, but the data I put in it is still bogus... I output proper rudder angle from -35 to 35 deg, that incontrol with potentiometer, but the rest of the data is static. I just plugged some direction and random number for commanded angle DegToRad(19)
I would like to understand little better how this works, so I do have few questions about the paremeters.
setN2kRudder(N2kMsg,DegToRad(RudderAngle),1,N2kRDO_MoveToStarboard,DegToRad(RudderCommandedAngle);
1. What is the second parameter "1"? Is that the instance?
2. What is the "MoveToStarboard" how and when you change it to "MoveToPort"? In your function I see 0 is unknown, 1 starboard, 2 port(if I remember correct...) so it surprised me that I needed to put in the string rather than the un. char 0, 1, or 2 which of course I was trying without success before your explanation. Do I have to create a function to compare the readings and then based on the fact that they get larger or smaller one replaces MoveToPort with MoveToStarboard and vice versa?
3. How you calculate "RudderCommandedAngle"?
4. Why are these parameters required? If they are what I think they are, why are they not calculated by the AP or by AP controller? Why rudder indicator should tell ap in which direction is moving? The APis the one issuing the commands to the steering to move so it should know already...
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 18, 2017, 04:08 pm
1. It is instance value. If you would have 2 rudder sensors, they all should have different instance value.

2. N2kRDO_MoveToStarboard is not a string. Strings will be marked on code with "...". N2kRDO_MoveToStarboard is a value of enumerated type tN2kRudderDirectionOrder. The point for enumerated types is to limit values only to allowed group and also make code readable. If that would be define as uchar, you should comment you code e.g. ...1 /* move starboard */... and also you could set value to e.g. 75, which is not allowed for that setting.

I think normally this PGN comes from AP, which uses integrated sensor. So then AP can say "Current Rudder Angle is 5, I am moving rudder To Starboard and the goal is 15" with this PGN. When you have standalone sensor, it should not use other than angle and instance values. For rest values it should give defaults as I have in function (N2kRDO_NoDirectionOrder,N2kDoubleNA). I was just guessing that may be that during calibration your AP will expect those commaned values. Can be wrong. But if you want to try, you should provide delta of angle.

3. Partially answered on 2. Also here you can ted delta angle.

4. Also answered on 2. Stand alone sensor should not provide these values.

What manufacturer code you have used for you Rudder sensor? If you have used 1875 (Simrad), then your AP may think that is manufactured by Simrad and may try to use their proprietary calibration system. I do not know any std sensor calibration system, so it is best to mfg code, which is not know (=registered) - e.g. 2046.

From your log I can see that probably your AP (source 0) is providing Rudder PGN with all fields as "unavailable" value.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 19, 2017, 05:46 pm
I ordered it, so I'll try to let you know when I get around to try it in a few weeks time.
There is now new version of NMEA2000 library, NMEA2000_teensy library and also under my repositories developed version of FlexCAN library.

I do not have dual CAN Teensy, so I can not test library with it. But you should not need NMEA2000 with dual CAN except if you are going to write some gateway system.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 19, 2017, 06:11 pm
Hi timo,
I tried the new code with 3 device output and it worked well. Then I tried adding 3rd device and I wasn't successful outputting 3 devices. I read the documentation and it says it is for two devices can you please confirm that it is for two devices only.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 19, 2017, 06:26 pm
Sorry, but I am bit lost. What do you mean with 2 devices? MultiDevice support? In principle it should have only memory limitation. Or something else?
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 19, 2017, 08:32 pm
LOL! I know what the "Or something else" limitation is :) Most likely my ability to write code.
I will sweat it little longer and then if I don't succeed I'll post my code with the attempt to add another device. This time I thought I have it right, damn! LOL :smiley-confuse:
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 20, 2017, 04:17 am
With "Something else" I meant that do you mean with 2 devices multi device support or something else. Device has so many meanings that I was not sure.

And about the multi device support - keep you code simple at the beginning and use just single device definition like in the simple example TemperatureSensor. I started multi device thinking in the very beginning, but soon noticed that other devices on bus actually does not care what you say you are. Roughly saying you can show you device as wind instrument and send only cabin temperature. Others are happy for someone sending cabin temperature.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 20, 2017, 10:28 am
Hi,
I did try hard for a long time and finally i discovered the "magic bullet"
Apparently I was missing something very simple

Code: [Select]

 NMEA2000.SetDeviceCount(2);

After I changed the number of devices to 3 it all worked as suppose to.
I did laugh at myself... for a long time. Still shorter time than what I spent trying to figure out why only 2 devices were showing up on the MFD.

I have a question about
NMEA2000.SetProductInformation
and
NMEA2000.SetDeviceInformation
it appears that if the second one is remed out everithing still works, or does it?
 
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 20, 2017, 11:52 am
In these small devices it is not good to use new/free to extend vectors. That is why you have to first say that "I'll have 3 devices, so reserve me this big vector" with NMEA2000.SetDeviceCount(3); So there will be only one new commad to make vector and no free to cause hole to small memory.

It is best to define both. SetDeviceInformation is the most important, since it defines unique ID for you device. Specially serial number should be different. If you do not define SetDeviceInformation, my library tries to survive by changin some instance value, but your MFD probably can't handle it.

SetProductInformation you need so that your MFD will show different names. Otherwise it will show same name for both devices.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jun 24, 2017, 07:10 pm
I'm very excited as the boards arrived on Friday. Here is the first look:
(http://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=216502)
Next stop is assambly and revival of the first 3 boards
Title: Re: NMEA 2000 Shield
Post by: FXVT on Jun 26, 2017, 11:46 pm
Bonjour Timo,

I am still waiting for the Mega board I ordered, so I continue my test with Arduino Boards.
Anyway, parts of my latest sketch work, but not together.

There are 2 main parts:
-   Acquiring datas from the serial port of a Victron BMV700 battery Monitor: Current (A),  Voltage (V) and capacity (%)
-   Sending those datas to the SeaTalkNG network (NMEA2000).
I can send datas to a Raymarine MFD or B&G display if I write test values directly in the     
Code: [Select]
SetN2kDCBatStatus(N2kMsg,0,13.87,5.12,35.12,1) command. That is ok.


I can get data from the BMV700 and print them on the serial Monitor. So I gess this part works.
But for that, I must comment (//) all the lines who send the N2K messages, especially this command
Code: [Select]
// tN2kMsg N2kMsg;

As soon as I uncomment these lines, I only get null values for Current, Voltage and Capacity
I get :
"0.00   0.00   0.00"
, instead of, for example:
 "-3.45   12.90   95.45"

Code: [Select]
     // Print the values on the Serial Monitor
     Serial.print (Current);
     Serial.print ("   ");
     Serial.print (Voltage);
     Serial.print ("   ");
     Serial.println (SOC);


During the test I have modified the structure of your Battery Monitor Example, copying the SendN2kBattery subroutine in the main loop.

Why the tN2kMsg N2kMsg; command seems to RAZ my datas ?

Regards, thanks for your great job.
François-Xavier.

Code: [Select]
// From http://www.jw5zla.com/?p=7 Interfacing the Victron BMV-700
// and Timo Lappalainen'NMEA2000 libraries

#include <Arduino.h>
#include <SoftwareSerial.h>
#include <SPI.h>
 
SoftwareSerial Victron(0,3);    // RX= Pin 0, TX= Pin 3(Not used)

char p_buffer[80];
#define P(str) (strcpy_P(p_buffer, PSTR(str)), p_buffer)

#define N2k_SPI_CS_PIN 9        // Valeur 10 pour le shield www.elecrow.com, 9 pour le Seeedunio

#include <NMEA2000_CAN.h>       // This will automatically choose right CAN library and create suitable NMEA2000 object
#include <N2kMessages.h>
 
char c;
String V_buffer;  // Buffer to hold data from the Victron monitor
String E_buffer;  // Buffer to hold data from the ethernet shield
 
float Current;
float Voltage;
float SOC;


// List here messages your device will transmit.
const unsigned long TransmitMessages[] PROGMEM={127506L,127508L,0};

// ---  Example of using PROGMEM to hold Product ID.  However, doing this will prevent any updating of
//      these details outside of recompiling the program.
const tProductInformation BatteryMonitorProductInformation PROGMEM={
                                       1300,                        // N2kVersion
                                       100,                         // Manufacturer's product code
                                       "Moniteur Batterie Arduino", // Manufacturer's Model ID C'est la ligne qui est détectée comme appareil par le Triton
                                       "1.0.0.0 (2017-06)",         // Manufacturer's Software version code
                                       "1.0.0.0 (2017-06)",         // Manufacturer's Model version
                                       "00000001",                  // Manufacturer's Model serial code
                                       0,                           // SertificationLevel
                                       1                            // LoadEquivalency
                                      };                                     

// ---  Example of using PROGMEM to hold Configuration information.  However, doing this will prevent any updating of
//      these details outside of recompiling the program.
const char BatteryMonitorManufacturerInformation  [] PROGMEM = "FX VAN THUAN";
const char BatteryMonitorInstallationDescription1 [] PROGMEM = "BMV700 Victron & Arduino";
const char BatteryMonitorInstallationDescription2 [] PROGMEM = "Send Informations to the N2K bus";


 
void setup()
{
  Serial.begin(19200);
  Victron.begin(19200);


  // Set Product information
  NMEA2000.SetProductInformation(&BatteryMonitorProductInformation );
  // Set Configuration information
  NMEA2000.SetProgmemConfigurationInformation(BatteryMonitorManufacturerInformation,BatteryMonitorInstallationDescription1,BatteryMonitorInstallationDescription2);
  // Set device information
  NMEA2000.SetDeviceInformation(1,      // Unique number. Use e.g. Serial number.
                                170,    // Device function=Battery. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                35,     // Device class=Electrical Generation. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                999     // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                               
                               );                         
                                 
  // Uncomment 3 rows below to see, what device will send to bus                           
  // Serial.begin(115200);
   NMEA2000.SetForwardStream(&Serial);
   NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);     // Show in clear text. Leave uncommented for default Actisense format.
 Serial.println ("ETAPE 1");
  // If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
  NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);
  // NMEA2000.SetDebugMode(tNMEA2000::dm_ClearText);     // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
  // NMEA2000.EnableForward(false);                      // Disable all msg forwarding to USB (=Serial)
   NMEA2000.SetN2kCANMsgBufSize(2);                      // For this simple example, limit buffer size to 2, since we are only sending data
   NMEA2000.SetN2kCANSendFrameBufSize(30);               // essai suite lecture forum
  Serial.println ("ETAPE 2");
    NMEA2000.Open();
  Serial.println ("ETAPE 3");

 
}
 
void loop() {
 
  // Victron
 
  if (Victron.available()) {
    c = Victron.read();
 
    if (V_buffer.length() <80) {
      V_buffer += c;
    }
 
    if (c == '\n') {  // New line.
 
      if (V_buffer.startsWith("I")) {
        String temp_string = V_buffer.substring(V_buffer.indexOf("\t")+1);
        double temp_int = temp_string.toInt();
        Current = (float) temp_int/1000;
      }     
 
      if (V_buffer.startsWith("V")) {
        String temp_string = V_buffer.substring(V_buffer.indexOf("\t")+1);
        int temp_int = temp_string.toInt();
        Voltage = (float) temp_int/1000;
      }     
 
      if (V_buffer.startsWith("SOC")) {
        String temp_string = V_buffer.substring(V_buffer.indexOf("\t")+1);
        int temp_int = temp_string.toInt();
        SOC = (float) temp_int/10;
      }     
      V_buffer="";
    }
   
  }
     // Print the values on the Serial Monitor
     Serial.print (Current);
     Serial.print ("   ");
     Serial.print (Voltage);
     Serial.print ("   ");
     Serial.println (SOC);


//---------------------- Section N2K

     #define BatUpdatePeriod 1000
     static unsigned long TempUpdated=millis();
// tN2kMsg N2kMsg;

   if ( TempUpdated+BatUpdatePeriod<millis() )
   {
        TempUpdated=millis();
    /*
    //SetN2kDCBatStatus(N2kMsg,0,13.87,5.12,35.12,1);     // test
    SetN2kDCBatStatus(N2kMsg,0,Voltage,Current,22.22,1);
    NMEA2000.SendMsg(N2kMsg);
   
    //SetN2kDCStatus(N2kMsg,1,0,0,56,92,38500,0.012);     // test
    SetN2kDCStatus(N2kMsg,1,0,N2kDCt_Battery,SOC,0,0,0);
    NMEA2000.SendMsg(N2kMsg);
    */
         Serial.print(millis()); Serial.println(", Battery send ready");

   
   }   // Fin de la boucle conditionnelle de temps

             
          NMEA2000.ParseMessages();
 
}
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 27, 2017, 06:25 am
Are you are still using Uno, I think it is simple memory problem. When you have tN2kMsg N2kMsg; on loop, it will make a reservarion on stack for that object. The total size of N2kMsg is about 240 bytes. That is over 10% of Uno memory.

You can try to squeeze memory more.
- Change NMEA2000.SetForwardStream(&Serial); -> NMEA2000.SetForwardStream(0);
- comment NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
- uncomment NMEA2000.EnableForward(false);
- change NMEA2000.SetN2kCANSendFrameBufSize(30); -> NMEA2000.SetN2kCANSendFrameBufSize(20);
- you can try even set NMEA2000.SetN2kCANMsgBufSize(1);

Make own functions for Victron and SendN2kInfo, which have own local variables and call them on loop. In this way it is sure that their local varables does not take memory from stack at same time.

Also you have buffers
char p_buffer[80];
...
String V_buffer;  // Buffer to hold data from the Victron monitor
String E_buffer;  // Buffer to hold data from the ethernet shield

If these are not needed globally, move them inside some function, so they will need RAM on stack, when needed and then released. I have not checked how String class works in point of memory use as global or local.

And also you have to define all options on NMEA2000_CompilerDefns.h to disable all new features to save memory.

I would say that using Uno is just banging your head to the wall!
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 27, 2017, 06:34 am
And also either disable interrupt by commenting  #define N2k_SPI_CS_PIN 9 to save one extra frame.

Remember also use format
Serial.println (F("ETAPE 2"));
for all string printing. Without F(...) "EATPE2" string takes RAM instead of Flash.
Title: Re: NMEA 2000 Shield
Post by: FXVT on Jun 27, 2017, 08:52 am
Bonjour Timo,

Thank you for your prompt reply.

Yes I am still working with a Uno board, waiting for the Mega to be delivered.

Lake of memory ! That is what I guessed.
When I add some lines, I loose the Victron values little by little. For example, Voltage or current go down to zero, or even both of them.

I will apply your advices and tell you the result.

Regards.
FX VAN THUAN
Title: Re: NMEA 2000 Shield
Post by: FXVT on Jun 27, 2017, 09:23 pm
Bonjour Timo,

Yesssssss !
I have modified the sketch according to your advices and it woooooooorks !
Thank you !

Thanks to your tricks, I have win around 5 % of memory, and it is enough. after compilation it use 90% of the UNO board memory.
I am on the limit.

Here are some pictures. The Arduino is well recognized by the Triton T41 B&G and the i70 Raymarine, and the datas are displyed on the a78 Raymarine MFD and the T41

The next sketch will be the termometer of the engine water and the fridge.

Regards.
FX VAN THUAN
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jun 27, 2017, 10:04 pm
But after all memory savings it it rather clear that you can not add much more code for your Uno.

Which Victron device you have? Do you know, does they have some output also on Victron MPPT solar charger? One can connect external display to it, but I have not seen any data how they send it, what protocol etc. Could it be same as in your device?
Title: Re: NMEA 2000 Shield
Post by: FXVT on Jun 28, 2017, 11:40 pm
Bonjour Timo,

I use a BMV700 Victron Battery Monitor
https://www.victronenergy.com/battery-monitors/bmv-700
It has 2 connectors at the rear:
- RJ-11 to the shunt
- JST 4 as Serial TTL 3.3V outpout.

His protocol is described here:
http://www.plaisance-pratique.com/IMG/pdf/BMV_Text_Protocol_1_.pdf
http://www.deszynski.com/victron-bmv-700-lan-port/

I have never used the Victron MPPT Monitor who has quite the same housing.
https://www.victronenergy.com/panel-systems-remote-monitoring/mppt-control
May be you will find some information here about the way to make it communicating with other devices:

https://www.victronenergy.com/live/vedirect_protocol:faq
https://www.victronenergy.com/upload/documents/Whitepaper-Data-communication-with-Victron-Energy-products_EN.pdf
https://www.victronenergy.com/live/open_source:ccgx:d-bus
https://www.victronenergy.com/upload/documents/Manual-MPPT-Control-A4-EN.pdf

Regards.
FXVT
https://www.victronenergy.com/live/open_source:start
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jul 06, 2017, 05:52 am
Hello all!
For those of you interested, here is the assembled RevA board
Finally I got to test the RS232 port today. It works great!
So it all works great!

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=217901)

For those of you interested, here are the specs:
8 x 0-30 VDC inputs
4 x 0-5 VDC or 0-3.3 VDC (with analog reference of 3.3v)
Each of the 4 ports above has 3.3vdc supply and ground - for easy connection to temperature or pressure sensors
1 x RS232 port for NMEA0183
1 x NMEA2000 port with MICRO-C male connector (or just bare wires if preferred)
external 12-18VDC power or N2K bus powered - jumper selectable.


I'm planning to make RevB based on feedback I get from the forum and few things that I feel I can improve.
Please let me know what you think should be added or substracted from the board. I prefer to keep it simple and have multiple boards for more interfaces.
This boat was tested with Timo's multi device interface with up to 5 devices.
I simulated:
Heading
Fluid levels
Rudder indicator
Compass
Battery

Please let me know if you have any other uses that I can implement the hardware for.
Cheers!
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 09, 2017, 01:44 am
Hi!

I just added Mercury VesselView to my boat and as part of the process I had to move the engine trim sensor from analog to digital so the ECU could use it to enable ECO MODE.   As such, my analog gauge became non-functional.  

So, I designed a PCB that uses a Teensy and MCP2551 among some other circuitry that can read the NMEA 2000 data and then control the gauge using PWM but I thought it was a better opportunity to convert the analog gauge into a color multifunction display.

I've got everything ready to go -- now I just need to plug into the NMEA 2000 bus to see if the Teensy can handle getting the Engine Trim data...

I'm using the NMEA2000 DataDisplay example, do you think what I'm trying to do (read Engine Trim) will work?  Meaning, will get the updates of position in a "real-time" update?

I will be going to the boat this week to finally plug in the board to the network to start testing -- for the last few weeks it was about the programing the color display, mechanical work, PCB design and 3d designing printing the case pieces.  

Here are photos of the progress so far --
(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218246)

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218248)

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218250)

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218252)

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218254)

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218256)

Video showing transitions (by tapping the chrome bezel):
https://www.youtube.com/watch?v=PfXNt46S_9c (https://www.youtube.com/watch?v=PfXNt46S_9c)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 09, 2017, 07:10 am
Hi,

In principle it should work.
- I expect you have DC-DC converter on your board and you remembered to cut link between VUSB and Vin on Teensy.

- Also hopefully ECU or some system will send trim data to NMEA2000

- DataDisplay is a bit old and does not seem have automatic library selection for board. DataDisplay2 seem to already have handling for EngineRapid (PGN 127488). On that you will need only comment unnecessary handlers on handler list NMEA2000Handlers. Or maybe you already rewrite datadisplay to match your needs?

Your gauge looks very nice and could be used to display different data. With single scroll button besides gauge one select data from NMEA2000 bus - not just trim.

And if you want to see your new gauge on NMEA2000 device list, you have to add device definition commands to setup as e.g. in TemperatureMonitor example. You should then use Class code 120 (Display) and Function code 130 (Display). In principle in NMEA 2000 listen only devices are not allowed. On reason is that each device, which is taking power from bus, should inform it so that total power can be calculated. Just on your own boat this does not matter, if you just remember to keep used power low enough. There are also other things to concern, if you start to change you device more "NMEA2000 certified".
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 09, 2017, 05:56 pm
- I expect you have DC-DC converter on your board and you remembered to cut link between VUSB and Vin on Teensy.
Yes, I have a 12v > 5v DC-DC converter onboard and cut the link.

- Also hopefully ECU or some system will send trim data to NMEA2000
The VesselView Link takes the ECU data and puts it on the NMEA2000 network -- this is all functioning already  on my Lowrance MFD.

- DataDisplay is a bit old and does not seem have automatic library selection for board. DataDisplay2 seem to already have handling for EngineRapid (PGN 127488). On that you will need only comment unnecessary handlers on handler list NMEA2000Handlers. Or maybe you already rewrite datadisplay to match your needs?
Got it -- I meant to say DataDisplay2 example.   I see these handlers in the demo -- are they all good?

Code: [Select]

// Do not forward bus messages at all
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
  NMEA2000.SetForwardStream(OutputStream);
  // Set false below, if you do not want to see messages parsed to HEX withing library
  NMEA2000.EnableForward(false);
  NMEA2000.SetMsgHandler(HandleNMEA2000Msg);
  NMEA2000.SetN2kCANMsgBufSize(2);
  NMEA2000.Open();
  OutputStream->print("Running...");


Your gauge looks very nice and could be used to display different data. With single scroll button besides gauge one select data from NMEA2000 bus - not just trim.
That's the plan -- right now I have two screens ready (Trim and Fuel).  I will add more screens I can cycle through to make it a quick-look MFD.

And if you want to see your new gauge on NMEA2000 device list, you have to add device definition commands to setup as e.g. in TemperatureMonitor example. You should then use Class code 120 (Display) and Function code 130 (Display). In principle in NMEA 2000 listen only devices are not allowed. On reason is that each device, which is taking power from bus, should inform it so that total power can be calculated. Just on your own boat this does not matter, if you just remember to keep used power low enough. There are also other things to concern, if you start to change you device more "NMEA2000 certified".
Good idea!  I'll add that code so the device shows up -- the power usage is pretty low overall.  The Teensy & Display plus the MCP2551 is all that is being used.   Initial measurement looked like about 90mA being pulled from the 12v input side.

Thanks again timolappalainen!
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 09, 2017, 08:30 pm
Got it -- I meant to say DataDisplay2 example.   I see these handlers in the demo -- are they all good?
I have tested them against Actisense NMEA Reader, so they should be all right.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 10, 2017, 10:04 pm
I have tested them against Actisense NMEA Reader, so they should be all right.
At the boat, connected to the network -- I see the data coming in!

However, I'm not getting the device showing up in the "Device List" on my Lowrance HDS7 when I scan the network for devices...

I'm doing the following in code:

Code: [Select]

// Set Product information
  NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
                                 100, // Manufacturer's product code
                                 "Myro Gauge MFD",  // Manufacturer's Model ID
                                 "1.0.0.0 (2017-7-10)",  // Manufacturer's Software version code
                                 "1.0.0.0 (2017-7-10)" // Manufacturer's Model version
                                 );
  // Set device information
  NMEA2000.SetDeviceInformation(000001, // Unique number. Use e.g. Serial number.
                                130, // Device function=Display. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                120, // Device class=Display. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                2041 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                               
                               );
  // Do not forward bus messages at all
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
  NMEA2000.SetForwardStream(OutputStream);
  // Set false below, if you do not want to see messages parsed to HEX withing library
  NMEA2000.EnableForward(false);
  NMEA2000.SetMsgHandler(HandleNMEA2000Msg);
  NMEA2000.SetN2kCANMsgBufSize(2);
  NMEA2000.Open();
  OutputStream->print("Running...");
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 10, 2017, 10:20 pm
You are missing type definition as default is just listen. So add
  NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,29);

Also since Teensy has enough memory you do not need to sqeeze it with
NMEA2000.SetN2kCANMsgBufSize(2);
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jul 10, 2017, 10:50 pm
@mavromatis
great project. Interested to know what display you used for that?
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 11, 2017, 01:23 am
You are missing type definition as default is just listen. So add
  NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,29);

Also since Teensy has enough memory you do not need to sqeeze it with
NMEA2000.SetN2kCANMsgBufSize(2);
Thank you!


@mavromatis
great project. Interested to know what display you used for that?
I was going to go down the route and use an STM32 with a 1.5" round display (from China) but ended up finding this screen from 4d systems (http://www.4dsystems.com.au/product/uLCD_220RD/ (http://www.4dsystems.com.au/product/uLCD_220RD/)) that actually fit perfectly into the 2" analog gauge frame.
Title: Re: NMEA 2000 Shield
Post by: Lunchrat on Jul 11, 2017, 10:52 pm
Hey guys,

Sorry to interrupt- I've got a quick question. I'm trying to read and record (not write) N2K with a tablet or phone. I didn't read all 16 pages of this thread so can anyone point me in the direction of a library (or existing sketch) I can use to read the N2K data on the network?

I saw the mention of that reverse engineered catalog of PGNs but I don't know if someone already compiled it into some easy to use Arduino thing.

Thanks for the help
Title: Re: NMEA 2000 Shield
Post by: seamaster on Jul 12, 2017, 03:34 am
In the library examples, there is an example file called ActisenseListner.ino. This  file listens for the trafic on the N2K network. Here is actually where you should start:
https://github.com/ttlappalainen/NMEA2000/tree/master/Documents (https://github.com/ttlappalainen/NMEA2000/tree/master/Documents)

and here:
https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/NMEA2000_library_reference.pdf (https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/NMEA2000_library_reference.pdf)

it is relatively simple if I figured it out..
good luck
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 12, 2017, 05:49 pm
I've logged down some of the output from the bus and I see some anomaly's I think it's normal as the numbers are Pa (Pascal), right? -- engine wasn't running but the VesselView Link (ECU > N2K bridge powered) -- the VesselView interface showed the correct data. See how the oil pressure and fuel pressure show some interesting values... then go to "not available" in the next update.

These readings were made via a Teensy 3.2 with NMEA2000.SetN2kCANMsgBufSize(2); -- I will check it again with that bit code code commented out (not sure if that causes the issue).


  In Main Handler: 127489
  Engine dynamic params: 0
  oil pressure (Pa): 200.00
  oil temp (C): -0.05
  coolant temp (C): 24.00
  altenator voltage (V): 13.29
  fuel rate (l/h): 0.00
  engine hours (h): 280.97
  coolant pressure (Pa): 0.00
  fuel pressure (Pa): 296000.00
  engine load (%): 0
  engine torque (%): not available




Then next update I get, it seems to cycle over and over:


  In Main Handler: 127489
  Engine dynamic params: 0
  oil pressure (Pa): not available
  oil temp (C): not available
  coolant temp (C): not available
  altenator voltage (V): not available
  fuel rate (l/h): 0.00
  engine hours (h): not available
  coolant pressure (Pa): not available
  fuel pressure (Pa): not available
  engine load (%): not available
  engine torque (%): not available
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 12, 2017, 08:44 pm
Update on trying to send the product info on the network: 

When I try to enable -- NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,29);

It seems to crash my NMEA network -- the Lowrance MFD Network device list cannot list any items and doesn't refresh and I lose my GPS (since it cannot get my POINT-1 GPS on the network) until I unplug my device. 

Anything look wonky below?  Wonder if it's software or possibly hardware on the TX side of my CAN?

Code: [Select]

 // Set Product information
  NMEA2000.SetProductInformation("00000001", // Manufacturer's Model serial code
                                 100, // Manufacturer's product code
                                 "Myro Gauge MFD",  // Manufacturer's Model ID
                                 "1.0.0.0 (2017-7-10)",  // Manufacturer's Software version code
                                 "1.0.0.0 (2017-7-10)" // Manufacturer's Model version
                                 );
  // Set device information
  NMEA2000.SetDeviceInformation(000001, // Unique number. Use e.g. Serial number.
                                130, // Device function=Display. See codes on http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                120, // Device class=Display. See codes on  http://www.nmea.org/Assets/20120726%20nmea%202000%20class%20&%20function%20codes%20v%202.00.pdf
                                2041 // Just choosen free from code list on http://www.nmea.org/Assets/20121020%20nmea%202000%20registration%20list.pdf                               
                               );
  // If you also want to see all traffic on the bus use N2km_ListenAndNode instead of N2km_NodeOnly below
  //NMEA2000.SetMode(tNMEA2000::N2km_NodeOnly,22);
  //NMEA2000.SetMode(tNMEA2000::N2km_ListenAndNode,29);
  // Do not forward bus messages at all
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text);
  NMEA2000.SetForwardStream(OutputStream);
  // Set false below, if you do not want to see messages parsed to HEX withing library
  NMEA2000.EnableForward(false);
  NMEA2000.SetMsgHandler(HandleNMEA2000Msg);
  //NMEA2000.SetN2kCANMsgBufSize(2); << Don't need this for teensy
  NMEA2000.Open();
  OutputStream->print("Running...");
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 12, 2017, 09:37 pm
If it would be on sw, none of my device would work. I have one board with MCP2551, which bricked and blocks the network too. Others with MCP2562 works still fine.

You get "not available", since your device reads 0xffff for all values and that will be translated as not available. Except for some reason you get 0 for fuel rate.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 12, 2017, 10:07 pm
If it would be on sw, none of my device would work. I have one board with MCP2551, which bricked and blocks the network too. Others with MCP2562 works still fine.
OK -- will check to see if it's possibly HW related -- if I just listen -- comment out, everything seems to work fine... so it's something on the TX part back into the network.


You get "not available", since your device reads 0xffff for all values and that will be translated as not available. Except for some reason you get 0 for fuel rate.
Sometimes I get not available other times I get the values -- not a big deal because at least I get the values multiple times a second it seems...

Example with engine running:

In Main Handler: 127489
Engine dynamic params: 0
  oil pressure (Pa): 323900.00
  oil temp (F): 31.91
  coolant temp (F): 109.40
  alternator voltage (V): 14.43
  fuel rate (l/h): 3.90
  engine hours (h): 281.00
  coolant pressure (Pa): 9500.00
  fuel pressure (Pa): 296000.00
  engine load (%): 0
  engine torque (%): not available
...
...
... then a few moments later...
...
...
In Main Handler: 127489
Engine dynamic params: 0
  oil pressure (Pa): not available
  oil temp (F): not available
  coolant temp (F): not available
  alternator voltage (V): not available
  fuel rate (l/h): 3.00
  engine hours (h): not available
  coolant pressure (Pa): not available
  fuel pressure (Pa): not available
  engine load (%): not available
  engine torque (%): not available
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 13, 2017, 06:42 am
I still expect hw problem also on rx side. DataDisplay2 does not anything than catches data and shows it directly. As an alternate you could try with ActisenseListener either with Actisense NMEA Reader or by uncommenting line NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); so that you will see data in clear text.

Just for checking that hopefully you have not forgot bus 120 ohm termination resistors, which you should have at both end of the bus. That has happed happened to me with test bed on disconnecting bus from wrong place.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 13, 2017, 04:42 pm
I still expect hw problem also on rx side. DataDisplay2 does not anything than catches data and shows it directly. As an alternate you could try with ActisenseListener either with Actisense NMEA Reader or by uncommenting line NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); so that you will see data in clear text.

Just for checking that hopefully you have not forgot bus 120 ohm termination resistors, which you should have at both end of the bus. That has happed happened to me with test bed on disconnecting bus from wrong place.
120ohm termination resistors are on -- but I'll try uncommenting the fwdt_Text line.

Below is the circuit I'm using with the MCP2551, could be that is incorrect (based it on one I found online that is sold on eBay as a MCP2551 breakout (http://www.ebay.com/itm/MCP2551-CAN-HI-SPD-Transceiver-Breakout-Board-/301881312565)) -- I'll also swap the MCP2551 for a MCP2561 and a MCP2562 to see if that changes anything...

(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=218738)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 13, 2017, 09:37 pm
It should be ok. It is same as I have with Mega (or CAN bus shield) https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoMega_CAN_with_MCP2515_MCP2551.pdf. Except I do not have RC filter on CAN-H and CAN-L

With  MCP2562 connect pin 5 to 3.3V as in my drawing https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/TeensyActisenseListenerSender/Documents/Teensy_Actisense_listener_sender_schematics.pdf
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 14, 2017, 06:36 pm
With  MCP2562 connect pin 5 to 3.3V as in my drawing https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/TeensyActisenseListenerSender/Documents/Teensy_Actisense_listener_sender_schematics.pdf
Will do and report back findings... thx.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 22, 2017, 01:54 am
Will do and report back findings... thx.
Built another board and used a MCP2551 and that one works.

Thanks!
Danny
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 30, 2017, 06:16 pm
@timolappalainen -- First, thanks for your help!

I've got everything mostly working and now I'm only the final stretch (you can see my progress HERE (http://www.mavromatic.com/2017/07/part-i-custom-nmea-2000-2-round-lcd-multifunction-display-for-boat-gauge/)).

I can't seem to get "ENGINE ROOM TEMP" updates... is there something I need to add or enable deeper in the code/library?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 30, 2017, 06:50 pm
Are you sure you have engine room temperature sensor and some device sending data from it?

Engine roome temperature will be sent either by PGN 130312 (obsolte) or 130316. Temperature source field will be then set to N2kts_EngineRoomTemperature.

So as in DataDisplay2, it handles those messages by function Temperature (130312) and TemperatureExt (130316). So if you have device sending engine room temperature with PGN 130312, you use it as in function Temperature:
    if (ParseN2kTemperature(N2kMsg,SID,TempInstance,TempSource,ActualTemperature,SetTemperature)  && !N2kIsNA(ActualTemperature) && TempSource==N2kts_EngineRoomTemperature ) {
  SetTempGauge(ActualTemperature);
}
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 30, 2017, 07:07 pm
Yes, I have one of these on the device network setup as Engine Room Temperature sensor (http://www.lowrance.com/en-US/Products/NMEA-2000/temperature-sensor-en-us.aspx (http://www.lowrance.com/en-US/Products/NMEA-2000/temperature-sensor-en-us.aspx)) -- it shows up on the Lowrance HDS screen just not seeing any messages show up in the output screen.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 30, 2017, 09:24 pm
Do you mean that it does not show on DataDisplay2?

You could program ActisenseListener - if you do not have any Actisense NGT-1  - to your Teensy connected to N2k bus and then listen data with Actisense NMEA Reader. Then you can see, what message your sensor is sending.
Title: Re: NMEA 2000 Shield
Post by: Rinkelein on Jul 30, 2017, 10:29 pm
Just a question. I have been able to read all N2K messages from my Raymarine i70 backbone using a Due, and even transmit them in NMEA 0183 format via WiFi (UDP) to be used in OpenCPN. However sending (Windmonitor) to the backbone does not work, even not with the NMEA simulator. Serial output tells me that PGN'S failed. I've not changed anything to Timo's most recent sketches. Simulator was connected  to the SerialUSB.

Any suggestions are highly appreciated.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 31, 2017, 05:04 am
Do you mean that it does not show on DataDisplay2?

You could program ActisenseListener - if you do not have any Actisense NGT-1  - to your Teensy connected to N2k bus and then listen data with Actisense NMEA Reader. Then you can see, what message your sensor is sending.
Yes, doesn't show using DataDisplay2 -- I will try programming ActisenseListener to see what type of messages that sensor is sending... will report back.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Jul 31, 2017, 09:20 am
Any suggestions are highly appreciated.
I just tested WindMonitor with my own DUE and it works OK. I made tests with old NMEA2000_due/due_can and new version of both (just released on my GitHub few minutes ago). So I think the problem is not with library.

If you can read, but TX fails, there is some problem with your TX side. Have you checked TX pin is connected? Are terminal resistors OK? Maybe tranceiver does not work on TX?
Title: Re: NMEA 2000 Shield
Post by: Rinkelein on Jul 31, 2017, 11:18 am
Many thanks Timo. We will check the terminal resistor and back with the result. I used a SN65HVD230 and didn't use a 120 Ohm terminator resistor. Also I will use the latest libraries.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Jul 31, 2017, 05:54 pm
Many thanks Timo. We will check the terminal resistor and back with the result. I used a SN65HVD230 and didn't use a 120 Ohm terminator resistor. Also I will use the latest libraries.
If it helps -- I was having issues with the TX side of things (RX worked fine) and put together another board and that one worked perfectly.  Not sure why yet, I thought it was related to a bad MCP2551 but most likely caused by bad solder joints or some other passives I soldered on the board. 
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 01, 2017, 08:53 pm
Do you mean that it does not show on DataDisplay2?

You could program ActisenseListener - if you do not have any Actisense NGT-1  - to your Teensy connected to N2k bus and then listen data with Actisense NMEA Reader. Then you can see, what message your sensor is sending.
Timo, I installed the ActisenseListener and ran Actisense NR -- if I set the temp sensor to Water I get the values showing up under Name: Temperature and Name: Environmental Parameters -- if the sensor is set to anything else, there is no active data under those items that were updating when set to Water in Actisense NR -- but, the weird bit -- the data showing correctly on the Lowrance HDS and data under the Lowrance Device List.   Are they doing something non-standard?

Here is what I get on the Lowrance:
(https://forum.arduino.cc/index.php?action=dlattach;topic=50893.0;attach=220980)
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 01, 2017, 09:27 pm
What do you mean by "if I set the temp sensor to Water"? Is there some switch to define what sensor is for?

It is very strange, if they would use some proprietary. Anyway if you listen bus at the same time with Actisense NR, while showing data on HDS, you should see the traffic. Actisense NR may show them unknown messages from source 10. There is one possiblity that data will be sent as no extended format. I do not know does library actually handle those messages and forward them to the USB.
Title: Re: NMEA 2000 Shield
Post by: seamaster on Aug 01, 2017, 10:47 pm
Quote
Timo, I installed the ActisenseListener and ran Actisense NR -- if I set the temp sensor to Water I get the values showing up under Name: Temperature and Name: Environmental Parameters -- if the sensor is set to anything else, there is no active data under those items that were updating when set to Water in Actisense NR -- but, the weird bit -- the data showing correctly on the Lowrance HDS and data under the Lowrance Device List.   Are they doing something non-standard?
If you are using Loweance temp sensor please pay attention to the data sheet of the product.  All Lawrence temp sensors output proprietary PGN
**************
Specifications
Temperature Range between -20 and 80 degrees Celsius.
PGNs transmitted
59392 - ISO Acknowledgment
60928 - ISO Address Claim
126996 - Product Information
65285 - Temperature with Instance  //this is the one that's proprietary
**************
I went through this with my Furuno MFD showing the temp sensor, but not reading the data. I was unpleasantly surprised that wasn't the configuration of the sensor for water, engine room  temp, etc., that was screwing up the reading, but rather the Lowrance proprietary PGN.
Maybe if you can capture the raw data from the sensor, Timo can add this PGN to the library if possible to easy interpret what is what...
Cheers!
Title: Re: NMEA 2000 Shield
Post by: seamaster on Aug 01, 2017, 10:57 pm
What do you mean by "if I set the temp sensor to Water"? Is there some switch to define what sensor is for?

Timo,
Lawrance uses their MF Displays to configure their sensors. Here is default sensor configurations -
 an extract from the installation manual:
**********
Fluid Level Sensor - tank levels for fuel*, water, gray water, live well, oil, and black water
• Fuel Flow Sensor - flow rate measurements of fuel for gasoline powered boats
• Fuel Data Manager - fuel used data from fuel flow messages it receives from up to three
NMEA 2000 compatible engines
• Temperature Sensor - temperatures for water*, outside, inside, engine room, cabin, live well,
bait well, refrigeration, and heating system
• Thru-Hull Temperature Sensor - temperatures for water*, outside, inside, engine room, cabin,
live well, bait well, refrigeration, and heating system
• Speed Sensor - boat speed
• Pressure Sensor - pressure data: Engine Boost Pressure, Engine Oil Pressure, Engine Water
Pressure*, Transmission Oil Pressure and Pitot Speed
* Sensor is pre-configured to display this information.

**********
Cheers,
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 02, 2017, 01:35 am
What do you mean by "if I set the temp sensor to Water"? Is there some switch to define what sensor is for?

It is very strange, if they would use some proprietary. Anyway if you listen bus at the same time with Actisense NR, while showing data on HDS, you should see the traffic. Actisense NR may show them unknown messages from source 10. There is one possiblity that data will be sent as no extended format. I do not know does library actually handle those messages and forward them to the USB.
Hi Timo -- like Seamaster stated, Lowrance allows you to setup the sensor via their MFD, I guess that is why they do some proprietary stuff?  Do you want me to ship you one of these sensors setup as Engine Rm or is it easier for me to capture the raw data so we can try to add the functionality to the library?


If you are using Loweance temp sensor please pay attention to the data sheet of the product.  All Lawrence temp sensors output proprietary PGN
**************
Specifications
Temperature Range between -20 and 80 degrees Celsius.
PGNs transmitted
59392 - ISO Acknowledgment
60928 - ISO Address Claim
126996 - Product Information
65285 - Temperature with Instance  //this is the one that's proprietary
**************
I went through this with my Furuno MFD showing the temp sensor, but not reading the data. I was unpleasantly surprised that wasn't the configuration of the sensor for water, engine room  temp, etc., that was screwing up the reading, but rather the Lowrance proprietary PGN.
Maybe if you can capture the raw data from the sensor, Timo can add this PGN to the library if possible to easy interpret what is what...
Cheers!
Bummer!  So are we out of luck? Or do you think there is a way I can capture the raw data from the sensor and share with the group -- just let me know how best to do this?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 02, 2017, 07:27 am
We seem to have information for PGN 65285 for Lowrance proprietary data.
{ "Lowrance: Temperature", 65285, false, 8, 0,
  { { "Manufacturer Code", 11, RES_MANUFACTURER, false, "=140", "Lowrance" }
  , { "Reserved", 2, RES_NOTUSED, false, 0, "" }
  , { "Industry Code", 3, RES_LOOKUP, false, "=4", "Marine Industry" }
  , { "Temperature Instance", 4, 1, false, 0, "" }
  , { "Temperature Source", 4, 1, false, 0, "" }
  , { "Actual Temperature", BYTES(2), RES_TEMPERATURE, false, "K", "" }
  , { 0 }
  }
}

So write handler for PGN 65285 and try code:
bool ParseN2kLowranceTempPGN65285(const tN2kMsg &N2kMsg, unsigned char &TempInstance, tN2kTempSource &TempSource,
                     double &ActualTemperature) {
  ActualTemperature=N2kDoubleNA;
  TempInstance=0;
  TempSource=N2kts_SeaTemperature;
  if (N2kMsg.PGN!=65285L) return false;
  int Index=0;
  uint16_t Manufacturer=(N2kMsg.Get2ByteUInt(Index) & 0x7ff);
  if ( Manufacturer != 140 ) return false; // Not Lowrance proprietary PGN
  uint8_t b=N2kMsg.GetByte(Index);
  TempInstance=(b & 0x0f);
  TempSource=(tN2kTempSource)( (b & 0xf0) >> 4 );
  ActualTemperature=N2kMsg.Get2ByteUDouble(0.01,Index);
 
  return true;
}
Title: Re: NMEA 2000 Shield
Post by: seamaster on Aug 02, 2017, 08:03 am
Quote
if ( Manufacturer != 140 ) return false; // Not Lowrance proprietary PGN
Timo,
don't forget that all of their sensors could be sold and go by either Lowrance, B&G or Simrad names. I think they have different manufacturer numbers/codes.
I found:
SIMRAD 1857;
Lowrance 140;
B&G ??; // I couldnt find one for them in the document here

http://www.nmea.org/Assets/20160116%20_%20jan%202016%20manu%20code%20and%20product%20code.pdf (http://www.nmea.org/Assets/20160116%20_%20jan%202016%20manu%20code%20and%20product%20code.pdf)

My point is: these 3 manufactures need to be included in the code not just Lawrance.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 02, 2017, 12:17 pm
B&G is 381 - on list "NMEA 2000 registration list". So change rule to:
  if ( !(Manufacturer == 140 ||
         Manufacturer == 1857 ||
         Manufacturer == 381) ) return false; // Not Lowrance, Simrad or B&G proprietary PGN
Title: Re: NMEA 2000 Shield
Post by: Rinkelein on Aug 02, 2017, 02:56 pm
I just tested WindMonitor with my own DUE and it works OK. I made tests with old NMEA2000_due/due_can and new version of both (just released on my GitHub few minutes ago). So I think the problem is not with library.

If you can read, but TX fails, there is some problem with your TX side. Have you checked TX pin is connected? Are terminal resistors OK? Maybe tranceiver does not work on TX?
Just to let you know that we have tested the TX side but weren't successfull. Several fora stated that this could be caused by the chip SN65HVD230. I've ordered a MCP2551 instead and will let you know later on. Thanks so far.
Title: Re: NMEA 2000 Shield
Post by: Rinkelein on Aug 02, 2017, 03:02 pm
I just tested WindMonitor with my own DUE and it works OK. I made tests with old NMEA2000_due/due_can and new version of both (just released on my GitHub few minutes ago). So I think the problem is not with library.

If you can read, but TX fails, there is some problem with your TX side. Have you checked TX pin is connected? Are terminal resistors OK? Maybe tranceiver does not work on TX?
Just to let you know that we weren't able to get the TX side working. From other fora we learned that this could be caused by the SN65HVD230 chip. We have ordered a MCP2551 and let you know the results later on. Many thanks so far.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 02, 2017, 03:28 pm
With DUE you need to remember to power MCP2551 with 3.3V only. I prefer MCP2562, since you can power it with 5V and provide 3.3V to pin 5 for defining IO levels.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 02, 2017, 04:54 pm
We seem to have information for PGN 65285 for Lowrance proprietary data.
{ "Lowrance: Temperature", 65285, false, 8, 0,
  { { "Manufacturer Code", 11, RES_MANUFACTURER, false, "=140", "Lowrance" }
  , { "Reserved", 2, RES_NOTUSED, false, 0, "" }
  , { "Industry Code", 3, RES_LOOKUP, false, "=4", "Marine Industry" }
  , { "Temperature Instance", 4, 1, false, 0, "" }
  , { "Temperature Source", 4, 1, false, 0, "" }
  , { "Actual Temperature", BYTES(2), RES_TEMPERATURE, false, "K", "" }
  , { 0 }
  }
}

So write handler for PGN 65285 and try code:
bool ParseN2kLowranceTempPGN65285(const tN2kMsg &N2kMsg, unsigned char &TempInstance, tN2kTempSource &TempSource,
                     double &ActualTemperature) {
  ActualTemperature=N2kDoubleNA;
  TempInstance=0;
  TempSource=N2kts_SeaTemperature;
  if (N2kMsg.PGN!=65285L) return false;
  int Index=0;
  uint16_t Manufacturer=(N2kMsg.Get2ByteUInt(Index) & 0x7ff);
  if ( Manufacturer != 140 ) return false; // Not Lowrance proprietary PGN
  uint8_t b=N2kMsg.GetByte(Index);
  TempInstance=(b & 0x0f);
  TempSource=(tN2kTempSource)( (b & 0xf0) >> 4 );
  ActualTemperature=N2kMsg.Get2ByteUDouble(0.01,Index);
 
  return true;
}

That's great Timo!  I guess I should have looked under the covers deeper -- Will add this method to my code and test at the boat today... will let you know.  My sensor is branded Lowrance with a manufacture code of 140 so we should be good.

Just to be clear, for the handler I'm adding:
Code: [Select]

...
{130314L,&Pressure},
  {130316L,&TemperatureExt},
  {65285,&LowranceTemp},
  {0,0}
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 03, 2017, 02:26 am
That worked!  However, the source is "sea" not "engine room" -- I can live with that but not sure if you want to correct that in the library if you want to officially support this sensor.

This code:
Code: [Select]

void LowranceTemp(const tN2kMsg &N2kMsg) {
    unsigned char TempInstance;
    tN2kTempSource TempSource;
    double ActualTemperature;
   
    if (ParseN2kLowranceTempPGN65285(N2kMsg,TempInstance,TempSource,ActualTemperature) ) {
        OutputStream->print("Lowrance Temperature source: "); PrintN2kEnumType(TempSource,OutputStream,false);
        PrintLabelValWithConversionCheckUnDef(", actual temperature (F): ",ActualTemperature,&KelvinToF);
    } else {
      OutputStream->print("Failed to parse PGN: ");  OutputStream->println(N2kMsg.PGN);
    }
}

bool ParseN2kLowranceTempPGN65285(const tN2kMsg &N2kMsg, unsigned char &TempInstance, tN2kTempSource &TempSource,
                     double &ActualTemperature) {
  ActualTemperature=N2kDoubleNA;
  TempInstance=0;
  TempSource=N2kts_SeaTemperature;
  if (N2kMsg.PGN!=65285L) return false;
  int Index=0;
  uint16_t Manufacturer=(N2kMsg.Get2ByteUInt(Index) & 0x7ff);
  if ( Manufacturer != 140 ) return false; // Not Lowrance proprietary PGN
  uint8_t b=N2kMsg.GetByte(Index);
  TempInstance=(b & 0x0f);
  TempSource=(tN2kTempSource)( (b & 0xf0) >> 4 );
  ActualTemperature=N2kMsg.Get2ByteUDouble(0.01,Index);
 
  return true;
}


Produces:
Code: [Select]
Lowrance Temperature source: sea, actual temperature (F): 88.88
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 03, 2017, 05:58 am
Are you sure it is returning everything right and my code was right? Did you test output with different temp source - does it change? If the enum tN2kTempSource does not match to Lowrance, we need to define own:
Code: [Select]
enum tN2kLowranceTempSource {
                            N2kLts_EngineRoomTemperature=0
                            };

const char* tN2kLowranceTempSourceStrs[] = { "engine room" };

and solve what enum values are.
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 03, 2017, 07:32 am
Are you sure it is returning everything right and my code was right? Did you test output with different temp source - does it change? If the enum tN2kTempSource does not match to Lowrance, we need to define own:
Code: [Select]
enum tN2kLowranceTempSource {
                            N2kLts_EngineRoomTemperature=0
                            };

const char* tN2kLowranceTempSourceStrs[] = { "engine room" };

and solve what enum values are.
I didn't try changing the TempSource -- but the TempInstance returned should have been 3 (as shown on my Lowrance HDS) which is "Engine Room", not 0 and Sea Temp as passed in the handler.  

Code: [Select]

bool ParseN2kLowranceTempPGN65285(const tN2kMsg &N2kMsg, unsigned char &TempInstance, tN2kTempSource &TempSource,
                     double &ActualTemperature) {
  ActualTemperature=N2kDoubleNA;
  >>>> TempInstance=0;
  >>>> TempSource=N2kts_SeaTemperature;
  if (N2kMsg.PGN!=65285L) return false;
  int Index=0;
  uint16_t Manufacturer=(N2kMsg.Get2ByteUInt(Index) & 0x7ff);
  if ( Manufacturer != 140 ) return false; // Not Lowrance proprietary PGN
  uint8_t b=N2kMsg.GetByte(Index);
  >>>> TempInstance=(b & 0x0f);
  >>>> TempSource=(tN2kTempSource)( (b & 0xf0) >> 4 );
  ActualTemperature=N2kMsg.Get2ByteUDouble(0.01,Index);
 
  return true;
}


But the code you provided didn't seem to get that  from the message data?

The Lowrance PGN I used in the handler was "65285", not "65285L" -- not sure if that matters?
Code: [Select]

...
 {130316L,&TemperatureExt},
 {65285,&LowranceTemp},


Interestingly, the Actual Temperature was correct value.

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 03, 2017, 08:01 am
Change your printing code to:
Code: [Select]

OutputStream->print("Lowrance Temperature (");
OutputStream->print(TempInstance);
OutputStream->print(") source: ");
OutputStream->print((unsigned char)TempSource);

and try with different sources (engine, water, cabin) and report the results.

L is integer literal and defines value to be treated as long. Actually for PGNs should have been UL
Title: Re: NMEA 2000 Shield
Post by: mavromatis on Aug 04, 2017, 08:11 pm
Change your printing code to:
Code: [Select]

OutputStream->print("Lowrance Temperature (");
OutputStream->print(TempInstance);
OutputStream->print(") source: ");
OutputStream->print((unsigned char)TempSource);

and try with different sources (engine, water, cabin) and report the results.

L is integer literal and defines value to be treated as long. Actually for PGNs should have been UL
So it looks like the TempSource is the issue -- the TempInstance is correct:

DEBUG:: Lowrance Temperature (Instance: 3 source: 0) // 3 is engine rm
DEBUG:: Lowrance Temperature (Instance: 4 source: 0) // 4 is cabin



Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 04, 2017, 08:56 pm
Please do not quote everything.

Change code to:
TempSource=(tN2kTempSource)(b & 0x0f);
TempInstance=( (b & 0xf0) >> 4 );
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Aug 06, 2017, 04:09 pm
Hi Timo and all,

I tend to built a depth alarm for NMEA 2000 first and later maybe something more ambitious. Have arduino due board and in the mail is coming http://copperhilltech.com/can-bus-mini-breakout-board/. I guess for NMEA-bus that 120 Ohm resistor has to picked off as bus has its own terminations. When trying to verify examples in Timos library following error is generated:


Arduino: 1.8.3 (Windows 10), Board: "Arduino Due (Programming Port)"





C:\Users\heikki\AppData\Local\Temp\arduino_build_230965\sketch\DataDisplay.ino.cpp.o: In function `__static_initialization_and_destruction_0':

C:\Users\heikki\Documents\Arduino\libraries\NMEA2000-master\src/NMEA2000_CAN.h:78: undefined reference to `tNMEA2000_due::tNMEA2000_due()'

collect2.exe: error: ld returned 1 exit status

Using library NMEA2000-master at version 1.1.141 in folder: C:\Users\heikki\Documents\Arduino\libraries\NMEA2000-master
Using library due_can-master at version 2.0.1 in folder: C:\Users\heikki\Documents\Arduino\libraries\due_can-master
exit status 1
Error compiling for board Arduino Due (Programming Port).



Left some jargon of in between the error message in order to make message shorter. What could possibly go wrong here?

Br:  Heikki
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 06, 2017, 06:42 pm
Reload the NMEA2000_due (https://github.com/ttlappalainen/NMEA2000_due) library. I can produce that error if I remove file NMEA2000_due.cpp from path libraries\NMEA2000_due-master so I expect you are missing that file.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Aug 06, 2017, 06:52 pm
I will try as Timo suggested. There is a file like that in the location with size of 3KB.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Aug 06, 2017, 07:56 pm
Then you could also try to remove completely your NMEA2000_due-master directory. Then it should give error:
In file included from xxx\Arduino\Examples\xxx\xxx:x:x

xxx\Arduino\libraries\NMEA2000/NMEA2000_CAN.h:77:26: fatal error: NMEA2000_due.h: No such file or directory

 #include <NMEA2000_due.h>

If not you have NMEA2000_due.h somewhere, where it should not be.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Aug 06, 2017, 07:58 pm
Now examples seem to verify correctly. Since my adventure with arduino is 5 days old I uninstalled and deleted everything related to arduino and downloaded everything again. Strangely enough computer still had stuff for due board left.
Title: Re: NMEA 2000 Shield
Post by: marcop20 on Sep 21, 2017, 12:45 am
Hi Timo, I'm using your library and I want to congratulate you first and foremost for the work you've done.

We come to the question ......

I joined n2k at my Lowrance Elite Ti and although I can see the device and all the data stream I can not see product information.

In their place I see blank fields, and in the selection of sources I see three question marks

I see that another user with the Lowrance HDS (page 14) had the same problem and then seems to have resolved it.

You could help me please

I'm using the latest version of your library, arduino-mega and shield can-bus V1.2
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Sep 21, 2017, 06:33 am
Hi, and thanks.

I did not find your reference for "Lowrance HDS" - I made just quick search with "Lowrance" and "HDS".

Have you tested that with e.g. example TemperatureMonitor and not done any memory squeezing prefered for Uno board? You could also try does it help to enable interrupt by adding line
Code: [Select]
#define N2k_CAN_INT_PIN xx
before any includes. xx is the pin where interrupt has been connected on CAN_BUS shield.

You could also enable rows on example:
Code: [Select]
  delay(5000); // add this row to have time to open serial monitor
  Serial.begin(115200);
  NMEA2000.SetForwardStream(&Serial);
  NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); // Show in clear text. Leave uncommented for default Actisense format.


And record the communication and email me.

In principle MDF devices should query "Product information", when they see new device on the bus. There are two way to do that and current version of library support only PGN request. I will publish new version of library within few days after finishing tests. That support also responding to query done by "Request group function" for "Product information". Meanwhile there are two possibilities:
1. Email me directly so I can send you a test release, which has that support.
2. Add to loop() code to send ProductInformation in every 1-2 sec.
Code: [Select]
#define ProductInformationSendPeriod 2000
void loop() {
  static unsigned long ProductInformationSendTime=millis()+ProductInformationSendPeriod ;
    if ( ProductInformationSendTime<millis() ) {
       NMEA2000.SendProductInformation();
       ProductInformationSendTime=millis()+ProductInformationSendPeriod ;
    }
}


Even if 2. will work, I prefere to test without it with new release. And I would like to get anyway the information for the solution.
Title: Re: NMEA 2000 Shield
Post by: marcop20 on Sep 21, 2017, 02:21 pm
Hi Timo .....
I solved Method 2, that is, sending the ProductInformation every two seconds as recommended by you.
Anyway I attach you the log obtained on Arduino's serial monitor.

Code: [Select]

CAN device ready
Start address claim for device 0
Pri:6 PGN:60928 Source:22 Dest:255 Len:8 Data:1,0,C0,FF,0,84,32,C0
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:6 PGN:127508 Source:22 Dest:255 Len:8 Data:1,F8,4,FF,7F,FF,FF,1
Pri:6 PGN:127508 Source:22 Dest:255 Len:8 Data:0,64,5,A,0,FF,FF,0
Pri:6 PGN:130316 Source:22 Dest:255 Len:8 Data:1,1,4,74,7D,4,84,B
Pri:6 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,4,F2,72,23,73,FF
Pri:6 PGN:130311 Source:22 Dest:255 Len:8 Data:1,4,F2,72,B6,35,F6,3
Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:1,C1,70,95,74,F6,3,FF
Pri:6 PGN:127513 Source:22 Dest:255 Len:8 Data:1,D2,1,9A,1,5F,82,61
Pri:6 PGN:127506 Source:22 Dest:255 Len:9 Data:1,1,1,56,5B,8C,5,D2,0
Pri:2 PGN:127257 Source:22 Dest:255 Len:8 Data:1,E3,FD,A3,1,AF,FA,FF
Pri:6 PGN:127489 Source:22 Dest:255 Len:26 Data:0,A0,19,B,E,C5,8A,8D,5,39,0,4C,6B,75,0,FF,FF,FF,FF,FF,1,0,0,0,7F,7F
Pri:6 PGN:127493 Source:22 Dest:255 Len:8 Data:0,FC,4C,1D,3B,D,5,FF
Pri:3 PGN:126992 Source:22 Dest:255 Len:8 Data:1,0,93,44,0,73,F4,24
Pri:6 PGN:129029 Source:22 Dest:255 Len:47 Data:1,93,44,0,73,F4,24,0,80,2,D6,50,2E,57,8,0,80,76,D2,4E,5C,1F,3,A0,37,A0,0,0,0,0,0,10,1,C,50,0,32,0,DC,5,0,0,1,F0,0,C8,0
Pri:6 PGN:129539 Source:22 Dest:255 Len:8 Data:1,6C,78,0,B0,FF,FF,7F
Pri:2 PGN:127250 Source:22 Dest:255 Len:8 Data:0,1A,9B,F4,FD,C0,3,FD
Pri:6 PGN:129038 Source:22 Dest:255 Len:27 Data:41,15,CD,5B,7,80,86,45,D0,C0,B5,BB,F,7,40,D,D0,7,FF,FF,FF,E0,93,0,0,F1,FF
Pri:6 PGN:127501 Source:22 Dest:255 Len:8 Data:2,CD,FF,FF,FF,FF,FF,FF
Pri:6 PGN:130314 Source:22 Dest:255 Len:8 Data:0,2,0,0,A0,F,0,FF
Pri:2 PGN:127245 Source:22 Dest:255 Len:8 Data:1,F9,97,FC,69,3,FF,FF
Pri:6 PGN:127501 Source:22 Dest:255 Len:8 Data:3,FF,DF,FF,FF,FF,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:6 PGN:127508 Source:22 Dest:255 Len:8 Data:1,F8,4,FF,7F,FF,FF,1
Pri:6 PGN:127508 Source:22 Dest:255 Len:8 Data:0,64,5,A,0,FF,FF,1
Pri:6 PGN:130316 Source:22 Dest:255 Len:8 Data:1,1,4,74,7D,4,84,B
Pri:6 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,4,F2,72,23,73,FF
Pri:6 PGN:130311 Source:22 Dest:255 Len:8 Data:1,4,F2,72,B6,35,F6,3
Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:1,C1,70,95,74,F6,3,FF
Pri:6 PGN:127513 Source:22 Dest:255 Len:8 Data:1,D2,1,9A,1,5F,82,61
Pri:6 PGN:127506 Source:22 Dest:255 Len:9 Data:1,1,1,56,5B,8C,5,D2,0
Pri:2 PGN:127257 Source:22 Dest:255 Len:8 Data:1,E3,FD,A3,1,AF,FA,FF
Pri:6 PGN:127489 Source:22 Dest:255 Len:26 Data:0,A0,19,B,E,C5,8A,8D,5,39,0,4C,6B,75,0,FF,FF,FF,FF,FF,1,0,0,0,7F,7F
Pri:6 PGN:127493 Source:22 Dest:255 Len:8 Data:0,FC,4C,1D,3B,D,5,FF
Pri:3 PGN:126992 Source:22 Dest:255 Len:8 Data:1,0,93,44,0,73,F4,24
Pri:6 PGN:129029 Source:22 Dest:255 Len:47 Data:1,93,44,0,73,F4,24,0,80,2,D6,50,2E,57,8,0,80,76,D2,4E,5C,1F,3,A0,37,A0,0,0,0,0,0,10,1,C,50,0,32,0,DC,5,0,0,1,F0,0,C8,0
Pri:6 PGN:129539 Source:22 Dest:255 Len:8 Data:1,6C,78,0,B0,FF,FF,7F
Pri:2 PGN:127250 Source:22 Dest:255 Len:8 Data:0,1A,9B,F4,FD,C0,3,FD
Pri:6 PGN:129038 Source:22 Dest:255 Len:27 Data:41,15,CD,5B,7,80,86,45,D0,C0,B5,BB,F,7,40,D,D0,7,FF,FF,FF,E0,93,0,0,F1,FF
Pri:6 PGN:127501 Source:22 Dest:255 Len:8 Data:2,CD,FF,FF,FF,FF,FF,FF
Pri:6 PGN:130314 Source:22 Dest:255 Len:8 Data:0,2,0,0,A0,F,0,FF
Pri:2 PGN:127245 Source:22 Dest:255 Len:8 Data:1,F9,97,FC,69,3,FF,FF
Pri:6 PGN:127501 Source:22 Dest:255 Len:8 Data:3,FF,DF,FF,FF,FF,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Pri:3 PGN:129026 Source:22 Dest:255 Len:8 Data:1,FC,D0,4E,A,0,FF,FF
Pri:3 PGN:127488 Source:22 Dest:255 Len:8 Data:0,F8,43,FF,FF,7F,FF,FF
Title: Re: NMEA 2000 Shield
Post by: marcop20 on Sep 21, 2017, 02:34 pm
Timo...
I forgot ..... if you have a version of the new library I would be happy to test it.
And .... thanks again for all the work you did
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Sep 21, 2017, 02:52 pm
Method 2 is not right and good solution. Also your record did not had any message from Lowrance. Was it connected? Sorry I forgot to say that you have to comment line
Code: [Select]
// NMEA2000.EnableForward(false); // Disable all msg forwarding to USB (=Serial)
And you should:
- Program Mega with some dummy program, which does not communicate with N2k bus
- Turn Lowrance on. Should not have any Temerature monitor info!
- Open Mega serial monitor
- Program TemperatureMonitor to Mega
- Now it Mega should start after delay(5000) - did you add it - to initialize it on the bus

Also leave peridical SendProductInformation away from this test. I would like to get list of conversation between Mega and Lowrance. I am looking for, which message it uses for query.

You can send you email with private message, so I can send code to you.
Title: Re: NMEA 2000 Shield
Post by: marcop20 on Sep 21, 2017, 08:17 pm
Hi Timo ....
I compared the two logs obtained with and without the modification in the loop .....

It looks like PGN: 126996 is not sent


Title: Re: NMEA 2000 Shield
Post by: pkeiramo on Oct 03, 2017, 11:27 am
Hello Timo and thanks for the great job you have done!

I'm trying out to use your NMEA0183 library and NMEA0183ToN2k.ino example within it.

I can't compile it because it seems that HardwareSerial.availableForWrite() method is not implemented for Arduino Due. How did you get around this? I understood that you have used Due also.

I have Arduino Time library, Standard C++ library for Arduino and NMEA2000 library.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Oct 03, 2017, 12:09 pm
They did implemented that for Due some time ago, but it has been left halfway. But you just need to add to both:
"C:\Users\<your account>\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino\Print.h"
and
"C:\Users\<your account>\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\cores\arduino\HardwareSerial.h"

virtual definition under public methods:
public:
...
    virtual int availableForWrite(void) = 0;
...

Then it compiles with DUE too. Note that path depends of your core version, but you understand what files I mean.
Title: Re: NMEA 2000 Shield
Post by: pkeiramo on Oct 03, 2017, 08:18 pm
Yes - now it compiles. Thanks!

My target is to get my old Raymarine RC435 plotter connected to NMEA2000 network. We'll see, how story continues...
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Oct 04, 2017, 01:40 am
Do you need both direction communication? I had problem with due Serial - with lot of traffic both direction it stopped communication time to time. That was before there was availableForWrite. I do not know about other Serials.

Keep me updated - I may have unpublished code/ideas.
Title: Re: NMEA 2000 Shield
Post by: pkeiramo on Oct 04, 2017, 11:49 am
I think that there is no need to send any messages to plotter. It can receive only WPL and RTE messages and I don't see much use for sending them to plotter from network.


But you'll never know - maybe appetite grows during coding. I'll keep you updated.
Title: Re: NMEA 2000 Shield
Post by: Rinkelein on Oct 07, 2017, 12:29 pm
Dear Timo,

On August 2nd I indicated that we would purchase the MCP2551 in order to be able to send PGN´s to the backbone. In the meantime the chip has arrived an we were able to make it work as the photo´s will prove.

Many thanks and for those who can read Dutch, please visit my website. Apart from being able to read and write to the backbone I also managed to convert the PGN´s into NMEA0183 and send them over WiFi and use if with OpenCPN.

http://rinkelein.000webhostapp.com/NMEA2000.html

Title: Re: NMEA 2000 Shield
Post by: Heikkif on Nov 27, 2017, 08:20 pm
Thank you Timo for great work on this,

I was able to read data from NMEA 2000 bus to Arduino Due but sending data to bus so that it could be seen on Garmin GNX 20 does not seem to work. I have connected both with MCP2562 as the drawing here shows:https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoDUE_CAN_with_MCP2562.pdf and also with this: http://copperhilltech.com/can-bus-mini-breakout-board. This test arrangement for hardware works http://copperhilltech.com/blog/app-note-testing-arduino-due-with-2-can-bus-breakout-boards/. I have uploaded sketches temp monitor and wind monitor as they are in examples folder but no wind data nor temp data when eco/temp sensor is not present can be seen on display. Only data source visible is the eco/temp sensor when it is connected. Actisense reader sees transmission when requested lines are commented/uncommented for testing. Library is of latest version.

Any advice how to debug this futher?

Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 27, 2017, 09:43 pm
I just tested few days ago TemperatureMonitor example with due and it works as it should. Some things:
- Remember to use at least one terminator resistor on bus even with short test bus wires.
- Check that you use due_can from my repository: https://github.com/ttlappalainen/due_can . Others does not compile or possibly does not work right.

Have you checked that you see any data e.g. with example ActisenseListener?
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Nov 29, 2017, 08:51 pm
Hi again Timo,

Made sure the due_can is the correct one from your repository. There is a termination resistor on the bus but only at the other end when using MCP2562. When uncommenting
 Serial.begin(115200);
 NMEA2000.SetForwardStream(&Serial);
and commenting //NMEA2000.EnableForward(false); Actisense NMEA Reader shows the data being sent
but nothing can be seen on display. Log shows some timeouts on updating operating mode, product info, configuration info. There is one unknown line on data view PGN 126993 and ISO address Claim seems to come when reset is pushed.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 30, 2017, 08:21 am
Uncomment also NMEA2000.SetForwardType(tNMEA2000::fwdt_Text); and look due output with serial monitor in. In text mode it shows possible internal errors in clear text. I expect you would get "Send failed" text.

When you read messages from sender USB, it shows messages, which it has tried to send to the bus. It does not mean that they have gone out to the bus from the lower level library. So in text mode you will see if libray buffers start to over run dues to sending proboem.

It is still unclear for mee, which side you read ISO address claim and 126993. Do you have other board connected to the bus or just due and you read its USB?

126993 is heartbeat PGN and old NMEA Reader does not know it.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Nov 30, 2017, 06:50 pm
Here is what is seen on serial monitor:

Initialize buffers
CAN device ready
Start address claim for device 0
202 : Pri:6 PGN:60928 Source:22 Dest:255 Len:8 Data:69,B6,1,FF,0,82,96,C0
2703 : Pri:6 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,4,7D,73,FF,FF,FF
2703 : Pri:6 PGN:130311 Source:22 Dest:255 Len:8 Data:1,44,7D,73,FF,7F,FF,FF
2705 : Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:1,C1,70,FF,FF,FF,FF,FF

that goes on until

45220 : Pri:6 PGN:130311 Source:22 Dest:255 Len:8 Data:1,44,7D,73,FF,7F,FF,FF
PGN 130310 send failed
45224 : Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:1,C1,70,FF,FF,FF,FF,FF
PGN 130312 send failed
47721 : Pri:6 PGN:130312 Source:22 Dest:255 Len:8 Data:1,1,4,7D,73,FF,FF,FF
PGN 130311 send failed
47721 : Pri:6 PGN:130311 Source:22 Dest:255 Len:8 Data:1,44,7D,73,FF,7F,FF,FF
PGN 130310 send failed
47729 : Pri:6 PGN:130310 Source:22 Dest:255 Len:8 Data:1,C1,70,FF,FF,FF,FF,FF

It makes no difference if arduino is connected to bus with display or not. So far I have tried only with one arduno. I have two arduinos and available so I could add another to the bus and see what it sees an the bus. Would Actisense listener be the sketch to download to the other arduino? So far I only have tested hardware with one arduino with this test program:
 http://copperhilltech.com/blog/app-note-testing-arduino-due-with-2-can-bus-breakout-boards/
 and it works and also have been able to read depth sounder from the bus.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Nov 30, 2017, 08:45 pm
That was I expected. When it comes to situation that send fails continuously, internal buffers are full and so it gives error. This means that no message goes out. This is normally caused, when there is no connection to the bus. Most common error has been that CAN-L and CAN-H has been crossed or chip (MCP2562) STBY signal is not connected to GND. Also missin terminal resistor is common reason, but that you already checked.

I just made a test with due. When it is connected to the bus, but there is no other devices on, it start to give error. Immediately, when I turn on any other device, it start to send normally.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Nov 30, 2017, 09:21 pm
With the same connection I can read depth sounder info from the bus so the connection could be ok. Also that two channel test shows the connection should be ok.  Could it be that GNX 20 is "refusing" to communicate with non genuine NMEA 2000 device? Would it be interesting to know if the other arduino with actisense listener sketch is reading what the other with temperature monitor is sending? Would two arduinos one sending  and one recieving see each other as devices on the bus?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 01, 2017, 05:48 am
N2k bus devices does not normally care who is sending data. They can show e.g. speed data even knowing anything about sender device. This of coarse may denpend of MFD, but e.g. my Garmin GMI 20 does not care. It just shows on devices "unknown device"

Two Arduinos communicate also well. There are examples MessageSender and DataDisplay2, which I have used to test different messages. They does not act as like normal N2k bus device. TemperatureMonitor is the most closes of certified device. So by connecting two TemperatureMonitor to the bus, they do all handshaking and sees each other, but since they are just sending data, they does not listen each other messages. If you change mode to N2k_ListenAndNode and enable message forwarding, then they will forward others messages.

I have to do some more tests. If you have some device sending on bus, then everything works fine, when you connect device. If I start due first and then connect my MFD, it start to work right. If I have due and then connect other TemperatureMonitor, it may get totally blocked.

So you could try cnnecting your MFD, depth sounder and due to the bus and then start due.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 01, 2017, 06:46 pm
I was testing Wind Monitor with eco and display last autumn but no wind info showed up on the display. It was then when I was able to read depth from the bus. Now depth sounder is at the boat and arduino and display are at home.
 When testing two arduinos in the bus should they be connected with separate T-connections or is it ok to connect them at the same branch?
 Can the send failed caused by failing hand shake? I will test two arduinos this weekend. The other could be loaded with TemperatureMonitor but which sketch to load to the other?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 01, 2017, 08:00 pm
For test bed it is enough to connect CAN-L/CAN-H with wires. I personally do not use M12 connectors at all, since they require so much space. Instead I use pluggable board connectors (see e.g. farnell codes 1717013 and 1717025 Connector order is shown on my drawing https://github.com/ttlappalainen/NMEA2000/blob/master/Examples/TeensyActisenseListenerSender/Documents/Teensy_Actisense_listener_sender_schematics.pdf). With those you can make CAN bus divider for 5 connectors to 100x55x40 mm box with about 20 €.

Due should work with just display connected. You could also use ActisenseListener example on due and when you turn on display, it should send ISO Address (PGN 60928) claim at the beginning. It is strange, if you do not receive anything from display.

There is actually no handshaking betwee N2k devices. They just do address claiming, which means they ask "I would like to use address 20". If other devices on the bus are happy for that, thats it. If there is other device using address 20, it compares its "name" to other and then either responces "I have address 20" or "I would like to use address 21" depending of priority of "name". All this will be done just using ISO address claim PGN.

The block I caused on my test was because of having two TemperatureMonitor with same "name" on the bus. This should never happen, since as I have documented for SetDeviceInformation: "Each device from same manufacturer should have unique number.". So if you have two TemperatureMonitor, you have to compile one with e.g. Unique number=112233 and other with Unique number=112234
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 03, 2017, 05:03 pm
Played with two dues and display connected as a bus. Both dues can see display info trough actisense listener as it is turned on. When the other due has Temperature monitor loaded it can't be seen on the other board with actisense listener. Also send failed appears after a while as previously.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 04, 2017, 04:13 pm
Unfortunately I can not produce that. I have only one due, so I can not test with two dues. But with due/TemperatureMonitor and Teensy/ActisenseListener it works fine. If I disconnect Teensy, "Send failed" appears, but immediately after powering it on, also due starts to send.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 06, 2017, 05:33 pm
To exclude software problem is it possible to download program to due from a file instead of first compiling it from sketch and libraries on my own computer? If so then both problems with libraries and Arduino programming IDE on my computer would be excluded.  Other way around would be to test my hardware with known working environment.
I think I have the correct due can and NMEA 2000 due as if I remove either of them compiling fails and when I download them from your repository compiling is successful.  Could there be a problem in the IDE on my computer?
I have two different CAN transceivers and they both receive but neither of them send with this software. Anyhow I have tested them both with a test program behind this link and it says they are ok: http://copperhilltech.com/content/Due_2CAN_Channel_Test.zip
After testing i have removed all of that CAN stuff from my computer.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 06, 2017, 06:21 pm
I have IDE 1.83, I do not believe that is the problem. Could you recheck STBY pin on MCP2562! In Coppertechhill code there is code:
Code: [Select]
cRetCode = Can0.begin(lBaudrate, ENABLE_PIN_CAN0);
and
#define ENABLE_PIN_CAN0      62

In my examples there is no enable pin used and STBY has been expected to be connected to GND. Start e.g. TemperatureMonitor and measure with voltmeter that STBY has 0 voltage.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 06, 2017, 07:37 pm
The IDE on my computer is the same then. Pins 2 and 8 are connected to ground on MCP2562. If i solder another MCP2562 with connections for due and mail it to you after having tested what it does would you test it yourself? You would not have to return it.
Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 06, 2017, 10:03 pm
Hi Timo and all.

I'm new here and for starters I'd like to say thanks to all of you for contributing tons of useful information on this topic. In fact, the info is so much it is overwhelming, for me being a newbie anyway.

Since this topic was started lots have changed with regards to new hardware available and changes to sketches as well, where to start.

I guess keeping it simple is the way to go for starters.

Basically I need some guidance as to what direction to go in in order to inject IMU heading data into my fishing boat NMEA2000 network.

I don't have any hardware yet so this is a fresh start, I'd like to keep it as cheap, small, simple and the least power consuming as possible. (with "No Hardware" I'm not referring to my boat equipment, I mean no MicroPrcessor Unit, CanBus Shield, Serial Converters etc.)

At a later stage I'd like to further my knowledge with NMEA0183 <-> NMEA2000 data sharing and monitoring.

Some direction and opinions would be much appreciated.

Thanks guys.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 06, 2017, 10:07 pm
Heikkif - yes, I can test it.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 06, 2017, 10:17 pm
As I have many times mentioned on this list I prefer at least Teensy 3.2. It draws only 90 mA current.

But before goint to hw, it is best to have some kind of idea about the goal. Either you did not mention what your IMU sends.
Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 06, 2017, 10:29 pm
As I have many times mentioned on this list I prefer at least Teensy 3.2. It draws only 90 mA current.

But before goint to hw, it is best to have some kind of idea about the goal. Either you did not mention what your IMU sends.
Haven't bought any components yet, I was hoping for good recommendations before I go out and spend money.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 06, 2017, 10:56 pm
Yes, but I can not give any recommendations, if you do not define any goal. And what about IMU - do you have any? Do you have or have you planned to buy some MFD? What sensors you would like to have? Did you thought to use PC, phone tablet? Etc.
Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 07, 2017, 12:21 am
I was thinking of using the SparkFun 9DoF Razor IMU, can it be combined with your Teeny 3.2 setup in order to inject heading data to NMEA2000 network?

I would probably use my PC for starters to set everything up and monitor for correct operation, thereafter it should be externally powered and run as a standalone system as to have a stable heading on my Lowrance Elite 7Ti unit.
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 07, 2017, 05:24 am
One company has started to make Teensy based sensor boards for NMEA2000. They contacted me due to my library and send me some sample boards. There is one nice ready IMU board. I can ask are they ready to sell.

On the other hand I have tested different IMU:s and none of then can not beat my GPS compass, which gives reliable 1 deg heading in any condition and boat tilt. You can get reasonable GPS compass in about 1000 € or spent 50-100 hours with IMU:s.
Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 07, 2017, 11:24 am
One company has started to make Teensy based sensor boards for NMEA2000. They contacted me due to my library and send me some sample boards. There is one nice ready IMU board. I can ask are they ready to sell.
I'd be interested thanks

You can get reasonable GPS compass in about 1000 € or spent 50-100 hours with IMU:s.
Lowrance Point 1 GPS/Heading antenna €280, but that defeats the object of accomplishing the task myself as a project.

Thanks for your input.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 07, 2017, 05:18 pm
Hi Johannes and Timo,

A bit offtopic maybe. I have been building compass also. It works but accuracy is not within 1 deg more like 3 degs. Self made compass might be feasible to control tiller pilot as gyro and heel data is also available from IMU.  I am using DUE for this as it was the first thing I bought for another purpose. Sparkfun has currently 3 products for this purpose. There are other sources also. For MPU 9250 there is no library from Sparkfun that would run on DUE. Haven't found elsewhere either. I am using LSM9DS1 which I can read to DUE. Otherwise ok but magnetometer needs temperature compensation and that I had to program on Arduino. I haven't found out how sensors own temperature compensation works. The sensor has temperature output but it looks like the resolution is a bit coarse compared to the slope of compensation needed. That limits the accuracy. LSM9DS1 means lot of calibration and each sensor needs its own calibration so if one needs to replace the sensor the calibration has to be done again.   Third one on Sparkfun would be that razor Johannes mentioned. It uses MPU 9250. It is not clear to me if the libraries can be loaded to for example teensy as well. If so then why not to use MPU 9250 and some board that is easily CAN-compatible. MPU 9250 should have factory calibration data stored in it. I do not know if the sketches can use it. People mention good calibration is needed with MPU 9250 also.
Some links worth checking:

http://sailboatinstruments.blogspot.fi/2014/08/a-low-cost-marine-compass-part-3.html
http://sailboatinstruments.blogspot.fi/2016/04/building-your-own-nmea-2000-device.html (this made me buy DUE when I found out Garmin GNX 20 does not have shallow water alarm)
http://www.pypilot.org/
https://github.com/seandepagnier/RTIMULib2
https://github.com/kriswiner/MPU9250
https://create.arduino.cc/projecthub/mitov/arduino-accelerometer-gyroscope-compass-mpu9250-i2c-sensor-79f5bf


Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 07, 2017, 05:47 pm
Thanks Heikkif, I'll look at your links and see what I can find useful.

I see the Genuino 101 has onboard IMU, wonder if this is worth looking at and if it would be compatible with the Tweeny 3.2 setup to get IMU data onto the Can Bus network?
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 07, 2017, 08:43 pm
"I see the Genuino 101 has onboard IMU" It has gyro and accel but for compass magnetometer is also needed.
Title: Re: NMEA 2000 Shield
Post by: Johannes_BlackSam on Dec 07, 2017, 09:07 pm
"I see the Genuino 101 has onboard IMU" It has gyro and accel but for compass magnetometer is also needed.
Aahaa, thanks mate
Title: Re: NMEA 2000 Shield
Post by: autopilotNOR on Dec 09, 2017, 02:50 pm
Hi,

I want to try to use a DUE to translate all the analog engine data from my V8 to be shown on my Raymarine Axoim through NMEA2000.

To do so I wanted to play a bit with the DUE and the multidevice example file.
I get this error while compiling it:

"In file included from /home/thomas/Arduino/libraries/NMEA2000_due-master/NMEA2000_due.cpp:28:0:
/home/thomas/Arduino/libraries/due_can-master/src/due_can.h:23:24: fatal error: can_common.h: No such file or directory
 #include <can_common.h>"

I added all the libraries from github which where asked for, also the due_can but without  luck.

First I tried it under Windows but there I got a lot of error due to the path to the libraries as there where wirtten / instead of \ in the pathes (if this was the reason for).

So can you help to find why it wants the can_common.h even if it not existing in the due_can libraries or what I am doing wrong?

I just choosed the example "MultiDevice" and added  the NMEA200_DUE librarie due to I want to use the Due.

Regards!
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 09, 2017, 07:24 pm
I have not yet updated the docs. Collin has made some changes and it does not compile anymore and I have not had time to check those. Please remote you current due_can completely and install the one under my repositories: https://github.com/ttlappalainen/due_can

In c/c++ language one should use only /, since then code in compatible with Linux and Mac. Translator will take care of right way of pointing directories.

Also I do not any use for you to start with MultiDevice example. I prefere to use some simpler example like TemperatureMonitor.
Title: Re: NMEA 2000 Shield
Post by: Heikkif on Dec 10, 2017, 05:23 pm
Hi again Timo,

I soldered another MCP2562 with connections for DUE. Is it ok to post it to Kave Oy with your name?
Title: Re: NMEA 2000 Shield
Post by: timolappalainen on Dec 10, 2017, 05:37 pm
Please send me personal message, so I'll give you address.