How do i add two 16 bit words to make one 32 bit word?

I am connected to an Allen Bradley powerflex 753 VFD using a 22-comm-e card over ethernet. I can am getting interger values back but they are 32 bit words broke up into 2 16 words. I end up with 2 integer files that i need to add together for a final value. How do I accomplish this?

Look at the BTD instruction in the Contrologix.
Move 16 bits of 1st word into 32 bit word starting at bit 0. Move the 16 bits of 2nd word into 32 bit word starting at bit 16

The Logix COP instruction will do this in one step for data delivered by the comm module in little endian order. It can also handle contiguous arrays in one go. Just remember that the “length” parameter is in units of the destination size. The COP instruction also happens to be the only way to move floating point values that are delivered in integer registers. Some 32-bit values from PowerFlex drives are floats, not 32-bit integers.

If you identify the parameter # you are dealing with, I can be more specific.

I am not using a processor to retrieve the data. I am direct connected using the SLC driver. I am setting up the data links in the VFD. [Belly Pump Cleanup VFD]N41:3 and [Belly Pump Cleanup VFD]N41:4 together are my Speed Feedback.

Ewww. Anyways, given N41:3 ==> “low” and N41:4 ==> “high”, the 32-bit combination is (high+1)*65536+low. The +1 for the high word compensates for the negative place value applied to the high bit of the low word.

You should be aware that this result may show weird behavior any time the high part changes, since OPC won’t guarantee both words are delivered together.

If the parameter you are feeding through the data link is an internal float, the above doesn’t apply at all. You’ll need to look up IEEE-754 to work out the bit patterns. I haven’t done that in a long time. :slight_smile:

What is controlling the VFD? Is it controlled via E I/P or is it hardwired and the Ethernet port is available, such as the newer PF525 VFDs?

Added floating point to decimal conversion in the math extensions.

Turns out java includes the int/float conversions as static methods of Float.

If tags ‘low’ and ‘high’ are the 16-bit values above, but carrying a binary float, this will give it to you:

import java.lang.Float
low, high = tuple([x.value for x in system.tag.readAll([‘low’, ‘high’]))
val = (high+1)*65536+low
floatval = java.lang.Float.intBitsToFloat(val)