Applies To: CitectSCADA 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0 CitectHMI 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0 CitectFacilities 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0

 Summary: How can I display the status of each of the individual bits which make up an unsigned integer?

Solution:

The logic operator which will mask everything but the required bit is 'BITAND'.  In a real world project it would be best to create a digital tags on a disk device in the project and run an event to update the digital tags with values from the integer on a regular basis.  That will provide a single location for the conversion code should any changes need to be made in the future.

Example:

Expression = Tag1 BITAND 0xXX

where:

Tag1 is an unsigned integer, and

 Bit of Int Decimal Mask Hexadecimal Mask Bit0 2^0 = 1 0x1 Bit1 2^1 = 2 0x2 Bit2 2^2 = 4 0x4 Bit3 2^3 = 8 0x8 Bit4 2^4 = 16 0x10 Bit5 2^5 = 32 0x20 Bit6 2^6 = 64 0x40 Bit7 2^7 = 128 0x80 Bit8 2^8 = 256 0x100 Bit9 2^9 = 512 0x200 Bit10 2^10 = 1024 0x400 Bit11 2^11 = 2048 0x800 Bit12 2^12 = 4096 0x1000 Bit13 2^13 = 8192 0x2000 Bit14 2^14 = 16384 0x4000 Bit15 2^15 = 32768 0x8000

Note: This should only be used for reading from a PLC or integers in the PLC which will only be writen by Citect.  That is because writting a change to a single bit will write the Citect values to all the bits.

 Keywords: