Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PicBasic Pro - Is it possible !!!!

Status
Not open for further replies.

tracking

New Member
Hello

Can anyone tell me if it is possible using PicBasic Pro with its limitations to calulate the distance on earth betwen two points of latitude/longitudes.

I know that PicBasic Pro has a problem handling large numbers and I wondered if anyone had a THOUGHT or might have a solution.

Thanks

Ray
 
Here are the formulas I use for calculating great circle distance;
Code:
Great Circle Calculations, Mike - K8LH

Here are the formulas I use to convert "From" and "To" coordinates into Direct (Short Path) and Reverse (Long Path) Heading and Distance data in my Amateur Logbook database program…  The Excel formulas are much simpler than the Alternate formulas but I had to create the Alternative formulas because my database program does not include the ATAN2 and ACOS functions found in Excel...

Convert the decimal Latitude and Longitude values from degrees to radians (Southern Latitudes and Western Longitudes are negative numbers)

      FLat = FLat_dec * PI() / 180        {From_Latitude}
      FLon = FLon_dec * PI() / 180        {From_Longitude}
      TLat = TLat-dec * PI() / 180        {To_Latitude}
      TLon = TLon_dec * PI() / 180        {To_Longitude}

Calculating Distance - the Excel and Alternate Formulas (output is Nautical Miles)

  Distance = +(ACOS(COS(FLat)*COS(TLat)*COS(FLon-TLon)+SIN(FLat)*SIN(TLat))*60)*180/PI()

The Excel formula above is pretty simple and elegant but my database doesn't have an ACOS function so here's a reasonably equivalent alternate;  ACOS(X)=ATAN(SQRT((1-X)*(1+X))/X)

         X = COS(FLat)*COS(TLat)*COS(FLon-TLon)+SIN(FLat)*SIN(TLat)

  Distance = IF (X = -1, 10800, 
                 IF(X = 1, 0, 
                    MOD(10800 + (ATAN(SQRT((1-X)*(1+X))/X))*60*180/PI(),10800)
                   )
                 )

I'm not familiar with PicBASIC Pro... Does it include the trig' functions used in either of the calculations above?

Regards, Mike
 
At the risk of being seen as an employee of EPE 8) the January 2005 issue has a GPS based 'speed camera warning system', it probably does EXACTLY what you want?.

You can dowload the software from **broken link removed** - just to save Samcheetah doing it :lol:
 
Nigel Goodwin said:
At the risk of being seen as an employee of EPE 8) the January 2005 issue has a GPS based 'speed camera warning system', it probably does EXACTLY what you want?.

You can dowload the software from **broken link removed** - just to save Samcheetah doing it :lol:

:lol: :lol: :lol:

actually im a big fan of EPE because it has some really good quality PIC projects. but i really dont like to browse the ftp server of EPE because the internet explorer window freezes for a little while whenever i open an FTP link. so thanx for posting that link :lol:
 
Thanks Guys -BUT

Thanks folks for the replies - I dont know if your familiar with CodeDesigner and PicBasic Pro - The problem is two fold.

My maths are not that brilliant so I dont quiet understand all the answer and second PicBasic Pro will not handle numbers greater than 65535 - is this still possible for a newbie like me to do this

Cheers all

Ray
 
Re: Thanks Guys -BUT

tracking said:
Thanks folks for the replies - I dont know if your familiar with CodeDesigner and PicBasic Pro - The problem is two fold.

My maths are not that brilliant so I dont quiet understand all the answer and second PicBasic Pro will not handle numbers greater than 65535 - is this still possible for a newbie like me to do this

Not in PICBasic, the link I posted is assembler, it uses fixed point maths, 8 bit whole, and 16 bit fractional.
 
You could do it in PicBasic, but you'd have to learn how to use 8-bit and 16-bit ints to do 32-bit calculations. And if you're going to do this you're better off doing it in assembly.

Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top