Integer to float????

ian.smith7

Member
Join Date
Aug 2002
Location
UK
Posts
145
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 would like the L553 to produce 2015.0
any advice any one.
Cheers
ian
 
Hi Bernie
thanks for your reply.
The data I am capturing may sit in the first PLC for a while and I am capturing the D&T at the moment the Float data I want is captured. It just seemed neater to keep all the data together in one data register set and send it all in one enet message.
I did not expect the MOV to work then I saw it working in another PLC and could not understand why it did work in one and not the other.
ian
 
Last edited:
Our location is actually a semi-arid part of Washington State, but this year's winter is even drier than normal. There may not be as much snow accumulation in the Cascade Mountains as normal for our summer water supply.
 
Its a strange thing to hear with all the storm warnings were seeing in USA that your not getting enough (any) snow to keep your water table topped up. I thought Washington state would be a certainty for 6ft of snow. How wrong can you be!!
 
Last edited:
Ive been online to both SLCs in the last 5 minutes and one is definately showing 2015.0 and the other 55331E-034.
is there a way round this without sending two messages for the different data types?
 
As I said in my first post - assuming that the proper date and time is not showing under the 'Main' tab of the 'Processor Status' window - Try setting the proper date and time in the second processor.

And the major storms that just occured were in the Eastern part of the country.

While the snowfall in the Cascades is usually in several hundred inches total (winter 2010 - 2011 was 498 inches on the major highway pass) this winter season so far is just 74 inches.
 
Last edited:
Hi Bernie
My problem is not setting the correct D&T I have set that up across our network using a CLX as a master driving the time to mainly SLCs. Though in the case of this PLC it comes via another SLC driving directly into S:37 to S42.
I am attempting to use this as a D&T stamp for the captured data which is all float. The data is stored locally in F191:0 > 99. Then it is grabbed by a CLX for storage, I could generate a second MSG just to grab The INT time data.

I am just interested and bemused why the MOV works differently in two virtually identical SLCs.
Ian
 
I doubt that it is the instruction - it should be the same between the units. I still think something is wrong with the source (year) or something else is overwriting the float.
 
Took a couple of screen shots online to the SLC.
First one is of a MOV instruction showing 2015.0 as the result. Second is in the same processor showing a COP instruction giving exponential answers.
How is this working as a MOV instruction in another SLC gives the same result as a COP instruction.
The destination registers are not used any where else in the program.
The MOV instruction does involve some math processing and the COP doesn't. So is this something in the processor math set up?

Int MOV to Float.jpg Int COP to Float.jpg
 
1) The only difference between the two processors is the amount of system memory.

MOV and COP are completely different instructions.
COP does a direct bitwise copy from the source to the destination, and copies enough to fill the destination (2 words, or 32 bits in the case of a float destination).
MOV can convert between nummeric formats, and so should be used to convert between integers and floats.

Just using COP to get a 16 bit direct binary field into a 32 bit sign/exponent/mantissa field isn't going to do much useful.

Just for fun, try a few things:

MOV S2:37 to an intermediate integer (N7:xx) and then from there to a float.

Try to add a float constant to the year and store in a float: ADD S2:37 0.0 F8:xx

Look at the binary (non-structured) view of S2:37 in your datafile, and see if it has any odd bits set.
 
Im not sure what I did differently yesterday but just been back to the other PLC and tried an [MOV S:37 F191:10] instruction and got the answer 2015.0 which I wanted.
Im a little confused by this as that is not the result that appeared yesterday. I even showed this to a colleague.
But today it is working OK!!
If there is a problem in the future it will show up in the stored data.

Thanks for your replies
Ian
 

Similar Topics

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
447
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,175
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,922
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,441
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...
Replies
6
Views
2,277
Back
Top Bottom