Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 06-05-2018, 05:47   #151
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

Not making any accusations, these things happen. The formula is tedious and arcane. I have a couple of scratch papers where I had started the derivation a week ago, and my brain started to hurt so I just copied the formula in post 78.

FWIW, I used that one because I quickly recognized the formula in the wiki had another error - the acos function was lacking the 180/π conversion factor that is needed to get its result from radians to degrees. I should have reported it, but it was very late and I forgot later.

I'm flying out on a business trip today, so things are a little crazy. I'll try to work on it on the plane.

Meanwhile, I can't find your problem setup entry in the wiki. Can you post a link to the right place?
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 06-05-2018, 06:06   #152
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

I would like to get the wiki, so it is infallibly correct.

ZZZ formula here is the #78 post and I tested it and thought it worked!
http://www.cruisersforum.com/forums/...ml#post2533127

These calcs came from Evans Starzinger's website calculators xls spreadsheets
Their website is now gone unfortunately.

Calculations Needed:
x =AWS*sin(AWA*3.14159265/180)
y =(x/tan(AWA*3.14159265/180)) - SOG
TWS (True Wind Speed) =x/sin(TWA*3.14159265/180)
TWA (True Wind Angle) =atan(x/y)*180/3.14159265

I'll be following this with interest.
rgleason is offline   Reply With Quote
Old 06-05-2018, 06:23   #153
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

See page 11 Starpath pdf
https://www.google.com/url?sa=t&rct=...mSQt64pR7U3Pfa

Also Andrew Cross
Calculating the True Wind and Why it Matters | Cruising Compass

Here is a github true wind calculator
https://www.npmjs.com/package/true-wind

https://github.com/cape-io/true-wind
rgleason is offline   Reply With Quote
Old 06-05-2018, 06:46   #154
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

Here are a few more:
https://samos.coaps.fsu.edu/html/tools_truewinds.php

How to solve for TWS
https://oic-nwreviewer.blogspot.com/...ind-speed.html
Solve for TWD
https://oic-nwreviewer.blogspot.com/...direction.html
Solve for AWS
https://oic-nwreviewer.blogspot.com/...ind-speed.html

TWS calculator
True Wind Speed And Direction Calculator

http://www.hydesailsdirect.com/Articles.asp?ID=278
rgleason is offline   Reply With Quote
Old 06-05-2018, 06:52   #155
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

Is this problem arising from upwind / downwind conditions?
rgleason is offline   Reply With Quote
Old 06-05-2018, 07:01   #156
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

Quote:
The computation of a true wind is often misinterpreted as removing the ship's course vector from the apparent wind vector. This error causes a distinct stair-step pattern (Fig. 1) in the incorrectly calculated true wind speed (red) that is associated with the ship's forward speed (black).
from 3 meterological true wind
Establishing more truth in true winds
See
A detailed methodology is presented in appendix A. Appendix B contains techniques to convert between meteorological, oceanographic, and Merchant Marine conventions. Also Table B
rgleason is offline   Reply With Quote
Old 06-05-2018, 07:09   #157
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

Quote:
Originally Posted by rgleason View Post
Is this problem arising from upwind / downwind conditions?
The VDR log is for predominantly downwind conditions, although I was motoring through heavy ship traffic with lots of course changes. You can play it back yourself if you want to see.
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 06-05-2018, 14:32   #158
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

Quote:
Originally Posted by rgleason View Post
I would like to get the wiki, so it is infallibly correct.

ZZZ formula here is the #78 post and I tested it and thought it worked!
http://www.cruisersforum.com/forums/...ml#post2533127

These calcs came from Evans Starzinger's website calculators xls spreadsheets
Their website is now gone unfortunately.

Calculations Needed:
x =AWS*sin(AWA*3.14159265/180)
y =(x/tan(AWA*3.14159265/180)) - SOG
TWS (True Wind Speed) =x/sin(TWA*3.14159265/180)
TWA (True Wind Angle) =atan(x/y)*180/3.14159265

