The SUB, also known as the Subtraction, is an instruction which will perform a mathematical subtraction of two values which may be integers or floats. This instruction is used quite frequently in PLC programming and is one of the most fundamental mathematical operations. It can be used to calculate the difference between two sensor values, the deviation from a setpoint and much more. At its core, the instruction will evaluate the difference between the two values specified in “Source A” and “Source B” and store the resulting outcome in the “Dest” or the destination register.
This is a companion discussion topic for the original entry at https://www.solisplc.com/tutorials/plc-programming-computational-mathematical-instructions-sub-subtraction