Angle Calculation Forumla Problem?

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
Toaster
Posts: 199
Joined: Mon Oct 29, 2018 5:25 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

Angle Calculation Forumla Problem?

Post by Toaster »

Hey everyone, I'm trying to write some scripts that can hit two points on the table and calculate the angle between those two points. I have most of the script worked out, but I'm having trouble with the "arc tangent" function.

I boiled down my script to a test of the "ATAN" function as you can see here:

#106=5
#108= atan 12 / 2
m225 #106 "atan is %f" #108
;Expected answer is: 1.4056

#108= atan 12 / 1
m225 #106 "atan is %f" #108
;Expected answer is: 1.4877

#108= atan 12 / .5
m225 #106 "atan is %f" #108
;Expected answer is: 1.5292

After each calculation is the answer I'd expect from doing each ATAN. The answers I actually get are off. It only seems to work the second example... Has anyone here had any experience with this?
swissi
Posts: 573
Joined: Wed Aug 29, 2018 11:15 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 985DADEB24D5-0309180716
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

Re: Angle Calculation Forumla Problem?

Post by swissi »

Toaster wrote: Fri Oct 16, 2020 5:29 pm Hey everyone, I'm trying to write some scripts that can hit two points on the table and calculate the angle between those two points. I have most of the script worked out, but I'm having trouble with the "arc tangent" function.

I boiled down my script to a test of the "ATAN" function as you can see here:

#106=5
#108= atan 12 / 2
m225 #106 "atan is %f" #108
;Expected answer is: 1.4056

#108= atan 12 / 1
m225 #106 "atan is %f" #108
;Expected answer is: 1.4877

#108= atan 12 / .5
m225 #106 "atan is %f" #108
;Expected answer is: 1.5292

After each calculation is the answer I'd expect from doing each ATAN. The answers I actually get are off. It only seems to work the second example... Has anyone here had any experience with this?
Check your expectations :D

First you need to put the numbers in brackets:

Code: Select all

#108= atan[12 / 2]
#108= atan[12 / 1]
#108= atan[12 / .5]
I don't know how you came up with the expected results but they are totally off. The ATAN(12/2) = 80.54 according to my calculator and that's exactly the result that CNC12 shows.

-swissi
If you are using Fusion 360, check out my CNC12 specific Post Processor
If you are using a Touch Probe, Tool Touch Off Device or a Triple Corner Finder Plate, check out my ProbeApp

Contact me at swissi2000@gmail.com
Toaster
Posts: 199
Joined: Mon Oct 29, 2018 5:25 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

Re: Angle Calculation Forumla Problem?

Post by Toaster »

Yep, I had the wrong numbers in there, that was from my spreadsheet before I converted them. The brackets definitely did the trick! I was getting some wacky numbers without them. Thanks Swissi!
Post Reply