beautypg.com

Bit field notes, String notes, Mode 3 – Contemporary Control Systems BASview User Manual

Page 47

background image

TD110500-0MC

47

Examples:

2,12,9,4,0

Mode=2, NV index=12, SVNT=9

(count_inc),

Offset=4,

DataType

=0 (unsigned short)

This example will read the data structure at NV Index 12, take a single byte

(DataType

0)

starting at byte 4 in the structure, and convert it to a value of type

count_inc

(SNVT 9).

2,23,48,9,4

Mode=2, NV index=23, SVNT=48

(amp_f),

Offset=9,

DataType

=4 (floating point)

This example will read the data structure at NV Index 23, take 4

bytes (DataType 4)

starting at

byte 9 in the structure, and convert it to a floating point value (SNVT 48).

2,18,0,14,1,12

Mode=2, NV index=18, SVNT=0 (no conversion), Offset=14,

DataType

=0 (unsigned short), Extra=12

This example will read the data structure at NV Index 18, take 1

byte (DataType

0) starting at

byte 14 in the structure, and convert it to a raw integer value (SNVT 0, no conversion)

Bit Field Notes:
Bits are numbered from right to left. Bit 0 is the right-most, or least-significant bit.

For bit field data types the "Extra" value should be an 8-bit mask to logically AND with the raw data byte.
The result is always returned right-shifted to the lowest significant bit.

For example, with a bit mask of 12 (binary 00001100), the resulting value would always be between 0 and
3 because after the AND operation the result is right-shifted twice.

If the user changes the value it is automatically left-shifted twice, then

AND/OR'd

back in to the original raw

data before it is sent to the device. This allows the point to always be treated as an integer value and
avoids any manual shifting of bits.

As another example, if a single byte in the structure contains the status of 8 relays and you want a point
for the status of just relay 5, the mask would be 16 (binary 00010000). After the data is read from the
device, the value of the point will be 0 or 1 to reflect the state of the relay.

The best way to calculate a mask is to determine which bits are significant and use the Windows
calculator to translate it to a decimal value (the calculator may need to be changed to "scientific" mode).

String Notes:
For string data types the "Extra" value should be set to the maximum length of the string, including the
NULL terminator.

Mode 3

Mode 3 is only used with custom device modules. All available points will be imported during a device
point scan so the format is very simple and inflexible.

The format is:

3,pointName

pointName = The point name assigned to the point by the device module.