![]() |
![]() |
|
![]() |
||
Multiply Instruction in Ladder Logic |
MUL - MultiplyUse the MUL instruction to multiply one value (source A) by another (source B) and place the result in the destination. Source A and Source B can either be constant values or addresses that contain values, however Source A and Source B cannot both be constants. Example 1Equation: N7:51 = N7:50 * 1000 Ladder Logic SolutionSource A = N7:50 = 12345 , Source A = 1000, Destination = N7:51 = 24232(why..) ![]() Math Register: When N7:50 = 12345 this will generate a value > 32767 this will generate an overflow status bit. But we will still get a valid result in the math register. We have to make sure to clear the minor error generate before we get a major error. ![]() Example 2Equation: F8:52 = N7:52 * F8:50 (F is for floating points). Ladder Logic SolutionSource A = N7:52 = 10 , Source B = F8:50 = 1.234, Destination = F8:52 = 12.34 ![]() Notice how we mixed Integer (N) numbers with floating (F) numbers. Example 3Equation: N7:52 = F8:52 * F8:54 (12 = 1.23 * 10.0) Ladder Logic SolutionSource A = F8:53 = 1.23, Source B = F8:54 = 10.0, Destination = N7:52=12 ![]() Notice how the value of two floats got truncated with the use of integer (N). |
|