Float to Integer SLC 504 Suggestion?

cmac2425

Lifetime Supporting Member
Join Date
Jul 2012
Location
Pittsburgh
Posts
48
I am trying to convert a 10 digit batch ID number from a Factory Talk View SE 7.0 screen to my SLC 504 PLC so that I can use the ID to designate a run in FactoryTalk Historian. For example the operator puts in a number 3500123.01 and I send the 7 digit number to F8:17 and I send the decimal float number to F8:18. My problem is that I obviously cannot send F8:17 to integer because is is larger than 32767. Does anyone have suggestions are how to sent both of these float variables to one string tag? I have put some effort into using VB but it has not been a consistent fix. Any help is appreciated! Thanks in advance.(y)
 
Why can't you use an Ascii Input in Factory Talk instead of numeric?
If converting to string why not have operator enter value as string?
 
Inputting the value as a string in FTV and having FTV send it to a string tag in the PLC is my suggestion as well.


If you attempt to put 3500123.01 into an IEEE754 float in your PLC, with 3500123 going into F8:17 and .01 going into F8:18, then what really ends up in F8:18 is .00999998. FTV will round the value to .01 when it displays it, but .00999998 is what is in memory. This is due to how floats work in all computers. You cannot exactly represent one digit precision numbers x/10n for any n except where x=5. In your example, that means that a float can never be exactly x.1 or x.01 or x.001, or x.2, x.02, x.002, etc. And that will be a nightmare to program for if you attempt to convert it to a set of integers and then convert those to strings to be concatenated together.

Its just far easier to input the value as a string tag to begin with.
 
That's what I originally tried. My problem is that the PLC reads it as 0.02 and when I concatenate the string, it adds a 0 to my "Integer" number. I would like to do it this way because it's much easier but that's why I've hit some road blocks and I asked for suggestions. Is it something stupid that I'm missing? A configuration of a tag or input string on the HMI? Thanks.

string_ex.jpg
 
The ACN command did exactly what it was supposed to do. It has no 'understanding' of the two strings as having a numeric value. They are just sequences of characters. The instruction was to place the '0.01' sequence of 4 characters just after the others. It did that.
 
In case it hasn't hit you by now the 5/04 doesn't have a variable type which will hold your format other than the string tag. As has been suggested have the HMI enter the value as one string tag and keep it that way. Don't try to convert it to any other form.
 

Similar Topics

I have a Float that is F45:10 and I need to convert it to an integer to display on an HMI that is in VB.net and we can't change. I look on the AB...
Replies
8
Views
9,429
Hi. I'm using a Modbus ProSoft where I basically map data to a big INT array. Example, where GX_I_63HPU is a REAL, MNETC.DATA.WriteData[200] an...
Replies
21
Views
437
How do I convert a float to an integer? I've got a floating-point number D606, value 3999.863. I need to convert it to an integer (4000), then I...
Replies
14
Views
4,163
I can't quite figure out what the issue is here. I read some things about floating point integers and rounding and I assume that's my issue but...
Replies
13
Views
3,912
Hi all Why would The instruction [MOV s:37 F8:18] = 2015.0 in an (SLC 1747-L552C) and [MOV s:37 F191:0] = 55331E-034 in an (SLC 1747-L553) I...
Replies
13
Views
2,287
Back
Top Bottom