![]() |
![]() |
|
Subtract Instruction in Ladder Logic |
Sponsored by: KronoTour Travel
|
SUB - SubtractWhen rung conditions are true, the SUB output instruction subtracts Source B from Source A and stores the result in the destination. Source A and Source B can either be values or addresses that contain values, however Source A and Source B cannot both be constants. Example 1Equation: N7:10 = N7:10 - 5 Ladder Logic SolutionSource A = n7:10 = 23276, Source B = 5, Destination = N7:10 = 23271.
Example 2Equation: N7:13 = N7:11 - N7:12 Ladder Logic SolutionSource A = N7:11 = 32700, Source B = N7:12 = 69 , Destination = 32767 (why..). The result is invalid since the maximum negative value in a register is -32768, therfore the result is invalid and the overflow bit is on.
Clearing minor error that might be generated if we have an underflow. Note
|
Sponsored by: KronoTour Travel
|
|||||||||||||||||||||||