Author Topic: Mach4 vs Mach3 Gcode?  (Read 333 times)

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Mach4 vs Mach3 Gcode?
« on: August 28, 2021, 16:04:27 pm »
Does Mach3 lathe code directly cross over to Mach4 lathe? I have a .tap that runs good in mach3. Mach4 has the arc mode settings matching my mach3 setup. At the G03 the tool path goes clockwise gouging into the piece instead of going counter clockwise and leaving a nice radius on the end of the piece.

Distance mode is set to Absolute and IJ mode is set to Incremental just like Mach3. I have been using this code to make this piece for well over a year just wont translate to Mach4.

G20 G90 G91.1 G64 G40 G18


Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #1 on: August 28, 2021, 20:21:41 pm »
Hello Steve

Maybe you can try to revert the arcs with the "Invert Arcs" property in your CamBam lathe post processor ? (in the "options" section of the PP)

++
David

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #2 on: August 28, 2021, 22:16:50 pm »
I will look into that. God I hope I dont have to redo all my code.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #3 on: August 28, 2021, 22:48:35 pm »
Re

"Invert Arcs" only switch G2 / G3 in the Gcode (the values remain the same), so if it do the trick, you can edit your old Gcodes to invert G2 and G3.

example for the shape on the picture.

Invert Arcs = True

Code: [Select]
G21 G90 G91.1 G64 G40
G0 X15.0
( Tournage1 )
M6 T01010101
G18
M3 S3000
G0 Z0.1
G0 X2.0
G1 F600.0 X0.0
G2 F800.0 X10.1 Z-10.0 I0.0 K-10.1
G1 Z-20.0
G0 X15.0
M5
M30

Invert Arcs = false

Code: [Select]
G21 G90 G91.1 G64 G40
G0 X15.0
( Tournage1 )
M6 T01010101
G18
M3 S3000
G0 Z0.1
G0 X2.0
G1 F600.0 X0.0
G3 F800.0 X10.1 Z-10.0 I0.0 K-10.1
G1 Z-20.0
G0 X15.0
M5
M30

++
David
« Last Edit: August 28, 2021, 22:50:30 pm by dh42 »

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #4 on: August 29, 2021, 00:33:18 am »
Yes sir I will probably just change all my g03's to G02's and vise versa. there are only 6 of them in that program. All the CW are CCW and all the CCw's are CW. It's late and well after beer:30 here so I will save it for tomorrow.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #5 on: August 29, 2021, 00:44:52 am »
In Mach3 there is a "Reversed arcs in front post" checkbox, maybe it exist also in Mach4 too.

(ports&pins / "Turn options" tabs)

++
David

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #6 on: August 29, 2021, 01:08:29 am »
I looked at the turn options in mach4 and didn't see anything like that but I'll check again. I also noticed that G90 and G91 are not in the Mach4 gcode set, only G90.1 and G91.1. Distance mode is ignored in Mach4 but is a setup option. Weird.

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #7 on: August 29, 2021, 11:09:02 am »
Well I changed all the G's and the code executes fine. The "Reversed arcs in front post" checkbox is checked in Mach3 which I assume means that I have a front mounted tool post. I am going to search for a similar option in Mach4. I have MANY programs that will have to be edited if I cant find this option.

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #8 on: August 29, 2021, 18:19:22 pm »
Hello

Quote
I am going to search for a similar option in Mach4

Also have a look in the Mach4 ESS plugin ; I see no "revert arcs" option in the Mach3 ESS plugin but maybe it exist in the one for Mach4 ?

++
David

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #9 on: August 29, 2021, 19:43:25 pm »
Hello

Quote
I am going to search for a similar option in Mach4

Also have a look in the Mach4 ESS plugin ; I see no "revert arcs" option in the Mach3 ESS plugin but maybe it exist in the one for Mach4 ?

++
David

It's not there. I went thru every tab in the mach4 config and every tab in the ESS config and unless i missed something or it's well hidden, it doesn't exist. Thanks for looking

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #10 on: August 29, 2021, 21:02:10 pm »
Hello

You can use this script in CamBam to revert G2/G3 in a selected GCode file.

There is no "standard" file requester to browse the file (I can't remember how to get it with script), so you must type the file name with it extension in the box when the script ask for it (ex: myfile.nc)

the path where the script will searche for the file is fixed by the line:     Dim path as string ="C:\"

you can change the text in boldface to the path you want.

to use it:

Unpack the file in attachment and move the remaining .vbs file to your cambam script folder

Open the script through the cambam script menu

if your files are not on C:\ , change the path in the code to match the one of your files as explained above.

run the script > give the file name to convert when the box appears

the converted Gcode will appears in the cambam log windows and a new file is created as arcrevert_filename.xx in the same folder than the source file.

the code (the same as in attachment)

Code: [Select]
' New CamBam VBScript
' revert G2/G3 in GCode file

sub main

    Dim line, line2 As String
   
    Dim path as string ="C:\"
   
    Dim fname as string, outname as string
   
    fname = InputBox("file:","","")
   
    if fname = "" then exit sub
    outname = path & "arcrevert_" & fname
       
        Try
            Using sr As System.IO.StreamReader = New System.IO.StreamReader(path & fname)
               
            FileOpen(1, outname, OpenMode.Output)
               
                Do
                    line = sr.ReadLine()
                   
                    if InStr(line,"G3 ")= 1 then 'G3 found
                        line = Replace(line,"G3 ","G2 ")
                    else if InStr(line,"G2")= 1 then 'G2 found
                        line = Replace(line,"G2 ","G3 ")
                    end if
                   
                    app.log(line)
                    PrintLine(1, line)

                Loop Until line Is Nothing
               
                sr.Close()
           
            End Using

        Catch E As Exception

        End Try
        FileClose(1)

end sub

++
David

Offline stevehuckss396

  • Wookie
  • ****
  • Posts: 432
    • View Profile
Re: Mach4 vs Mach3 Gcode?
« Reply #11 on: August 29, 2021, 21:27:56 pm »
Thank you! Can I just copy the MachLathe post processor to create  Mach4Lathe PP and change the G02 and G03 around to each other. Also have to blank out G90 and G91 from ending up in the code as it throws an error. There are a couple other G codes that no longer exist in mach4 so I need to figure out how to handle those.

There is supposed to be a big update coming soon. If that comes and there is no improvement to this issue Would a Mach4 Lathe PP be a good solution?

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 6604
    • View Profile
    • Cambam V1.0 French Doc
Re: Mach4 vs Mach3 Gcode?
« Reply #12 on: August 29, 2021, 21:44:04 pm »
Quote
Can I just copy the MachLathe post processor to create  Mach4Lathe PP

Yes

To revert the G2/G3, just change the "Invert Arcs" property in the Mach4 PP

Quote
Also have to blank out G90 and G91 from ending up in the code as it throws an error.

in the Header section of the PP, remove the {$distancemode} so the G90/G91 will not be written

Quote
There is supposed to be a big update coming soon. If that comes and there is no improvement to this issue Would a Mach4 Lathe PP be a good solution?

Yes, the PP will easily revert the arcs for newly created Gcodes

++
David