Page 1 of 2 12 LastLast
  1. I am writing a simple hole generator in Processing because I can run it on the Mac and there is very little CAM on the Mac. So I have this generator that will generate G code snippets. However when it comes to the D shaped hole I ave hit a snag. The yellow is the hole I want to draw and the orange is the tool path. The two orange circles represent the limit of the tool path before going horizontal. The question is how do I calculate the position of these holes, given the diameter of the hole can change as can the tool diameter and the depth of the D shape. My maths isn't up to is could someone help please.

    Click image for larger version. 

Name:	D-Hole.png 
Views:	191 
Size:	10.7 KB 
ID:	2450
    Last edited by irving2008; 26-07-2010 at 10:54 PM.

  2. #2
    Hi Mike,

    Just seen your post, but got to go. Sorry it's Wikipedia, but this might be a starter:
    http://en.wikipedia.org/wiki/Circular_segment

    Also, the corners will have a radius, not be sharp as per the yellow outline. Sure you knew that . . .
    Building a CNC machine to make a better one since 2010 . . .
    MK1 (1st photo), MK2, MK3, MK4

  3. Thanks but that doesn't solve the problem. I know all that maths in the link, that's how I drew the figure I posted in the first place. The problem is when it comes to creating the path at the corners. The tool (circle) has to be tangential to both the curve of the hole and the straight line. Yes the sharpness of the corners will depend on the tool size.

  4. #4
    Assuming you have the circle radius and the distance from the circle centre to the line centre you can do it with pythagorus.

    X = square root (r squared - centre to centre squared).

    Your x coordinates for the line ends are then circle centre x + X, and circle centre x - X

    Or have I misunderstood?

  5. Thanks but yes you have misunderstood. It is the center of the tools position I am after when it is at the end of the straight bit. It is where the tool path for the straight bit crosses the tool path for the circular bit. Or put it another way it is the difference in the angle between the center and the bit where the straight joins the curve (which I know as that was part of defining the shape) and the angle between the tool center and the center of the hole. These angles are not the same as I first thought.

  6. make the centre of the circle 0,0

    call the tool radius t, the radius of the actual hole R and the location of the chord is y = -d

    the coordinate of the holes are x = +/- (R-t)sin(arccos((d-t)/(R-t))), y = -d+t

    How are you programming this, there may be an easier way

  7. #7
    Quote Originally Posted by Grumpy Mike View Post
    Thanks but yes you have misunderstood. It is the center of the tools position I am after when it is at the end of the straight bit.

    Well you just subtract the tool radius from the arc radius and add the tool radius to the line y co-ordinates before you do the pythagorus bit.

    I've just been writing code to do much the same thing, decided pythagorus was a lot easier than applying the cosine rule even if it meant rotating the chord into the vertical and then back again :whistling:

    Just to make it interesting I also spiral down into draft angles and hemispherical sections which is taxing my brain a bit but I'm getting there. Slowly. The G-Code is a bit whacky, I define the arc centre using I and J but the end co-ordinates are not necessarily on the same radius as the start. Dubiously G-code legal. I had to mod my mill driving code a bit before it would accept a spiral

  8. Thanks irving, I worked out what I needed this morning on the drive in to work and I agree with you. I just got the sin and cos swapped over but that don't matter it just rotates it through 90 degrees.
    It's good to have confirmation before I try and code it. I am using the free language called Processing, it runs on all platforms.

    Do you think there would be any interest if I posted the final result? I am also working on a program to send a G code file to the miller. I wanted to use Replicator G but I can't get that to work reliably on my Mac, despite several email exchanges with the authors.

  9. #9
    Hi Mike,

    The above posts sound alot quicker than my solution which was:
    Take the equation for a circle (x^2 + y^2 = r^2)
    Take the equation for a straight line (y = mx + c)
    these 2 lines are coincident when the x from the circle = x from the line, and y from the circle = y from the line, therefore substitute one equation into the other to create a quadratic equation (x^2 + mx + [c-r^2] = 0. Solve this using the quadratic formula to give x. Substitute back into either of the above to give y. This gives the 2 sets of coordinates of where the circle and line intersect.

    This is a bit more generic than the solutions above, so should work for other related shapes, but is more complex!
    Building a CNC machine to make a better one since 2010 . . .
    MK1 (1st photo), MK2, MK3, MK4

  10. Quote Originally Posted by Grumpy Mike View Post
    Thanks irving, I worked out what I needed this morning on the drive in to work and I agree with you. I just got the sin and cos swapped over but that don't matter it just rotates it through 90 degrees.
    It's good to have confirmation before I try and code it. I am using the free language called Processing, it runs on all platforms.

    Do you think there would be any interest if I posted the final result? I am also working on a program to send a G code file to the miller. I wanted to use Replicator G but I can't get that to work reliably on my Mac, despite several email exchanges with the authors.
    Always interesting to see other people solutions to problems...

Page 1 of 2 12 LastLast

Similar Threads

  1. Calculating timing belt lengths
    By Jonathan in forum Gantry/Router Machines & Building
    Replies: 11
    Last Post: 10-12-2015, 11:32 AM
  2. Romi EZ-Path S Lathe crt replacement
    By Nemo1966 in forum Monitors
    Replies: 5
    Last Post: 07-10-2013, 04:25 PM
  3. Calculating Stepper Motor Power? Strength?
    By antsals in forum General Discussion
    Replies: 2
    Last Post: 11-07-2011, 12:18 PM
  4. Calculating torque settings for bolts.
    By swarf-boy in forum Machine Discussion
    Replies: 2
    Last Post: 22-12-2010, 12:18 AM
  5. Calculating forces on linear bearings ...
    By Jonathan in forum Rails, Guideways & Bearings
    Replies: 7
    Last Post: 24-11-2010, 02:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •