Computing complex equations
The term complex is subjective, to say the least. For this book, a complex question will refer to a calculation that requires a mixture of the four basic mathematical operations, as well as a complex math function that was previously explored. The first equation that we’re going to program is commonly used in automation programming – that is, calculating the distance between two points.
Distance between two points
Calculating the distance between two points is a very common task in PLC programming. It is often necessary to know how long to power motors and so on to ensure the machine reaches its new destination. To figure out the distance, it is common to use the following equation:
In this equation, we will need to subtract two sets of numbers, square two numbers, sum them, and finally take the square root of that sum. As such, we will need to use the EXPT
function and the SQRT
function.
There are two ways that this equation...