Go Down

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

timolappalainen

I did not understood your questions?

There is now way to see if some unit sends false information. What do you mean with fresh? Due to normal collisions messages may be delayed. Sending one frame (8 bytes) takes about 400 us. So you can expect frame to be time to time delayed that much due to collision.

PGN 127250 is for heading. If true heading has been used deviation and variation should be set to not available. If message has been sent by magnetic compass, it can provide those values. Variation should be fixed on location and deviation should come from compass deviation table.

Possible referencies on NMEA 200 library are simply N2khr_true or N2khr_magnetic.

Heikkif

Is there a way to see if a message is sent by other devices and how long ago it was last sent?

When reading heading what is the variable type for reference? I mean like double, float, boolean, integer and so on. With GPS compass I can send TrueHeading without defining that variable.  Reading heading from bus to other device needs to have all variables or it does not compile for me.

timolappalainen

The only way is to save in your device internally for each message time stamp, when you last received it.

If you mean my NMEA2000 library SetN2kTrueHeading function that actually calls SetN2kPGN127250 with all parameters by setting deviation and variation to NA and reference to N2khr_true.

If you read heading from bus ParseN2kHeading you can see in header file the types:
ParseN2kHeading(const tN2kMsg &N2kMsg, unsigned char &SID, double &Heading, double &Deviation, double &Variation, tN2kHeadingReference &ref)
So reference type is enum tN2kHeadingReference. See example DataDisplay2 and function
void Heading(const tN2kMsg &N2kMsg)
You must handle reference variable so that you know is sent andle true or magnetic.

Celso_Kupsch_Junior

I'd be happy to help. PM sent.
Hello @Allen652, can you give me The arduino connection diagram with The motor and nmea?

joe3982

Hi All,

When using timolappalainen's N2k library with the Teensy 3.6, I assume it defaults to CAN0. Is that correct?

If so, how would I go about setting it to CAN1?


timolappalainen

Currently there is no CAN port definition, if you use simple method by including NMEA2000_CAN.h. Instead of having
Code: [Select]
#include "NMEA2000_CAN.h"
on beginning of your project you include necessary libraries and define NMEA2000 object with can index 1 directly:
Code: [Select]
#include "N2kMsg.h"
#include "NMEA2000.h"
#include <FlexCAN.h>
#include <NMEA2000_teensy.h>
tNMEA2000 &NMEA2000=*(new tNMEA2000_teensy(4,1));

joe3982


felipemasuda

#922
Jul 17, 2020, 07:20 am Last Edit: Jul 17, 2020, 07:25 am by felipemasuda
Hi guys, I'm trying to read the information from a Garmin GPS19x NMEA 2000 (I only have it on my network) to my Arduino Mega, I put the DataDisplay2 on my arduino with this sentence in the begging: #define MCP_CAN_CLOCK_SET MCP_8MHz
because I'm using this little guy here: https://www.makerfabs.com/can-module-mcp2515.html
I already conected two 120 ohms resistor between my can high and can low output
All the other conections are already done (Pin 21, 50, 51 , 52 and 53), but I only get this message on my serial monitor "CAN device failed to open"
Does anyone know how can fix it, please?

timolappalainen

"CAN device failed to open"  simply means that library can not communicate with can controller.

You have wrong definition for clock set. See NMEA2000_CAN.h descriptions on the beginning.
The right definition is:
#define USE_MCP_CAN_CLOCK_SET 8

felipemasuda

"CAN device failed to open"  simply means that library can not communicate with can controller.

You have wrong definition for clock set. See NMEA2000_CAN.h descriptions on the beginning.
The right definition is:
#define USE_MCP_CAN_CLOCK_SET 8
Thank you, now I can get some datas, but I only get 129026 information instead 129029. It's strange because I only have a Garmin GPS19x NMEA2000 on my bus.


This is what I got:
CAN device ready
Running...In Main Handler: 129025
In Main Handler: 129025
In Main Handler: 129026
COG/SOG: 243
  reference: true
  COG (deg): 0.00
  SOG (m/s): 0.04

timolappalainen

There seem to be default receive frame buffer only 2 for mcp_can. Uncomment line
//  NMEA2000.SetN2kCANReceiveFrameBufSize(50);
To set it 50. You may need to reduce it smaller due to low RAM on Arduino Mega.

felipemasuda

There seem to be default receive frame buffer only 2 for mcp_can. Uncomment line
//  NMEA2000.SetN2kCANReceiveFrameBufSize(50);
To set it 50. You may need to reduce it smaller due to low RAM on Arduino Mega.
Thanks Timo, everything is running good! Sorry to bother you again, but is it possible to get more decimal places on Latitude and Longitude informations?

timolappalainen

DataDisplay2 is one example how you can catch messages and parse their data. You should study it and understand the idea and build your own code for handling data. With parse functions you get data in full resolution double (note that on Mega double is actually float), which you can handle as you like. The DataDisplay2 example is not very usable execpt as example of using library functions.

Go Up