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 09-14-2010, 02:19 AM
 
Join Date: Sep 2010
Location: iran
Posts: 29
Farzaneh_2010 is on a distinguished road
G02 and problems

hello
i am sorry.i have a question about calculate angle part of circle.I have center points and two point in circle.i need to angle between strart point and end point. i search internet but i did not find any formol.so i think may be you know this. so i want to help me please.
Reply With Quote

  #2   Ban this user!
Old 09-14-2010, 02:53 AM
 
Join Date: Mar 2009
Location: canada
Posts: 7
skip56uk is on a distinguished road

use trig mate
or send me your points and i will give you angle ok
or tell me what size you want your hole and with what tool you are using and i will give you code
Reply With Quote

  #3   Ban this user!
Old 09-14-2010, 01:32 PM
samu's Avatar  
Join Date: Feb 2007
Location: quebec
Posts: 216
samu is on a distinguished road

First you have to find your radius. You can use any of the two point on the circle.

R=sqrt[(x-h)*(x-h)+(y-k)*(y-k)]
where:
R=radius
x=x coordinate of a point on the circle
y=y coordinate of the same point on the circle
h=x coordinate of the center
k=y coordinate of the center
sqrt=square root

then you have to find the chord length(the lenght of the line that join the 2 point on the circle)

L=sqrt[(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)]
where:
x1=x coordinate of the first point
x2=x coordinate of the second point
y1=y coordinate of the first point
y2=y coordinate of the second point

then you can calculate angle between two point

