NMEA2000 icon indicating copy to clipboard operation
NMEA2000 copied to clipboard

Device only showing up on MFD only on boot up

Open TryingToGITthis opened this issue 4 years ago • 11 comments

I have a Simrad EVO2 and while I reboot or upload new code, the Simrad sees it in the list. However, if after a minute or two I refresh the list, my device disappears. Speeding up heartbeat interval didn't resolve it either. Other devices on the network show up quickly.

As long as I don't refresh the device list on the Simrad, I do see the data I'm transmitting.

What do I need to do to refresh the product info in the device list? I do call NMEA2000.SendProductInformation() every two seconds but that didn't help.

TryingToGITthis avatar May 23 '20 23:05 TryingToGITthis

had problems like that, following Timo's suggestions ended up using:

NMEA2000.SendIsoAddressClaim(); NMEA2000.SendProductInformation(); NMEA2000.ParseMessages();

every 20secs (you need the ParseMessages()!) lately and having sorted all varying issues with my code, I noticed I don't really need that anymore! So as Timo explained, check v.carefully for bits of code that delay loops, examine if messages are indeed sent at right intervals, and go from it

good luck!

V.

virtuvas avatar May 24 '20 05:05 virtuvas

This is not correct!

You should call NMEA2000.ParseMessages(); in loop as often as possible and avoid longer than 40 ms delays between calls. ParseMessages is like a "task", which should run continuosly without delays. Arduino systems except ESP32 does not have tasks, so one should make them. Any other "task" in loop() should be designed so that it does not cause long delay. E.g. default example of DallasTemperature is good example of bad "task", since it stops loop for 700 ms. Instead it should be interrupt driven (possible with Teensy and 1-wire control chip) or at least asynchronous, which lowers delay down to 10 ms.

In your problem first check that your loop runs without delays and calls ParseMessages every time on loop. Make a timer to measure maximum delay time inside your loop.

When you call ParseMessages right in loop, library takes care of right responces to basic bus requests like product information, address claiming etc. If you do not call ParseMessages often enough, library will loose those and cause other systems to loose your device. You need to call SendIsoAddressClaim and SendProductInformation periodically in every e.g. 10 sec ONLY, IF YOU HAVE DEVICES (normally older ones), which does NOT WORK RIGHT on the bus. Either you should not change heartbeat interval.

When you have measured your maximum delay in loop e.g. 20 ms, you need to define receive buffer size. In worst case burst you may get 2.5 frames/ms, so for 20 ms delay you need at least 50 frame receive buffer. I prefer to avoid continuously more than 40 ms delays, since if device does not respond to request fast enough, caller may give up.

Also check that you have 2 120 ohme termination resistor on your bus.

ttlappalainen avatar May 24 '20 08:05 ttlappalainen

apologies Timo, my mistake, yes, I run ParseMessages() in a tight loop, just have the other two in 20sec loop, sorry for confusion!

V.

virtuvas avatar May 24 '20 08:05 virtuvas

Thank you. I did check I my loop was VERY slow. It's now under 20ms. I will test it on the boat in a little bit.

I have one resistor, do I need two? resistor

TryingToGITthis avatar May 24 '20 13:05 TryingToGITthis

One resistor is OK for testing. In final installation on boat there must be two.

Remember that if you dor not use isolated tranceiver, you should not have your device far from NMEA 2000 power feed point. Otherwise you may cause ground loop and get fancy effecs.

ttlappalainen avatar May 24 '20 14:05 ttlappalainen

In series or parrallel?

TryingToGITthis avatar May 24 '20 14:05 TryingToGITthis

Parallel. Between CAN H and CAN L in both end of the main bus.

ttlappalainen avatar May 24 '20 14:05 ttlappalainen

This good? resistor

TryingToGITthis avatar May 24 '20 14:05 TryingToGITthis

Yes, but you must have one resistor on both end of main bus. This means that if your N2k bus goes from aft to bow, you have one resostor on aft and one on bow. Nothing between.

ttlappalainen avatar May 24 '20 15:05 ttlappalainen

I'm plugging this into an existing network with other devices. There are terminators on all ends. So for a single device, I only need a single resistor, correct?

TryingToGITthis avatar May 24 '20 15:05 TryingToGITthis

No. On the whole bus system there should be exactly 2 terminator resistors on one on each end of main bus. There shold not be resistors at the end of stubs. See e.g. https://www.wikiwand.com/en/NMEA_2000

ttlappalainen avatar May 25 '20 02:05 ttlappalainen