QuickServer - How to unpack Bits from a 16bit Register in a FieldServer Configuration

Introduction

What happens if you want to serve some/all of the bits that form a 16 bit register ie. Your client reads a 16bit register but you want to serve those bits as separate binary objects?

Here is an example

Let's say the client reads 40001 data into DA_REG[0] (Data Array = DA_REG Offset=0). The 1st Move copies 1x 16 bit number from DA_REG[0] to DA_PACKED[0]. DA_Packed's offsets can be interpreted in two ways:
  • A series of 16 bit numbers
  • A series of bits

The way it's interpreted depends on what kind of operation access the Data Array. If it's a 16 bit or analog-number-type operation, then it addresses 16 bit numbers. If the operation is a bit-operation, like for a binary data point, then the operation addresses each bit.

Therefore DA_PACKED[0] is ambiguous.

If you connected a server Map Descriptor to that point and the type is an Analog In/output, then it means it will address the 16bit number found at DA_PACKED[0].

If you connected a server Map Descriptor to that point and the type is an Binary In/output then it means the bit number found at DA_PACKED[0] and DA_PACKED[15] is the 16th bit. DA_PACKED[16] is the 1st bit of the next 16 bit number...

If that seems to complicated then add one more move:

Data_Arrays

Move_OnlyDA_PACKED0DA_BIT016


This move moves the 16 bits for DA_PACKED[0] to 16 separate bits with unambiguous offsets and you can use those in the server map descriptors.

Heads Up

Some Modbus server devices number the bits in reverse order. You can only be sure when you test.

Data_Arrays
Data_Array_NameData_FormatData_Array_Length
DA_REGUINT1620
DA_PACKEDPacked_Bit100
DA_BITBIT1200

Preloads

Data_Array_NamePreload_Data_IndexPreload_Data_Value
DA_REG033

Moves

FunctionSource_Data_ArraySource_OffsetTarget_Data_ArrayTarget_OffsetLength
Move_OnlyDA_REG0DA_PACKED01
Move_OnlyDA_PACKED0DA_BIT016

Contact Us

Contact us via phone (+1 866-383-1657) or leave a detailed message below for sales, support, or any other needs

*Required Field
*Required Field
I'd like to receive the newsletter. *Check email for confirmation.
*Required Field
8:00am - 12:00pm 12:00pm - 5:00pm
Message Sent Successfully