What's new
What's new

Coding for Yasnac. Is this program crazy over defined?

std88

Plastic
Joined
Aug 16, 2018
Location
boston, ma
Hey guys,

Known parameters....
1. I'm mechanical engineer (tech) and do a bunch of design for manufacturability with SolidWorks.
2. Our product is something we have made for 30 years, with slight variation changes...
3. Our programmers (mostly operators) do all coding manually (NO CAM software... i know see reason 2 if confused. Investment wasn't worth it).
4. I have slowly been getting involved and guys are becoming more receptive to culture change; trying CAM/ me diagnosing their G-code... HOWEVER, I am a newbie to G-code programming (done other types in past).

We have 5-ish milling centers that use Yasnac, and 1 Fanuc. I was given code the other day and want to call bull-shit on some of the bad habits i think i am observing; the code was written for YASNAC controller.

Can some people give me feedback if the code is "clean" or repetitive and confusing? Also is there a "cleaner" way to write this? Thanks.

O1372(C-3 RIBS)
G0G17G40G49G80G90G98
T2M6(1/2 SPOT )
G54J1X1.25Y-1.75S2760M3
G43H2T3Z.1
M8
G82Z-.190F15.R.1
X2.875Y-1.Z-.160
X3.625
X4.625Y-1.125Z-.190
G0M9
G53H0Z0M19
T3M6(3/8DRLL)
G54J1X1.25Y-1.75S1226M3
G43H3T4Z.1
M8
G73Z-1.15F7.3R.1Q.2
X4.625Y-1.125
G0M9
G53H0Z0M19
T4M6(5/16DRLL)
G54J1X2.875Y-1.S1474M3
G43H4T5Z.1
M8
G73Z-1.15F8.8R.1Q.2
X3.625
G0M9
G53H0Z0M19
T5M6(1/2INSRT MILL)
G54J1X.45Y.4S5400M3
G43H5T6Z.1
G1Z-.15F50.M8
Y-2.65F40.
X.495
Y.4
G0X.45
G1Z-.3F40.
Y-2.65
X.495
Y.4
G0M9
G53H0Z0M19
T6M6(1/2 FIN)
G54J1X.438Y.4S950M3
G43H6T7Z.1
G1Z-.314F50.M8
Y-2.625F12.
X.503
Y.4
G0M9
G53H0Z0M19
T7M6(1-1/8DRILL)
G54J1X2.125Y-1.25S830M3
G43H7T8Z.1
M8
G73Z-1.125F2.Q.3R.1
G0M9
G53H0Z0M19
T8M6(7/8FIN)
G54J1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"B" FROM HERE)
T13M6(3/8 INSRT MILL)
G56J1X.3Y0S6000M3
G43H13T14Z.1
G1Z-.06F75.M8
X-5.7F40.
G0Z.1
X.3
G1Z-.13F75.
X-5.7F40.
G0M9
G53H0Z0M19
T14M6(3/8 5FL.)
G56J1X.3Y0S3053M3
G43H14T15Z.1
G1Z-.135F50.
M8
X-5.7F15.
Y-.002
X.3
Y.002
X-5.7
G0M9
G53H0Z0M19
T15M6(SM.CHMFR MILL)
G56J1X0Y0S5000M3
G43H15T16Z.1
G1Z-.05F50.
M8
X-6.F30.
G0M9
G53H0Z0M19
T16M6(3/8SPOT)
G56J1X-1.5Y0S2760M3
G43H16T17Z.1
M8
G82Z-.29F5.R-.1
X-4.
G0M9
G53H0Z0M19
T17M6(F DRLL)
G56J1X-1.5Y0S1816M3
G43H17T18Z.1
M8
G83Z-.885F5.R-.1Q.25
X-4.
G0M9
G53H0Z0M19
T18M6(5/16X18TAP)
G56J1X-1.5Y0S320M3
G43H18T19Z.2
M8
G93
G84Z-.75F.055R.2
X-4.
G94
G0M9
G53H0Z0M19
T19M6(7/8RGH)
G56J1X-.305Y-1.05S650M3
G43H19T8Z.1
G1Z-.370F50.
M8
Y1.05F7.
Z-.745F50.
Y-1.05F7.
Z-1.12F50.
Y1.05F7.
G0M9
G53H0Z0M19
T8M6(7/8FIN)
G56J1X-.339Y1.05S650M3
G43H38T19Z.1
G1Z-1.125F50.M8
Y-1.05F11.
G0M9
G53H0Z0M19
T19M6(7/8RGH)
G57J1X-.305Y-1.05S650M3
G43H19T8Z.1
G1Z-.25F50.M8
Y1.05F7.
Z-.495F50.
Y-1.05F7.
G0M9
G53H0Z0M19
T8M6(7/8FIN)
G57J1X-.3385Y1.05S650M3
G43H38T20Z.1
G1Z-.5F50.M8
Y-1.05F11.
G0M9
G53H0Z0M19
T20M6(CHMFR-MILL)
G57J1X0Y1.2S2600M3
G43H20T2Z.1
G1Z-.175F15.M8
X-3.4
Z-.225
X0
Z-.265
X-3.4
Z-.275
X0
G0Z.1
Y-1.2
G1Z-.175F15.
X-3.4
Z-.2
X0
Z-.25
X-3.4
Z-.275
X0
G0M9
G53H0Z0M19
M98P9901
%
 
