Considerations for Nonintrinsic Math Functions
PLC Coder™ encounters a math function that is not intrinsic, it generates Structured
Text by replacing the non-intrinsic function with an equivalent IEC-61131 compatible
intrinsic function. For such cases, an input value that is larger than the allowed input
range, causes overflow and generates a
For example, hyperbolic tan is not an intrinsic function. Simulink PLC Coder uses exp in the generated code to represent tanh. More specifically, it uses (exp(2*x)-1)/(exp(2*x)+1). For large values of x, this function overflows. The issue can be addressed by adding validation code or using blocks before calling the tanh function to check that the range of the input is within acceptable values. In MATLAB®, tanh(x) for x>19 is 1.0000. So if x>19, return a value of 1.0000.