584,812 active members*
5,228 visitors online*
Register for free
Login
IndustryArena Forum > MetalWorking Machines > Haas Machines > Haas Mills > Haas parametric programming (floating point) help
Results 1 to 13 of 13
  1. #1
    Join Date
    Jan 2018
    Posts
    7

    Question Haas parametric programming (floating point) help

    I am building a macro (to run on a CHC) to log serial numbers and operator IDs for later database query at a relatively large foundry.

    Our Serial format is nonconsecutive as follows

    123A

    I am using a line of code to concatenate several (manual) operator entries into a single string where:
    #500-#503 are numerical digits
    #504 is an alpha character
    #805 is the numerical translation of the serial number

    #805=[[ROUND[[[[#500-48]*100]+[[#501-48]*10]+[#502-48]+[[#503-64]/100]]*100]]/100]

    The trouble that I am having is that the final digit, which should always read in increments of 0.01 is plagued with what appears to be a floating point error. The effort towards placing the numerical value and the alpha value into a single variable is in hopes that the operator can verify the value and reenter as necessary.

    This seems to be an extremely simple task, but I've put the above line together numerous ways, always to be plagued with a similar error.

    Any suggestions?

  2. #2
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    Do you have any computer programming experience? You need to separate all those into steps and figure out where it goes wrong. It could be an overflow somewhere. Also, floating point loses precision with large numbers as well.

  3. #3
    Join Date
    Jan 2018
    Posts
    7

    Re: Haas parametric programming (floating point) help

    I don't have any programming experience beyond g code and very basic PLC work.

    I do know, however, that the error originates in the
    [[#503-64]/100] operation


    Sent from my Pixel 2 using Tapatalk

  4. #4
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    Do you know the approximate values before and after for that step? And what is the desired value?

  5. #5
    Join Date
    Jan 2018
    Posts
    7

    Re: Haas parametric programming (floating point) help

    The value changes based upon operator inputs.

    Typically the numerical portion is less than 200, and the alpha input is A, B, C or D.

    If I am understanding your previous response correctly, you are suggesting g that I concatenate at

    VALUE * 10^N

    and in a separate operation, divide by 10^(N+2) in order to restore the desired decimal location.

    In this case, doe Haas treat division and multiplication by less than one on the same way?

    Sent from my Pixel 2 using Tapatalk

  6. #6
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    What I am trying to say is that it isn't really a haas limitation, but rather likely the a math float type limitation. You need to figure out where and why this happens and reformulate your formula. That's why I suggest splitting it all out into single steps, that way you can single step through your code and watch the actual values as it gets calculated in the macro param window.

  7. #7
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    I don't understand what you are doing well enough to give ideas. I do think there is a pow option in the macros though.

  8. #8
    Join Date
    Jan 2018
    Posts
    7

    Re: Haas parametric programming (floating point) help

    Sorry, pow option?

    Sent from my Pixel 2 using Tapatalk

  9. #9
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    Power

  10. #10
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    What is your desired output, anyway? Also, I think you perhaps said wrong, #503 = the alphanumeric. If I understand your problem you want the alpha to be the decimal.

    Perhaps
    #805=[[#500-48]*100]+[[#501-48]*10]+[#502-48]+[[#503-64]/100]

    I think this would output

    123.01 for 123A
    123.26 for 123Z

  11. #11
    Join Date
    Jan 2018
    Posts
    7

    Re: Haas parametric programming (floating point) help

    Quote Originally Posted by erikfriesen View Post
    What is your desired output, anyway? Also, I think you perhaps said wrong, #503 = the alphanumeric. If I understand your problem you want the alpha to be the decimal.

    Perhaps
    #805=[[#500-48]*100]+[[#501-48]*10]+[#502-48]+[[#503-64]/100]

    I think this would output

    123.01 for 123A
    123.26 for 123Z
    This is absolutely correct, however, the value returned is

    123.01 for 123A but
    123.01999999... for 123B

    I will try your specific line shortly as well as the FUP operator.

    Sent from my Pixel 2 using Tapatalk

  12. #12
    Join Date
    Feb 2012
    Posts
    115

    Re: Haas parametric programming (floating point) help

    Ok, Perhaps round on the last? the .01999 is definitely caused by floating point math, unfortunately. You could try something like [[[#503-64]+0.00001]/100] or ROUND[[#503-64]/100]

  13. #13
    Join Date
    Nov 2006
    Posts
    490

    Re: Haas parametric programming (floating point) help

    What about the "FIX" macro command? If I remember correctly that will dump out the trailing remainder numbers and give you a value that has been "rounded down". I never used it outside of the probing macros though, so it may not do what you need...

Similar Threads

  1. Replies: 5
    Last Post: 09-25-2013, 05:20 PM
  2. Xilog 3 Parametric Programming Offline Programming
    By julioykaly in forum Commercial CNC Wood Routers
    Replies: 1
    Last Post: 04-27-2013, 09:22 PM
  3. G-code and floating point numbers?
    By donek in forum G-Code Programing
    Replies: 6
    Last Post: 09-27-2012, 08:05 AM
  4. new to parametric programming
    By dougdownunder in forum Commercial CNC Wood Routers
    Replies: 1
    Last Post: 04-24-2012, 08:48 PM
  5. Parametric Programming
    By gene rhodes in forum Parametric Programing
    Replies: 15
    Last Post: 07-26-2010, 10:32 AM

Tags for this Thread

Posting Permissions

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