Changing byte order from Motorola to IEEE

25 views
Skip to first unread message

Tim Alosi

unread,
Jan 23, 2009, 6:24:41 AM1/23/09
to drde...@googlegroups.com
Originally posted in DeltaV Facebook Group by Bruce Brandt

We have a Mettler Toledo scale coming into DeltaV using a DeviceNet
interface from an AnyBus. We see that the byte order of the words is
in Motorola format not IEEE. Has someone already written something to
change the byte orderand then decode the words into a floating point
number? My project is on a tight budget so I'd love to get an .fhx of
this routine from someone.

jas...@gmail.com

unread,
Jan 23, 2009, 11:56:36 AM1/23/09
to ControlDoctors.com DeltaV
This is untested right now, but the code should look like the
following.


====================== CODE ========================
HIGH_WORD_16 := shr('^/INPUT.CV',16);
LOW_WORD_16 := '^/INPUT.CV' & 65535;
IEEE_32 := shl(rotr16(LOW_WORD_16,8),16) + rotr16(HIGH_WORD_16,8);


===================== NOTES ========================
The three variables on the left hand side are temporary variables.
The INPUT parameter is expected to by 32 bit unsigned.
This does not account for the floating point part of the question.

tim....@gmail.com

unread,
Jan 27, 2009, 5:25:50 PM1/27/09
to ControlDoctors.com DeltaV
Are you using the Mettler Toledo DeviceNet bridge? (MT part #
DNB0001000)

You shouldn't need to do any special manipulation- when you create
your serial dataset in DeltaV, specify "DeltaV data type" as "Floating
point with status", and the bytes will be read correctly.

Also, if you have multiple load cells connected to a single head, be
aware that there are some functions that you may not be able to
perform via DeviceNet. For example: if I remember correctly, you need
an additional discrete output from DeltaV to toggle the local display
on the Mettler Toledo from load cell 1 to load cell 2.
Reply all
Reply to author
Forward
0 new messages