Page 1 of 3

custom macro help (Resolved)

Posted: Tue May 29, 2018 7:54 pm
by antpdrake
Hi everyone

i need to set up function "M106" (move plus to switch) for my plasma.
i have a limit switch on the plasma torch to automatically set the correct torch height.

i need m106 to move Z in + direction until the switch on input 8 closes at the set feed rate then that will be set to 0 in the next line of code then after that moved to -15 or whatever measurement..

i have tried writing the file into the cncm file but am doing it wrong and am so far unable to work it out.

can someone please help!?

thanks!

Re: custom macro help

Posted: Wed May 30, 2018 8:36 am
by diycncscott
in a file, saved in the c:cncm directory -let's call it mfunc28.mac-

to move until the switch is closed, write: M106 /Z P#5000* F.5

to move until the switch is open, write: M106 /Z P-#5000* F.5

Replace * with the input number the switch is wired into. F is the feedrate it will move at while looking for switch (.5" per minute here). You probably want to move at a faster rate until the switch trips and then use M105 to move in the negative direction at a slow rate until it changes state nad then use:

M26 /Z to set machine home there.

To run it, simply type M28 at MDI or put it in a program.

Re: custom macro help

Posted: Mon Jun 11, 2018 10:44 pm
by antpdrake
thanks for that!

the custom macro seems to be working but it is not recognising the limit switch opening, in the wizard what should i set input 8 to?
i have tried a few different one with no success

cheers

Re: custom macro help

Posted: Mon Jun 11, 2018 11:52 pm
by martyscncgarage
antpdrake wrote: Mon Jun 11, 2018 10:44 pm thanks for that!

the custom macro seems to be working but it is not recognising the limit switch opening, in the wizard what should i set input 8 to?
i have tried a few different one with no success

cheers
You DO NOT set the input to anything in the Wizard.
The macro simply watches the state of input 8

Did you open the diagnostic screen from the main CNC12 screen (Alt+I) and manually trip the switch? Does input 8 toggle on and off as you trip the switch?

Marty

Re: custom macro help

Posted: Tue Jun 12, 2018 1:28 am
by antpdrake
ok so i set input 8 to unused, NC

it comes up as a green dot in diagnostic screen when i trip the switch so that side seems to be good,

its probably a problem in my macro file which goes as follows..

M106 /Z P#50008 F300
M105 /Z P-#50008 F50
M26 /Z

what do you think?

cheers

Re: custom macro help

Posted: Tue Jun 12, 2018 10:10 am
by cnckeith
please post a report.zip file

Re: custom macro help

Posted: Tue Jun 12, 2018 1:37 pm
by Centroid_Tech
It appears that diycncscott got the P values reversed. When the P value is positive, the control is looking for the switch to open and when the P value is negative, the control is looking for the switch to close. Based on your original requirements, the M105/M106 logic in your program as well as the behavior of the switch is incorrect.

You stated that you wanted to move the Z axis in the positive direction until input 8 closes. That means that normally, that input is open until it hits at which point, that input is closed. Is that how you wish for it to operate? If so, in the wizard, you should set that input as NO as it's normally open until it trips. When you press ALT+I to look at the PLC Diagnostic menu in the CNC12 software, that input should be red until you trip it which will then turn green. You should also see a white line above that input which tells the control that input is NO logic rather than NC logic. If the input is behaving correctly, then you will need the following logic.

M106 /Z P-#50008 F300 ; Move Z in positive direction at 300in/min until input 8 closes
M105 /Z P#50008 F50 ; Move Z in negative direction at 50in/min until input 8 opens
M26 ; Set absolute encoder count to 0

Re: custom macro help

Posted: Tue Jun 12, 2018 7:12 pm
by antpdrake
yes you have it right centroidtech,

NO switch, when i go to cnc diagnostics the input 8 light is staying green and going red when i trip the switch, and yes it has the little line above it and is set to NO in the wizard,

macro is now as follows;

M106 /Z P-#50008 F300
M105 /Z P#50008 F50
M26 /Z

FYI im working in metric mm/min

and see attached report

must be getting close to it working!

thanks guys

Re: custom macro help

Posted: Wed Jun 13, 2018 12:46 pm
by Centroid_Tech
I apologize. I didn't read your first post properly. I believe that if you switch that input back to being NC in the wizard, it should work.

Re: custom macro help

Posted: Wed Jun 13, 2018 6:55 pm
by antpdrake
so i change the wizard to "NC" and now diagnostic input 8 light goes green when tripping the switch but Z is not stopping when it trips in the program..

any more ideas?? :idea: :oops: