PDA

View Full Version : Radial Slot Macro



ArchieF
12-28-2007, 11:31 AM
Hi all,
here is my first attempt of a macro. You should save the attached Radial Slot.txt-file as Radial Slot.mac in the macro-subdirectory of NCPLOT to let the Macro Translator find it.
If you don't want the predefined variables just delete all between the two (----)-lines.
The tree other files have different predefined variables to show the macro and may be opened as normal nc-files.

To have a better look of what is happening you might change in the NCPLOT-Preferences the Animate-Delay to about 200 or more ms and in the Machine-Configuration the viewport-settings to color by G-Code.
Also the Show Plunge Moves, the Show Rapid Moves and perhaps Show Marker in the Draw-Menu should be enabled.

The Radial Slot.mac file would also work as normal nc-file but then no G-Code is generated. You would just see the result.
Since it is my first macro please apologize any error.
This macro has no checks for collision or any other damage so be careful. Hope it is useful to someone anyway.

Richard

MetLHead
01-16-2008, 05:24 PM
Richard,

This is a great application of the macro translator tool, nice work!

For anybody that is not familiar with this tool it allows you to create G-Code from a Macro B program. It will also expand loops and sub programs into one continuous program that can be run on any control that can accept G-Code. The required variables can be assigned values before executing the program so you don't need to edit the program.

Thanks,
Scott

ArchieF
01-17-2008, 04:53 AM
Thanks Scott for your kind words!
I'll try to explain a little bit which power NCPLOT has:

Loading the 2slot_example via the File -> open-menu will show in the editor-window of NCPLOT the code:

(RADIALSLOT WITH ZIG-ZAG PLUNGE MOVE)

(#240 RADIUS OF THE SLOT)
(#241 WIDTH OF THE SLOT)
(#242 ANGLE OF THE SLOT)
(#243 STARTANGLE)
(#244 ANGLE BETWEEN SLOTS)
(#245 COUNT OF SLOTS)
(#246 RADIUS OF THE TOOL)
(#247 COORDINATE CENTER X)
(#248 COORDINATE CENTER Y)
(#249 DEPTH OF THE SLOT)
(#250 COUNT OF ZIG-ZAGS)
(#251 COUNT OF CUTS FOR FINISHING)

#240=100
#241=16
#242=180
#243=0
#244=180
#245=2
#246=8
#247=0
#248=0
#249=10
#250=3
#251=2
M0


#200=0
WHILE [#200 LT ABS[#245]] DO 1
#261=#200*#244+#243
#262=2*[ASIN[[#241/4]/#240]]
#263=[#242/2]-#262
#265=#240*COS[#261+#263]+#247
#266=#240*SIN[#261+#263]+#248
#267=#240*COS[#261-#263]+#247
#268=#240*SIN[#261-#263]+#248
#269=#249/#250/2
#270=#269
G0 X#265 Y#266
G0 Z2.
G1 Z0. F100

WHILE [#270LT#249] DO 2
G2 X#267 Y#268 R#240 Z-#270
#270 = #270 + #269
G3 X#265 Y#266 R#240 Z-#270
#270 = #270 + #269
END 2

G2 X#267 Y#268 R#240
G0 Z2.

#280=#249/#251
#281=#240*COS[#261-#262]+#247
#282=#240*SIN[#261-#262]+#248
#283=#240*COS[#261+#262]+#247
#284=#240*SIN[#261+#262]+#248
#285=#240*COS[#261]+#247
#286=#240*SIN[#261]+#248
#287=[#240+[#241/2]]*COS[#261]+#247
#288=[#240+[#241/2]]*SIN[#261]+#248
#289=[#240+[#241/2]]*COS[#261+#263]+#247
#290=[#240+[#241/2]]*SIN[#261+#263]+#248
#291=[#240-[#241/2]]*COS[#261+#263]+#247
#292=[#240-[#241/2]]*SIN[#261+#263]+#248
#293=[#240+[#241/2]]*COS[#261-#263]+#247
#294=[#240+[#241/2]]*SIN[#261-#263]+#248
#295=[#240-[#241/2]]*COS[#261-#263]+#247
#296=[#240-[#241/2]]*SIN[#261-#263]+#248


#297=#280
WHILE [#297LE#249] DO 3
G1 X#285 Y#286 F2000
G1 Z-#297 F500
G41 G1 X#281 Y#282
G3 X#287 Y#288 R[#241/2]
G3 X#289 Y#290 R[#240+[#241/2]]
G3 X#291 Y#292 R[#241/2]
G2 X#295 Y#296 R[#240-[#241/2]]
G3 X#293 Y#294 R[#241/2]
G3 X#287 Y#288 R[#240+[#241/2]]
G3 X#283 Y#284 R[#241/2]
G40 G1 X#285 Y#286
#297=#297+#280
END 3
G0 Z2.
#200=#200+1
END 1

After clicking the refresh-button (the green arrow) you will see in the viewport the two slots. The code only works within NCPLOT or a control which knows MACRO-B code.

But: if you start the same 2slot_example via Tools -> Macro Translator and then click the refresh-button you will see in the viewport the same graphical result but in the editor-window the following code comes up:

G0X7.994Y99.68
G0Z2.
G1Z0.F100
G2X7.994Y-99.68R100.0Z-1.667
G3X7.994Y99.68R100.0Z-3.333
G2X7.994Y-99.68R100.0Z-5.0
G3X7.994Y99.68R100.0Z-6.667
G2X7.994Y-99.68R100.0Z-8.333
G3X7.994Y99.68R100.0Z-10.0
G2X7.994Y-99.68R100.0
G0Z2.
G1X100.0Y0.0F2000
G1Z-5.0F500
G41G1X99.68Y-7.994
G3X108.0Y0.0R8.0
G3X8.633Y107.654R108.0
G3X7.354Y91.706R8.0
G2X7.354Y-91.706R92.0
G3X8.633Y-107.654R8.0
G3X108.0Y0.0R108.0
G3X99.68Y7.994R8.0
G40G1X100.0Y0.0
G1X100.0Y0.0F2000
G1Z-10.0F500
G41G1X99.68Y-7.994
G3X108.0Y0.0R8.0
G3X8.633Y107.654R108.0
G3X7.354Y91.706R8.0
G2X7.354Y-91.706R92.0
G3X8.633Y-107.654R8.0
G3X108.0Y0.0R108.0
G3X99.68Y7.994R8.0
G40G1X100.0Y0.0
G0Z2.
G0X-7.994Y-99.68
G0Z2.
G1Z0.F100
G2X-7.994Y99.68R100.0Z-1.667
G3X-7.994Y-99.68R100.0Z-3.333
G2X-7.994Y99.68R100.0Z-5.0
G3X-7.994Y-99.68R100.0Z-6.667
G2X-7.994Y99.68R100.0Z-8.333
G3X-7.994Y-99.68R100.0Z-10.0
G2X-7.994Y99.68R100.0
G0Z2.
G1X-100.0Y0.0F2000
G1Z-5.0F500
G41G1X-99.68Y7.994
G3X-108.0Y0.0R8.0
G3X-8.633Y-107.654R108.0
G3X-7.354Y-91.706R8.0
G2X-7.354Y91.706R92.0
G3X-8.633Y107.654R8.0
G3X-108.0Y0.0R108.0
G3X-99.68Y-7.994R8.0
G40G1X-100.0Y0.0
G1X-100.0Y0.0F2000
G1Z-10.0F500
G41G1X-99.68Y7.994
G3X-108.0Y0.0R8.0
G3X-8.633Y-107.654R108.0
G3X-7.354Y-91.706R8.0
G2X-7.354Y91.706R92.0
G3X-8.633Y107.654R8.0
G3X-108.0Y0.0R108.0
G3X-99.68Y-7.994R8.0
G40G1X-100.0Y0.0
G0Z2.

As you can see this is pure G-Code and this code will work with nearly every control (industrial or hobby) or control-software (i.e. Mach3 or similar).
And even if your control should only know the G1-command then you could convert the G-Code via Tools -> Break arcs into lines into only G1-moves which makes the program of course very much longer (depending on the number of slots and the other parameters you can change).

I hope this helps !

Richard