Remote control by location (PIC in Oshonsoft)

jjw

Joined Dec 24, 2013
823
It is the page. Thanks
This is the better equation. It needs only to check the signs of x, y in four quadrants.

atan_approx(x) = (Pi/2)*(b*x + x*x)/(1 + 2*b*x + x*x) where b = 0.596227, with a maximum approximation error of 0.1620º
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
It is the page. Thanks
This is the better equation. It needs only to check the signs of x, y in four quadrants.

atan_approx(x) = (Pi/2)*(b*x + x*x)/(1 + 2*b*x + x*x) where b = 0.596227, with a maximum approximation error of 0.1620º
Well done B.
Hi J,
Is this the total equation?
Is it correct that Pi and b need to be set up as CONSTANTS?

E,
Here: https://forum.allaboutcircuits.com/threads/gps-nmea-antenna-aiming-tracker.96520/page-6 at #109
you say that you fully tested this equation, did you convert it to Oshonsoft? I've searched but can't find it.
C
 

ericgibbs

Joined Jan 29, 2010
21,452
hi C,
I am looking thru my archives for this, if I find it I will post.
BTW: the atn equation we were using has one worst case error of only 0.27 degrees, what accuracy are you working too.

Also remember the rounding 'funnies' we had with Oshonsoft, when using 5 or 6 decimal places in the maths.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
hi C,
I am looking thru my archives for this, if I find it I will post.
BTW: the atn equation we were using has one worst case error of only 0.27 degrees, what accuracy are you working too.

Also remember the rounding 'funnies' we had with Oshonsoft, when using 5 or 6 decimal places in the maths.

E
Hi E,
1Deg is fine.
I've also been looking.
Is this any good?:
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Well done B.
Hi J,
Is this the total equation?
Is it correct that Pi and b need to be set up as CONSTANTS?

E,
Here: https://forum.allaboutcircuits.com/threads/gps-nmea-antenna-aiming-tracker.96520/page-6 at #109
you say that you fully tested this equation, did you convert it to Oshonsoft? I've searched but can't find it.
C
It is not the total equation. It needs to check the four quadrants, x>0 y>0, x>0 y<0 , x<0 y<0 , x<0 y>0
I have tested it succesfully in another language and will write it in Oshonsoft soon.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
It is not the total equation. It needs to check the four quadrants, x>0 y>0, x>0 y<0 , x<0 y<0 , x<0 y>0
I have tested it succesfully in another language and will write it in Oshonsoft soon.
Hi J,
Look in #362 It looks as though Octants were use. The first one works, but the < and > need introducing.
Did you recall if CASE was used?
There is also a Z component
C.
 

jjw

Joined Dec 24, 2013
823
Hi J,
Look in #362 It looks as though Octants were use. The first one works, but the < and > need introducing.
Did you recall if CASE was used?
There is also a Z component
C.
Octants were needed in the other equation. This calculates in 90 degrees quadrants.
How the direction is calculated with x, y, z?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
Octants were needed in the other equation. This calculates in 90 degrees quadrants.
How the direction is calculated with x, y, z?
Hi J,
Just found your calculation for Octants.

Thinking about it, as the main purpose for me is videos, and the Z component is for tilt compensation, X and Y will most likely be ok..

Here is a page of explanation:
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Here is the Oshonsoft untested version of arctangent.
Might have syntax and other errors.
Code:
' Result in degrees clockwise from North = 0
'
function atn( x as single, y as single) as single
const b=0.596227
dim w as single

if y=0 then
   y=y+0.000001 ' to prevent divide by zero
endif

w=x/y
at1 = 90*w*(b+w)/(1+2*b*w+w*w)
at2 =-90*w*(b-w)/(1-2*b*w+w*w)

if x>=0 then 
if y>0 then
   atn=at1
endif
endif 

if x>=0 then
if y<0 then
   atn=180-at2
endif
endif
 
if x<0 then
if y<0 then
  atn=180+at1
endif
endif

if y>0 then
if x<=0 then
  atn=360-atn2
endif
endif

end function
 

jjw

Joined Dec 24, 2013
823
Hi J,
This compiles, does it look somewhere near?

What is 'W' in the equation?
C.
You can see, that it is x/y or the tangent from which we calculate the corresponding angle:)
Why do you rename it "what" ?

edit: found that w is a stupid reserved undocumented internal variable!
 
Last edited:

jjw

Joined Dec 24, 2013
823
Here is the Oshonsoft untested version of arctangent.
Might have syntax and other errors.
Code:
' Result in degrees clockwise from North = 0
'
function atn( x as single, y as single) as single
const b=0.596227
dim w as single

if y=0 then
   y=y+0.000001 ' to prevent divide by zero
endif

w=x/y
at1 = 90*w*(b+w)/(1+2*b*w+w*w)
at2 =-90*w*(b-w)/(1-2*b*w+w*w)

if x>=0 then
if y>0 then
   atn=at1
endif
endif

if x>=0 then
if y<0 then
   atn=180-at2
endif
endif

if x<0 then
if y<0 then
  atn=180+at1
endif
endif

if y>0 then
if x<=0 then
  atn=360-atn2
endif
endif

end function
atn2 should be at2 in the function.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,835
You can see, that it is x/y or the tangent from which we calculate the corresponding angle:)
Why do you rename it "what" ?

edit: found that w is a stupid reserved undocumented internal variable!
Hi J,
Is it correct to rename 'W' as tang?
C.
 
Top