Go Down

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

autopilotNOR

NMEA0183 -> NMEA2K & Teensy 3.2 & Linx GM gps module

I order to translate the 0183 messages of an GPS module I tried this library.

I tested the module with the Adafruit library on Serial3 (pin 7 & 8 on Teensy 3.2), I have uncommented to show in clear type and I uncommented NMEA200EnableForward(false).

The handlers are still like default   InitNMEA0183Handlers(&NMEA2000, &BoatData);
  NMEA0183_3.SetMsgHandler(HandleNMEA0183Msg);

the baudrate of the gps module is correct (9600) update every second.

I do see anything in the serial monitor.

What is missing to get the gps and heading data into NMEA2K?

Sorry if this is again a stupid question...

timolappalainen

I have tested that only with NMEA0183 from port 3 -> NMEA2000 bus converter. So as default it does not send anything to USB.

After Serial.begin(115200); you must have NMEA2000.SetForwardStream(&Serial); to define where forwarded messages will be send. Then do not uncomment NMEA200EnableForward(false); since that tells library not to forward anything to forward stream.

autopilotNOR

Ok I thought that forward(false) ignores that there is no BUS available. I`ll try.

jsholovitz

I have a question that I hope you can help with.

Let me first describe my hardware:
  • Arduino Due
  • MCP2562
  • Wiring exactly as described in ArduinoDUE_CAN_with_MCP2562.pdf


My overall setup is using the Arduino to receive messages from the N2K bus.

The results I'm seeing are not as expected. The following 3 screen captures all had about 5 minutes of running the application to collect data before each:

When I use the sketch ActisenseListener, I see all of the PGNs that I think should be there:



When using the ActisenseListenerSender sketch, I see fewer PGNs - for example, the AIS Class A data is missing:


And when using the ArduinoGateway sketch, all of the AIS data is now missing:


Thoughts? Help, please!

timolappalainen

No good ideas. They all have small differences. Message forwarding uses same method on all.
- ActisenseListener just listens and forward messages.
- ActisenseListenerSender also polls serial. This could somehow disturb, but should not.
- ArduinoGateway does same as ActisenseListenerSender, but also shows itself on the bus. After it has done address claiming, it does not send much to the bus. There will be only time to time requests from other devices.

With 5 min period you should see all messages anyway. Any slowdown caused by extra polling of other serial is random and should not effect with that long period.

Some questions:
- Which version of Actisense Reader you run the tests?
- Did you close and restart NMEA Reader between each test?
- Do you have other system like Teensy for making same test?
- Can you make same test by feeding Due bus with other device and with NMEA Simulator?

jsholovitz

Thanks, Timo

Here are a few responses:


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


Any other thoughts? Thanks!

popeye_70

Hi all,
anyone tried this actisenselistnersender to connect and program the Actisense EMU-1 interface? Like a true NGT-1 cable?
Thanks

timolappalainen

Actisense NGT-1 has special messages e.g. for configuring it. I think Actisense configuration tool may require right response from NGT-1 before it continues. ActisenseListenerSender transfers only NMEA 2000 messages in Actisense format and does not respond to any Actisense NGT-1 specifig messages. So it may be that it will not work.

pronaga

Hi Timo,

I am a beginner in Arduino programming!

I would like to send fuel rate in the nmea 2000 bus.
As a first step I modified your sketch" temperature monitor" to read the fuel rate with Actisense NMEA Reader, but  tells me error to the SetN2kEngineDynamicParam line "fuelRate was not declared in this scope"

This is the sketch. Can you help me! Thank you!

// Demo: NMEA2000 library. Send fuel rate data 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={127489L,0};

void setup() {
 // Set Product information
 NMEA2000.SetProductInformation("00000002", // Manufacturer's Model serial code
                                100, // Manufacturer's product code
                                "Simple fuel rate  monitor",  // Manufacturer's Model ID
                                "1.1.0.22 (2016-12-31)",  // Manufacturer's Software version code
                                "1.1.0.0 (2016-12-31)" // Manufacturer's Model version
                                );
 // Set device information
 NMEA2000.SetDeviceInformation(1, // Unique number. Use e.g. Serial number.
                               160, // Device function=FLOW. 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
                               2046 // 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,23);
 NMEA2000.SetDebugMode(tNMEA2000::dm_Actisense); // Uncomment this, so you can test code without CAN bus chips on Arduino Mega
 //NMEA2000.EnableForward(false);
 NMEA2000.ExtendTransmitMessages(TransmitMessages);
 NMEA2000.Open();
}


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

double ReadFuelRate() {
 return 30; // Read here the measured flowrate e.g. from analog input
}

#define FuelRateUpdatePeriod 1000

void SendN2kFuelRate() {
 static unsigned long FuelRateUpdated = millis();
 tN2kMsg N2kMsg;

 if ( FuelRateUpdated + FuelRateUpdatePeriod < millis() ) {
SetN2kEngineDynamicParam(N2kMsg,0,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,FuelRate,N2kDoubleNA);

NMEA2000.SendMsg(N2kMsg);
   FuelRateUpdated = millis();
   NMEA2000.SendMsg(N2kMsg);
    }

timolappalainen

Hi,

Have you used some other languages than C++?

This is normal for undefined variables - in this case FuelRate. C++ is strict language and requires that everything you use must be defined. Note that it is also case sensitive. E.g. Visual Basic does not require that all variables should have been defined (e.g. with Option Explicit).

So instead using undefined FuelRate in call use
SetN2kEngineDynamicParam(N2kMsg,0,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,N2kDoubleNA,ReadFuelRate(),N2kDoubleNA);

Note also that you call NMEA2000.SendMsg(N2kMsg); unnecessarily twice at the end. It just sends same message twice with very short period, which is not good.

You have no chosen the easiest task. If you read previous posts, you should find some information what problems you will have with measuring fuel rate. Fuel rate reading may have a lot of noise and variation, which you should filter with averaging or with low pass filter.

pronaga

thanks for the reply!
You are always friendly and helpful!
At the moment I just want to read the fixed value "30" on actisence reader!

autopilotNOR

Hello Timo,

just a short question regarding CANbus using Teensy 3.2. I need to use CANBus1 instead.
Can I force to use can0 by this?

#define CANbus Can1


The NMEA2000_teensy is written for teensy 3.1&3.2 right?!
I would like to use a teensy 3.5, will this work or is it necessary to make huge changes to the NMEA200_teensy?

Thank you!
Regards..

timolappalainen

Teensy 3.2 has only 1 CAN bus, so you can not use Can1. Only Teensy 3.6 has 2 CAN busses. Currently there is no definition on NMEA2000_CAN.h for selecting secondary CAN bus. You can use it anyway, if you force to use NMEA2000_teensy. So instead of having

#include <NMEA2000_CAN.h>

you use

#include <N2kMsg.h>
#include <NMEA2000.h>
#include <NMEA2000_teensy.h>

...

tNMEA2000 &NMEA2000=*(new tNMEA2000_teensy(4,1));


Library works fine with Teensy 3.2 ... 3.6


autopilotNOR

Of course, you are right with that there is just one can bus... damn. It was I2C I was looking at.

regarding the #define CANbus Can1, this is defined in the NMEA2000_teensy.h file. At least there I found this part which has brought me to this idea.
I also thought that it is necessary to use the NMEA2000_teens.h instead of the NMEA2000_can so I used it all the time?!

But if the 3.5, which I have here as well, have the can bus at other pins or more than one canbus everything is fine.

I bought the 3.5 once to have the card slot already integrated since I wanted to add some engine and tour logging. But from this plans, I am still far away..

timolappalainen

I could not found any #define CANbus Can1 on any NMEA2000_teensy file. Where you have copied those files? I prefer to use files under my git to ensure compatibility.

You have to study how to change to alternate pins for CAN on Teensy 3.5. Again 3.5 has only one CAN and 3.6 has two can.

Go Up