Tool Change Code

MSM Mill mode support
gdmarsh
Posts: 8
Joined: Wed Feb 13, 2013 1:26 pm

Tool Change Code

Post by gdmarsh »

Dave,

If you remember, a while back I built a swing-out Touch Plate to handle ATLO.
I've tried a couple of different rotary actuators to position the arm, but have not been satisfied with either, so I settled on stepper motor control to position the arm.
I have the code set up to control the stepper in the 'ProfileM6StartUserScript' macro .. What I'm having trouble with is the timing ..

The macro runs immediately when starting a tool change .. While using air to position the arm, I just slowed the movement down down to a crawl which allowed the head to raise to TCP before the arm made it into final position (thus avoiding a crash with the existing tool in the spindle)
Under stepper control, the macro wants to complete the stepper movement entirely before the head even begins to move .. (a crash every time!)

I've played around with a few attempts at moving the head first by simply adding a line: code "G0 Z12" ahead of the stepper code line.
It did move the head first, but I'm not comfortable with it because if I have a vise on the table an a thick work piece in the vise .. there wouldn't be 12" clearance left & I would hit a limit.
Seems to me If I could add a line to my macro ahead of the stepper code, that would send Z to TCP, I would have it licked.
My problem is I'm confused about how to move the Z to a (M Coord) position rather than a (WC Offset) position. I've tried G28 Z0 .. but that sent the head down to the WC "0" position.
I tried 'G59 P0' to turn off WC .. then 'Z0' .. then 'G59 P54' to turn WC back on .. not sure what happened there, but it wasn't what I was looking for!

Any help would be greatly appreciated,
Gary
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Tool Change Code

Post by DaveCVI »

Hi Gary,
I think what you want is G53...
G53 is "execute the movement for this block in machine coordinates". Note that a G53 applies only to the block it is in - i.e. G53 is not modal like G54 or G55 etc.

So G53 X0 Y2 Z0 would send the machine to machine coordinates x,y,z = 0,2,0

BTW is you want to "go to the TCP" in Z, you can read the TCP Z dro to get the Z location of the current TCP. That DRO is 1722 in MSM (which can be found byu looking at the DRO number in Machscreen).

The next trick will become issuing the movement command and getting the code to wait there until the movement is complete - I do this with a utility routine that I've included below.

So this code would move the Z axis to the Z TCP position:

Code: Select all

Option Explicit		' I alsway do this as it foreces me to declare variables before they can be used - saves you from problem caused by typos in varaiable names 

Const TCPZDRO = 1722

' this is the line that does the actual Z movement
' the movement will be done in whatever modes are active when G53 is used (G00/G01 & G90/G91 etc)
CodeQW("G53 Z" & GCN(GetOEMDRO(TCPZDRO)))


' here are the util routines the line uses

Sub CodeQW(ByVal CodeString As String)
	' QUEUE Up Code AND Wait for Execution to Complete
  	' this function takes the passed g-code string and give it to Mach to be put
	' into the Gcode queue for execution
	'
	'This routine WAITS for all motion to stop before returning to the caller
	
	Code(CodeString)
	Call MotionWait()
	Exit Sub
End Sub

Function MotionWait()
	' Wait for movement to complete
	While IsMoving()
	Wend
	Exit Function
End Function


Function GCN(ByVal VBNum) As String
	' GCodeNumber: a small util to take a VB double, format it and return it as a string
	' this is needed so that all numbers put into strings that will be sent to CodeQ or CodeQW will not 
	' have things of the form: X0.123456e-9   - which is not legal gcode format
	GCN = Format(VBNum, "#########0.000000")		' 6 sig digits to right of decimal point should be enough 
End Function	' GCN


Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
gdmarsh
Posts: 8
Joined: Wed Feb 13, 2013 1:26 pm

Re: Tool Change Code

Post by gdmarsh »

Thanks Dave,

Wow! my VB skills are like baby steps compared to that ..

Everything is not completely reassembled yet, but things seem to be working as expected now.
Sure do appreciate the quick response time!

Gary
gdmarsh
Posts: 8
Joined: Wed Feb 13, 2013 1:26 pm

Re: Tool Change Code

Post by gdmarsh »

Want to thank you again for the code Dave, it works beautifully!