I'll be following this with interest.
I haven't verified your equations, but they look reasonable.

One problem that I can anticipate is if the wind instrument reports AWA as 180.0 or 0.0 (when motoring, obviously), tan(AWA) will be indeterminate. But this can be easily worked around by using AWA+0.0000001. Then you'll never have the problem.

I'm heading to the airport soon, I'll try to work on this on the plane. I'm taking one of my boat tablets with me so I can tweak other settings before I launch in a week.
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 06-05-2018, 16:39   #159
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

Thanks Rhythm DR & TDan
rgleason is offline   Reply With Quote
Old 06-05-2018, 21:43   #160
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

OK, I've got this figured out. I am not sure why the post #78 formula did not work, but there had to be an error since you cannot take an arccosine of a number whose absolute value is greater than 1. I didn't have time to figure out exactly what the error was. Instead I used the Starzinger equations that you showed factored in a way that's easier to debug:

Quote:
Originally Posted by rgleason View Post
These calcs came from Evans Starzinger's website calculators xls spreadsheets
Their website is now gone unfortunately.

Calculations Needed:
x =AWS*sin(AWA*3.14159265/180) This is fine as-is.
y =(x/tan(AWA*3.14159265/180)) - SOG This is more clearly expressed as AWS*cos(AWA*3.14159265/180) - SOG
TWS (True Wind Speed) =x/sin(TWA*3.14159265/180) It's better to just use the hypotenuse length of the x-y vector components (Pythagorean theorem)
TWA (True Wind Angle) =atan(x/y)*180/3.14159265 This is theoretically correct, but unfortunately Excel and the plugin provide atan values from -90 to + 90, instead of 0 to 180. This leads to negative TWA for reaches and runs, which OpenCPN cannot deal with. So you need to use a rotation transformation, which is 90-180/3.14159265*atan(y/x). This gets the same values for close-hauled, but gives proper values for TWA between 90 to 180 degrees
When you put all that together, here are my equations:

TWA=90-180/3.14159265*atan(y/x)
=90-180/3.14159265*atan((AWS*cos(AWA*3.14159265/180)-SOG)/AWS*sin(AWA*3.14159265/180))

TWS(Pythagoras)=sqrt(sqr(AWS*sin(AWA*3.14159265/180))+sqr(AWS*cos(AWA*3.14159265/180)-SOG))

Using the NMEA sentence syntax that my Seatalk converter spits out gives this:

TWA=90-180/3.14159265*atan(($GPVWR3*cos($GPVWR1*3.14159265/180)-$GPRMC7)/$GPVWR3*sin($GPVWR1*3.14159265/180))

TWS=sqrt(sqr($GPVWR3*sin($GPVWR1*3.14159265/180))+sqr($GPVWR3*cos($GPVWR1*3.14159265/180)-$GPRMC7))

Here's the whole sentence that goes into NmeaConverter. This works for the VDR examples that I show above with no NaN/Indeterminate errors:

