Copy functions copy a value from a source register to destination register. Â
The source register isn’t affected by the operation.
Source | # of Bits | Destination | What Happens |
---|---|---|---|
= | Data is copied. | ||
< | Source is copied into lower bits. Upper bits are typically left in their previous state. Verify with PLC manual. | ||
> | Lower bits of source are copied into destination. |
Pack functions copy bits from specific locations into an integer.
Why: It may be more convenient to store a set of On Off values inside an integer, instead of keeping track of individual bits, or perhaps you need the in integer form to export them serially.
Example: Â Pack Bit_A into the 3’rd bit of Integer_B
Unpack functions copy an integer’s individual bits into specific bit registers.
Why: An integer may represent many On Off values and now you need to break them out
Example: Unpack the 3’rd bit of Integer_B into Bit_A
                               Â
I’ve only seen the Pack and Unpack functions/terms with the Click PLC so it might be a little too specific for an intro.
A good subject might be Copy versus Move (in AB). Copy makes an exact image of the source bit pattern into the target without regard to storage type type, Move takes the numeric value as represented in the source and reproduces it as closely as possible in the target with regard to different types.
I really like the concept of Pack & Unpack. What I’m hoping comes across here is that integers don’t have to represent a single number, they can also be used as a collection of bits.
The Copy vs Move for AB is a good point.