Produce a large array
Transferring a large array as smaller packets improves system performance.
- Large arrays use fewer connections than breaking the data into multiple arrays and sending each as a produced tag. For example, an array with 5000 elements takes40 connections (5000/125=40) by using individual arrays.
- Large arrays achieve faster transmission times than using a message instruction to send the entire array.
- Messages are unscheduled and executed only during the system overhead portion of the Logix5550 execution. Therefore, messages can take a fairly long time to complete the data transfer.
- Improved transfer time by increasing the system overhead time slice, but this diminishes the performance of the continuous task.
To produce a large array:
- In theController Tagsfolder of the controller project that produces the array, create these tags.PTag NameTypearray_ackDINT[2]Xarray_packetDINT[125]
- Convert the array_ack tag to a consumed tag.ForSpecifyControllerName of the controller that is receiving the packet.Remote Tag Namearray_ackBoth controllers use the same name for this data.
- In either theController Tagsfolder or the tags folder of the program that contains the logic for the transfer, create these tags.Tag NameTypearrayDINT[x] where x equals the number of elements to transfer plus 122 elementsarray_offsetDINTarray_sizeDINTarray_transfer_timeDINTarray_transfer_time_maxDINTarray_transfer_timerTIMER
- In the array_size tag, enter the number of elements of real data, which is the value of x from step 3 minus the 122 elements of buffer.
- Create or open a routine for the logic that creates packets of data.Enter this logic.When the offset value in array_ack[0] is not equal to the current offset value but array_ack[1] equals -999, the consumer begins receiving a new packet, so the rung moves -999 into the last element of the packet. The consumer waits until it receives the value -999 before it copies the packet to the array. This guarantees that the consumer has new data.When the offset value in array_ack[0] is equal to the current offset value, the consumer copied the packet to the array; so the rung checks for more data to transfer. If the offset value plus 123 is less than the size of the array, there is more data to transfer; so the rung increases the offset by 123. Otherwise, there is no more data to transfer; so the rung resets the offset value, logs the transfer time, and resets the timer. In either case, the rung uses the new offset value to create a new packet of data, appends the new offset value to the packet, and clears the acknowledge element of the packet (packet[124]).If the current transfer time is greater than the maximum transfer time, update the maximum transfer time. This maintains a record of the longest time to transfer data.
- In theController Tagsfolder of the controller project that consumes the array, create these tags.PTag NameTypeXarray_ackDINT[2]array_packetDINT[125]
- Convert the array_packet tag to a consumed tag.ForSpecifyControllerName of the controller that is sending the packet.Remote tag namearray_packetBoth controllers use the same name for this data.
- In either theController Tagsfolder or the tags folder of the program that will contain the logic for the transfer, create these tags.Tag NameTypearrayDINT[x] where x equals the number of elements to transfer plus 122 elementsarray_offsetDINT
- Create or open a routine for the logic that moves the data from the packets to the destination array.
- Enter this logic.When the offset value in array_packet[123] is different than the offset value in array_ack[0], the controller begins receiving a new packet of data; so the rung checks for the value of -999 in the last element of the packet.If the last element of the packet equals -999, the controller received an entire packet of new data and begins the copy operation.
- The offset value moves from the packet to array_offset.
- The COP instructions copy the data from the packet to the destination array, starting at the offset value.
- The offset value moves to array_ack[0], which signals that the copy is complete.
- Array_ack[1] resets to zero and waits to signal the arrival of a new packet.If the last element of the packet is not equal to -999, the transfer of the packet to the controller may not be complete; so -999 moves to array_ack[1]. This signals the producer to return the value of -999 in the last element of the packet to verify the transmission of the packet.
Provide Feedback