Open quantenschaum opened 3 months ago
I agree... Mainly old code there. And switching of computations is for sure a good idea.
OK
The conversions also seem to be wrong.
N2kWind_True_North
is treated as true wind but is actually ground wind ("true" refers to true north not to true wind)WindReference
s are sent as MWV-T
MWV-T
is sent as N2kWind_True_North
TWD
in MWV-T
but should be TWAMWD
sent as N2kWind_True_North
or N2kWind_Magnetic
(ground wind)So, there is a confusion of (see https://github.com/wellenvogel/avnav/issues/367)
For NMEA0183 sentences and PGNs see https://github.com/wellenvogel/avnav/issues/367.
AFAIK there are only 2 possible direct conversions between N2K and 0183.
MWV-R
(AWA/AWS) (as well as VWR
)MWV-T
(TWA/TWS) :exclamation: ANGLE (not direction)There is no PGN containing TWD, it must be calculated as TWD=TWA+HDT to be able to send MWD
(analogous for reception).
There are no NMEA0183 sentences for ground wind.
I suspect that many of the (expensive) devices out there do not exactly follow these specs and send/receive wrong wind data or process them incorrectly. It's a mess. And then you wonder why your $$$ instruments display funny numbers.
To make the converter work correctly with systems that send wrong wind data (i.e. true wind in 130306-True_North [ground wind]) it would make sense to have a config option to select how the data in PGN130306 is interpreted. Like 2 pairs of dropdown boxes N2K <-> 0183 with the following options
N2K | 0183 |
---|---|
0 true north ground dir | AWA/S |
1 magnetic ground dir | TWA/S |
2 apparent angle | TWD/S |
3 ground angle | GWA/S |
4 true angle | GWD/S |
Then you could select something like
2 apparent angle <--> AWA/S
0 true north ground dir <--> TWD/S
which tell the GW how to translate the data.
This way you can tell the GW to do the conversion right even if your devices on the bus send the data with the wrong reference flags.
I started to implement the proposed mappings for the N2K wind reference. As far as I see we currently can only use 3 values at the NMEA0183 side: AWA/S,TWA/S,TWD/S. For the others we would need to implement more computations - similar to Sail_Instrument. Finally I'm not really sure if this would make sense in the gateway... @quantenschaum: could you imagine to write a short summary for the wind definitions and issues that we could directly add to the documentation? Maybe just a wind.md in the doc directory? Currently the information is a bit distributed and potentially hard to follow for the normal user.
That sounds good!
could you imagine to write a short summary for the wind definitions Currently the information is a bit distributed and potentially hard to follow
That's true. Sure, I could wrap this up. I would merge the information from
Finally I'm not really sure if this would make sense in the gateway
Performing calculations in the gateway can make sense in certain cases when the devices receiving the data need these fields but are not capable of calculating them on their own. But it should be optional. Performing the calculations downstream in the receiving devices/software might be more flexible.
Performing calculations in the gateway can make sense in certain cases when the devices receiving the data need these fields but are not capable of calculating them on their own. But it should be optional. Performing the calculations downstream in the receiving devices/software might be more flexible.
Completely agree.
first steps with https://github.com/wellenvogel/esp32-nmea2000/releases/tag/20241114
First, thanks for this project! :tophat:
related to https://github.com/wellenvogel/avnav/issues/367 and https://github.com/kdschmidt1/Sail_Instrument
I noticed that the gateway computes true wind from COG/SOG and AWA/AWS, but I suspect the calculations not to be correct.
Testing
I fed the gateway with the following test data (as return by the GW in
PCDIN
) and got this output. The test data values were generated usingCourseData
.Wind data is sent to the GW as PGN130306
N2kWind_Apparent
.1. No Current
GW output
VTG
COG/SOG = 90°/5kn :heavy_check_mark:MWV-R
AWA/AWS = 310°/7.7m/s :heavy_check_mark:MWV-T
TWA/TWS = 292°/6.4m/s :heavy_check_mark:MWD
TWD/TWS 292°/12.4kn :x: same asMWV-T
but should be true wind direction not angle (need to add HDT) Forwarding this to AvNav results in a wrong TWD.2. With Current
GW output
VTG
COG/SOG = 73.9°/6.2kn :heavy_check_mark:VHW
HDT/STW = 90°/5kn :heavy_check_mark:HDT
90° :heavy_check_mark:MWV-R
AWA/AWS = 310°/7.7m/s :heavy_check_mark:MWV-T
TWA/TWS = 286.5°/6.2m/s :x: should be 292° 12.4kn (6.4m/s) because true wind is relative to water and must be calculated from HDT/STW, here COG/SOG is used and yields ground wind insteadMWD
:x: same problem as in 1. (angle instead of direction)Workaround
Blacklisting
MWD
, butMWV-T
is still wrong.Suggestions
MWV
is sent in two flavors which cannot be blocked separately.)