1 Attachment(s)
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?
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.
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
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?
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
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.
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.
Re: Haas parametric programming (floating point) help
Sorry, pow option?
Sent from my Pixel 2 using Tapatalk
Re: Haas parametric programming (floating point) help
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
Re: Haas parametric programming (floating point) help
Quote:
Originally Posted by
erikfriesen
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
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]
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...