Convert Long to Float in AB MicroLogix 1400

OneShot

Member
Join Date
Sep 2011
Location
Illinois
Posts
13
I have an Allen Bradley MicroLogix 1400. I am trying to display a value onto an HMI, however my HMI will not accept a Long (i.e. L10:2) as an accepted tag, but it will accept a Float. My Long values are all 8 digits long and will be only numbers (i.e. 99475491.)
It is in a Long in the first place because when I get this value into the PLC via EthernetIP it comes in as a String. I am then converting them into a Long via an ACI instruction (ACI ST52:1 L10:2.)
Is there a way I can convert my Long into a Float, or even better would be to convert my String into straight into a Float? Thanks!!
 
What exact type of HMI are you using ?

Many HMI's that have an Allen-Bradley driver will allow you to define the first of two 16-bit Integer words as the source address, then select a 32-bit integer datatype.
 
It is an EZPanel HMI with Ethernet. It will accept a Long file tag if I have the Allen Bradley DF1 driver selected in the HMI software. But I am looking to communicate with the screen via Ethernet as it will be located on the actual piece of equipment and the PLC will be about 20 feet away in the main cabinet. When I select to use it with EthernetIP it says the Long tags are no longer valid with that driver/protocol, but it will still accept a Float.
 
Given that limitation do a (MOV - Long Address - Float Address) as an instruction. Continue to accumulate in the Long data type in the PLC as there will occur limitation in the transfer to the Float data type later on. The MOV with send the closest representable Float version of your Long into the Float address.

Mickey, given the limitations stated, it's not enough to just transfer the bit pattern as CPW would do. MOV will transfer the closest approximation of the 'value' into the destination with its unique method of representing the value.

But when the Long reaches its overflow point (2,415,919,103 MSB changes from 0 to 1) then everything goes South.
 
Another potential problem here is the 8 digit float. The largest 32 bit floating point number that can represent all 8 digits 16,777,215. Any 8 digit number larger than 16.7 million will not correctly indicate all 8 digits.

One option that you can do on some displays is to place two or even three integer display fields right next to each other. If you use static comma seperators then you can make the display look like a single number.
XX,YYY,ZZZ where X, Y, and Z are all three different integers into which the original long value is distributed. Each display field needs to be formatted to display leading zeros so you don't get funny looking gaps.
 
I was unaware the upper limit of a 32 bit floating point was 16.7 million. I tried what bernie_carlton suggested by using a move (MOV) instruction, but I'm assuming since my 8 digit Long was greater than 16.7 million, it didn't exactly move over correctly.
I ended up taking TConnolly's idea and used two String Extract (AEX) instructions, the first one extracting the first 4 characters, and the second extracting the second 4 characters, moving each into it's own string. I then used two String To Integer (ACI) instructions to convert each extracted string into its own integer. From there I set two integer fields side by side in the HMI with the first one displaying the first 4 character integer, and the second displaying the second 4 character integer. This works Great! Thanks for the help and suggestions! :)
 

Similar Topics

Hi all, I'm communicating with a modbus device which sends data in 32 bits data. You can see the structure in this example: N7:4...
Replies
6
Views
4,563
Hi all, I am communicating with a modbus device which sends data in 32 bits format. The MSW represent the integer part of the value and the LSW...
Replies
3
Views
5,573
Using Logix 500 with a AB Micrologix 1100, I need to convert a 5 character string to a long. example 99999(string) to 99999 (long). The function...
Replies
7
Views
3,183
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
87
I have an application using an incremental encoder and then I convert it to degree (0-360) using calculation program. For a while, the calculation...
Replies
7
Views
233
Back
Top Bottom