Need help writing macro

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
Tlempicke
Posts: 169
Joined: Wed Jul 04, 2018 1:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: Yes
CPU10 or CPU7: No

Need help writing macro

Post by Tlempicke »

I have added a laser pointer to my CNC router. It projects a + onto the workpiece. This is offset from the tool tip and I would like to write a macro to add to my pendant to set the tool position. Shortly I will post a picture of the setup if this is not clear. I think that there might be a macro already in the program that would come pretty close to doing what I want, but I cannot find it.

The macro would do this

set Z height to 3"
Pause for input
receive input
set X and Y axis to zero
move tool to X=3.0, Y=3.16
Pause for input

ShawnM
Posts: 2234
Joined: Fri May 24, 2019 8:34 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 7804734C6498-0401191832
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Clearwater, FL

Re: Need help writing macro

Post by ShawnM »

If you load the "router" version of CNC12 there's a button and a sample macro for this already. You set up your "offset" in the wizard on the "input devices setup" page. There's a section labeled "cross hair laser setup". I believe the oem macro is mfunc76 if you want to manually edit.

I have the exact same setup with a cross hair laser and it's programmed to button 1 of the WMPG as I use it a lot. My macro is slightly different than the stock one but it does the same thing. My laser is mounted to the fixed, backplate for the Z axis and it focused to the spoilboard so no need to move my Z axis when using the macro. You would simply add that Z move into your custom macro.
Sword
Posts: 667
Joined: Fri Nov 30, 2018 1:04 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Thorp WI

Re: Need help writing macro

Post by Sword »

My crosshair laser and macro is set up is similar to Shawn's. I've added the option to choose what WCS (1-6) I would like to set as well. The offsets are hard coded, but as Shawn states, the latest versions now have the crosshair laser offset option in the Wizard and a macro to go with.

Code: Select all

;------------------------------------------------------------------------------
; Filename: plcmacro4.mac
; Description: User Customizable Macro, currently set for laser alignment
; Notes:
; Requires: Machine home must be set prior to use.
; Please see TB300 for tips on writing custom macros.
;------------------------------------------------------------------------------

IF #50010                        ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching

;M225 #100 "This is an example macro run from the Macro2 button on the Centroid CWP-4 MPG\nThe macro is named MPGmacro2.mac and can be found\nin the \cncm\system directory.\nEdit it to include the desired functionality. Press Cycle Start to Exit"


N100                             ;Insert your code between N100 and N1000  

; Set XY to Laser

  #101 = 1           ; Default WCS G54
  #102 = -3.2702       ; X offset to Laser  (pos or neg)
  #103 = -4.089      ; Y offset to laser  (pos or neg)
  #104 = 4           ; Length of time to wait for M225 message
  #105 = 0           ; "NO" to setting another location
  
M5                   ; Turn off spindle

M200 "SET XY LOCATION WITH LASER?\nCycle Start to continue\nCycle Cancel to get out of here"

M25                  ; Raise Z to machine home

N200

M224 #101 "What WCS would you like to set? (Enter 1-6)"
IF [#101 < 1] || [#101 > 6] THEN GOTO 200
E#101                ; Set the chosen WCS

M94/29                  ;Turn on laser
M200 "MOVE CROSSHAIRS TO DESIRED LOCATION\nPress Cycle Start when finished"
G91 G0 X[#102] Y[#103]
G90
G92 X0 Y0
G4 P 0.5
M95/29                   ;Turn off laser
M225 #104 "XY LOCATION SET FOR WCS #%.0f" #101

N300

;M224 #105 "Would you like to set another location? (0 = NO, 1 = YES)"
;IF #105 == 0 THEN GOTO 1000
;IF #105 == 1 THEN GOTO 200 ELSE GOTO 1000

N1000 ; end 


Scott
ShawnM
Posts: 2234
Joined: Fri May 24, 2019 8:34 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 7804734C6498-0401191832
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Clearwater, FL

Re: Need help writing macro

Post by ShawnM »

That's a great option/addition Scott if you use multiple work coordinates. I always use G54 for every project but I know there are those who use multiple so a nice added feature to your macro.
Sword
Posts: 667
Joined: Fri Nov 30, 2018 1:04 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Thorp WI

Re: Need help writing macro

Post by Sword »

I tend to leave G54 at the table corner (which is also machine coord) for those times I may put a whole or partial sheet on the table or when surfacing the table, and 2-6 wherever else I may have something set up with a jig or in a corner clamping frame. The laser is for non critical alignment, and a 5" x 5" corner plate with a bore for setting exact with the probe app. ;)
Scott
Tlempicke
Posts: 169
Joined: Wed Jul 04, 2018 1:32 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: Yes
CPU10 or CPU7: No

Re: Need help writing macro

Post by Tlempicke »

Thank you!
ShawnM
Posts: 2234
Joined: Fri May 24, 2019 8:34 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 7804734C6498-0401191832
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Clearwater, FL

Re: Need help writing macro

Post by ShawnM »

Sword wrote: Sun Jan 28, 2024 3:41 pm I tend to leave G54 at the table corner (which is also machine coord) for those times I may put a whole or partial sheet on the table or when surfacing the table, and 2-6 wherever else I may have something set up with a jig or in a corner clamping frame. The laser is for non critical alignment, and a 5" x 5" corner plate with a bore for setting exact with the probe app. ;)
That certainly makes sense and a good plan of attack if using multiple WCS. I don't really cut material or parts where I need to know EXACTLY where the corner is so the cross hair laser gets it "close enough" for me. I think this is why I haven't tried the probe app yet. I don't need anything that precise as I cut parts from whole sheets. I have a 3D probe that I use to find the center of holes in aircraft panels and do wall following with and the Centroid interface works great for what I need.
Post Reply