I need some help for my homemade CNC

Thread Starter

CVMichael

Joined Aug 3, 2007
419
I posted on another forum (to show off :D ) about my homemade CNC:
http://www.vbforums.com/showthread.php?t=565474
You can also see the it in action here:
http://www.youtube.com/watch?v=izudmpqHE74


My problem is that I don't know the logic to make it move in circle (oval, etc.) motion. Right now I can only make straight lines.

Btw, the "O" in the "hello" is drawn kind of like this:
Rich (BB code):
/---\
|   |
|   |
\---/
I don't need code, as long as I know how to do it logically, I can figure out the programming.
 

jpanhalt

Joined Jan 18, 2008
11,087
Very nice. I like your use of twin lead screws on X and Y axes. I have not built one (yet), but when I see designs that use single lead screws, particularly to move the gantry, I wonder about rigidity.

Sorry I can't help on the logic question.
John
 

Wendy

Joined Mar 24, 2008
23,415
Figure steps, X, then Y, then X, etc.

I've been known to do something similar with a milling machine. I figured where the radius of the cutting tool would be with in the circle. I was cutting a larger circle with a flat side for a component in a case. I could draw it better than descibing it, but I went in steps of 5 mils each, and figured the start and stop points accordingly.

The resulting cutout had noticable ripple, but worked like a charm.
 

Thread Starter

CVMichael

Joined Aug 3, 2007
419
jpanhalt, I am not familiar with all the terms when it comes to hardware, I tried to search for "twin lead screws" on google, and I get many kinds of things....

But relating to that (I think), I plan to re-create the CNC, and next time I will use acme rods instead of threaded rods. I was told they are much more precise.

Bill_Marsden, I want to do the calculations in the microcontroller, and I am not satisfied if I make it move in a circle by calculating in small lines.

I want to enter the formula for a circle, and calculate very precisely at what position it should be at any point in the circle.

For example, I made a picture with a circle that I zoomed 600%, and you can see that a circle is not really made of straight lines connected together
 

Attachments

Thread Starter

CVMichael

Joined Aug 3, 2007
419
Hi Alberto

That is not really what I had in mind.

What I need is to get every point on the circle at 1 point distance each.

For example, if you look at the image I attached.

Suppose I start making the circle from the red point, then blue, then brown, and so on...

I will get the points like this
X, Y
2, 8
2, 7
2, 6
3, 5
4, 4
5, 3
etc...

But if I do it the way posted, and if I have the Resol too high, then it will miss points, if the Resol is too low, then it will return the same point more than once.

I was thinking to use the equation of the circle: X2 + Y2=r2 and solve for X when I have Y, and the other way around
 

Attachments

Thread Starter

CVMichael

Joined Aug 3, 2007
419
I still don't think you understand what I want.

The way you said, you always get the same number of points regardless of the radius of the circle. And this way A LOT of points repeat or not enough points. Either way, it is too difficult to fiddle with the resolution to get the perfect number of points for each radius of every circle.

Here are some examples with radius, and how many points there should be:

Radius 5 = 36 points
Radius 10 = 64 points
Radius 20 = 120 points
Radius 30 = 176 points
Radius 50 = 288 points
Radius 100 = 572 points
Radius 150 = 856 points
Radius 200 = 1136 points
Radius 500 = 2836 points
etc...

Here is some code in Visual Basic 6 that shows how it's done, and how I got the above numbers:
This code draws a perfect circle every time !
Rich (BB code):
Option Explicit

Private PointCount As Long

Private Sub Form_Load()
    Me.Show
    DoEvents
    
    PointCount = 0
    DrawCircle 100, 100, 500
    Debug.Print PointCount
    Unload Me
End Sub

Private Sub DrawCircle(ByVal CX As Single, ByVal CY As Single, ByVal R As Single)
    Dim PX As Single
    Dim PY As Single
    Dim T As Single
    Dim M As Single
    
    'this function is using the formula (x^2 + y^2 = r)
    
    R = R * R
    M = Sqr(R) / 1.4
    
    For PY = 0 To M
        PX = Sqr(R - (PY * PY))
        
        DrawPoint CX + PX, CY + PY
        DrawPoint CX - PX, CY + PY
        DrawPoint CX + PX, CY - PY
        DrawPoint CX - PX, CY - PY
    Next PY
    
    T = PX
    For PX = 0 To T
        PY = Sqr(R - (PX * PX))
        
        DrawPoint CX + PX, CY + PY
        DrawPoint CX - PX, CY + PY
        DrawPoint CX + PX, CY - PY
        DrawPoint CX - PX, CY - PY
    Next PX
End Sub

Private Sub DrawPoint(ByVal X As Single, ByVal Y As Single)
    PointCount = PointCount + 1
    Debug.Print PointCount, Fix(X), Fix(Y)
    Me.PSet (X, Y)
End Sub
The ONLY problem with that code is that it does not give the points in sequence.

Actually while writing this, I just got an idea how to do it.
 
Last edited:

Thread Starter

CVMichael

Joined Aug 3, 2007
419
I tried to explain to you, but it seems it does not work.

Yes, I did look at the project you posted, but the same problem still persists.

It does not make sense to enter the "resolution" when you don't have to.

And on top of that a circle made up of lines is not a circle.

Did you look at the code I posted ? you don't have to give the resolution, it always makes a perfect circle with not too many points, and not too few.

Anyways... there is no point to continue.
 
Top