Bit Overlay

nmurray

Member
Join Date
Apr 2014
Location
USA
Posts
90
I have some questions about overlays.

Lets say I have a UDT:
INTEGER INT[5]


Ex:
MyUDT.Integer[0].0 could be a bit assignment of my tag.

Can I do a bit overlay of that Arrayed INT?
Can I do an overlay an INT or SINT data type the same way you can a bit?

I've been searing the net and the KB but I can't find any useful information.
 
i'm showing my ignorance here, what do you mean by overlay?


+1

Maybe?

In a general computing sense, overlaying means "the process of transferring a block of program code or other data into main memory, replacing what is already stored". Overlaying is a programming method that allows programs to be larger than the computer's main memory.

Overlay (programming) - Wikipedia
 
Last edited:
Bit overlays can be a bit confusing. They aren't supported by the editor, must edit the file externally, ex. notepad

[UDT Example]
----------------------------------------------------------
data type MyBits (FamilyType := NoFamily)
SINT ZZZZZZZZZZMyBits0 (Hidden := 1);
BIT MyBit0 ZZZZZZZZZZMyBits0 : 0 (Radix := Binary);
BIT MyBit1 ZZZZZZZZZZMyBits0 : 1 (Radix := Binary);
END_DATATYPE
----------------------------------------------------------


[Bit Overlay UDT Example]
----------------------------------------------------------
data type MyBits (FamilyType := NoFamily)
SINT MyOverlay;
BIT MyBit0 MyOverlay : 0 (Radix := Binary);
BIT MyBit1 MyOverlay : 1 (Radix := Binary);
END_DATATYPE
----------------------------------------------------------

I usually peek at a data type RA has created for inspiration and guidance.
 
Here's another example, The word "Code" and the 7 Bits are treated as the same, you can set a bit in the word "Code" and the corresponding Bit 1-7 will be high. Likewise, set a bit 1-7, and the corresponding bit in the word "Code" will be high. Notice where you "map" the bit number.

Code:
<DataType Use="Target" Name="UDT_Name" Family="NoFamily" Class="User">
<Members>
<Member Name="Code" DataType="DINT" Dimension="0" Radix="Decimal" Hidden="false" ExternalAccess="Read Only"/>
<Member Name="Bit1" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit2" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="1" ExternalAccess="Read Only"/>
<Member Name="Bit3" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="2" ExternalAccess="Read Only"/>
<Member Name="Bit4" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="3" ExternalAccess="Read Only"/>
<Member Name="Bit5" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="4" ExternalAccess="Read Only"/>
<Member Name="Bit6" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="5" ExternalAccess="Read Only"/>
<Member Name="Bit7" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="6" ExternalAccess="Read Only"/>
</Members>
</DataType>
 
Yes Prog30 is exactly correct, however is it possible to do something like this?
(Assuming correct sintax)

Code:
<DataType Use="Target" Name="UDT_Name" Family="NoFamily" Class="User">
<Members>
<Member Name="Code" DataType="DINT" Dimension="10" Radix="Decimal" Hidden="false" ExternalAccess="Read Only"/>
<Member Name="Bit001" DataType="BIT" Dimension="0" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit101" DataType="BIT" Dimension="1" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit201" DataType="BIT" Dimension="2" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit301" DataType="BIT" Dimension="3" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit401" DataType="BIT" Dimension="4" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit501" DataType="BIT" Dimension="5" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
<Member Name="Bit601" DataType="BIT" Dimension="6" Radix="Decimal" Hidden="false" Target="Code" BitNumber="0" ExternalAccess="Read Only"/>
</Members>
</DataType>

obviously the Dimension is not the correct part to pick which array element you want your data to be in...
 
The BitNumber attribute is not limited to the data type size of the data the Target points to. So you will have to calculate bit numbers across word boundaries. For example, if you want to overlay Code[1].0, the Target attribute would be Code and the BitNumber attribute would be 16.
Code[2].0 would be Target=Code, BitNumber=32
Code[3].0 would be Target=Code, BitNumber=48

As far as I can find you can only overlay on the bit level. You can't overlay an integer over a specific integer array index, for example.

Originally posted by drbitboy:

Is this the same as an EQUIVALENCE statement in Fortran?

Kind of...ish? I'm not a Fortran guy so I'm not familiar with the in's and out's of EQUIVALANCE. I would think that is similar to a union in C. Bit overlays are way more restrictive than that. I think they were really developed for the specific case where bit-packed words are used to transfer conditions. Bit overlays provide a way to develop a UDT that breaks the bits apart into meaningful items in a UDT without any data management. It is all under the hood, so to speak.
Bit overlays have their baggage. They can only be used as part of a UDT definition. And, as has already been stated, once you apply bit overlays the UDT cannot be edited in the Logix environment anymore. Bit overlays are defined in an L5X file external to the Logix environment and then imported. But for something you KNOW is not going to change, they do work.

Keith
 

Similar Topics

See the screenshot of EIP tag list. We are trying to read in a digital input that is hard-wired. It is shown here as I31.1. I believe we cannot...
Replies
7
Views
270
A couple days ago I accidentally toggled an alwasyoff bit. The issue is it was set up as a single OTU on a rung, nothing else, and used as XICs...
Replies
3
Views
219
Hi I have an old panel builder 32 that I’m replacing for a factory talk me hmi . In the plc for the old panel builder there is a coms bit for the...
Replies
0
Views
69
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
143
I tried researching but I still don't quite get it. As far as I understood, it's used after a function is called in STL and then if the function...
Replies
1
Views
134
Back
Top Bottom