TIA Portal "AT"
In this practice, we will see a small example of the use of AT, this is the description provided by Siemens:
With the keyword "AT", a declared variable can be overlaid with another declaration if, for example, you want to access independent bits of a Word data type variable with a binary data array (bool).
For this example, we will use a FC, and the first step is that we need to change one of its properties and deselect the checkbox Optimized block access.
Once this is done, we will declare a Date_And_Time variable and on this variable, which has a length of 8 bytes, we will use the reserved word AT to declare an Array from 0..8 to access the different bytes.
The following image shows the example.
And with the following images, we complement the declaration of our variable.
As a complement, as we have already said that we are working on a FC, in the output parameters, we will declare 8 bytes, which correspond to the decomposition of the date and time.
Here we are using this example to decompose Date and Time, but we can use it, for example, when we are working with drives and telegram words, where we need to decompose a word to know the state of the different bits...
The code is very simple, we are going to read date and time and we will pass the decomposition of the bytes of our Array to the bytes we have defined as output of our FC. Here is how it works...
April 25, 2015
If you liked it or found it useful, share it ... :-)