585,567 active members*
3,421 visitors online*
Register for free
Login
Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2005
    Posts
    219

    Variables/Macro uses....

    Hi Guys,

    I have a cheap cad cam system that works well for what I use it for on a HMC. I just use it for engraving names,eblems, logos, etc.....

    I now run a CNC lathe with a fanuc 18i-TB. X,Z, with a sub spindle.

    Is there a way to enter an equation in the front of the program that divides all C-axis moves by a number??

    For example:
    If I use the clyndrical interpolation function it uses degrees of rotation for the C-axis moves. For a 2." work piece I need to divide all the Y-axis moves (that my cad/cam produces) by .017453 to get degress of rotation on a 2." O.D for C-Axis

    I am just wondering if there is a way to use macros or variables to do this equation internally in the machine without me having to convert all the numbers manually in a spread sheet.


    I hope I am making my self clear enough for you guys to understand.
    If Im not just ask me some questions.

    thanks Jon Thee

  2. #2
    Join Date
    Sep 2005
    Posts
    767
    Jon,

    With the macro option on a Fanuc, you can assign any unused G-code to automatically call a macro and pass "arguments" to it. Then, inside the macro, you make the calculation and move the axis the way you want.

    For example, if you want to assign "G23" as a macro call, you can have your CAD/CAM program put this in your main program:

    G23 Y1.2345

    The "G23" calls a macro number (set by parameters), and this G23 command DOES NOT try to move the Y axis. Instead, the "Y" value becomes variable #25 inside the macro. Note: The address "A" becomes variable #1, and the address "Z" becomes variable #26. If you use address "C" in your macro call, then the C value becomes macro variable #3 because it's the 3rd letter of the alphabet.

    Inside your macro, you can make any calculation or series of calculations you want, and then move the C axis, like so:

    Note: In a macro, the asterisk (*) is used for multiplication.

    O9010
    G01 C[#25*.017453]
    M99

    This should move the C axis by your Y value times .017453. Be sure to include a feedrate PRIOR to this macro call, or else you'll have to put it the macro too.

    If you want that value ".017453" to also be a variable, you can use one of the Fanuc's "500" variables, which the operator can enter in MDI mode. For example:

    O9010
    G01 C[#25*#501]
    M99

    This way, the operator uses the MDI mode to manually key in the multiplication factor in variable #501, then you run the program.


    In the Fanuc 18i, you use parameter 6050 to set the number of the G-code that you want to use to call macro 9010. Just put the number "23" in this parameter (or any G-code number you want to use), then you can use this G-code macro call in your main programs.

  3. #3
    Join Date
    Nov 2005
    Posts
    219
    Sounds good. I cant wait to get back to work and try it. Im on vacation this week...

    This may be a stupid question but does every macro that I create have the same variables?? Like #1=A....#25=Y....#26=Z... or Do I have to assign the designaiton's?? Are these variables considered system variables I assume??

    This is great help..I really appreciate it.

    thanks
    Jon

  4. #4
    Join Date
    Sep 2005
    Posts
    767
    The variables from #1 (A) to #26 (Z) are called "local variables", and these variables are only used as "arguments" when you call a macro. For example, if G23 calls a macro, then this macro:

    G23 X1.2344 Y4.5678 F10.0

    can use variable #24 (X), #25 (Y) and #6 (F) to make calculations. The other variables between #1 and #26 are all "zeros". Once you return from the called macro, these variables are no longer valid. Local variables are only used to pass data from the main program to the first macro. If your macro calls another macro, then these values don't apply anymore.

    If you use the "common" variables from #100 and up, then these variables can be calculated in one macro, then you can call another macro and the variable's value remains. Use the #100's variables to pass values from one macro to another, or to pass values between programs. The macros in the 500 range are also a kind of common variable, only these variables don't lose their values even if you turn the CNC off, then back on. Use these variables when entering data like we spoke of earlier. The 500 variables are kind of like tool offsets in that they stay put until you change them.

    The "system" variables are in the 1000 and up range. These variables are passed from the CNC "system" to the macro, so the macro can read things like the effective feedrate, the current X axis position, the last G-codes or M-code executed by the control, etc.

    Hope this helps.

  5. #5
    Join Date
    Nov 2005
    Posts
    219
    These programs are like 1600 lines long... For every Y move I have to have the G23 in front of it correct??? Will this cause any problems calling the same macro on almost every line???

    thanks
    Jon

  6. #6
    Join Date
    Sep 2005
    Posts
    26
    See if you have macro modal call(g66).Then all you do is call your macro like this.
    G66 p8000 A2 B3.1 D33 F40 for example
    x???y???
    x???y???
    x???y???
    G67 macro modal cancel.
    This way, you only have your call and then all locations after that become modal.
    I do this on a mill, so I don't know if you can do it on a lathe, but it should have it.On the control I run (16m), I cant call a custom macro like dans example,on a G66 call, so I have to do a full program call(p8000) and then the local variables after that.Dan can explain it a lot better than I can.He's helped me a couple of times.Hope this helps.

  7. #7
    Join Date
    Nov 2005
    Posts
    219
    Yea if I have a G66 marcro modal call than thats the way to do that....
    In your example, can you explain the G66 p8000 A2 B3.1 d33 F40 in detail.


    thanks guys,
    there are alot of smart guys on here!!!!!!!!

  8. #8
    Join Date
    Sep 2005
    Posts
    767
    The G66 puts the control into a "modal macro call" mode, which means that the same macro gets called on every block after that, and it continues to call that same macro until you cancel G66 with a G67. The P command is the macro number (O-number) that you want to call, and all the other addresses like "A", "B", etc. are arguments that you are passing to the macro.

    A G66 P8000 A2 B3.1 D33 F40 command will pass the variables #1 (A), #2 (B), #4 (D) and #6 (F) to macro 8000. Inside macro 8000, you can use those values for any calculation you'd like to make. The macro 8000 will continue to get called with every move command after the G66 using the same arguments.

    G66 P8000 A--- B--- C---- etc. (Calls the macro)
    G00 X1.2344 Y3.4567 (after X-Y move, macro 8000 gets called again)
    X2.3456 Y4.5678 (after X-Y move, macro 8000 gets called again)
    G67 (cancel)

  9. #9
    Join Date
    Nov 2005
    Posts
    219
    If I use the G66.... and it calls the macro on a G0 Z.1 or a G01 Z-.1 move what will it do??? I assume it will do nothing since I dont have any variables loaded for Z but just want to make sure.

    thanks
    Jon

  10. #10
    Join Date
    Sep 2005
    Posts
    26
    Use the macro modal call(G66) to get to your locations and do ALL movement in the macro sub.Something like this using the local variables in the example below.
    G66 p8000A2 B.31 D33 F40

    O8000
    Go z.02
    G1 Z0 F[#9/5]
    G91
    G1 Z-#2
    G1G41X[#1/2]D#7 F#9
    G3 I-[#1/2]
    G1G40X-[#1/2]
    G90 GO Z6
    M99
    If I typed this in right you should end up with a 2.0 dia hole .31 deep.The local variables sort of have two meanings.On the call line in the main you use them with letters and they translate into the #variables in the sub.So, A is the equivelant of #1,B is #2, D is #7,F is #9.You keep the sub protected and use those call letters to manipulate the sub.So you can change them later or on another job to machine a pocket say 2.75 dia and .5 deep for example and it would look like this
    G66p8000A2.75 B.5 D33 F20
    The sub will never change and works using the info you gave it on the G66 call line
    You need to look in your manual or get a book on macro programming.I don't know if this helps but you need to screw around with it doing air cuts and practice.Thats a simple example.

  11. #11
    Join Date
    Nov 2005
    Posts
    219
    ok, I am having a hard time comprehending this without being able to try it on the machine. I will try it next week when I go back to work.....

    thanks
    Jon

  12. #12
    Join Date
    May 2006
    Posts
    265
    I dont think a macro works.. What he need is to set up a table with all X and C coordinates and scale the C-axis to produce the right movement on the OD surface.( is that possible on FANUC?).. I think that the way to do it is to change the post you have. (It sounds like you uses a cam for a mill). Just scale the axis that you uses as C. ... Works for me...

    What s the cam u uses? Mabe it is the same as us, then I ve got a post that works for C-axis...

  13. #13
    Join Date
    Nov 2005
    Posts
    219
    I use Myers CNC cam. It works good for what I use it for. It directly interfaces with autocad.

    It just does not have many options to choose from thou.

    Jon

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •