1. ## Assigning Variables

Hi-
I have a family of 14 parts that I will be using some type of parametric programming to produce. There are 5 variables that will have to be set for each part.

I was going to use multiple G65's in a main program to write the variables to a sub. Which G65 is read will be determined by another variable at the start of the main program. For example:

IF [#100 EQ 8] GOTO23;
.
.
N23 G65 P0123 A12 B65 F5. Z16;

It is my understanding that G65 is the only way to assign multiple variables on one line.

#1=12 #2=65 #9=5.#26=16; Is not legal, correct?

If possible, I would like to avoid using a subprogram. After assigning my variables I'll jump down in the same program to the lines containing the variables.

N51 G01 X#1 Y#2 F#9
N52 Z=26

If I leave out the "P0123" can I still us the G65 to write all my variables for one part on one line?

Tom

2. you cannot call G65 without Pxxxx. And the value of the variable assigned in G65 is passed in the local variable of the subprogram that it call. It does not affect the value of the main program local variable. There is a set of local variable for each level of programing up to three level, i think.
1st level is the main
2nd level is a sub called by the main
3rd level is a sub called by the second level.

But why it is so important to define your variable in one line ??

this should work:
IF [#100 EQ 1] GOTO 10
IF [#100 EQ 2] GOTO 20
IF [#100 EQ 3] GOTO 30
N10 #1=1
#2=2
#3=3
GOTO 40
N20 #1=2
#2=3
#3=4
GOTO40
N30
#1=3
#2=4
#3=5
N40 START OF CUTTING PATH
....
....

3. Since I have 14 parts in the family so far and a minimum of 5 variables per part, I need 70 lines just to write variables. Possibly add 2 more variables because I probably forgot some stuff and I'm at 100 lines already.

I was just trying to have my cake and eat it too, I guess.

Thanks for taking the time to reply,
Tom

4. Are there any mathematical 'rules' to these variables? If so you could compress the size of your sub by getting the control to work out the variables based on the part number.

I tend to put all this kind of stuff in a standard sub program, which is called by my main program via a setup macro. All I then have to do is input my part number at the top of my sub program.

DP

5. G65 doesn't assign variables, it passes the variable values to a subprogram, hence the need for the P word, to designate which sub program.
I haven't tried to assign values to multiple variables on one line like this:
#100=1 #101=5;
It might work; you'd have to try it.

Remember that #1-26 are reset to "null" when the reset is pressed or power goes out, or (I think) when the program restarts.
#100+ will reset on power off, and #500+ will maintain their values until something else changes them. Some of this stuff is contolled by parameter, but I don't know which ones.

6. Hi Tom,
Originally Posted by itstom
#1=12 #2=65 #9=5.#26=16; Is not legal, correct?
Correct, this is not possible

As beege points out, G65 is used to call a Macro program, and is able to pass arguments to the Macro program defined by the P address in the G65 call. The variables associated with the agreement addresses are Local Variables, #1 to #33. As samu stated, there are Local Variables available to different G65 nested levels. G65 and G66 Calls can be nested to a depth of four levels. Accordingly, there are 5 levels of Local Variables, the Local Variables in the main program are defined as Level 0. As Local variables retain their vales at each nested level, you can't assign vales to Local Variables in, say, Level 1, and then use that variable assignment in the Main Program from whence the G65 call was made. You therefore have two options:

1. Use the Macro Program called via G65 to execute the commands the variable assignment was for
or
2. Assign the passed value to a Common Variable in the Macro program, then carry on with the execution of program from whence the G65 call was made. For example:

----------
----------
Main program stuff
---------
---------
G65 P1234 A1 B2 C3 I4 J5 K6 I7 J9 K10 I11 J12 K13 I#0 A Null value is passed in the last argument to ensure you have control over when the Macro Program returns control to the Calling program
---------
---------
Main program stuff after return from variable assignment
---------
---------

O1234
#33=1 Initialize Index
N10
IF[#[#33]EQ#0]GOTO20 If the variable is <vacant>, quit.
#[100+#33] = #[#33] 1st time through #101 = #1, 2nd time through #102 = #2 and so on
#33=#33+1
IF[#33EQ33]GOTO20 If #33 = Index variable, quit.
GOTO10
N20
M99

In the above example, 14 arguments are being passed to Local Variables #1 to #14 in the called Macro program. The 14th argument ensures that the Macro program returns control after setting #101 to #113.

In the Macro program, the values passed by the G65 call will be assigned to Common Variables starting at #101, and will continue to do so until a Null value is encountered. The assigned Common variables are then available across all programs using them.

The above Macro program will accommodate the assignment of up to 32 variables (#33 is being used as the index) if Argument specification II is used in the G65 Call statement. The main requirement is that the arguments are passed in ascending order incrementing by 1 as shown following.

A - B - C - I -- J - K - I - J -- K - I --- J --- K etc
#1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 etc

Argument specification I and Argument specification II can be mixed, but its important the order in which the arguments from specification I and II are passed. Accordingly, its probably better to pass addresses A, B, C and then I, J, K, can be passed repeatedly up to 10 times.

All Local Variable, #1 to #33, and Common Variable #100 to #149(#199) are cleared to null values when a Reset operation is executed. They can be prevented from being cleared by setting, CLV and CCV respectively, (bits 7 and 6 of parameter 6001 in a late model control).

Although this is a fairly flexible method of being able to pass arguments to a Macro program for the purpose of variable assignment, it doesn't make the program anymore compact. There is no real difference between
G65 P1234 A1 B2 C3 I4 J5 K6 I7 J9 K10 I11 J12 K13 I#0
and
#101 = 1
#102 = 2
#103 = 3
#104 = 4
#105 = 5
#106 = 6
#107 = 7
#108 = 8
#109 = 9
#110 = 10
#111 = 11
#112 = 12
#113 = 13

except that the former is a more structure method and will possibly make the calling program a bit more readable; it will consume fewer pages.

If the variables are assigned in the program where they'll be used, Local Variables could be used instead of Common Variables.

Hope the above helps.

Regards,

Bill

7. As stated below, even if you could put multiple assignments on one line it is the same number of characters being used. Is there a reason you are concerned about the number of lines?

Why do you not like the G65 approach, it appears to do everything you want, separating the parameters from the generic part program, which would always stay the same and cannot get messed up by editing.

Then you could have a separate main program for each part number and there would not be all that messy testing to determine which parameter set to use.

8. Thanks for the replies everyone. I'm going to go ahead and do this with macro and a sub. I am going to set it up so entering a part number drives everything. To answer someone's question, there are no mathematical formulas that I can apply to any of the variables.

There is one more piece of the puzzle that I asked in another thread, but I'll throw it in here as well. Different parts in the family will stick out of the collet a different amount. I would like to pass that information to the sub via my macro too. I tried to write to #5222 and #2103 thinking that I could use those as a Z workshift, but it generates an error "ILLEGAL OFFSET VALUE IN G10".

What little documentation I have on this control lists G10 as "date setting"

Thanks again guys,
Tom

9. Originally Posted by itstom
Thanks for the replies everyone. I'm going to go ahead and do this with macro and a sub. I am going to set it up so entering a part number drives everything. To answer someone's question, there are no mathematical formulas that I can apply to any of the variables.

There is one more piece of the puzzle that I asked in another thread, but I'll throw it in here as well. Different parts in the family will stick out of the collet a different amount. I would like to pass that information to the sub via my macro too. I tried to write to #5222 and #2103 thinking that I could use those as a Z workshift, but it generates an error "ILLEGAL OFFSET VALUE IN G10".

What little documentation I have on this control lists G10 as "date setting"

Thanks again guys,
Tom
G10 is used for loading or changing the value of various offset types from program, or for Programmable Parameter Entry.
Hi Tom,
You haven't indicated how you were trying to use the above System Variables, but there is no need to be using G10. #5222 is the system variable for the 2nd axis of G54, and can be Read and Written to directly. For example:

#5222=-200.1 assign value to
#5222=#5222+20.5 modify existing value

Regards,

Bill

10. Originally Posted by FANUCCNC
Then you could have a separate main program for each part number and there would not be all that messy testing to determine which parameter set to use.
Maybe I misunderstand you, but having a separate program in the control for each of the 14 parts with the correct part program being called by assigning the part number is not my idea of macro programming. The only thing that would be good for is not needing to know the program number associated with each part.

Pretty certain we are talking about a mill. I have master programs for several families of parts made on lathes. The set-up person is responsible for changing a few variables using dimensions given on the drawing. Program sets the workshift using G10. We are not talking 14 parts, but hundreds.

11. He is talking about parametric programming, which would include macro variables. Might help to see a few of the part prints. I have been following this thread a while and I am just not seeing the real problem here. I do not see the reason for the passing of variable to a sub program unless the parts are extremely complicated.

12. I believe the purpose of the macro program is so that the main program with all the geometry is standard, proven and does not need to be modified to produce another part in the family. It is a REALLY powerful canned cycle that can make a whole part. Test it and debug it and put it in the library.

Setting the parameters for a particular part does not need to be part of the macro program. In fact, if you put the macro variables in the top of the main macro and you add a new variation you have to edit the main program. That means it is not tested and you lost some of the advantage.

By having a calling program, whether it passes the parameter variables as parameters, or sets other macro variables is a matter of style.

Anyway the calling program is simply one or two lines, just setting up the parameters.

Page 1 of 2 12 Last