This article explains how to handle different data types in the Anybus input/output arrays in Logix/Studio 5000 when the data types are different from the data type within the array. For example, the default is an array of SINT but you may wish to transfer REAL, DINT, BOOL or a combination of these types.
APPLICABLE PRODUCTS
Anybus units with an EtherNet/IP adapter interface
QUESTION
How do I get the correct data type(s) in Logix to match the Anybus unit?
ANSWER
When you add your Anybus unit to Logix/Studio 5000, it adds an input array and an output array. These arrays are of the SINT data type. The data being transferred often contains different types in which case changing the type in the array is arbitrary.
While there are different data types in your Anybus configuration, internally, the Anybus is transferring bits of data to and from the PLC without any regard for the data type. Because of this, you must tell the PLC how to interpret the data as it is on the other side of the Anybus gateway. To do this, you can use the COP instruction to move between the input/output array and a tag with your desired data type.
Example using a REAL number:
From Anybus to PLC
For this example, we are using the default SINT data type for the Anybus array. Our first data point is a REAL data type. Since a REAL is 32 bits, it will occupy 4 SINTs of the input array (8 bits x 4) which means this number is stored from index numbers 0 to 3. The values displayed here won't make sense but they will after the conversion. At the very least, you can see that the data is coming through.
To interpret the data correctly, you can use the COP (Copy) instruction. Unlike a MOV (Move) instruction, COP doesn't regard the data type. It simply copies the data bits the same way the Anybus does.
In the example below, the COP instructions starts with index 0 of the Anybus input array (the starting index for our REAL) and is copying the data into a new tag called "Temperature" with the REAL type. The last parameter in the instruction specifies the length of the destination so, in this case "Temperature" is 1 REAL, though it will take 4 SINTs to fill it completely.
The new tag has the same bit field from the array but, because it has the REAL type, it is now interpreted correctly. This is the tag that is used in the program logic.
From PLC to Anybus
To send data to the Anybus, you can use the COP instruction similar to the previous example. In this example, there is a tag in the PLC program called "Setpoint".
Using the COP instruction, "Setpoint" is being copied to the Anybus output array. It starts at index 0, making this data point first in the output array. The last parameter of 4 specifies that the output array is having 4 SINTs overwritten which is the equivalent length of the REAL being copied from.
The data from "Setpoint" occupies the first 4 SINTs of the Anybus output array. The values don't make sense as they are displayed but it is the same bit field coming from the REAL number tag and it can be interpreted properly from the other side of the Anybus gateway.