Controller board to cut Bezier curves?!?? - Page 2


Page 2 of 2 FirstFirst 12
Results 13 to 14 of 14

Thread: Controller board to cut Bezier curves?!??

  1. #13
    Member
    Join Date
    Jul 2017
    Location
    Italy
    Posts
    64
    Downloads
    0
    Uploads
    0

    Default Re: Controller board to cut Bezier curves?!??

    Follow a sample code to get a 2 dimension bezier (XY) of 3 degree using RosettaCNC macro language (compliant with Fanuc-B macro language).


    Controller board to cut Bezier curves?!??-400px-bezier_curve-svg-png

    Code:
    G17 G21 G40 G49 G80 G90
    G54
    
    
    G52 X200 Y200
    G0 X0 Y0
    
    
    F1000
    
    
    ; Sample of path with 3 bezier curve (3 degree)
    G65 P1000 T0.01 A0 B0 C0 D50 E100 F50 I100 J0
    G65 P1000 T0.01 A100 B0 C150 D-25 E220 F-10 I180 J0
    G65 P1000 T0.01 A180 B0 C180 D75 E120 F200 I0 J50
    
    
    M2
    
    
    ; create a degree 3 Bezier curve
    ;
    ;   dt      T   #20
    ;   p0.x    A   #1
    ;   p0.y    B   #2
    ;   p1.x    C   #3
    ;   p1.y    D   #7
    ;   p2.x    E   #8
    ;   p2.y    F   #9
    ;   p3.x    I   #4
    ;   p3.y    J   #5
    O1000
    ;   local variables
    ;   #1000 = t
    ;   #1001 = x0
    ;   #1002 = y0
    ;   #1003 = x1
    ;   #1004 = y1
    
    
        #1000 = 0.0
    
    
        ; calc x1 & y1
        G65 P1001 T#1000 A#1 B#3 C#8 D#4
        #1003 = #100
        G65 P1002 T#1000 A#2 B#7 C#9 D#5
        #1004 = #100
        
        ; t = t + dt
        #1000 = [#1000 + #20]
    
    
        WHILE [#1000 LT 1] DO01
            ; x0 = x1
            #1001 = #1003
            ; y0 = y1
            #1002 = #1004
    
    
            ; calc x1 & y1
            G65 P1001 T#1000 A#1 B#3 C#8 D#4
            #1003 = #100
            G65 P1002 T#1000 A#2 B#7 C#9 D#5
            #1004 = #100
    
    
            G1 X#1001 Y#1002
            X#1003 Y#1004
    
    
            ; t = t + dt
            #1000 = [#1000 + #20]
        END01
    M99
    
    
    ; X function for a degree 3 Bezier curve
    ;
    ;   t       T   #20
    ;   x0      A   #1
    ;   x1      B   #2
    ;   x2      C   #3
    ;   x3      D   #7
    ;
    ;   #100 =  x0 * (1 - t) ^ 3 +
    ;           x1 * 3 * t * (1 - t) ^ 2 +
    ;           x2 * 3 * t ^ 2 * (1 - t) +
    ;           x3 * t ^ 3
    O1001
        #100 = [ 0    + [#1 * [[1 - #20] ** 3]] ]
        #100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
        #100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
        #100 = [ #100 + [#7 * [#20 ** 3]] ]
    M99
    
    
    ; Y function for a degree 3 Bezier curve
    ;
    ;   t       T   #20
    ;   y0      A   #1
    ;   y1      B   #2
    ;   y2      C   #3
    ;   y3      D   #7
    ;
    ;   #100 =  y0 * (1 - t) ^ 3 +
    ;           y1 * 3 * t * (1 - t) ^ 2 +
    ;           y2 * 3 * t ^ 2 * (1 - t) +
    ;           y3 * t ^ 3
    O1002
        #100 = [ 0    + [#1 * [[1 - #20] ** 3]] ]
        #100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
        #100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
        #100 = [ #100 + [#7 * [#20 ** 3]] ]
    M99
    You get this:
    Controller board to cut Bezier curves?!??-bezier-jpg


    The inner macro can be used to creare a new user-defined G code (Eg: G300):

    Code:
    G17 G21 G40 G49 G80 G90
    G54
    
    
    G52 X200 Y200
    G0 X0 Y0
    
    
    F1000
    
    
    ; Sample of path with 3 bezier curve (3 degree)
    G300 T0.01 A0 B0 C0 D50 E100 F50 I100 J0
    G300 T0.01 A100 B0 C150 D-25 E220 F120 I180 J0
    G300 T0.01 A180 B0 C180 D75 E120 F200 I0 J50
    G300 T0.01 A0 B50 C73 D80 E20 F100 I210 J50
    
    
    M2
    And obtain:
    Controller board to cut Bezier curves?!??-bezier2-jpg

    A video of toolpath executed in CNC:



    Attached Thumbnails Attached Thumbnails Controller board to cut Bezier curves?!??-bezier-jpg   Controller board to cut Bezier curves?!??-bezier2-jpg   Controller board to cut Bezier curves?!??-400px-bezier_curve-svg-png  
    Last edited by shineworld; 09-24-2019 at 11:33 AM.


  2. #14
    Member
    Join Date
    Jul 2017
    Location
    Italy
    Posts
    64
    Downloads
    0
    Uploads
    0

    Default Re: Controller board to cut Bezier curves?!??

    In this last example I've matched a circle made with bezier with a native circle made with arcs.
    The G300 macro is changed to use K instead of F and missing last segment added.

    G300 Macro code:
    Code:
    ; create a degree 3 Bezier curve
    ;
    ;   dt      T   #20
    ;   p0.x    A   #1
    ;   p0.y    B   #2
    ;   p1.x    C   #3
    ;   p1.y    D   #7
    ;   p2.x    E   #8
    ;   p2.y    K   #6
    ;   p3.x    I   #4
    ;   p3.y    J   #5
    O1000
    ;   local variables
    ;   #1000 = t
    ;   #1001 = x0
    ;   #1002 = y0
    ;   #1003 = x1
    ;   #1004 = y1
    
    
        #1000 = 0.0
    
    
        ; calc x1 & y1
        G65 P1001 T#1000 A#1 B#3 C#8 D#4
        #1003 = #100
        G65 P1002 T#1000 A#2 B#7 C#6 D#5
        #1004 = #100
        
        ; t = t + dt
        #1000 = [#1000 + #20]
    
    
        WHILE [#1000 LT 1] DO01
            ; x0 = x1
            #1001 = #1003
            ; y0 = y1
            #1002 = #1004
    
    
            ; calc x1 & y1
            G65 P1001 T#1000 A#1 B#3 C#8 D#4
            #1003 = #100
            G65 P1002 T#1000 A#2 B#7 C#6 D#5
            #1004 = #100
    
    
            G1 X#1001 Y#1002
            X#1003 Y#1004
    
    
            ; t = t + dt
            #1000 = [#1000 + #20]
        END01
        
        ; connect final point
        #1000 = 1
    
    
        ; x0 = x1
        #1001 = #1003
        ; y0 = y1
        #1002 = #1004
    
    
        ; calc x1 & y1
        G65 P1001 T#1000 A#1 B#3 C#8 D#4
        #1003 = #100
        G65 P1002 T#1000 A#2 B#7 C#6 D#5
        #1004 = #100
    
    
        G1 X#1001 Y#1002
        X#1003 Y#1004
    M99
    
    
    ; X function for a degree 3 Bezier curver
    ;
    ;   t       T   #20
    ;   x0      A   #1
    ;   x1      B   #2
    ;   x2      C   #3
    ;   x3      D   #7
    ;
    ;   #100 =  x0 * (1 - t) ^ 3 +
    ;           x1 * 3 * t * (1 - t) ^ 2 +
    ;           x2 * 3 * t ^ 2 * (1 - t) +
    ;           x3 * t ^ 3
    O1001
        #100 = [ 0    + [#1 * [[1 - #20] ** 3]] ]
        #100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
        #100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
        #100 = [ #100 + [#7 * [#20 ** 3]] ]
    M99
    
    
    ; Y function for a degree 3 Bezier curver
    ;
    ;   t       T   #20
    ;   y0      A   #1
    ;   y1      B   #2
    ;   y2      C   #3
    ;   y3      D   #7
    ;
    ;   #100 =  y0 * (1 - t) ^ 3 +
    ;           y1 * 3 * t * (1 - t) ^ 2 +
    ;           y2 * 3 * t ^ 2 * (1 - t) +
    ;           y3 * t ^ 3
    O1002
        #100 = [ 0    + [#1 * [[1 - #20] ** 3]] ]
        #100 = [ #100 + [#2 * 3 * #20 * [[1 - #20] ** 2]] ]
        #100 = [ #100 + [#3 * 3 * [#20 ** 2] * [1 - #20]] ]
        #100 = [ #100 + [#7 * [#20 ** 3]] ]
    M99
    Sample code:
    Code:
    G17 G20 G40 G49 G80 G90
    G54 F100
    
    
    G52 X2 Y2
    G0 X0 Y1
    
    
    G64 Q.01 P.01
    
    
    ; select T1 color
    M61 Q1
    
    
    ; control point for 1 inch radius
    #1=0.55191502449
    
    
    ; circle of 1 inch with bezier curve
    ;
    ;     dt    p1.X  p1.Y  p2.X  p2.Y  p3.X  p3.Y  p4.X  p4.Y
    ;    =====  ====  ====  ====  ====  ====  ====  ====  ====
    G300 T0.01  A0    B1    C#1   D1    E1    K#1   I1    J0
    G300 T0.01  A1    B0    C1    D-#1  E#1   K-1   I0    J-1
    G300 T0.01  A0    B-1   C-#1  D-1   E-1   K-#1  I-1   J0
    G300 T0.01  A-1   B0    C-1   D#1   E-#1  K1    I0    J1
    
    
    ; select T2 color
    M61 Q2
    
    
    ; circle of 1 inch with g2
    G0 X0 Y1
    G2 X0 Y1 I0 J-1
    
    
    M2
    Result:
    Controller board to cut Bezier curves?!??-bezier-circle-jpg

    Video:


    In next days I will try to create a macro to manage cycles with NURBS control points eg:

    Code:
    G66 p"nurbs" Q1 L3
         X0 Y1 Q1
         X2 Y2 Q1
         X2 Y0 Q1
         X0 Y0 Q2
    G67
    


    Attached Thumbnails Attached Thumbnails Controller board to cut Bezier curves?!??-bezier-circle-jpg  


Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Controller board to cut Bezier curves?!??

Controller board to cut Bezier curves?!??

Controller board to cut Bezier curves?!??