Hello Guest it is March 28, 2024, 06:57:16 AM

Author Topic: Free G76 Macro Helping program for Mach3 Turn  (Read 46947 times)

0 Members and 1 Guest are viewing this topic.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #50 on: December 03, 2019, 06:23:36 AM »
G01: Well, we will find out, won't we?   :)
Double G32: OK.  I will test that too.
I have the time.

Debugging the CypressBasic macro is a pain. The tools available are 'not good'. Never mind, work in progress.
I wonder whether Lua is better?

Cheers
Roger
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #51 on: February 25, 2020, 08:59:19 AM »
Hi!

I want to give it a try on your program, but whichever thread I try, it generates a buggy gcode, in the G77 line:

G77 r __ x18.893 k0.0 z __

It always comes with these r___ and z___

How can I fix it?

Thanks a lot!

Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #52 on: February 25, 2020, 10:44:51 AM »
Hello Rimbaldo,

two lines of code are generated. The first line is for preparing the bolt or nut with the M1077 macro, turning it to the right diameter and length. For example, the outer diameter of an M10 ist not 10.00 millimeter, but only 9.85. But the program cannot now your starting diameter and the length you wish, so I made underscores you can replace with the values of your stock material. Of course, you will need an different tool for this turning operation, but I supposed anyone can copy the line in his favorite gcode template. For tapered threads, it will actually make the tapered bolt in the right dimensions. Because of that, the M1077 macro is included in the package.

The second line is the actual G76 threading line for usage with an V-shaped tool.
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #53 on: February 25, 2020, 11:53:58 AM »
Stephan, thanks for your quick answer!!

I have some more installation doubts... maybe some are dumb...

The new macros supposed to be in the  mach3 “Macros” directory, should be put on the root “Macros” or in “Macros/Turn” directory? I put in the “Turn” subdirectory. The “Macros” directory has no macros and only the mill, turn and plasma subdirectories and no files in it.

The new screenset, and new 1076 macro are still compatible with the normal threading wizard? I tried the threading wizard and it gave my an error in line 199 (divided by zero)


Thanks!!





Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #54 on: February 25, 2020, 02:21:07 PM »
The macros are updates of existing ones. The m1077 and m1078 should be in mach3\macros\%yourturnprofile%\  with the subfolder named after the name of your turning profile. This folder should not be empty. I only improved these macros and by the way, i use them for most of my turning operations because you more or less for most operations turn from diameter a to b on length c. m1077 (G77) is turning, m1078 (G78) is facing. Far easier than using the wizards. The documentation of the variables is on the beginning of each macro.

m1176 is a new addition and allows the display of the current cut values on the diagnostics page. Because the labels of the DROs didn't match i fixed them and that is why the screenset is included. So this also doesn't change the functionality. I had to do this with an extra macro because the Gcode from G76 is precompiled and cannot display information on runtime. It simply calls m1176 and that displays the information.

Only the m1076 is different, because you can find it at the mach3\ root folder. Here I also improved only the inner workings of the macro and did not change its interface.

The only source of problems can be if you use the variables #101 following parallel because i needed them for additional input.

So everything should be compatible with existing features because all changes (except the variables) are internally for each macro.

Code: [Select]
'==============================================
' M1076 UNIVERSAL MACH3 THREADING MACRO
'==============================================

' This macro implements the G76 call inside Mach3 to cut a wide variety of
' threads. Because some features aren't supported by the G76 letters,
' this macro also uses # variables.

' USAGE:
'--------
' #121=   (Taper in degrees)
' #122=   (Trapezoid Tool width or 0 for V - Threads)
' #123=   (Trapezoid Tool widening)
' (122 + 123 together are the width of the trapezoid bottom)
' #124=   (Trapezoid Flank Angle: 0 - vertical, ACME - 14.5, Tr - 15 )
' #125=   (Flank sizing)

' G76 X~ Z~ Q~ P~ H~ I~ R~ K~ L~ C~ B~ J~
' R - XStart
' X - XEnd
' K - ZStart
' Z - ZEnd
' Q - Spring Passes (optional)
' P - Pitch
' H - Depth of first pass
' I - Infeed angle
' L - Retraction in degrees (360 - one full turn)
' B - Depth last pass (optional)
' J - Minimum depth per pass (optional)
' C - Clearance (optional)

' From Mach3- Turn Options:
' - Minimum depth per pass
' - Cut Type: 0 - righthanded / 1 - lefthanded / 2 - alternating from inside / 3 - alternating from outside
' - Infeed Type: 0 - equal chip area / 1 - Sandvik formula (only for V - Threads)

' The controlled point of the tool for all threads is in the Z center position

' This macro is based on the original m1076.m1s macro from the Mach3 Installation,
' but heavily extended and reworked by Stephan Brunker

' IMPORTANT: Usage changes against previous versions:
' Cut type alternating and lefthanded are now switched
' Lefthanded always cuts against the Z-Axis movement, independent of Z-Axis direction


Code: [Select]
'G77
'(Xx.*********x XDia NEEDED)
'(Zx.*********x End Z NEEDED)
'(Fx.*********x Feedrate)
'(can be Set In the settings page:)
'(Hx.*********x Depth of cut)
'(Cx.*********x Clearance In the X)
'(Qx.*********x Clearance In the Z)
'(Kx.*********x ZStartpoint)
'(Rx.*********x XStartpoint)
'(#101 = Taper in Deg)
'(#102 = Taper Anchor Mode 1 or 2)
'There're different ways to anchor the taper
'Mode 1 anchors the Taper End at EndZ and StartX
'   and will turn parallel, then tapered and correcting EndX if neccessary
'Mode 2 anchors the Taper at StartZ and EndX
'   and reduces the dia first, then turns the taper, corrects EndZ if neccessary
'default is Mode 1
'refer to attached TaperModes.png for illustration

