The Programmable Limit Switch (PLS) feature in the ACR9xxx and IPA products is useful for assigning predefined output values relative to a selected source parameter. For example, one common use is to generate digital output patterns based on incoming encoder positions. Up to 8 different PLS objects can be defined and employed.
A local array of values is defined in your program and as the source parameter increments or decrements these array values are moved to the destination parameter. Simply put, the source parameter is the array index.
The basic PLS configuration settings are:
PLSx SRC nnnnnn This command defines what the PLSx source parameter will be. It controls when the destination parameter will be updated. The source parameter effectively becomes the array index.
PLSx DST nnnnnn This command defines what the PLSx destination will be. The values defined in the local array will be written to this destination parameter as the source indexes through the array.
PLSx BASE nnnnn This command points to the local array of “output valuesâ€.
PLSx MASK nnnn This command allows you to mask bits in the destination parameter so that only select bits are affected by the “output values†if desired. This is most useful if updating digital outputs so that only those outputs you want to be controlled by the PLSx are affected and others can be used elsewhere in your program.
PLSx ON This command enables PLSx.
PLSx OFF This command disables PLSx.
While the examples included below use a position register parameter for the SRC and digital output parameter for the DST the PLS is not restricted to these. Any valid parameter can be used for the source or destination
Here is a simple example:
DIM LA(1) REM dimension 1 local array in the program
DIM LA0(11) REM dimension LA0 with 11 elements
LA0(0) = 1 REM define the desired output values in each array element
LA0(1) = 0
LA0(2) = 0
LA0(3) = 8
LA0(4) = 0
LA0(5) = 0
LA0(6) = 0
LA0(7) = 0
LA0(8) = 0
LA0(9) = 7
LA0(10) = 0
PLS0 SRC P12297 REM define the PLS0 source as the AXIS0 jog offset parameter (P12297)
PLS0 DST P4097 REM define the PLS0 destination as the onboard digital outputs (P4097)
PLS0 BASE LA0 REM point to local array 0 (LA0) for the PLS0 output values
PLS0 MASK 15 REM mask off the first 4 output bits so the other bits in P4097 are unaffected
PLS0 ON REM enable PLS0
DIM LA0(11) REM dimension LA0 with 11 elements
LA0(0) = 1 REM define the desired output values in each array element
LA0(1) = 0
LA0(2) = 0
LA0(3) = 8
LA0(4) = 0
LA0(5) = 0
LA0(6) = 0
LA0(7) = 0
LA0(8) = 0
LA0(9) = 7
LA0(10) = 0
PLS0 SRC P12297 REM define the PLS0 source as the AXIS0 jog offset parameter (P12297)
PLS0 DST P4097 REM define the PLS0 destination as the onboard digital outputs (P4097)
PLS0 BASE LA0 REM point to local array 0 (LA0) for the PLS0 output values
PLS0 MASK 15 REM mask off the first 4 output bits so the other bits in P4097 are unaffected
PLS0 ON REM enable PLS0
This chart shows how the output bits will be updated based on the value in P12297.
AXIS0 JOG OFFSET POSITION
|
Output Bits 35, 34, 33, 32 (in P4097)
|
P12297 = 0
|
0001
|
P12297 = 1
|
0000
|
P12297 = 2
|
0000
|
P12297 = 3
|
1000
|
P12297 = 4
|
0000
|
P12297 = 5
|
0000
|
P12297 = 6
|
0000
|
P12297 = 7
|
0000
|
P12297 = 8
|
0000
|
P12297 = 9
|
0111
|
P12297 = 10
|
0000
|
P12297 = 11
|
0000 - Outside of array index boundary so a value of 0 is automatically applied.
|
Note that no other bits in P4097 will be affected due to the MASK value chosen. Only those bits with a MASK value of 1 will be affected by the PLS updates.
This previous example is not be very useful unless AXIS0 is going to travel very, very short lengths. For a second example, let us assume AXIS0 is going to travel through multiple revolutions and each revolution equals 4000 counts.
One option would be to create an array 4000 elements in size. If we want specific output patterns for every distinct count AXIS0 moves then that is what you would do, limited only by the amount of memory you have dimensioned for the program space.
However, its more common that we want an output pattern to come on at a few specific points through the travel. Some additional PLS commands provide ways to achieve this without having to create a very large array.
PLSx RATIO nnnnn This command is a multiplier for the for the PLSx source. The result is then used as the array index. This defaults to a value of 1 and so you have the example above. A value > 1 will increment/decrement through the array table more rapdily. A value < 1 will increment/decrement through the array table more slowly.
PLSx FLZ nnnnn This command is an offset value that is added to the result of the PLSx SRC after the PLSx RATIO has been applied. It allows you to jump to a specific point in the array table.
PLSx ROTARY nnnnn This command allows the PLSx to wrap around the array and repeat the patterns rather than simply exceed the array boundary as shown in the basic sample above. The PLSx ROTARY value defines the length you will go into the array table before it wraps around to the beginning. This value defaults to 0 which means the wrap around is disabled.
PLSx RES nnnnn This command only applies if the PLSx ROTARY feature is non-zero. It allows you to reset or preset the location in the array you are at via the rotary feature. This is most commonly used to re-start the rotary feature at the beginning of the index table.
This second example will have output patterns turn on every 90 degrees of travel of AXIS0 and assumes AXIS0 has 4000 counts per revolution and will be starting at zero.
DIM LA(1) REM dimension 1 local array in the program
DIM LA0(4) REM dimension LA0 with 4 elements
LA0(0) = 1 REM define the desired output values in each array element
LA0(1) = 2
LA0(2) = 4
LA0(3) = 8
PLS0 SRC P12297 REM define the PLS0 source as the AXIS0 jog offset parameter (P12297)
PLS0 DST P4097 REM define the PLS0 destination as the onboard digital outputs (P4097)
PLS0 BASE LA0 REM point to local array 0 (LA0) for the PLS0 output values
PLS0 MASK 15 REM mask off the first 4 output bits so the other bits in P4097 are unaffected
PLS0 RATIO 0.001 REM defines the multiplier as 1/1000
PLS0 ROTARY 4000 REM defines the roll over point as 4000
PLS0 ON REM enables PLS0
DIM LA0(4) REM dimension LA0 with 4 elements
LA0(0) = 1 REM define the desired output values in each array element
LA0(1) = 2
LA0(2) = 4
LA0(3) = 8
PLS0 SRC P12297 REM define the PLS0 source as the AXIS0 jog offset parameter (P12297)
PLS0 DST P4097 REM define the PLS0 destination as the onboard digital outputs (P4097)
PLS0 BASE LA0 REM point to local array 0 (LA0) for the PLS0 output values
PLS0 MASK 15 REM mask off the first 4 output bits so the other bits in P4097 are unaffected
PLS0 RATIO 0.001 REM defines the multiplier as 1/1000
PLS0 ROTARY 4000 REM defines the roll over point as 4000
PLS0 ON REM enables PLS0
This chart shows how the output bits affected will be updated based on the value in P12297
AXIS0 JOG OFFSET POSITION
|
Array Index Math
|
Output Bits 35, 34, 33, 32 (in P4097)
|
P12297 = 0
|
0 * 0.001 = 0
|
0001
|
P12297 = 1000
|
1000 * 0.001 = 1
|
0010
|
P12297 = 2000
|
2000 * 0.001 = 2
|
0100
|
P12297 = 3000
|
3000 * 0.001 = 3
|
1000
|
P12297 = 4000
|
0 * 0.001 = 0
|
0001
|
P12297 = 5000
|
1000 * 0.001 = 1
|
0010
|
P12297 = 6000
|
2000 * 0.001 = 2
|
0100
|
P12297 = 7000
|
3000 * 0.001 = 3
|
1000
|
P12297 = 8000
|
0 * 0.001 = 0
|
0001
|
P12297 = 9000
|
1000 * 0.001 = 1
|
0010
|
P12297 = 10000
|
2000 * 0.001 = 2
|
0100
|
Continues
|
|
Continues
|
You can see that once P12297 reaches 4000 the rotary length has been reached and a modulo operation is done on it before the multiplier is applied and we have started back at the beginning of the array table. This occurs again at P12297=8000 and will again at P12297 = 12000 if AXIS0 continues in that same direction.
This example clearly uses easy round numbers for the destination update points. You may need to adjust the number of elements in your array so that the math works out as you require for the array index points relative to the source parameter. The result of the SRC * RATIO + FLZ will always be evaluated as an integer when applied to the array table as an index, no rounding, simple truncation.