Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Davek0974 on December 31, 2017, 04:55:46 AM

Title: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 04:55:46 AM
Hi all,

not been inside my Bridgeport conversion for a while, decided to add knee movement for tool length compensation so i can retain full Z axis travel.

A very helpful guy has forwarded me a lot of info (thanks) on how he made it work but it was a long time back and exact detail is vague, he had it working on a replacement for the G43 call using a macro titled M843 which was called along with the tool offset parameter so M843 P10 for tool 10 etc.

It seems possible that a better way might be to embed the knee movement code into my M6Start macro - this macro already knows what tool is being called. Tool length compensation would be turned OFF as the machine would think all tools are one length because the knee has moved to compensate.

I was trying to get acquainted with macros again and pulled my M6Start apart - I have attached it below, as far as i can see it contains loads of redundant code? It was cut down from the 2010 screenset code, IIRC all it does is move Z to machine zero??

The rest seems superfluous no??

If someone could scan it and let me know I can get going, of course if there is a better way then do let me know :)
Thanks
Title: Re: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 06:18:08 AM
Something like the M6Start attached,

It still has the odd code from before but I have grafted in bits of the macro from my friends conversion.

It seems to make sense to me, most likely has bugs in it, I'm not sure if the code relating to G90/91 is needed??


My guess is that I will modify the Z axis DRO zero button to also zero the A axis DRO out - This way once the initial Z ref is set with my Haimer probe, all moves are relative to work zero on the A axis.


Any glaring faults here??
Title: Re: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 08:44:20 AM
Hmm, using my trusty paper and pencil, I think I can see one possible bug to start with, but i may be wrong...

The code moves the knee to a negative of the tool length offset, surely it needs to move the knee to negative of the difference between the height setter tool and the new tool????

Downwards on the Z axis is negative, upwards on the A axis is negative.

My 3d Haimer probe is always Tool 100 and is 150mm tall in the height setter.

Say T1 is 65mm tall.

I would zero Z ref with T100 manually set and zero out both Z & A axes DRO's.

Then start the code, this would call T1, now my work is 85mm away from the tool (150-65) so the knee has to move -85 NOT -65

Am I wrong or am i wrong??
Title: Re: M6 Macro tweaking
Post by: TOTALLYRC on December 31, 2017, 08:50:22 AM
You are correct in that the Aaxis has to move the difference in the tool lengths, same as the Z would normally do.

Mike
Title: Re: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 09:08:45 AM
Ok, revised my code.

Added a call for the height Probe offset, added a variable for Heightprobeoffset-tooloffset

Move now made with the new variable.


Seems to make more sense reading it I think??
Title: Re: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 09:31:45 AM
Some numbers and moves...

Probe Length  Tool Length  Difference  A-Axis Position
15015000
1506585-85
15011535-35
150160-1010

 
I think it makes sense?

Title: Re: M6 Macro tweaking
Post by: Davek0974 on December 31, 2017, 11:54:33 AM
Anyone know what this would be doing in the middle of the M6Start macro??

SetVar(1, GetOEMDRO(800))
SetVar(2, GetOEMDRO(801))
SetVar(3, GetOEMDRO(802))

Even in the original use of the macro the vars being set do not seem to be used??
Title: Re: M6 Macro tweaking
Post by: garyhlucas on December 31, 2017, 10:18:19 PM
Dave,
My multi-purpose machine has a PLC in it because it allows me to do things not easily done by Mach 3. I recently replaced the surplus DL06 I was using with a DoMore BRX because of all the stuff it brings to the table. It has high speed inputs and outputs with motion commands so it could control the motion of your knee lift. It talks ethernet, serial, and modbus so you can send the tool length to the BRX and let it position the table and tell mach 3 the position move is done. Mine runs everything including air blowoff, misting, flood, vacuum cleaner, lights, safety circuit, heaters for the 3d extruder, 3d bed heater, lathe spindle and index pulse for threading etc.
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 01, 2018, 03:23:37 AM
Thanks Gary,

This mill is running a CSMIO IP/A with Encoder and MPG modules added, I'm not sure a separate PLC will offer much more for this simple task?

If I were adding an ATC maybe but the BP won't play nicely with and ATC ;)
Title: Re: M6 Macro tweaking
Post by: garyhlucas on January 01, 2018, 02:23:50 PM
Dave,
My thinking was actually driving the table vertical axis entirely separate from Mach 3 and only passing the actual tool length to the PLC in the M6 macro.
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 01, 2018, 02:33:25 PM
Ah, ok

I think adding the knee as an axis - A, B or C will be ok.

As soon as M6 T10 is called, the Z axis should lift to machine zero and the knee should move to the difference between the Haimer probe (T100) and T10. The knee AND Z axis both zero together when setting Z ref.

The macro reads ok i think, the code makes sense to me, whether it will work in reality i'll have to wait and see :)

Title: Re: M6 Macro tweaking
Post by: garyhlucas on January 01, 2018, 06:54:38 PM
Yes, the issue I thought was that you couldn't make a motion move while the M6 macro was active.
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 02, 2018, 03:03:13 AM
I will need to test it again, I know the Z move to zero works ok in the M6Start as that has been running for some time successfully, so i presume having the code move the knee will also be ok.

IIRC it was something to do with manually moving the table while the machine was paused inside the M6 pair, but i need to check that again as it was some time ago and pretty specific to the CSMIO.

I am hoping to put the knee positioning code in the M6End macro as it would make sense to drop the knee in M6Start for easy tool change then lift it at the end.
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 03, 2018, 08:07:03 AM

IIRC it was something to do with manually moving the table while the machine was paused inside the M6 pair, but i need to check that again as it was some time ago and pretty specific to the CSMIO.


With reference this issue, another forum member forwarded a very useful link that fully explains the issue, http://www.calypsoventures.com/forums/viewtopic.php?f=9&t=75#p337

It is all to do with Mach3, CSMIO and auto tool length setting while INSIDE the M6 loop - I had long since given up on this and have disabled the button macros on my 2010 screenset as any attempt to set tool length in the M6 loop will put Mach into reset with an ePid error. It seems CS Labs have no intention of fixing the issue.

I can confirm that tool probing works well OUTSIDE the M6 loop as i use it on the mini-mill setup on my CSLABS controller.
Title: Re: M6 Macro tweaking
Post by: rcaffin on January 23, 2018, 03:40:30 AM
SetVar(1, GetOEMDRO(800))
SetVar(2, GetOEMDRO(801))
SetVar(3, GetOEMDRO(802))


Somehow, I don't think the M6Start macro you have is the normal one distributed with Mach3. It suggests someone was playing all sorts of games at some stage, transferring the X, Y & Z DROs into #1, #2 & #3. I can see why one might do that while experimenting though.

A bit embarrassing if you were already using those variables for something else of course.

Cheers
Roger
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 23, 2018, 04:46:02 AM
I think they are superfluous to the current usage, the macro came originally with the 2010 screenset which does all sorts of clever stuff in the M6 etc.

I have deleted them now and will see what happens when i get the knee axis up and running this week.
Title: Re: M6 Macro tweaking
Post by: rcaffin on January 27, 2018, 12:28:36 AM
Yes, the issue I thought was that you couldn't make a motion move while the M6 macro was active.
IF (IF) I understand you correctly, that is wrong.
I move all 3 axes around after M6Start has been called, so I can change the tool. And I can also change the Z axis zero as well to compensate for tool length. I think most people do (unless they have a fully functional ATC).
Caution: when you hit the continue button, the spindle will return to where it came from - subject to any changes in the axis zeroes. Make sure nothing is in the way!

Cheers
Roger
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 27, 2018, 03:14:12 AM
Yes i was in error there, it was related to probing while in the loop, that is a major issue for some versions of Mach3, the earlier ones tend to be better it seems.
Title: Re: M6 Macro tweaking
Post by: Davek0974 on January 27, 2018, 03:16:49 AM
Just as an update, here is my M6 code presently....

Code: [Select]
Sub Main()

If GetSelectedTool() = GetCurrentTool() Then Exit Sub '***Do nothing if current tool is called again

If GetOEMLED(1866) Then Exit Sub '***Ignore M6 calls LED

Tool = GetSelectedTool()'***Set the requested tool to be the current tool
SetCurrentTool(Tool)

Code "G53 G0 Z0" '***Move Z axis to machine zero - fully retracted for tool change
While IsMoving()
  Sleep(100)
Wend

'***Get the respective backlash clearance allowance for knee moves
If GetOEMLED(801) Then '***On  = English Measure INCH
  ClearAllow = 0.125   
Else                   '***Off = Metric Measure MM
  ClearAllow = 3.0   
End If

'***Lookup the offset in the tool table, T100 is our 3d Haimer Probe
ToolOffset = GetToolParam(GetCurrentTool(), 2)
ProbeOffset = GetToolParam(100, 2)
OffSetDifference = ProbeOffset-ToolOffset'***Calculate the difference between the probe and the new tool - can be negative or positive

'***Calculate the new knee machine coordinate value based on tool length difference
'KneeRefPosition = GetUserDRO(1012) '***Get the knee ref position - set when pressing "Z Zero" at probing stage, this is a hidden DRO
KneeRefPosition = GetVar(179) '***Get the knee ref position - #var is set when pressing "Z Zero" at probing stage
TargetKneePosition = KneeRefPosition - OffsetDifference

'***Check if knee axis has enough travel to make the move - C position is always negative
If TargetKneePosition + ClearAllow >0 Then
  Response=MsgBox("Not Enough Travel On Knee Axis - Move Aborted!", 48, "Axis Travel Error")
  Exit Sub
End If

'***Rapid to a position lower than needed
Code "G53 G0 C" & (TargetKneePosition + ClearAllow)
While IsMoving()
  Sleep(100)
Wend

'***Now move the knee UP slowly to its final position
Code "G53 G1 C" & TargetKneePosition & " F100"
While IsMoving()
  Sleep(100)
Wend

End Sub