# Converting LonWorks SNVT’s to BACnet or Modbus Units

Converting LonWorks SNVT’s to BACnet or Modbus Units

LonWorks SNVT's are metric units. When putting a LonWorks device on a BACnet network using a Babel Buster, data will default to metric on the BACnet side. Usually BACnet (or Modbus) is not happy with this, at least in the USA. There is a way to get the gateway to do the units conversions as data passes through.

The formula for conversion as found in LonMark documentation is:

S = a * (10^b) * (R+c)

where R is the raw data from the network variable, and S is the scaled data as would be displayed in engineering units. The middle term is 10 raised to the power of b, or in other words an exponent.

Do not use the standard SNVT type index values. Use SNVT index 0 to select raw data instead. Set size to 2 bytes, or 16-bit signed integer. Now use the A,B,C scale factors to do the non-standard conversions.

To get degrees in hundredths from SNVT_temp_p, use scale a: +18 b: -3 c: +1780

To get degrees in tenths from SNVT_temp, use scale a: +18 b: -2c: -2562

To get PSI from kPa in SNVT_press, use scale a: +145 b: -4 c: 0

One more piece of useful information: If you want scaling other than tenths or hundredths of degrees, you can change the 'b' scale factor. This is the power of ten in the formula.

In addition to setting SNVT index to 0 when configuring the gateway, you need to set the raw NV type, and this is determined according to what the original NV type was. For SNVT_temp it is unsigned 16-bit. For SNVT_temp_p it is signed 16-bit (which LonMark calls signed long). SNVT_press is also signed 16-bit or long. The NV type values are as follows:

1 NVT_CAT_SIGNED_CHAR 8-bit signed character

2 NVT_CAT_UNSIGNED_CHAR 8-bit unsigned character

3 NVT_CAT_SIGNED_SHORT 8-bit signed integer

4 NVT_CAT_UNSIGNED_SHORT 8-bit unsigned integer

5 NVT_CAT_SIGNED_LONG 16-bit signed integer

6 NVT_CAT_UNSIGNED_LONG 16-bit unsigned integer

7 NVT_CAT_ENUM 8-bit enumeration

8 NVT_CAT_ARRAY Array

9 NVT_CAT_STRUCT Structure

10 NVT_CAT_UNION Union

11 NVT_CAT_BITFIELD Bitfield

12 NVT_CAT_FLOAT 32-bit IEEE 754 floating-point value

13 NVT_CAT_SIGNED_QUAD 32-bit signed integer

14 NVT_CAT_REFERENCE Reference type

Note that array, structure, union, and reference types are not recognized by the gateway. Structures need to be broken down into their raw components and one structured NV will turn into multiple BACnet objects (or Modbus registers).

You can find all of the raw type, data element size, and standard scale factor information in the SNVT master list available for download as part of the resource file set from LonMark (http://www.lonmark.org).