Page 1 of 2 12 LastLast
Results 1 to 12 of 19

Thread: Changing signs using variables

  1. #1
    Registered
    Join Date
    Oct 2008
    Location
    USA
    Posts
    25
    Downloads
    0
    Uploads
    0

    Changing signs using variables

    We are using Custom Macro B extensively on a CNC lathe. When trying to change the sign of a variable from positive to negative, we seem to only be able to change it using a two line formula. In the example below, we are trying to change variable #527 to a negative value. I would like to do it on one line, but either MacroB doesn't follow all algebraic rules or my algebra just plain sucks (and that may very well be the case). The fact that we can't use parenthesis doesn't help either, since the control ignores it like any comment in the code.

    #6=#527-.12
    #6=-#6

    I've tried things like #6=[-]#527-.12 and #6=[[#527*-1]-.12]

    Any suggestions from the sharp folks on here?


  2. #2
    Registered beege's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    546
    Downloads
    0
    Uploads
    0
    As far as I understand it, 1-33 are reserved for argument transfers from the G65 macro call line to the macro. I'd use either the common variables 100-199 (which reset to null on power off/on cycle) or 500-599 (which stay put when powered is cycled).

    #100=-[#6]

    of course, you could try #6=-[#6], but i wouldn't because I don't like using those variables as a matter of personal taste.


  3. #3
    Registered
    Join Date
    Nov 2006
    Location
    UK
    Posts
    160
    Downloads
    0
    Uploads
    0

    Or maybe...

    You could try...

    #6=[#527*[-1]]-0.12


  4. #4
    Registered
    Join Date
    Jul 2003
    Location
    New Zealand
    Posts
    1,137
    Downloads
    0
    Uploads
    0
    Or this
    #6=[0-#527]-0.12


  • #5
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    What number is #527 usually set to? Are you trying to get a negative value for the result of #527-.12? Where is #6 playing a factor into your calculation? There is a few ways to do this. If the value of #527 is normally greater than .12 you can reverse the calculation. Ex #527 is set to .7 #6=.12-#527=-.58

    I guess you didn’t need all of that but anyway if you want #527 set to a negative value program #527=[-#527]. This works on all of my Fanuc’s. Or you can use as Beege has formatted #527=-[#527]

    Beege,
    FYI….you can use #1-#33 anytime that you want. You don’t have to use them exclusively as a passing of variables with the G65 command.

    Stevo


  • #6
    Registered
    Join Date
    Apr 2008
    Location
    sweden
    Posts
    3
    Downloads
    0
    Uploads
    0

    how i did it on an Okuma

    VC10=VC10*-1 when using global variables.
    Hope this helps you.


  • #7
    Registered beege's Avatar
    Join Date
    Feb 2008
    Location
    USA
    Posts
    546
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by stevo1 View Post
    Beege,
    FYI….you can use #1-#33 anytime that you want. You don’t have to use them exclusively as a passing of variables with the G65 command.

    Stevo
    Yup, knew it; just don't as "a matter of personal taste". Thanks for the reaffirmation.


  • #8
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Perkulator,
    Jmeckes never told us what control he was using. Now this could depend on what control he is using but none of my 15 series Fanucs support #527=[#527*-1] it is an improper format. I am assuming that he is using a Fanuc and this statement will not work. However I have seen this format in other threads so it must work on different controls.

    Beege,
    I am just opposite. I like to use the #1-#33 just for the fact they clear at reset or program end. No chance for opps forgot to set it to 5 in the second program when it was used as 1 before that. I also like the fact that if I want to go 2 subs deep I can use them again in the second program set to a different number and they return to the previous value when coming back to the 1st sub. As you know with macros there is dozens of ways to approach it. No 1 way is right or wrong.

    Stevo


  • #9
    Registered
    Join Date
    Oct 2008
    Location
    USA
    Posts
    25
    Downloads
    0
    Uploads
    0
    It's a 21i on a sub-spindle lathe. We are using it to control the depth of a drill at the end of a peck cycle. That's where the - comes in. The positive values used for the sub were no problem for the calculation. We ended up using Kiwi's formula, but both that one and Chattaman worked for what we needed. Thanks all!


  • #10
    Registered
    Join Date
    Mar 2005
    Location
    Silicon Valley, CA
    Posts
    988
    Downloads
    0
    Uploads
    0
    Why bother with the math? so to speak....

    Just say...

    -#527


    But without knowing what the conditions are...

    Are you trying to use #527 as a negative function?
    -#527

    or you just simply want to insert a negative value in #527?
    #527=-#527
    It's just a part..... cutter still goes round and round....


  • #11
    Registered
    Join Date
    Oct 2008
    Location
    USA
    Posts
    25
    Downloads
    0
    Uploads
    0
    The program is variable loaded so I was trying to simplify and reduce program size. By keeping the sign change on one line of code instead of two, we are able to greatly reduce the size of the program. This also helps when it comes to training employees who are new to parametric programming. We've found that loading a control with a series of "variable" programs and having the operators copy and merge these mini programs is much less time consuming than using CAM software, and definitely more efficient than writing line by line G code. For almost everything we do now, we just have to input numbers without writing the entire program.


  • #12
    Registered
    Join Date
    Mar 2005
    Location
    Silicon Valley, CA
    Posts
    988
    Downloads
    0
    Uploads
    0
    ....

    edit...

    never mind... missed one of your posts....
    It's just a part..... cutter still goes round and round....


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Need Help!- Carving Signs
      By Sam A in forum BobCad-Cam
      Replies: 2
      Last Post: 05-04-2008, 10:01 PM
    2. Painting wooden signs?
      By abomb55076 in forum WoodWorking
      Replies: 26
      Last Post: 08-07-2007, 11:39 PM
    3. RFQ Billet superman signs
      By clarq_kent in forum Employment Opportunity
      Replies: 21
      Last Post: 05-26-2007, 12:40 PM
    4. wood signs
      By Pugster in forum WoodWorking
      Replies: 1
      Last Post: 07-08-2006, 12:21 AM
    5. Top Ten Signs
      By wms in forum CNCzone Club House
      Replies: 19
      Last Post: 06-21-2003, 08:04 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.