... HOWEVER, I am a newbie to G-code programming (done other types in past).

We have 5-ish milling centers that use Yasnac, and 1 Fanuc. I was given code the other day and want to call bull-shit on some of the bad habits i think i am observing; the code was written for YASNAC controller.

Can some people give me feedback if the code is "clean" or repetitive and confusing? Also is there a "cleaner" way to write this? Thanks.

<snip>
There's absolutely nothing wrong with that program, it's as clean as they get.

You sure as hell aren't going to post anything cleaner or easier to read from your CAM.
 
There's absolutely nothing wrong with that program, it's as clean as they get.

You sure as hell aren't going to post anything cleaner or easier to read from your CAM.

You can make it easier to read.. ADD SPACES..

I agree, its all there, almost exactly like I would do it... I don't get the J thing after the G57, but
I'm assuming thats a Yasnac thing.. And the extra tool called up when making the first Z move, but I
assume its to stage the next tool...

You should see some of the "stuff" some newbs post here on occasion... Not bashing the newbs, but
I'd say your guys are doing a pretty spiffy job.
 
You're "diagnosing" their G-code, AND you're "new" to G-code. WTF??!!

The code posted is fine. I see no problem at all, and I read through that crap all day.

R
 
You can make it easier to read.. ADD SPACES..
The spaces get deleted when you copy from the control, but they are there when you are running the machine.

If anything, I'd have more lines- cancel codes at each tool with a N number, G80's at the end of the canned cycles.

I agree, its all there, almost exactly like I would do it... I don't get the J thing after the G57, but I'm assuming thats a Yasnac thing.. And the extra tool called up when making the first Z move, but I
assume its to stage the next tool...
I assumed the J is a control thing too. He stages the tool changer at the first Z move. That's fine- it's in the same line on every tool, just his habit. I do it on first positioning move, but no difference.

I usually have some note lines in the beginning on where to set zeros and a tool list.

That program is tight- the guy who wrote it ran the parts himself.
 
The spaces get deleted when you copy from the control, but they are there when you are running the machine.

If anything, I'd have more lines- cancel codes at each tool with a N number, G80's at the end of the canned cycles.

I assumed the J is a control thing too. He stages the tool changer at the first Z move. That's fine- it's in the same line on every tool, just his habit. I do it on first positioning move, but no difference.

I usually have some note lines in the beginning on where to set zeros and a tool list.

That program is tight- the guy who wrote it ran the parts himself.

Sure, maybe? hell I don't know. But everything you posted is a personal preference, not necessarily the Right way. I don't think this is about preferences. So much as Right or Wrong, and the above code is Good to go.

R
 
Are you coming to g-code from other, more general purpose programming languages like C, java, python etc etc?
Because the standards for what makes an elegant G-code program are much different than in those languages.

Readability, edit-ability as well as whether the code just plain makes good parts quickly are more important than getting the most clever, tiny and resource-optimized code snippet for any one action. Especially for stuff that is programmed at the control, g-code is best if written quickly with known-good practices rather than iterated upon endlessly for best optimization. YMMV if you are working for Foxconn or some other giant but that's not most people on this site.

There are some guys on PM who do amazing stuff with macro programming that is more complex and interesting from a computer programmer standpoint (as opposed to a pure G-coder/machinist), see the sticky macro thread. But IMO this is more specialist stuff that needs a certain application, not usually necessary for plain-old "making parts."
 
The spaces get deleted when you copy from the control, but they are there when you are running the machine.

If anything, I'd have more lines- cancel codes at each tool with a N number, G80's at the end of the canned cycles.

I assumed the J is a control thing too. He stages the tool changer at the first Z move. That's fine- it's in the same line on every tool, just his habit. I do it on first positioning move, but no difference.

I usually have some note lines in the beginning on where to set zeros and a tool list.

That program is tight- the guy who wrote it ran the parts himself.

I was thinking there should be G80's, wasn't sure why they didn't use. I guess its also confusing why G54 is called up every time? I thought it all references that until you change it to 'G55' or if the G54 is canceled?
 
