Go Down

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

timolappalainen

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)

seamaster

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?
 

timolappalainen

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.

seamaster

#168
Feb 21, 2017, 08:06 am Last Edit: Feb 21, 2017, 08:58 am by seamaster
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)

timolappalainen

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.

seamaster

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?



timolappalainen

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.

seamaster

Hi Timo,
Excuse my ignorance but I'm not exactly clear what sources I need to download?

timolappalainen

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.

flemmingdjensen

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?

timolappalainen

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.

flemmingdjensen

#176
Mar 20, 2017, 08:57 pm Last Edit: Mar 20, 2017, 09:07 pm by flemmingdjensen
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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy