Bit Overlay

With Bit Overlays, a BOOL member of a user-defined type can represent a bit within a DINT, SINT, or INT member of the same user-defined type. The member of the user defined structure is known as the bit host. Bit Overlays are used only in a structure.
Use Bit Overlays to overlay a member of a larger data type (such as an INT or DINT) with a member of BOOL data type. This overlay means you can access and manipulate individual bits within the larger data type. FactoryTalk Design Studio has some built in types that use Bit Overlays, and you can use Bit Overlays to optimize the memory layout of user-defined types.
For example, if there are three BOOL members together, the BOOLs are packed together into one DINT as opposed to allocating a DINT per BOOL member. You can create bit overlays if you want more control over how BOOL members are laid out in memory.
You can create bit overlays only in the Code Editor.
Using Bit Overlays:
Bit Overlays can be used only within user-defined members of the same structure.
  • If you have a DINT data type, which is 32 bits, you can use the Bit Overlay feature to create 32 separate BOOL tags, each corresponding to a single bit within the DINT. You can then use this overlay for programming logic that interacts with individual bits within a larger data type. 
  • For a structure with a member scalar type DINT and member Mem1, define a bit overlay as:
    data type.struct myStruct { dint myHost; bool bit2Overlay := myHost:2;}
    Now that Mem1 has overlays to it, if MemOverlay is deleted, then Mem1 is no longer a host.
Some predefined data types have visible bit host.
bit overlay data types example
  • Timer’s EN, TT, and DN are all bits of a hidden host member called control.
  • PID’s host member (CTL) is visible. PID’s EN and CT are all bit overlays into the CTL member.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.