Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:11 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Updated Boat Computer

     Page 3 of 3    
Author Message
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 949
Posted: 08:17pm 09 May 2016
Copy link to clipboard 
Print this post

Hi Paul,

are looking for this version? 2016-05-10_061615_Boat_Computer_BASIC_Program.zip

Frank
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:37pm 09 May 2016
Copy link to clipboard 
Print this post

  palcal said   I updated to the new Boat Computer Code and also updated to MM.V5.1 and now I have the problem of the heading needle jumping all over the place. The actual heading readout in degrees is rock solid.

Paul.

Did you do the mods to the getX() and getY() functions that I described a few posts above.

Jim
VK7JH
MMedit
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 09:09pm 09 May 2016
Copy link to clipboard 
Print this post

Thanks Frank
Jim,
No I didn't change that, I got a bit lost with davematt and Peter's code I wasn't sure they were referring to Geoff's code. Why did the original code work, I didn't think Geoff changed anything besides the number of POI's and a little hiccup with the font.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:17pm 09 May 2016
Copy link to clipboard 
Print this post

Paul,
I made the following changes to the V2 version of the Boat Computer program:
  Quote  To stop the errors when POI's are too far away, I added a line to POIDistance()
a = Sin(m/2) * Sin(m/2) + Cos(lat1) * Cos(lat2) * Sin(n/2) * Sin(n/2)
if a > 1 then a = 1 ' sanity check
n = (2 * atan2(Sqr(a), Sqr(1 - a)))

The formula should still work OK for distances up to 1000 km or more.

The errors reported with the compass display were caused by using a 'clock' function but not changing it from the 60 steps in a circle to 360.
I removed the '*6' form both getX() and getY()

' utility to get the x coord of a vector on the analogue clock
Function GetX(tim As Float, r As Float) As Float
Local Float t = tim
If t > 359 Then t = t - 360
If t < 0 Then t = t + 360
GetX = 250 + Cos(Rad(t)) * r
End Function


' utility to get the y coord of a vector on the analogue clock
Function GetY(tim As Float, r As Float) As Float
Local Float t = tim
If t > 359 Then t = t - 360
If t < 0 Then t = t + 360
GetY = 160 + Sin(Rad(t)) * r
End Function

I then ended up with the compass needle running backwards so I changed a line in DrawCompassNeedle

ldeg = 90 - deg
to
ldeg = deg - 90


I think these changes will fix the issues you are having.

Jim
VK7JH
MMedit
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 10:50pm 09 May 2016
Copy link to clipboard 
Print this post

OK Jim I will do the mods. to the code. I am still a bit lost as to why the original code worked and why Geoff did not pick up the problem when he tested the code. But all is well I will see how it goes.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 12:34am 10 May 2016
Copy link to clipboard 
Print this post

Ah, I can see what went wrong.

My fault entirely. In V2 of the Boat Computer I wanted to improve the look of the pointer so I stole some code from a digital/analogue clock project that will appear in the June issue of Silicon Chip. This code assumed that the pointer's position was given in minutes (ie, 60 in a circle) not degrees (ie, 360).

Brilliant job Jim in spotting that. Thanks. I will post V3 containing your fix ASAP.

I did some testing but obviously not enough to expose this problem. This just goes to show that ANY change to a program has a good chance of introducing a bug. For example, with MMBasic the bugs are nearly always related to new features and rarely the long standing code.

There is an old joke that goes something like this...

Manager to programmer: "What are you doing?"
Programmer: "I'm bugging"
Manager: "What do you mean?"
Programmer: "Well, tomorrow I will be debugging this program so today I must be bugging it"

Geoff
Geoff Graham - http://geoffg.net
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 04:41pm 10 May 2016
Copy link to clipboard 
Print this post

OK, I have posted an updated version of the Boat Computer (ver 3) which contains the fixes discovered by Jim. You can download the files from: http://geoffg.net/BoatComputer2.html#Downloads and eventually they will also be available on the Silicon Chip website.

