ttlappalainen / NMEA2000

NMEA2000 library for Arduino
521 stars 218 forks source link

Issue on sending PGN130306 Wind Angle #157

Open simonebusoe opened 4 years ago

simonebusoe commented 4 years ago

Hi Timo, I'm trying to send with a Due over N2k bus Apparent wind Angle and speed infos by using PGN130306. void SendN2kWindSpeed(){ tN2kMsg N2kMsg; SetN2kWindSpeed(N2kMsg,1,mwsDampedms,mwaDamped,N2kWind_Apparent); NMEA2000.SendMsg(N2kMsg); } mwaDamped is a double type result of atan2 and its value range is from -3.14 to +3.14 ( as described, in radians) depending on the sensor position. On Garmin GNX120 i recognize that the angle have some problem around 0 and 180, and on NMEAReader i found that WindDirection has value between 0 and 180 (0-3.14) if positive and from 195 to 375 (3.40-6.55) for negative ones. This looks very strange. 0------->15--------------->180->-180--------->0 deg Sensor/Ardu Plotter 0,1,2--->14->0,1,2------->180-->195---------->0 NMEAreader
0,1,2--->14->0,1,2------->180-->-165---------->0 GNX120

I've tried to modify the Wind_reference but nothing happens, i've tried also to make a relation of 3.14 and 3.275 and scale the mwa with the right ratio, but doesn't work.

Does anyone found this kind of problem, or similar?

Thank you in advance, Simone

ttlappalainen commented 4 years ago

NMEA2000 requires wind direction as positive 0-2pi. The Set... function does not fix negative values or values over 2pi