|
Post by alexfish on Dec 22, 2023 19:09:05 GMT 1
Strange Title No more that a I was asked Q how good is a CNC router at CIRCLES Without further bits to explain the SIN COS and blagh , Here we use the Hypotenuse function sqr(x) as the RADIUS an the stepper motor constraint in the X axis(steps to mm) as in ARCS/QUADS Have Fun + BR Alex ' Hypotenuse functions OPTION PARSE FALSE INCLUDE "hug.bac" HUGOPTIONS("NOSCALING")
FUNCTION HYPOT(double a,double b) TYPE double RETURN SQR(a*a + b*b) END FUNCTION
FUNCTION RESIP(double a,double b) TYPE double RETURN (double)SQR((double) a*a - (double)b*b) END FUNCTION
win = WINDOW("Something",900,900)
can = CANVAS(600,600) ATTACH(win,can,0,0)
' 'Hypotenuse C squared = A squared + B squared = ARCS & CIRCLE LOCAL RESX ,RESY , RADIUS = 150.0, t TYPE float LOCAL A=3.0, B=4.0, C TYPE double C = HYPOT(A,B) PRINT "Hypotenuse of (a = 3 b = 4) = ", C
' Stepper motor x constraint 0.02 mm per step FOR t = 1 TO RADIUS STEP 0.02 RESY = RESIP(RADIUS,t) PIXEL("#FF0000",RADIUS + t,RADIUS+RESY) PIXEL("#FFFF00",RADIUS + t, RADIUS -RESY) PIXEL("#FF0000",RADIUS - t,RADIUS+RESY) PIXEL("#FFFF00",RADIUS - t, RADIUS -RESY) NEXT
DISPLAY Q: can it be improved on A: yes ::= DIY Attachments:
|
|
|
Post by alexfish on Dec 22, 2023 19:23:43 GMT 1
DIY 2
BACK TO ground ZERO
' Stepper motor x constraint 0.02 mm per step FOR t = 0 TO RADIUS STEP 0.02 RESY = RESIP(RADIUS,t) PIXEL("#FF0000",RADIUS + t,RADIUS+RESY) PIXEL("#FFFF00",RADIUS + t, RADIUS -RESY) PIXEL("#FF0000",RADIUS - t,RADIUS+RESY) PIXEL("#FFFF00",RADIUS - t, RADIUS -RESY) NEXT
|
|
|
Post by alexfish on Dec 22, 2023 19:45:08 GMT 1
In a Puritanical Sense I avoided such terms such as Get a piece of plywood , a hammer , a nail,a bit of string + the router Hammer the nail in center of plywood tie the string to nail + other end of string to , yes you got it , to the router Away Ye Go And No , I can not that change nose to nuse May be Peter Can , Change TO Hypotenuse C squared = A squared + B squared = A CIRCLE
|
|
|
Post by alexfish on Dec 29, 2023 0:31:39 GMT 1
Hi All Have applied simple algo to resolve the usual infinite number syndrome the values are put into the editor + can compare to a Normal HUG CIRCLE My Conspiracy Theory ' a bit like PI = 4 theory and nibble away at the corners: IE draw a circle inside a SQUARE www.youtube.com/watch?v=D2xYjiL8yyE' Hypotenuse functions /* /| Hypotenuse / | 5 / |opposite / | / | /__________| Adjacent */ OPTION PARSE FALSE INCLUDE "hug.bac" HUGOPTIONS("NOSCALING")
USEH #define PRINTS(arg1,arg2,arg3) sprintf(arg3,arg2,arg1) END USEH
PROTO PRINTS
FUNCTION EVAL$(double hug_number,int decimal_places) TYPE STRING
LOCAL EVS$ IF decimal_places > -1 THEN
EVS$ ="%." & STR$(decimal_places) & "f" LOCAL gx[20] TYPE static char
PRINTS(hug_number,EVS$,gx)
RETURN gx
ELSE RETURN NULL END IF
END FUNCTION REM ------------------------------------------------ FUNCTION HYPOT(double a,double b) TYPE double RETURN SQR(a*a + b*b) END FUNCTION REM ------------------------------------------------ FUNCTION RESIP(double a,double b) TYPE double RETURN (double)SQR((double) a*a - (double)b*b) END FUNCTION REM ------------------------------------------------ SUB Draw() ' 'Hypotenuse C squared = A squared + B squared = ARCS & CIRCLE LOCAL RESX ,RESY , RADIUS = 150.0, t TYPE float LOCAL A=3.0, B=4.0, C TYPE double LOCAL val$ LOCAL ptr TYPE double C = HYPOT(A,B) PRINT "Hypotenuse of (a = 3 b = 4) = ", C
'rectify infinit dims from SIN(rad(1)) 0.0174524 and adjust to LOCAL rfy TYPE double rfy = 0.0195524 ' Stepper motor x constraint 0.02 mm per step ptr = 0.0-0.02 RADIUS = 300 SQUARE("#C03500",0,0,650,850,1) CIRCLE("#000000",5,5,RADIUS*2,RADIUS*2,0) SYNC
WHILE (1) DO INCR ptr,0.02
RESY = RESIP(RADIUS,ptr+rfy) val$ = EVAL$(RESY,2) RESY = VAL(val$) ptr$ = EVAL$(ptr,2) ' reallt needs the isnan from geo.bac IF STR$(RESY) = "nan" THEN RESY = 0.0 TEXT(ed, ptr$ & " : " & STR$(RESY) & NL$) 'bottom right , draw up to cx/cy PIXEL("#FFFF00",RADIUS+5 + ptr,RADIUS+5+RESY) 'top right , draw down to PIXEL("#FFFFFF",RADIUS+5 + ptr, RADIUS+5 -RESY) 'bottom left , draw up PIXEL("#FFFF00",RADIUS +5 - ptr,RADIUS+5+RESY) 'top left , draw down to PIXEL("#FFFFFF",RADIUS+5 - ptr, RADIUS+5 -RESY)
IF ptr >= RADIUS- 0.01 THEN BREAK WEND
END SUB REM ======================================================== win = WINDOW("BaCon 4.7",1200,900)
but = BUTTON("test",100,30) ATTACH(win,but,5,5) CALLBACK(but,Draw)
can = CANVAS(650,850) ATTACH(win,can,0,50)
ed = EDIT(500,850) ATTACH(win,ed,700,50)
DISPLAY
HAVE FUN + BR Alex
|
|
|
Post by alexfish on Dec 29, 2023 3:26:35 GMT 1
Well Well I put the above results into GCODE using TEXT(ed,"G01 X " & ptr$ & " Y " & STR$(RESY) & NL$) Then saved the quadrant/ARC saved as nc file > open the file with bCNC Added GCODE ARC G02 X300 Y300 R300 and Viola Tit for Tat The Diff in the Y axis this was due to the Invert image one has to do but did not reset the origin :: so back check on the start y and the two bits = 300 See Screen shot :: also zoomed into the drawing and can not find Error in the pixel positions I am amazed picky Attachments:
|
|