In TIA Portal, you can access Bits in Bytes / Words by using the .%# notation

In the example above, we’re taking a Byte and setting Bits 0 and 1 to True using Signal_1 and Signal_2.

If both Bits are True, we check if the Signal_Byte is equal to 3 (binary of 00000011, where Signal_1 and Signal_2 have turned on the first 2 bits). If Signal_Byte is 3, we then turn on OK

The above shows that Signal_1, which is True, is driving Signal_Byte.%X0.

This affects the overall value of Signal_Byte by setting the value to 16#01.

When both Signal_1 and Signal_2 are set to True, both bits %X0 and %X1 of Signal_Byte are set to True, this sets the Signal_Byte value to 16#03, which then passes the comparator instruction on Network 3, setting the OK variable to True

Conclusion

This is a nice way of quickly checking individual bits in a Byte or Word, however you should consider moving the data into a structure of the same length.

The problem with the approach above is you cannot set comments or a symbolic name, which means you don’t actually know what Signal_Byte.%X1 is representing.

If you use a structure and a BLKMOV command, or an AT constructor, you can move the Signal_Byte over a structure of 8 Bools, with each Bool having its own symbolic name and comment.

However, for a quick check, this is a suitable approach!

See More About BLKMOV and AT Constructors…


Check Out Another Post

Leave a Reply