Concatenate 2 words Control Logix

Chado613

Member
Join Date
Mar 2005
Location
Kingston
Posts
79
I have signals coming in over Modbus where 1 word "provides value to the left of the decimal point"and another word "provides value to the right of the decimal point".

My question is, what's the best way to concatenate (for lack of a better word) these to put them into a useable word?
 
If the number of decimal digits is always the same then just create a tag of type REAL and do this in a compute block

REAL = WordLeft + WordRight/(10 ^ # of digits)

This gives you the value in floating point.
 
Last edited:
Are you sure its not a 32 IEEE754 float being transmitted as two 16 bit words on Modbus. That is very very common. If it is an IEEE754 float then one word contains the sign bit, 8 bits for the exponent, and the remaining 7 bits are the first part of the mantissa. The other word contains the rest of the mantissa. So you have to get the first word into bits 16 thru 31 of the float and the second word into bits 0 thru 15 of the float. However, it is really easy to do.

576px-ieee-754-single-svg1.png

Given the following tags
RealTag: Floating point tag
IntArray: Array containing 16 bit integers received from Modbus.

and where i represents the location of first word on IEEE754 float in IntArray then

COP RealTag IntArray 1

will make the conversion for you.

It is important that you specify a length of 1 since length is the number of Destination sized words. The 32 bit IEEE754 float pattern in the two consecutive integers is then copied to the RealTag.


A little more information about the instrument and the data format will be helpful.
 
Last edited:
Thank you Damian, Alaric for your answers.

The device is a Modcon 75 controller.
From Manual: (MI refering to modbus address)
Value is split into two registries;
For example, ID#2 sensor #1:
• MI300 provides value to the
left of the decimal point
• MI325 provides value to the
right of the decimal point.
(See Appendix B, "Memory Integers").
 
I would have to agree with you

Am I missing something with your formula?

ie:1.55
NumOfDigits[2.74] = log[base10](WordRight)[1.74] + 1

REAL = WordLeft[1] + WordRight[55]/(10 ^ [2.74]# of digits)
=1+55/549.54
=1.1
 
Chad, There is a slight problem with how my CompactLogix is calculating the logs. Not sure if it is the same with the Control Logix processor. For values of 10, 100, 1000 etc it is incorectly giving values
.9999999, 9.99999, 99.99999 etc which means for those specific values the number of digits will not calc right.
 
Have to guard against a zero result. See the attached.

I suspect though that the decimal will be fixed, since otherwise you would interpret 1,10,100, etc all as 0.1


But if it is variable this should work. If not, the math gets a whole lot simpler.

Math.jpg
 

Similar Topics

I have a panelview plus and a controllogix Plc that all the words above the start/stop buttons to display equipment names use a Concatenate...
Replies
3
Views
4,203
Has anyone concatenated two 16-bit (B3) words into one 32-bit (L) word in a Micrologix 1400? I do not want to add the values. I need to maintain...
Replies
4
Views
4,372
Hello All, I have a little problem that I need some help with. I have got a 17 digit number coming from a supplier. It's basically a barcode...
Replies
11
Views
3,057
Hi, I have a list selector which I want to display the recipe found inside a plc-5. The recipe is store in an ascii table with each character...
Replies
4
Views
1,414
I am trying to concatenate two INTs into one DINT I have try following Knowledgebase Article 552006 but I am not having any luck. I have found...
Replies
6
Views
3,082
Back
Top Bottom