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:
  1. In the
    Controller Tags
    folder of the controller project that produces the array, create these tags.
    P
    Tag Name
    Type
    array_ack
    DINT[2]
    X
    array_packet
    DINT[125]
  2. Convert the array_ack tag to a consumed tag.
    For
    Specify
    Controller
    Name of the controller that is receiving the packet.
    Remote Tag Name
    array_ack
    Both controllers use the same name for this data.
  3. In either the
    Controller Tags
    folder or the tags folder of the program that contains the logic for the transfer, create these tags.
    Tag Name
    Type
    array
    DINT[x] where x equals the number of elements to transfer plus 122 elements
    array_offset
    DINT
    array_size
    DINT
    array_transfer_time
    DINT
    array_transfer_time_max
    DINT
    array_transfer_timer
    TIMER
  4. 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.
  5. 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.
    L5K_PM011_ProduceArrayExample1_v32
    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]).
    L5K_PM011_ProduceArrayExample2_v32
    L5K_PM011_ProduceArrayExample3_v32
    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.
    L5K_PM011_ProduceArrayExample4_v32
  6. In the
    Controller Tags
    folder of the controller project that consumes the array, create these tags.
    P
    Tag Name
    Type
    X
    array_ack
    DINT[2]
    array_packet
    DINT[125]
  7. Convert the array_packet tag to a consumed tag.
    For
    Specify
    Controller
    Name of the controller that is sending the packet.
    Remote tag name
    array_packet
    Both controllers use the same name for this data.
  8. In either the
    Controller Tags
    folder or the tags folder of the program that will contain the logic for the transfer, create these tags.
    Tag Name
    Type
    array
    DINT[x] where x equals the number of elements to transfer plus 122 elements
    array_offset
    DINT
  9. Create or open a routine for the logic that moves the data from the packets to the destination array.
  10. 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.
      L5K_PM011_ProduceArrayExample5_v32
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal