Data handling instructions are used to perform movement and manipulations of the memory in the programmable logic controller. The Productivity 1000 Series PLC has fifteen different data handling instructions that can be used in a wide variety of applications. In this second part we will be looking at the following instructions:
Lookup Table (LKUP) – Find a value within an XY Table by looking at the intercept of a referenced X Axis value and Y Axis value.
Pack Bits (PKB) – Convert up to 32 Boolean Tag Bits or Constant Bits into an Output Integer Tag.
Pack Word (PKW) – Convert up to four 8 bit tags or two 16 bit tags, or four Constants into a 16 or 32 bit Destination Tag.
Shift / Rotate Bits (SFR) – Shift or Rotate Bits of a Tag or Constant value.
Sign Magnitude (SMAG) – Convert Sign Plus Magnitude data type values to 2’s Complement or Convert 2’s Complement data type values to Sign Plus Magnitude.
UnPack Bits (UPKB) – Convert up to a 32 Bit Integer Tag or Constant into Boolean Tags.
UnPack Word (UPKW) – Convert one 32 bit or 16 bit source tag into four 8 bit tags or two 16 bit tags.
A review of data handling instructions part 1 can be found here. Here is a link to the video.
Let’s get started with the Productivity 1000 Series PLC data handling instructions part 2.
Previously in this Productivity 1000 series PLC we have discussed:
System Hardware – Video
Installing the Software – Video
Establishing Communication – Video
First Program – Video
Documenting the Program – Video
Monitoring and Testing the Program – Video
Online Editing and Debug Mode – Video
Numbering Systems and Tag Database – Video
Contact and Coil Instructions – Video
Timer Instructions – Video
Counter Instructions – Video
Math Instructions – Video
Data Handling Instructions Part 1 – Video
Lookup Table (LKUP)
This instruction will find a value within an XY Table. It will look at the intercept of a referenced X Axis value and Y Axis value.
We will use a structure named Lookup_Table. This will set up our inputs XKey, YKey and our output Output.
Then number of X references will be 5 and the number of Y references will be 10. This will give us a grid shown above. We now enter the data in the table.
We can now define the tags for Lookup_Table. Make XKey and YKey retentive with an initial value of 60 each.
When Switch1 is on the look up table instruction will take the XKey and YKey inputs and send the corresponding value based on the table specified to the Output.
Pack Bits (PKB)
This instruction will convert up to 32 Boolean Tag Bits or Constant Bits into an Output Integer Tag.
We will specify tag Pack_Bits_Out. Using the eight switches on our input card we will send the value to the Pack_Bits_Out tag.
When Switch2 is on the first eight switches will be converted into the Pack_Bits_Out flag.
Pack Word (PKW)
This instruction will convert up to four 8 bit tags or two 16 bit tags, or four Constants into a 16 or 32 bit Destination Tag.
We will use the structure name Pack_Word and specify Byte (8-bit) to Word (16-bit)
We will set Position 1 and 2 as retentive with the initial values of 12 and 34 respectfully.
When Switch3 turns on the fist 8 bits of Position 1 will be the least significant byte. The first 8 bits of Position 2 will be the most significant byte of the output.
Shift / Rotate Bits (SFR)
This instruction will Shift or Rotate Bits of a Tag or Constant value.
We will call the structure Shift_Rotate. Select Rotate Left, Include Sign Bit and One Shot.
Set the Input and Number to Shift/Rotate to retentive with the initial value of 1 each.
When Switch4 transitions from off to on the output will shift by 1 left. When the lost bit of the output is shifted it will rotate back to the first bit.
We have covered Shift Registers in previous posts. Here are a couple that will show you what can be done with rotating and shifting instructions.
PLC Programming Example Sorting Station – Video – Testing Video
PLC Programming Example – Shift Register (Conveyor Reject) – Video
Sign Magnitude (SMAG)
This instruction will convert Sign Plus Magnitude data type values to 2’s Complement or Convert 2’s Complement data type values to Sign Plus Magnitude.
The following link is a good tutorial on signed binary numbering systems.
We will use the structure name Sign_Mag_Out and select Sign magnitude to 2’s Complement.
Make the Input memory retentive with an initial value of -200.
When Switch5 is turned on the output will contain the sign magnitude to 2’s complement of the Input number.
UnPack Bits (UPKB)
This instruction will convert up to a 32 Bit Integer Tag or Constant into Boolean Tags.
We will use the Pack_Bits_Out as the input to this instruction. This represents the 8 switches that we packed into the output. This instruction will do just the opposite. Our output will be Unpack_Bit:1 to 8.
When Switch6 is turned on the input number will get broken out into bits. In our case this represents the switches when we packed the input.
UnPack Word (UPKW)
This instruction will convert one 32 bit or 16 bit source tag into four 8 bit tags or two 16 bit tags.
We will name the structure UnPack_Word. Select Word (16-bit) to Byte (8-bit).
Our input (Source) will be broken out into two 8 bit bytes of data.
Make the source memory retentive and set the initial value of it to 1234.
Switch7 when turned on will unpack the source into two bytes. This happens every scan as long as Switch7 is on. (The rung is true.)
Download the PLC program here.
Watch the video below to see the data handling instructions used in 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 continue to look at the array functions in the Productivity 1000 Series PLC.
Watch on YouTube : Productivity 1000 Series PLC Data Handling Instructions Part 2
If you have any questions or need further information please contact me.
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.