If you have modified Ver 2 according to Jim's changes you can continue to use it but it would be worthwhile to also change the following lines:
x1 = GetX(ldeg - 15, 4)
y1 = GetY(ldeg - 15, 4)
x2 = GetX(ldeg + 15, 4)
y2 = GetY(ldeg + 15, 4)

to
x1 = GetX(ldeg - 90, 4)
y1 = GetY(ldeg - 90, 4)
x2 = GetX(ldeg + 90, 4)
y2 = GetY(ldeg + 90, 4)

as that helps create a nicer looking pointer.

Ver 3 contains this change also.

Geoff


Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 08:56pm 10 May 2016
Copy link to clipboard 
Print this post

Thanks For that Geoff and Jim
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 11:21pm 12 May 2016
Copy link to clipboard 
Print this post

Took the Boat Computer out for a shakedown cruise (fishing trip) today. I had only entered four marks but it performed extremely well. The owner of the boat preferred it to his $800 unit although his is also a depth sounder. We navigated to the marks using the Boat Computer, then positioned the boat using the depth sounder.
He preferred it due to ease of use and the easy to read screen. We also caught some fish.
Thanks Geoff it works extremely well.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 12:38am 13 May 2016
Copy link to clipboard 
Print this post

Excellent news. Thanks Paul, good to know that it is performing well in the real world.
Geoff Graham - http://geoffg.net
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 12:15pm 13 May 2016
Copy link to clipboard 
Print this post

Something I failed to mention is that the set button won't work for POI 4 and 5, 10 and 11 and other POIs in the same position on the screen. I am using a 2.8" screen and am thinking it maybe a fault with the screen.
Paul.

Edit... Another problem TassyJim wrote
  Quote  to stop errors when POIs are far away

I am going on a road trip to a spot some 300Km away so I thought I would try the Boat Computer to navigate. I entered 3 POIs, I checked one on Google Earth and it is 275KM but the Boat Computer shows it as over 3000Km and the same error for the other two.
Paul.Edited by palcal 2016-05-14
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 01:20pm 13 May 2016
Copy link to clipboard 
Print this post

No damn it, it is another bug. The two top SET buttons do not work.

I will look into it now and get back to you.

EDIT: OK, found the bug. Below is V4 which fixes it, I will also update my website.
2016-05-14_000731_BoatComputerV4.zip

GeoffEdited by Geoffg 2016-05-15
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 01:29pm 13 May 2016
Copy link to clipboard 
Print this post

  palcal said  
Edit... Another problem TassyJim wrote
  Quote  to stop errors when POIs are far away

I am going on a road trip to a spot some 300Km away so I thought I would try the Boat Computer to navigate. I entered 3 POIs, I checked one on Google Earth and it is 275KM but the Boat Computer shows it as over 3000Km and the same error for the other two.
Paul.


If it is not a secret fishing spot, can you give me the co-ordinates of the POI's and your 'current' position?

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 06:28pm 13 May 2016
Copy link to clipboard 
Print this post

Paul,
I set the demo location to Balgal Beach and the first POI (Harbour) to Cairns Airport.

The mite gave a distance of 238km and my map gives 246km
Some of the difference is due to my inaccurate clicking on the maps and some due to the formula used in the boat computer.

The only way I can see to get the big distances you observed is if you have North instead of South etc.

Geoff,
Boat computer V3 seems to be happy with V5.2beta firmware. - Still don't have a GPS connected.

Jim

VK7JH
MMedit
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1993
Posted: 10:49pm 13 May 2016
Copy link to clipboard 
Print this post

@ TassyJim
I am at Balgal Beach and my POIs were in the Cairns area I entered the coordinates and I have rechecked they are correct. I am leaving in the morning so won't be able to recheck until next week. You are in Tassie so can you enter coordinated for say Melbourne and see what the result is.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025