Code:
$XXVWT,90-180/3.14159265*atan(($GPVWR3*cos($GPVWR1*3.14159265/180)-$GPRMC7)/$GPVWR3*sin($GPVWR1*3.14159265/180)),$GPVWR2,sqrt(sqr($GPVWR3*sin($GPVWR1*3.14159265/180))+sqr($GPVWR3*cos($GPVWR1*3.14159265/180)-$GPRMC7)),$GPVWR4,,,,
(Be sure to include the invisible return character after the four commas, or it won't work)

When I get some time, I will try to generate pseudo-TWD (true wind direction) from COG. Unfortunatly, my Raymarine 4000+ autopilot does not output HDG to calculate this in the correct way. (Oddly, my previous boat had a 4000+MkII autopilot, cosmetically identical but a couple years newer, and it did output HDG. Go figure!)

And another side note: I really wish my Seatalk Converter would use a different talker ID than GP, since that's the same ID my GPS puts out. It kind of defeats the purpose of having talker IDs. I haven't been able to adjust this anywhere.
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 06-05-2018, 22:13   #161
Registered User
 
Viking Sailor's Avatar

Join Date: Nov 2006
Location: San Francisco Bay
Boat: Fantasia 35
Posts: 1,251
Re: New Plugin NmeaConvertor

TWA=90-57.2957795*atan(($GPVWR3*cos($GPVWR1/57.2957795)-$GPRMC7)/$GPVWR3*sin($GPVWR1/57.2957795))

TWS=sqrt(sqr($GPVWR3*sin($GPVWR1/57.2957795))
+sqr($GPVWR3*cos($GPVWR1/57.2957795)-$GPRMC7))
Viking Sailor is offline   Reply With Quote
Old 07-05-2018, 04:38   #162
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

Quote:
Originally Posted by Viking Sailor View Post
TWA=90-57.2957795*atan(($GPVWR3*cos($GPVWR1/57.2957795)-$GPRMC7)/$GPVWR3*sin($GPVWR1/57.2957795))

TWS=sqrt(sqr($GPVWR3*sin($GPVWR1/57.2957795))
+sqr($GPVWR3*cos($GPVWR1/57.2957795)-$GPRMC7))
You can use that if you prefer. But two years from now, when something breaks and I'm trying to figure out wth I was doing, or if someone else is trying to figure out what I was doing, -180/3.14159265 is immediately recognizable as the needed conversion between degrees and radians. Sometimes the fewest keystrokes is not the cleanest code.

That's the same reason I used the unfactored Pythagorean theorem, instead of trying to reduce the terms using cos^2(x)+sin^2(x)=1 (like my trigonometry teacher would have demanded). It's just easier to see and debug.
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 07-05-2018, 04:57   #163
Registered User
 
transmitterdan's Avatar

Join Date: Oct 2011
Boat: Valiant 42
Posts: 6,008
Re: New Plugin NmeaConvertor

Guys,

The functions rad() and deg() might be helpful to you.

rad() converts its argument from degrees to radians.
deg() converts its argument from radians to degrees.

Would eliminate a lot of 180/3.14159... and the inverse.
transmitterdan is offline   Reply With Quote
Old 07-05-2018, 05:33   #164
Registered User

Join Date: Jan 2011
Posts: 670
Re: New Plugin NmeaConvertor

Quote:
Originally Posted by transmitterdan View Post
Guys,

The functions rad() and deg() might be helpful to you.

rad() converts its argument from degrees to radians.
deg() converts its argument from radians to degrees.

Would eliminate a lot of 180/3.14159... and the inverse.
That would be great. I was not sure what functions were in the library. It appears that pi() is not, so I assumed those others were not either. There was a prior post where someone (Roodirk?) mentioned the need to keep supported functions to a minimum, which is why there is no pi(). I guess you can’t have your pi and eat it too.

I don’t have the right computer with me now to try it. Have you verified that those are supported?
__________________
Please support OpenCPN by donating through Paypal!
RhythmDoctor is offline   Reply With Quote
Old 07-05-2018, 07:21   #165
Registered User
 
rgleason's Avatar

Join Date: Mar 2012
Location: Boston, MA
Boat: 1981 Bristol 32 Sloop
Posts: 17,710
Images: 2
Re: New Plugin NmeaConvertor

Rhythm DR wow! I'd like to get some of these formulas into Calculator_pi. Do you think you might be able to help in this way?
rgleason is offline   Reply With Quote
Reply

Tags
nmea, plug


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculator_pi New Finished Plugin for OpenCPN SaltyPaws OpenCPN 136 28-12-2022 07:19
New IAC Fleetcode Plugin for OpenCPN CBorchardt OpenCPN 77 23-04-2019 05:40
New Plugin Development on Linux globalkeith OpenCPN 5 03-05-2012 07:16
New History Plugin for OpenCPN seandepagnier OpenCPN 11 04-10-2010 14:11

Advertise Here


All times are GMT -7. The time now is 12:12.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.