Productivity 1000 Series PLC Array Functions Part 3

An array is a storage area for a group of common data type tags. They usually have some relationship to each other and need to be manipulated as a group.

Previously we defined an array and use this in an indirect addressing program. It sequenced bits in an output card indirectly. We then looked at the following instructions: Array Statistics (STA), Copy Array (CPA), Fill Array (FLA) and Shift / Rotate Array (SRA). We will now look at the final four array instructions:
Pack Boolean Array (PBA) – Pack an Array of Boolean tags into a destination Word Array
Pack Word Array (PWA) – Convert one 8 bit or 16 bit array into a 16 or 32 bit Destination Array tag.
UnPack Boolean Array (UPBA) – Unpack an Array of Word tags into a destination Boolean Array.
UnPack Word Array (UPWA) – Convert one 32 or 16 bit array source tag into four 8 or 16 bit array tags.
Let’s get started with our final look at arrays in our Productivity 1000 Series PLC.

Previously in this Productivity 1000 series PLC we have discussed:
System HardwareVideo
Installing the SoftwareVideo
Establishing CommunicationVideo
First ProgramVideo
Documenting the ProgramVideo
Monitoring and Testing the ProgramVideo
Online Editing and Debug ModeVideo
Numbering Systems and Tag DatabaseVideo
Contact and Coil InstructionsVideo
Timer InstructionsVideo
Counter InstructionsVideo
Math InstructionsVideo
Data Handling Instructions Part 1Video
Data Handling Instructions Part 2Video
Array Functions Part 1Video
Array Functions Part 2Video

The following instructions will demonstrate the ability to manipulate the arrays from one form to another.
We will start by creating three different arrays. This is done with the Tag Database that we have discussed previously.
Boolean Array

Name: Boolean_Array – Boolean, 1D Array – Columns 64

We can then populate some information in the array by selecting some bits to be on for the initial state.
Word 8 Bit Array

Name: Word_8Bit – Integer, 8 Bit Unsigned, 1D Array – Columns 10
Word 16 Bit Array

Name: Word_16Bit – Integer, 16 Bit Unsigned, 1D Array – Columns 5

Pack Boolean Array (PBA)
This instruction will Pack an Array of Boolean tags into a destination Word Array.

The above example shows 16 bits being packed into two 8 bit arrays.

We will use structure with this instruction. (Pack_Bit_Array) If we did not use structure then you will need to specify all of the parameters for the instruction.

We will use the Array called Boolean_Array for our source and Word_8Bit for our destination array.

The structure tags will define how the instruction will work. Our source start and end columns will be 1 to 32. The destination start column will be 1. Remember that the array instruction will always start at 1 for the first element.
Hit OK

When Switch 6 is on the first 32 bits of the Boolean Array will be moved into the Word 8 Bit Array. This will then populate the first 4 words. (8 bits x 4 words = 32 bits)

Pack Word Array (PWA)
This instruction will Convert one 8 bit or 16 bit array into a 16 or 32 bit Destination Array tag.

The above example shows eight 8 bit words being packed into two 32 bit words.

We will use the structure named Pack_Word_Array.

Our example will move 8 bit words to 16 bit words. The source array will be our Word_8Bit and the destination will be Word_16Bit array. Hit OK.

The tags of the instruction will be defined as follows:
Source Start Column = 1
Source End Column = 4
Destination Start Column = 1

Switch 7 will active the pack word instruction. It will move the first four 8 bit words from the source array to the first two 16 bit works in the destination array.

UnPack Boolean Array (UPBA)
This instruction will Unpack an Array of Word tags into a destination Boolean Array.

The above example takes two 8 bit words and moves them into 16 bits of the destination Boolean array.

We will use a structure named UnPack_Boolean.

The source array will be Word_8Bit and the Boolean_Array will be our destination.

Source start column will be 1 and the end column will be 2. The destination start column will be 16.

When switch 8 is on the UnPack Boolean Array instruction runs and will take the first two 8 bit words and move them to the destination Boolean array starting at bit 16.

UnPack Word Array (UPWA)
This instruction will Convert one 32 or 16 bit array source tag into four 8 or 16 bit array tags.

The above example moves two 32 bit array words to eight 8 bit array words. We specify the start and end column in the source array and the start column in the destination array.

We will name the structure UnPack_Word.

Select the Word (16-bit) to Byte (8-bit). Our source array is Word_16Bit and the destination array is Word_8Bit. Hit OK.

Our source start and end initial values will be 1 and 2. The destination initial value will be 3.

When Switch 1 is energized the first two 16 bit words in the source array will be placed into four 8 bit words (byte) in the destination. The destination will be the third location.

Download the PLC program here.

Watch the video below to see the array instructions that we created in action running on our Productivity 1000 Series PLC.

Productivity 1000 Series PLC form Automation Direct
Overview Link (Additional Information on the Unit)
Configuration (Configure and purchase a system – BOM)
User Manual and Inserts (Installation and Setup Guides)
Productivity Suite Programming Software (Free Download Link)
This software contains all of the instruction sets and help files for the Productivity Series.

Next time we will look at program control in the Productivity 1000 Series PLC.

Watch on YouTube : Productivity 1000 Series PLC Array Functions Part 3
If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.




Leave a Reply

Your email address will not be published. Required fields are marked *