beautypg.com

Spectrum Controls 1769sc-HART Modules User Manual

Page 119

background image

Chapter 8: Programming Examples

User's Manual 0300215-03 Rev. A

8-3

8.1.2

Swap Byte Order

This ladder sample demonstrates how to reverse the order of the bytes for a floating point
tag and then convert it to 4 consecutive SINT tags, so that it can be used in a HART
message.

!

Attention

If the HART message being sent or received using the pass-through
command contains floating point values, the order of the bytes must be
reversed.


Figure 8-3 (Change Byte Order)

8.1.3

Converting Unpacked ASCII to Packed ASCII

Packed ASCII is a HART-specific 6-bit character code representing a subset of the
ASCII character code set (see table below). Produced by compressing four packed
ASCII characters into three 8-bit bytes, packed ASCII strings must be a multiple of 4
characters (3 bytes) and must be padded out to the end of the data item with space
characters. For example, 4 space characters at the end of a string would appear as the 3
bytes: 0x82, 0x08 and 0x20.

Construction of Packed ASCII characters:

Constructing a packed ASCII string is a simple matter of discarding the most significant
two bits from each character and compressing the result:

1.

Truncate Bits 6 and 7 of each ASCII character.

2.

Pack four, 6 bit-ASCII characters into three bytes.

3.

Repeat until the entire string is processed.