Use SCL Exponential and Logarithmic Functions in PCS 7
For calculations with many REAL inputs and a smaller number of REAL outputs, implement the calculation as a reusable SCL function block and expose only the required values through its interface. The Siemens S7-SCL V5.3 manual documents exponential and logarithmic standard functions, including EXP, EXPD, LN and LOG. Confirm that this SCL/compiler version is supported by the project's STEP 7 and PCS 7 versions before deploying the block.
Table of Contents
- Why use an SCL function block
- Documented exponential and logarithmic functions
- Implementation workflow
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
Why use an SCL function block
A function block provides a defined interface for multiple input and output values while keeping the calculation in one maintainable implementation. This is a practical fit when a calculation combines many values and mathematical operations; the ticket does not identify a specific PCS 7 release, CPU family or compiler version, so compatibility must be checked against the installed engineering environment.
Documented exponential and logarithmic functions
The Siemens S7-SCL V5.3 manual, Chapter 14.2, documents EXP for e raised to the input, EXPD for 10 raised to the input, LN for the natural logarithm and LOG for the common logarithm. The manual accepts ANY_NUM inputs such as INT, DINT and REAL, converting the input internally to REAL; the returned value is REAL. Use LN or LOG only for positive arguments because logarithms are undefined at zero and for negative real arguments. Confirm numeric range and result handling for the target CPU and application.
Implementation workflow
- Define the calculation's required inputs and outputs in the SCL block interface, using the project's established data types and naming conventions.
- Implement the calculation in small, named intermediate steps. Select
EXP,EXPD,LNorLOGaccording to the mathematical definition and base required. - Check input domains before logarithms and define how the block should signal invalid or out-of-range input; do not silently assume the requested process values are valid.
- Compile the block for the target CPU with the installed SCL toolchain, resolve compiler diagnostics, and integrate the resulting block into the PCS 7 project using the project's supported workflow.
- Test representative nominal, boundary and invalid-input cases offline or in an approved test environment before using the result in control logic.
Verification
Compare calculated outputs against independently calculated reference values, including values near logarithm domain limits and exponential range limits. Verify the block's behavior for invalid inputs and confirm the compiled block and call interface match the intended CPU and project versions. A successful compile alone does not establish that the engineering formula is correct.
Limitations and Operational Precautions
The S7-SCL manual cited here is V5.3 and does not establish compatibility with an unspecified PCS 7 release, compiler installation or CPU. Numeric range, overflow behavior and any safety classification must be confirmed in documentation applicable to the target. Do not download a changed control block to a live process without the site's review, backup, test and change-control procedures.
Engineer FAQ
Can one SCL block accept many REAL values and return only a few results? Yes. Define the needed input and output parameters in the block interface, then implement the calculation internally. Select a function block or function according to whether the calculation needs retained state.
What is the difference between EXP and EXPD in the cited S7-SCL manual? EXP calculates e raised to the input. EXPD calculates 10 raised to the input. Both return REAL values in the cited manual.
Which SCL function calculates a natural logarithm? LN calculates the natural logarithm. Its real-valued argument must be positive.
Which SCL function calculates a base-10 logarithm? LOG calculates the common, base-10 logarithm in the cited S7-SCL V5.3 manual. Check the applicable manual for the installed compiler.
Can an INT value be passed to these numeric functions? The cited manual defines the inputs as ANY_NUM and lists INT, DINT and REAL as supported numeric types, with conversion to REAL.
Why should a logarithm input be checked before calling LN or LOG? A real logarithm is defined only for positive arguments. The block should handle zero or negative values explicitly according to the application's requirements.
Should I use a single expression for a large calculation? Named intermediate variables can make the formula easier to review and compare with the engineering specification. Keep the mathematical definition traceable.
Does the S7-SCL V5.3 manual prove support in every PCS 7 version? No. It documents functions in that SCL edition. Confirm the compiler, STEP 7 and PCS 7 versions and target CPU used by the specific project.
How should the block be tested before process use? Compare its outputs with independent reference calculations for representative nominal, boundary and invalid-input cases, then review behavior in the approved test environment.
Does compiling the block prove the process calculation is correct? No. Compilation checks language and target constraints; engineering review must still verify the formula, units, ranges and handling of invalid values.