CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 03-22-2008, 03:07 AM
 
Join Date: Mar 2007
Location: UK
Age: 60
Posts: 493
Robin Hewitt is on a distinguished road
Finding the centre of an arc

Don't know if anyone can help with this one, but working to the notion that the only dumb question is the one that is never asked...

I'm writing a G code interpreter for an 8 bit micro. I have an algorythm that will give me next step on an arc but it needs the centre point and RČ.

Easy if the arc is defined with I and J because that defines the centre and RČ = IČ + JČ

Unfortunately I and J are not guaranteed, I may only get a radius, the direction of rotation and a promise that the arc is not greater than 180 degrees.

Is there an easy way to find the centre if that is all you've got to work with? So far I have got away without sines, cosines, tangents, roots and binary fractions.

I could use a pre-processor on the host computer and replace R with I and J but that is an added complication. I could simply throw an Error and demand I and J, but is it fair to assume g-gode generating software can be switched?

Also, I'm working in signed 24 bit numbers and my maximum useable distance is 34 feet. Plenty for x, y and z co-ordinates, but is it fair to throw a 'number too big' error if the arc radius exceeds 34 feet? There has to be a limit somewhere.
Reply With Quote

  #2   Ban this user!
Old 03-22-2008, 07:28 AM
 
Join Date: Oct 2003
Location: USA
Age: 64
Posts: 263
mrainey is on a distinguished road

Some formulas and links here.

http://www.analyzemath.com/CircleEq/Tutorials.html
__________________
Software For Metalworking
http://closetolerancesoftware.com
Reply With Quote

  #3   Ban this user!
Old 03-22-2008, 07:55 AM
 
Join Date: Mar 2008
Location: canada
Posts: 25
denjo is on a distinguished road

not sure what you're asking here. if you know the i,j values you can easily determine the radius as the i & j are are your adjacent & tangent values. therefore the hypotenus is your 'R' value. if you know the start point of the arc, simply add or subtract you i, j values to find the centre.
hope this clarifies.
Reply With Quote

  #4  
Old 03-22-2008, 09:50 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,455
ger21 is on a distinguished road
Buy me a Beer?

I think he wants the center of a G2/G3 arc using R and not I and J.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #5   Ban this user!
Old 03-22-2008, 10:09 AM
 
Join Date: Mar 2007
Location: UK
Age: 60
Posts: 493
Robin Hewitt is on a distinguished road

The problem is when there are no I and J values, example

N35 G03 X180.000 Y123.000 R1.500 F72.000

Very easy to draw. You simply set your compass to R and then draw intersecting arcs centred on the start and end points.

I can't believe it is a difficult, the early g-code interpreters were kinda basic, (unless the R only option came later). I think I may be missing a trick which is making something simple, complicated
Reply With Quote

Sponsored Links
  #6  
Old 03-22-2008, 10:41 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,455
ger21 is on a distinguished road
Buy me a Beer?

Don't know the math off hand, but if you draw two circles with the R radius and their centers at the start and end points of the arc, they'll intersect at the center. Basic geometry.
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #7  
Old 03-22-2008, 10:43 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,455
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by ger21 View Post
Don't know the math off hand, but if you draw two circles with the R radius and their centers at the start and end points of the arc, they'll intersect at the center. Basic geometry.

http://local.wasp.uwa.edu.au/~pbourke/geometry/2circle/

http://mathworld.wolfram.com/Circle-...ersection.html
__________________
Gerry

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #8   Ban this user!
Old 03-22-2008, 10:44 AM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

080322-1014 EST USA

Robin:

From your first post there is insufficient information to define the arc center.

I will assume you know the starting point of the arc, and you said the radius was known. Thus, the center of the arc is some place on the locus of a point at a distance of R from the start point.

In your second post you imply knowledge of the end point.

From a knowledge of the start and end points you can create a straight line, AB, between the two points. A line drawn perpendicular to the line AB and thru its midpoint contains the arc's center. You can determine the equation for this line, the length of AB, and the length of the line from AB center to the arc center.

The length of AB is ( (X1-X2)^2 + (Y1-Y2)^2 )^(1/2), and the center point of AB is at X2 + (X1-X2)/2 = Xcp and Y2 + (Y1-Y2)/2 = Ycp .

Let the perpendicular line be CD, then the length of CD is ( (R)^2 - (AB/2)^2 )^(1/2).

Whether you use this technique or trig functions your processor must be able to perform the operations.

.
Reply With Quote

  #9   Ban this user!
Old 03-22-2008, 11:00 AM
 
Join Date: Mar 2007
Location: UK
Age: 60
Posts: 493
Robin Hewitt is on a distinguished road

Tried that, the line CD is a vector so it only solves it if CD happens to be horizontal or perpendicular
Reply With Quote

  #10   Ban this user!
Old 03-22-2008, 11:29 AM
BlueChip's Avatar  
Join Date: Jun 2003
Location: Massachusetts
Posts: 130
BlueChip is on a distinguished road
Finding Arc Centers from R

We have written a few applications that do this ... our Trig Kalculator is one.

I believe you are trying to do this from a G code program. I hope I got that right ... if so, you need to know the START POINT and the END POINT ... you should know the start point from the last coordinate point in the G code program ... using that start point and the end point ( called out in the G2/G3 line) and other sine, cosine functions, you can find the arc center. But it takes a couple of calculations to get there.

Real World Machine Shop Software at www.KentechInc.com
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 03-22-2008, 11:35 AM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

Robin:

I do not understand your comment. The Pythagorean theorem does not require a relationship to a coordinate system.

From the
The American Heritageź Dictionary of the English Language, Fourth Edition

"The theorem that the sum of the squares of the lengths of the sides of a right triangle is equal to the square of the length of the hypotenuse."

Line CD and 1/2 of AB as I proposed forms a right triangle.

What I suggested was a way to find the center of the arc from a geometric construction knowing the arc's end points. This involved straight lines and right triangles. and calculatable values.

.
Reply With Quote

  #12   Ban this user!
Old 03-22-2008, 11:48 AM
 
Join Date: Mar 2007
Location: UK
Age: 60
Posts: 493
Robin Hewitt is on a distinguished road

That's how I did it when I had the benefit of a C compiler, it is a vector.

But now I'm re-writing it in machine code. Everything is lightning fast and extremely compact. I want to keep it that way and I'm going to try and solve this for a while longer before I give up


sep = hypot(x-xx,y-yy); // separation start to end in XY
ang = getangle(xx,yy,x,y); // angle of line start to end
vect = racos((sep/2)/r); // vector to center
if(dir==CW) vect = ang-vect; // CW = turn left
else vect = ang+vect; // CCW = turn right
while(vect>=r360) vect-=r360;
while(vect<0.0) vect+=r360;
cx=xx+(cos(vect)*r); // locate arc center
cy=yy+(sin(vect)*r);
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hub centre steering spoiledbrat Moldmaking 2 09-07-2009 05:30 AM
Another Aussie Adventure in Optical Edge/Centre Finding Greolt Mach Software (ArtSoft software) 8 04-01-2008 03:48 PM
Threading on a CNC turning centre cnc-it Fanuc 4 10-24-2007 01:32 PM
Off centre turning Integrex General Metalwork Discussion 0 04-10-2007 10:35 PM
Kitamura My Centre 2c scappini Mechanical Calculations/Engineering Design 0 07-10-2006 07:34 PM




All times are GMT -5. The time now is 10:10 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361