New to writing G code

More
15 Mar 2017 01:45 #89643 by ArtJ
New to writing G code was created by ArtJ
So I just learned the G code basics and am writing some basic code. I am new to Linux and new to, well, everything. I am having trouble getting linuxcnc to load my program. My question is is there a particular format after the safe line that should be followed? And what format should I be saving documents in when I write code. I am writing in OfficeLibre. I keep getting bad character near line 2 message and a few others.

Please Log in or Create an account to join the conversation.

More
15 Mar 2017 05:00 - 15 Mar 2017 05:02 #89648 by kornphlake79
Replied by kornphlake79 on topic New to writing G code
It will help if you can post the first few lines of your code, it will be easier to spot what might be happening. For refrerence here are a few lines of a program I recently ran, it was created using autodesk fusion CAM with the included EMC2 post processor with a couple very minor modifications.
%
(FACE PLATE .125 EM)
(T2  D=0.125 CR=0. - ZMIN=-0.135 - FLAT END MILL)
G90 G94 G17 G91.1
G20
G53 G0 Z-0.1
(BORE HOLES)
M9
T2 M6
S8000 M3
G54
M9
G0 X1.3275 Y-0.8443
G43 Z0.6 H2
G0 Z0.08
G1 Z0.0125 F24.
G19 G2 Y-0.8567 Z0. J-0.0125 K0.
G1 Y-0.863
G17 G3 X1.34 Y-0.8755 I0.0125 J0.
Y-0.8045 Z-0.0197 I0. J0.0355

The program begins with a %, comments are between parenthesis, several commands are given on the first line of code to set the distance mode, feed rate mode, setup the plane and arc distance mode, these could all be on separate lines, but it keeps the code a little neater having them all on one line. The next line sets the units to inches. With the machine setup I retract the Z axis to a safe height. M9 turns off the coolant, I don't have coolant on my machine so this is superfluous, but I haven't taken the time to modify the post processor to remove the coolant commands. I then load tool 2 with an M6 command, for whatever reason whenever I'm writing code manually or entering code in MDI I reverse the format from what the post processor uses, M6 T2 works the same as T2 M6, likewise S8000 M3 turns on the spindle the same as M3 S8000. With the spindle turned on, I set the work coordinate system, turn off the coolant again, and begin machining the part.

G code is pretty flexible, you don't have to follow a rigid syntax like other programming languages, for example you don't have to use capital letters and a zero doesn't need to proceed a decimal point. That said there is a certain style that you get used to when you've worked with programs generated with a CAM program and it's generally nice to follow the same style when manually editing or creating new code.

As far as using OfficeLibre, while I can't say I've had a bad experience with OfficeLibre, I can't say I've tried to use it for coding. I generally use Gedit, but any simple text editor will do, I don't like using a word processor for coding because they can occasionally act unpredictably, doing things like adding carriage returns, or converting 2 hyphens to a dash. While this behavior might be desirable for writing a report, it's not necessarily what you'd want when writing code.

You'll want to save your files in a generic ascii format (usually the default format in any of the simple text editors) with a .ngc extension.
Last edit: 15 Mar 2017 05:02 by kornphlake79.

Please Log in or Create an account to join the conversation.

More
15 Mar 2017 14:43 #89665 by tommylight
Replied by tommylight on topic New to writing G code
Libreoffice will not work. Use gedit, mousepad, xed, or any other simple text editor.

Please Log in or Create an account to join the conversation.

More
15 Mar 2017 18:17 #89678 by BigJohnT

Please Log in or Create an account to join the conversation.

Time to create page: 0.067 seconds
Powered by Kunena Forum