ttlappalainen / NMEA2000

NMEA2000 library for Arduino
535 stars 226 forks source link

ParseN2kWaterDepth Parsing -> depth not available #73

Closed ronzeiller closed 7 years ago

ronzeiller commented 7 years ago

Parsing PGN 128267 Water depth with function from NMEA Library as written in display2.ino

PGN is coming from Kave simulator standard settings. But PGN128267 Water depth is messaging: "Water depth is not available"

Should there not be a "!" in line 407? if ( ! N2kIsNA(DepthBelowTransducer) ) { ...... } otherwise it will always jump to "not available"

ttlappalainen commented 7 years ago

Yes, thanks. This is tested code:) I'll fix it to next release of library hopefully on this week.

BTW with curren code it will not allways jumpt to "not available". In case value would be NA, it would show you crazy depth. Value can be NA depending of transducer. Some transducers may send NA for depth to deep to measure.

ttlappalainen commented 7 years ago

I made a separate fix.

ronzeiller commented 7 years ago

Great, thank you 👍

ronzeiller commented 7 years ago

A short follow up question just arose: if ( N2kIsNA(Offset) ) { WaterDepth = DepthBelowTransducer; } else { if (Offset>0) { OutputStream->print("Water depth:"); } else { OutputStream->print("Depth below keel:"); } }

If Offset == 0 should there not also be DepthBelowTransducer? Like: if ( N2kIsNA(Offset) || Offset == 0 ) {......

ttlappalainen commented 7 years ago

Maybe you are right. 0 would be actually a bit crazy value. It means that you have transducer on the surface, where is won't work reliably. I changed code to: if ( N2kIsNA(Offset) || Offset == 0 ) { PrintLabelValWithConversionCheckUnDef("Depth below transducer",DepthBelowTransducer); if ( N2kIsNA(Offset) ) { OutputStream->println(", offset not available"); } else { OutputStream->println(", offset=0"); } } else {

ronzeiller commented 7 years ago

Hmm, I think offset = 0 just means Water Depth below Transducer It makes also sense, when you are looking to the "according" NMEA0183 sentence DBT (Depth below transducer)

See also image taken from Raymarine: image

Some transducers have separate settings for measurement of transducer -> keel and transducer -> water surface.

May be the NMEA2000 PGN is then translated like: If offset > 0 => automatic for Water depth sea If offset < 0 => automatic for Depth below keel or more general Depth from bottom of boat (as you had in debug print in your code.)

On chartered boats they sometimes make higher negative offset for to keeping people off shallow water :-)

ttlappalainen commented 7 years ago

I am not quite sure. Offset should be defined NA for meaning "below transducer". There is no clear document for 0. Document says positive. So is 0 positive? With positive you can show water depth. So if 0 is positive, then it means water level and transducer difference is 0, so it also shows "below transducer", since it is same.

On the picture I do not see any sense for meaning 0 for depth from transducer. It just does not have any sense - who would like to show that specially on sailboat. And it is not first time I see error in Raymarine docs.

ronzeiller commented 7 years ago

Which document?

For Raymarine I totally agree! :-) But in this case is just a matter of definitions and I saw the same image (in principle) at Simrad.

Well, on a motor boat depth from transducer could be possible if it is mounted on the deepest part.

But, to asume 0 as positiv makes sense.

For my use (translation into NMEA0183 DPT sentence) I set offset = 0 if an in coming offset == NA and everything is fine.

ttlappalainen commented 7 years ago

Google "20151026 nmea 2000 pgn_website_description_list". That says only about positive values, but I could not find doc, which defines NA behaviour. It may have been some general doc about NA, which I have "translated" to this.

BTW: I added Range, but did not yet publish it.