Got the whole thing back together today and the stepper control works SO MUCH NICER than the pneumatic rotary actuator did.
Have a little more cleanup work to do on wiring, and have to make some covers for the stepper, pulleys, & belt.
Once it's all nice & neat I'll shoot a little video and post it.

Gary
nthliabrtn
Posts: 1
Joined: Fri Mar 08, 2013 11:09 pm
Location: Jacksonville, FL

Re: Tool Change Code

Post by nthliabrtn »

Is there any other representation of x,y,z co-ordinates? Are they set into zero by default if any value is not assigned there???
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Tool Change Code

Post by DaveCVI »

Hi,
nthliabrtn wrote:Is there any other representation of x,y,z co-ordinates? Are they set into zero by default if any value is not assigned there???
I don't think I understand the question;

X,Y,Z values are the coordinates of the current position of the machine. They always have a value as the machine always has a current position. That is true for both Machine coordinate and work coordinate values. There is a mathematical relationship between machine coordinates and work coordinates. Machine coordinates are not "set" by a user; the machine coordinates zero point is "located" within the physical travels of the machine by the home/reference operation when a machine is initialized.

Work Coordinates are shifted from machine coordinates by the various "offset" values. Technically, WC are not set, they are calculated by mach from machine coordinates. Even when you enter a value into a WC DRO, and it looks like you are setting the WC value, what you are really doing is saying "Set the WC offset such that the resulting calculated WC value be the value I just input".

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
gdmarsh
Posts: 8
Joined: Wed Feb 13, 2013 1:26 pm

Re: Tool Change Code

Post by gdmarsh »

I put a copy of this video on the Zone .. but thought I'd add one here also since it's the MSM software that inspired it ..
I went with a spring loaded touch plate also to absorb the over-travel in the head as it touches off .. Works beautifully!

http://www.youtube.com/watch?v=hoVivgo3jhk

Thanks Dave!
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Tool Change Code

Post by DaveCVI »

Very nice, I like it!

BTW I noticed you mention that the TLOS were long when the tools were wet - you may find this section of the user manual interesting:
15.9.1.1.4 Pre-AutoTLO Measurement
I had exactly that problem and put a hook into MSM to let you run a script before the tool is measured. I run a little script that blasts my touch plate wiht compressed air. I have the mist output from my control hooked to a solenoid in the compressed air line. So the script just has to do:
mist on
dwell
mist off

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
gdmarsh
Posts: 8
Joined: Wed Feb 13, 2013 1:26 pm

Re: Tool Change Code

Post by gdmarsh »

Dave,
I recently changed from USB to Ethernet SmoothStepper (too many USB issues with my PC)
Everything is working as it should except for a very strange occurence during Auto Tool Changes ..
With the same Start & End macros as I've been using for quite some time, when the M6 call is made, the machine moves to the prescribed TCP (Z0X12Y12)
After changing tool .. when I push 'Cycle Start' .. the X&Y axis both do a random rapid move of approx .2" to .75" before the Z begins to move down & touch off the tool.
I say random because though the movements always happen .. they do not happen in a repeatable way .. different amounts & different directions without any detectible pattern to them.
And after touching off the tool .. both axis move back to their proper position as the Z begins to move back up.

I'm not using any other macros in conjunction with tool changes & have checked everything I can think of to make sure I'm not missing something obvious.
Are there any know issues with the ethernet SmoothStepper that you're aware of? OR, can you think of where those funky little movements might be coming from?

I've got the Y TCP set nearly to the limit to get the vise & material as far out front & out of the way as I can. So far there's been no collisions involving the swing-out TP .. but on occasion these random moves will cause the Y axis to limit.

Mach R3.043.037
MSM V2.0.0

Thanks
User avatar
DaveCVI
Site Admin
Posts: 798
Joined: Mon Feb 04, 2013 3:15 pm
Contact:

Re: Tool Change Code

Post by DaveCVI »

Hi,
Check this setting in MSM:
Settings common page, "Rnd Diam" DRO. It's on the right side in the TCP TP area.
Is there a non-zeo value in that DRO?
If it's not zero that may be the XY movement you are seeing. (this is the Random XY amount for TCP TLO probes).
More info as to what this is for in section 7.1.4.2 of the user manual.

Dave
Productivity Software for Personal CNC Machinists
http://www.CalypsoVentures.com
Post Reply