How to truncate floating point in PLC5

wildswing

Member
Join Date
May 2005
Location
Sault Ste Marie, Ontario
Posts
281
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.
 
Last edited:
Thanks Mikey. I new this had been discussed before, but nothing came up in my search. I only used the site search and not Google however. Thanks again. I'll do some reading and get back to y'all.

Yes, filtering is an option I've considered, but I do not want to slow the thing down too much. Even though the positioning does not have to be very precise, it does have to respond quickly.
 

Similar Topics

I would like to truncate an F8 Example (2.528195) to 2.5 I have searched the forums but haven't had any luck. I am fairly new to programming...
Replies
6
Views
3,264
Hi, Can anyone tell me if there is an equivalent 'truncate' function in Mitsubishi GX Works 2. Ive worked with Rockwell and Siemens for years...
Replies
23
Views
4,578
I'm currently working on a project that requires me to use a compute. I'm trying to truncate the first part of the equation and then divide by...
Replies
10
Views
13,922
I have a question on AB SLC 5/05 RSLogix 500. I need to take a floating point number and break it into two integer words, the lower word for...
Replies
4
Views
4,511
How is floating web accumulator works ? I have a project where I will control a floating accumulator without speed trim. Input and Output rolls...
Replies
14
Views
3,525
Back
Top Bottom