From what i can tell the 'j' thing is an equivalent to G54.1 or H54 p1, it uses J as the controlling letter. I really appreciate the feedback as I am trying to figure out if programs are being used appropriately. Basically the person who wrote the program probably no longer works here, and every time we need to run this job, operator import this program (to 1 of 6 different machines all with different specs ie. maybe a pallet changer). This is helping me under stand if people are talking out of their a$$ as they don't know the programming well enough to articulated what the program is doing line-by line.

Please keep in mind this is not to be an 'i-gottcha' situation, i want the mfg dept to move forward and not be stuck in old bad habits.
 
I was thinking there should be G80's, wasn't sure why they didn't use.
Hello std88,
Canned Cycles can be canceled using G80 or any Group 01 G Codes.

Group 01 G codes
G00, G01, G02, G03, G60 (G60 can be a Group 00, or Group 01 G Code depending on parameter setting)

Accordingly, its common to see Canned Cycles canceled with G00 as in your example code in Post #1.

Wasn't sure why some code is repeated everytime? I thought G54 was more of a modal command, where you don't have to specify it every time.
It helps extraordinarily when the operation of any particular tool has to be rerun, or when starting the program from a tool that is not at the Start of the Program. In effect, each tool operation is a Stand Alone Program within the whole program.


Regards,

Bill
 
Wasn't sure why some code is repeated everytime? I thought G54 was more of a modal command, where you don't have to specify it every time.

SAFETY.. Same reason there is a whole string of code at the top of the program to cancel everything
that could possibly be active, and set everything to what you actually want it to be.

AngelW said it pretty well.. Stand alone programs strung together..

The worst thing you can do is make assumptions.. Like why bother calling the first tool in the
program if its the tool that is already in the spindle. Why call a G17 at the beginning when
you may use G18 or G19 once or twice a year??
 
From what i can tell the 'j' thing is an equivalent to G54.1 or H54 p1, it uses J as the controlling letter. ....

Yes, on Yasnac controls with the extended fixture offset option address J is used to determine which extended register to use. Each J address has G54-G59 available. J addresses go at least to 27, maybe further, I don't remember.
 
Not bad but the first two lines after a tool change should be one, big pet peeve of mine as it saves a second or two. G54J1 is the same as G54. I would like to see a G80 to cancel the canned cycles, and the safe line at the begining lacks a G52. All in all it is a very clean program, not perfect but damn close. Exactly how the control wants a program coded depends on how it was set up by the MTB, and what has been changed since. I have a J50 and a J300, the J50 requires less code because of the tool change macro, the J300 doesn't have one.

Calling an M3 before the tap is flat wrong for both of my controls. It turns the spindle on, then the G93 turns the spindle off to tap. Calling the spindle speed before the G93 is critical for the J300, it will randomly alarm out, but not the J50.
 
I have only got about two years experience myself in G-code and CNC work overall, but MY WORD would I love to have had the programs here that I came into possession of when I took this job to look HALF as clean as that code right there..

:eek: Program has the part name and the TOOLS called out at each change...
Do you know how many codes i sorted thru that were Prog1 part1 op 1 Tool 1 , just over and over again.

This is a great code that is easy to read and functional too!
 
I like to think that the way programs look are like your signature. It can be picked up from the people you learnt from,modified to suit you and also standardised within a company so that everyone there knows what programs look like. Think of it as either your own signature or as the companies signature. The code above looks good to me from a quick scan through. I like his way of cancelling a cycle with a G0 (like Bill explained above) and switching the coolant off on the same line. This to me looks like a bit of his own program signature.

I don't put safety lines at the head of programs, before toolchanges or at the end of programs. WHY? Because I can't be bothered to type all that crap out every time. Also my brain likes to look at things that are "neat" and simple to read through. I have subs in all my machines that I just call for that. I do however have a tendency to still put a G80 after a cycle even though I have it in my subs... it is a habit I guess. A guy I used to employ put G80 after EVERY operation so to this day I can still spot programs he finger CAMmed in. I taught him how to program and no matter how many times I explained to him that G80 cancels cycles and he did not need it if he did not use a cycle for that operation he would still put it in out of habit. He was decent at simple programs if he had a similar program to browse through while he was writing. I suspect that before my CAM posts were setup correctly it used to spit out G80 all over the place so he might have picked it up from there.

I prefer to stage my tools directly after a change because it adds an extra block to cycle through before machine movement if you are testing out a program for the first run in single block mode. When not in single block mode it anyway stages the tool while it is moving in it's X and Y on the next line because it is not a stop block, at least not on machines I have worked on.

My Nast "signature" looks something like this...

O1000
P8003 M98
T1 M6 (TOOL NAME)
T2
G00 G54 X0.0 Y0.0 S1500 M3
G43 H1 Z3.0 M8
G83 G98 Z-20.0 R3.0 Q7.67 F130
X2.0
Y2.0
X0.0
Y0.0
G80
P8002 M98
T2 M6
T3
And so on...
 








 
Back
Top