Pulse Multiplier (PMUL)
This information applies to the
CompactLogix
5370, ControlLogix
5570, Compact GuardLogix
5370, GuardLogix
5570, CompactLogix
5380, CompactLogix
5480, and ControlLogix
5580 controllers.The PMUL instruction provides an interface from a position input module, such as a resolver or encoder feedback module, to the digital system by computing the change in input from one scan to the next. By selecting a specific word size, you configure the PMUL instruction to differentiate through the rollover boundary in a continuous and linear fashion.
Available Languages
Ladder Diagram
This instruction is not available in ladder diagram.
Function Block
Structured Text
PMUL(PMUL_tag);
Operands
Function Block
Operand | Type | Format | Description |
---|---|---|---|
PMUL tag | PULSE_MULTIPLIER | Structure | PMUL structure |
Structured Text
Operand | Type | Format | Description |
---|---|---|---|
PMUL tag | PULSE_MULTIPLIER | Structure | PMUL structure |
See Structured Text Syntax for more information on the syntax of expressions within structured text.
PULSE_MULTIPLIER Structure
Input Parameter | Data Type | Description |
---|---|---|
EnableIn | BOOL | Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set. |
In | DINT | The analog input signal to the instruction.
Valid = any DINT
Default = 0 |
Initialize | BOOL | The initialize input. When set, Out is held at 0.0 and all the internal registers are set to 0. On a set to cleared transition of initialize, In n-1 = InitialValue (not valid for Absolute mode). When cleared, the instruction executes normally. |
InitialValue | DINT | The initial value input. On a set to cleared transition of initialize, In n-1 = InitialValue Valid= any DINT Default = 0. |
Mode | BOOL | The mode input. Set to enable Relative mode. Clear to enable Absolute mode.
Default is set. |
WordSize | DINT | The word size in bits. Specify the number of bits to use when computing (In n -Inn-1 ) in Relative mode.WordSize is not used in Absolute mode. When the change in In is greater than 1/2 * 2 (Wordsize-1) , Out changes sign.When WordSize is invalid,Out is held and the instruction sets the appropriate bit in Status. Valid = 2 to 32 Default = 14 |
Multiplier | DINT | The multiplier. Divide this value by 100,000 to control the ratio of In to Out. If invalid, the instruction limits the value and sets the appropriate bit in Status.
Valid = -1,000,000 to 1,000,000
Default = 100,000 |
Output Parameter | Data Type | Description |
---|---|---|
EnableOut | BOOL | Enable output. |
Out | REAL | The instruction’s Out. If the Out calculation overflows, Out is forced to + /- and the appropriate bit in Status is set. Math status flags are set for this output. |
Status | DINT | Status of the function block. |
InstructFault (Status.0) | BOOL | The instruction detected one of the following execution errors. This is not a minor or major controller error. Check the remaining status bits to determine what occurred. |
WordSizeInv (Status.1) | BOOL | Invalid WordSize value. |
OutOverflow (Status.2) | BOOL | The internal output calculation overflowed. |
LostPrecision (Status.3) | BOOL | Out < -2 24 or Out > 224 . When the instruction converts Out from an integer to a real value, data is lost if the result is greater than |224 | because the REAL data type is limited to 224 . |
MultiplierInv (Status.4) | BOOL | Invalid Multiplier value. |
Description
The PMUL instruction operates in Relative or Absolute mode.
In Relative mode, the instruction’s output is the differentiation of the input from scan to scan, multiplied by the (Multiplier/100,000). In Relative mode, the instruction saves any remainder after the divide operation in a scan and adds it back in during the next scan. In this manner, position information is not lost over the course of the operation.
In the Absolute mode, the instruction can scale an input, such as position, without losing any information from one scan to the next.
Calculating the Output and Remainder
The PMUL instruction uses these equations to calculate Out in either relative or absolute mode:
Ans = ((DiffInput x Multiplier) + INT_Remainder)
INT_Out = Ans / 100,000
INT_Remainder= Ans - (INT_Out * 100,000)
Out = INT_Out
Affects Math Status Flags
No
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand-related faults.
Execution
Function Block
Condition | Function Block Action |
---|---|
Prescan | EnableIn and EnableOut bits are cleared to false. |
Tag.EnableIn is false | EnableIn and EnableOut bits are cleared to false. |
Tag.EnableIn is true | EnableIn and EnableOut bits are set to true. The instruction executes. |
Instruction first run | N/A |
Instruction first scan | In n-1 = In. Outn-1 =0. Reminder = 0. |
Postscan | EnableIn and EnableOut bits are cleared to false. |
Structured Text
Condition/State | Action Taken |
---|---|
Prescan | See Prescan in the Function Block table. |
Normal Execution | See Tag.EnableIn is true in the Function Block table. |
Postscan | See Postscan in the Function Block table. |
Examples
Example 1
The most common use of the PMUL instruction is in the relative mode of operation. In this mode, the PMUL instruction serves several purposes. First, in the relative mode, the PMUL instruction differentiates the information that it receives at its input from scan to scan. As data is received, the instruction outputs the difference of the input from one scan to the next. This means that if In = 500 at scan "n", and then In = 600 at scan "n+1", Out = 100 at scan "n+1."
Secondly, while in this mode of operation, the PMUL instruction also compensates for "rollover" values of binary data originating from a feedback module. For example, a resolver feedback module may have 12 bits of resolution, represented as a binary value, with sign, ranging from -2048 to 2047. In terms of raw data coming from the feedback module, the rotation of the feedback device might be represented as shown below:
In this example, as the value of the feedback data moves from 2047 to -2048, the effective change in position is equivalent to a jump of 4095 counts in position. In reality, however, this change in position is only 1 part in 4096 in terms of the rotation of the resolver feedback device. By understanding the true word size of the data that is being input from the feedback module, the PMUL instruction views the data in a rotary fashion as shown in the following diagram:
By knowing the word size of the data that is input to this block, the PMUL instruction differentiates an output of 1 count as the input to the block moves from 2047 to -2048, instead of the mathematically calculated 4095.
TIP:
When applying this block, it is important to note that the feedback data should not change by more than one-half of the word size from one scan to the next, if rotational direction is to be properly differentiated.
In the example above, if the feedback device is moving in a clockwise direction such that at scan 'A' it reads 0 and then scan 'B' it reads -2000, actual change in position is equivalent to +2096 counts in the clockwise direction. However, since these two values are more than one half the words size, (or more than one half the rotation of the physical device,) the PMUL instruction calculates that the feedback device rotated in the opposite direction and returns a value of -2000 instead of +2096.
The third attribute of the pulse multiplier block is that it retains the fractional components from one scan to the next of any remainders that exist as a result of the Multiplier/100,000 scaling factor. As each execution of the block is completed, the remainder from the previous scan is added back into the total of the current value so that all counts or "pulses" are ultimately accounted for and no data is lost in the system. The output of the block, Out always yields a whole number in a floating point data type.
Function Block
Assuming Initial_Position = 0 and Multiplier = 2500 => (25,000/100,000)
Scan | Position_Feedback | PMUL_02.Out | Total_Position |
---|---|---|---|
n | 0 | 0 | 0 |
n + 1 | 1 | 0 | 0 |
n + 2 | 2 | 0 | 0 |
n + 3 | 3 | 0 | 0 |
n + 4 | 4 | 1 | 1 |
n + 5 | 5 | 0 | 1 |
Structured Text
MUL_02.In := Position_feedback;
PMUL_02.Initalize := Initialize_Position;
PMUL_02.WordSize := 12;
PMUL_02.Multiplier := 25000;
PMUL(PMUL_02);
UPDN_02.Initialize := Initialize_Position;
UPDN_02.InPlus := PMUL_02.Out;
UPDN(UPDN_02);
Total_Position := UPDN_02.Out;
Example 2
In this electronic line shaft application, motor A’s feedback acts as a master reference which motor B needs to follow. Motor A’s feedback is aliased to "Position_feedback." Motor B’s feedback is aliased to "Follower_Position." Due to the multipliers of both instructions being a ratio of 1/4, motor B needs to rotate once for every four revolutions of Motor A in order to maintain an accumulated value of zero in the UPDN accumulator. Any value other than zero on the output of the UPDN instruction is viewed as Position_error and can be regulated and driven back out to motor B in order to maintain a phase-lock between the two motors.
Function Block
Structured Text
PMUL_02.In := Position_feedback;
PMUL_02.Initalize := Initialize_Position;
PMUL_02.WordSize := 12;
PMUL_02.Multiplier := 25000;
PMUL(PMUL_02);
PMUL_03.In := Follower_Position;
PMUL_03.Initalize := Initialize_Position;
PMUL_03.WordSize := 12;
PMUL_03.Multiplier := 100000;
PMUL(PMUL_03);
UPDN_02.Initialize := Initialize_Position;
UPDN_02.InPlus := PMUL_02.Out;
UPDN_02.InMinus := PMUL_03.Out;
UPDN(UPDN_02);
Position_error := UPDN_02.Out;
Provide Feedback