A=2*arcsin[L/(2*R)
Reply With Quote

  #4   Ban this user!
Old 09-15-2010, 07:00 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

What do these things have to do with G02?
G02 is a basic function and it should work on all machines without any problem.
I could not understand his basic problem.
Reply With Quote

  #5   Ban this user!
Old 09-15-2010, 07:50 AM
 
Join Date: Sep 2010
Location: iran
Posts: 29
Farzaneh_2010 is on a distinguished road

Originally Posted by samu View Post
First you have to find your radius. You can use any of the two point on the circle.

R=sqrt[(x-h)*(x-h)+(y-k)*(y-k)]
where:
R=radius
x=x coordinate of a point on the circle
y=y coordinate of the same point on the circle
h=x coordinate of the center
k=y coordinate of the center
sqrt=square root

then you have to find the chord length(the lenght of the line that join the 2 point on the circle)

L=sqrt[(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)]
where:
x1=x coordinate of the first point
x2=x coordinate of the second point
y1=y coordinate of the first point
y2=y coordinate of the second point

then you can calculate angle between two point

A=2*arcsin[L/(2*R)

Thankyou very much
i use this formol but i could not success.because i want to draw a circle with small lines.i mean i start a point and find secend point with increase degree and
draw a line between them and continue it so simulate a circle.
i write it in delphi.
a part of my program is;

Xs and Ys is start point and Xe and Ye is end point and I1 and J1 are cordinate of center

alpha:=Pi/180 //1 radian
L:=SQRT(((Xs-Xe)*(Xs-Xe))+((Ys-Ye)*(Ys-Ye)));
R1 := SQRT((Xe-I1)*(Xe-I1) + (Ye-J1)*(Ye-J1));
n:=L/(2*R1);
A:=2*arcsin(n);
X:=I1+R1*cos(alpha);
Y:=J1+R1*sin(alpha);
Paintbox1.Canvas.MoveTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // move to start point
while (alpha<A) do
begin
alpha:=alpha+Pi/180; //increase radian
X:=I1+R1*cos(alpha);
Y:=J1+R1*sin(alpha);
Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // draw a line
end;


please help me.....
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 09-15-2010, 07:54 AM
 
Join Date: Sep 2010
Location: iran
Posts: 29
Farzaneh_2010 is on a distinguished road

Originally Posted by sinha_nsit View Post
What do these things have to do with G02?
G02 is a basic function and it should work on all machines without any problem.
I could not understand his basic problem.

you are right.but i want to write a program about Gcodes in delphi. i mean i need to write this for windows language and i had to a basic program for machine.i hope that you understand my mean. sorry my english is weak...
Reply With Quote

  #7   Ban this user!
Old 09-17-2010, 02:45 PM
samu's Avatar  
Join Date: Feb 2007
Location: quebec
Posts: 216
samu is on a distinguished road

Paintbox1.Canvas.MoveTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // move to start point

Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // draw a line

If your program is written like that, you use X coordinate instead of Y in both line
Reply With Quote

  #8   Ban this user!
Old 09-18-2010, 12:25 AM
 
Join Date: Sep 2010
Location: iran
Posts: 29
Farzaneh_2010 is on a distinguished road

Originally Posted by samu View Post
Paintbox1.Canvas.MoveTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // move to start point

Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(X*Scale+OffY)); // draw a line

If your program is written like that, you use X coordinate instead of Y in both line

yes
i write X insted of Y in this page.but i use Y in my program and i can not success.i can not find my mistake.i think everything is right and it is not error but it draw a extravagant lines that it is not like a circle.if you can please help me i don not have time....
Reply With Quote

  #9   Ban this user!
Old 09-20-2010, 11:40 AM
samu's Avatar  
Join Date: Feb 2007
Location: quebec
Posts: 216
samu is on a distinguished road

You forgot one important thing, you have to calculate alpha at start point. your arc could began somewhere else than 0 rad or deg.

To know your Alpha at start :Arcsin[(Y-J)/R] But arcsin is expressed between 90 and -90 deg (pi/2 -pi/2 rad)

so calculate Arccos[(X-I)/R] But arccos is expresse beween 0 and 180 deg.

suppose that
A1=arccos[(x-i)/R]
A2=arcsin[(y-J)/R]

if A1 and A2 are positive Alpha at start point=A1
if A1 is positive and A2 negative Alpha at start point=2pi-A1
if A1 is negative and A2 is positive Alpha at start point=A1
if A1 and A2 are negative Alpha at start point =2Pi-A1

Also, G02 is clockwise arc and the positive direction of the trigonometric circle is counterclockwise. Cause you add a positive value at each segment, you will turn counter clockwise(G03).

Why you dont move at Xs Ys to begin your arc. (you calculate the point after the start point and then start there)
When you calculate angle between start and end point with the formula i gave to you, you obtain a result between 0 and 180 deg (0 and pi rad) because L is always positive(it is the result of a square root)and R also is always positive, you have to determine if it is really the result of the formula or 2pi-(this result). Cause you have to see it from a clockwise point of view.

Use the same method to find aplha at end point that I suggest to find alpha at start point and you won't need the first formula i gave to you. With that you will get alpha at start point and alpha at end point both wit positive value from 0 to 2pi.
To find angle between start and end from a clockwise point of view:
If Alpha start>Alpha end Angle between =(Alpha at start)-(alpha at end)
If Alpha start< alpha end Angle between=2pi+[(Alpha at start)-(alpha at end)]

then it is easy enough to program wath you want I know nothing about delphi and you will have to do a couple of IF...Then or something like that to resolve these formula but once its done:
As=Alpha at start point(angle on the trigonometric circle of start point)
A=angle between start and End (from a clockwise point of view)
AI=angular increment between each segment
At=total increment
Xs=Xcoordinate at start point
Ys=y coordinate at start point
Xe=X coordinate at end point
Ye=ycoordinate at end point
I= x center
J= Y center
R= Radius
Paintbox1.Canvas.MoveTo(Round(Xs*Scale+OffX), Round(Ys*Scale+OffY)); // move to start point
At=AI
while (At<A) do
begin
As=As-At;
X:=I+1*cos(As);
Y:=J+R*sin(As);
Paintbox1.Canvas.LineTo(Round(X*Scale+OffX), Round(Y*Scale+OffY)); // draw a line
At=At+AI;
end;
Paintbox1.Canvas.LineTo(Round(Xe*Scale+OffX), Round(Ye*Scale+OffY)); // draw a line

Last edited by samu; 09-20-2010 at 12:57 PM.
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
5t problems markjb Fanuc 16 11-30-2011 11:36 PM
340 problems cuthy83 Daewoo/Doosan 1 09-28-2009 06:44 PM
KMB-1 problems MTMW HURCO 4 07-22-2007 03:40 AM
.dwg problems anyone??? slideleft BobCad-Cam 10 03-23-2007 01:03 PM
Tap Problems Skeeterd5150 General Metal Working Machines 33 06-07-2006 03:12 PM




All times are GMT -5. The time now is 07:47 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