wildswing
Member
Hey fellas,
I've got a 4-20 analog signal coming from a distance measuring laser into a Flex IO analog input module. I'm locating the position of a machine component. Since Flex module config does not allow for scaling, I have to work with the raw data. No problem with that.
My issue is that the laser is picking up very slight movement when the machine is stationary, resulting in a +/- 0.1 inch variation in my final position (after washing the raw value through a y=mx+b CPT, where x is raw integer value and y is in inches (floating point)).
In preparation for positioning this thing automatically, we moved the machine to various positions, measured with a tape measure, and compared those to the raw integer values coming from the Flex IO module. We put raw vs measured into Excel, made an x-y scatter chart and asked for a linear equation. Note R squared = 1, so the points were linear.
Note that I only really need 1 inch resolution. 1/2 inch at most.
I tried making the destination of the CPT an integer but if the position lands in the sweet spot between inches (###.4 <---> ###.6), it rounds off, back and forth and I see the one's flipping back and forth by and inch.
If I keep the floating point value, when it's bouncing around whole inches (##1.9 <--> ##2.1) it messes with my LIM and other instructions that command repositioning since they're all in integers.
Is there a way to truncate a floating point value? I remember seeing it done once, but can't for the life of me remember how. Maybe I'm just over complicating this or missing something really obvious here and just can't see it.
I've got a 4-20 analog signal coming from a distance measuring laser into a Flex IO analog input module. I'm locating the position of a machine component. Since Flex module config does not allow for scaling, I have to work with the raw data. No problem with that.
My issue is that the laser is picking up very slight movement when the machine is stationary, resulting in a +/- 0.1 inch variation in my final position (after washing the raw value through a y=mx+b CPT, where x is raw integer value and y is in inches (floating point)).
In preparation for positioning this thing automatically, we moved the machine to various positions, measured with a tape measure, and compared those to the raw integer values coming from the Flex IO module. We put raw vs measured into Excel, made an x-y scatter chart and asked for a linear equation. Note R squared = 1, so the points were linear.
Note that I only really need 1 inch resolution. 1/2 inch at most.
I tried making the destination of the CPT an integer but if the position lands in the sweet spot between inches (###.4 <---> ###.6), it rounds off, back and forth and I see the one's flipping back and forth by and inch.
If I keep the floating point value, when it's bouncing around whole inches (##1.9 <--> ##2.1) it messes with my LIM and other instructions that command repositioning since they're all in integers.
Is there a way to truncate a floating point value? I remember seeing it done once, but can't for the life of me remember how. Maybe I'm just over complicating this or missing something really obvious here and just can't see it.
Last edited: