Page 2 of 2 FirstFirst 12
Results 13 to 19 of 19

Thread: Changing signs using variables

  1. #13
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    277
    Downloads
    0
    Uploads
    0
    Try
    #6=ABS[#527-.12]


  2. #14
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by JMECKES View Post
    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.
    Cogsman,
    He is trying to make it a negative number not a positive number. The ABS would change a negative to a positive.

    He is using #6=[0-#527]-0.12 to get his calculation. The 0 can be removed #6=[-#527]-.12 but all and all it works and it works in one line of code.

    Stevo


  3. #15
    Registered
    Join Date
    May 2007
    Location
    US
    Posts
    779
    Downloads
    0
    Uploads
    0
    This should work.
    Code:
    #6=[-#6]
    Or if you want to do it at run time and/or with more then one variable.

    Code:
    (TOP OF PROGRAM)
    #19=[-1](SET TO 1 OR -1 AS NEEDED)
    .
    .
    .
    .
    #6=[#6*#19]
    .
    .
    #100=[#100*#19]
    .
    .


  4. #16
    Registered
    Join Date
    Jun 2008
    Location
    United States
    Posts
    1,509
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by JMECKES View Post
    In the example below, we are trying to change variable #527 to a negative value. I would like to do it on one line,
    using more then 1 variable won't work for what he wants.

    Quote Originally Posted by stevo1 View Post
    I guess you didn’t need all of that but anyway if you want #527 set to a negative value program #527=[-#527]
    Quote Originally Posted by JMECKES View Post
    We ended up using Kiwi's formula, but both that one and Chattaman worked for what we needed. Thanks all!
    Stevo


  • #17
    Registered
    Join Date
    Jan 2005
    Location
    USA
    Posts
    277
    Downloads
    0
    Uploads
    0
    Sorry, I should have read more slowly.

    This will give you the negative value.

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


  • #18
    Registered jamesweed's Avatar
    Join Date
    Jan 2007
    Location
    USA
    Posts
    82
    Downloads
    0
    Uploads
    0
    #6=#6*[-1]
    This will change #6 to it's opposite. If #6 is positive, it will become negitive, negitive will be positive. I have several subs that use this logic.
    Last edited by jamesweed; 05-21-2009 at 09:41 PM. Reason: confusing statement :(


  • #19
    Registered
    Join Date
    May 2007
    Location
    USA
    Posts
    939
    Downloads
    0
    Uploads
    0
    You said

    Quote Originally Posted by JMECKES View Post
    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.
    AND

    Quote Originally Posted by JMECKES View Post
    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.
    I'm lost. How does eliminating one block for the drill cycle "greatly reduce the size of the program"?

    Also since it is a loaded variable, why don't you just load it as a negative number?

    EDIT: Okay, I can see why you are loading it as a positive number if #527 is being used on the main and subspindle (how often does that happen that the same value is needed?). Still from your posts it seems like you are only adding one block. You must be making the change a lot more than once.


  • Page 2 of 2 FirstFirst 12

    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.