Code: [Select]
'G78
'(Xx.*********x XDia NEEDED)
'(Zx.*********x End Z NEEDED)
'(Fx.*********x Feedrate)
'(can be Set In the settings page: 'Hx.*********x Depth of cut)
'(Cx.*********x Clearance In the X)
'(Qx.*********x Clearance In the Z)
'(Kx.*********x ZStartpoint)
'(Rx.*********x XStartpoint)
'(#101 = Taper in Deg)
'(#102 = Taper Anchor Mode 0 or 1)
'There're different ways to anchor the taper
'Mode 1 anchors the Taper End at EndZ and StartX
'   and will turn parallel, then tapered and correcting EndX if neccessary
'Mode 2 anchors the Taper at StartZ and EndX
'   and reduces the dia first, then turns the taper, corrects EndZ if neccessary
'default is Mode 2
'refer to attached TaperModes.png for illustration
« Last Edit: February 25, 2020, 02:24:19 PM by stephanbrunker »
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #55 on: February 25, 2020, 04:46:59 PM »
Thanks Stephan!

I was just making sure everything was alright.

Should I edit something in yours m1076.m1s file?

The screenset is ok, DROs are correct.  If I try your G76 line or the threading wizard's G76 it just goes to the other line and doesn't even begin to thread. G76 doesn't even begin to move.


If I go back to the original m1076.m1s file, then yours G76 line and the wizard's G76 works normally apparently.  I'm cutting air for testing, so I can't check number of passes yet. Just checking if spindle get's turned on and synchronizes with the axes and makes the threading moves.



So.. do I have to do something else?

Thanks for your support!




Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #56 on: February 25, 2020, 05:12:28 PM »
If nothing happens, look into the macro. There is a line

test = true (or false) .

If this option is set to true, the output is dumped into a ThreadTest.tap file and nothing else happens. I just saw that this was the case in the 0.33 version of the macro, remaining from my debugging. Just change that to test = false and the code will be run instantly as usual.

(You can also load that ThreadTest.tap file to see all the code generated by the macro)

Sorry for that oversight!  :-[
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #57 on: February 25, 2020, 06:51:35 PM »
Thanks Stephan!

As I’m not in the lab anymore, i tried over my laptop in the demo mode. Indeed it was set to true.

I changed to false and mach3 generates the number of passes accordingly and simulates correctly the code generated by your macro!

But when trying to generate the code using the threading wizard, it gets back to that error in line 199 of the m1076.m1s file: it says divided by zero and doesn’t work.

Apart from that, you could also save all last user inputs of your program. Everytime I turn it on it gets back to the first thread of the list. It could go back to the last one used. For instance, I’ll try the UNF 3/4 16 TPI and it resets to metric when restarting.

Also, is it possible to set the depth of the first layer at will, or it’s always automatic?

Thanks again for your quick support!
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #58 on: February 25, 2020, 08:08:12 PM »
How convenient that it shows the line where the error occurs. I presume that the wizard is not very clean programmed and inputs a retraction of zero which then makes that div/0 error. It is just not possible to retract instantaneously. To circumvent that bug, the simplest solution is a default value for the L-word, like 360 degrees - one full turn.

Insert before line 116
Code: [Select]
RetractZ = Retract_Deg * Pitch / 360
this line
Code: [Select]
If Retract_Deg = 0 Then Retract_Deg = 360
I looked into the original file and there the retraction value in Z was allowed to be zero. So it coded an instantaneous retraction in X while Z ist still moving … the result is a very unclean cut which has very likely an offset in Z for each pass, but more or less unpredictable. I cleaned that up and now the retraction follows exactly the pitch and constantly reduces the depth to zero and that with the same increment like the main thread.

-----

I decided against an automatic saving of the last used thread because the thread selection is just two clicks. And it seemed unlikely that you would make a lot of only slightly different threads in multiple sessions. More likely are very different threads.

-----

The depth of the first pass (not the last finishing one) is determined in the formula like all the others. There are two strategies: Equal chip area and the Sandvik formula. You can change that in the Mach3 Turn options (Infeed Type 0 and 1) and in the options of my Program to get the same values. The Sandvik formula uses a smaller first pass and increases the following ones.

Offline rcaffin

*
  •  1,052 1,052
    • View Profile
Re: Free G76 Macro Helping program for Mach3 Turn
« Reply #59 on: February 25, 2020, 08:54:02 PM »
Tricky stuff, threading.
I created my own M1076 macro from the original.
I stripped all the taper thread stuff out: I never turn a taper thread.
I stripped all the Sandvik/other stuff out and do a simple radial feed (mainly Al & brass).
I stripped all the Test stuff and other variables out.
(If I want any of these, I can revert to the original of course.)
What is left is the hard core of threading, and it works.

Then I tweaked the ESS settings in the very latest driver to improve the sync, since I have a 512 line encoder on the spindle. With Mach3 you can't do PID control successfully, so don't bother trying. (Warp9 endorse this.) Instead of telling the driver to use 512 pulses per rev and a prescaler of 1, I now use 32 pulses per rev with a prescaler of 16 (32*16=512). The prescaler stabilised the sync pulses so the Mach3 RPM DRO became very steady, and it now gives me a nice clean thread on a semi-production basis. (You could go 16/32 instead: it makes little difference.)

Background theory: with a prescaler of 1 you are at the mercy of any noise or line-to-line variations, and this noisy signal gets sent to Mach3 - which cannot handle it properly. That means Mach3 is wandering all over the place with the starting sync position and with the RPM. Erk.

Cheers
Roger