EcoStruxure Machine Expert - Basic Example Guide
EIO0000003361 12/2018
                   EcoStruxure Machine
                   Expert - Basic Example
                   Guide
                   Analog Scaling with Multiple Operands
                   xSample_Analog_Scaling_Multio-
                   perand.smbe
                   12/2018
EIO0000003361.00
                   www.schneider-electric.com
    The information provided in this documentation contains general descriptions and/or technical
    characteristics of the performance of the products contained herein. This documentation is not
    intended as a substitute for and is not to be used for determining suitability or reliability of these
    products for specific user applications. It is the duty of any such user or integrator to perform the
    appropriate and complete risk analysis, evaluation and testing of the products with respect to the
    relevant specific application or use thereof. Neither Schneider Electric nor any of its affiliates or
    subsidiaries shall be responsible or liable for misuse of the information contained herein. If you
    have any suggestions for improvements or amendments or have found errors in this publication,
    please notify us.
    You agree not to reproduce, other than for your own personal, noncommercial use, all or part of
    this document on any medium whatsoever without permission of Schneider Electric, given in
    writing. You also agree not to establish any hypertext links to this document or its content.
    Schneider Electric does not grant any right or license for the personal and noncommercial use of
    the document or its content, except for a non-exclusive license to consult it on an "as is" basis, at
    your own risk. All other rights are reserved.
    All pertinent state, regional, and local safety regulations must be observed when installing and
    using this product. For reasons of safety and to help ensure compliance with documented system
    data, only the manufacturer should perform repairs to components.
    When devices are used for applications with technical safety requirements, the relevant
    instructions must be followed.
    Failure to use Schneider Electric software or approved software with our hardware products may
    result in injury, harm, or improper operating results.
    Failure to observe this information can result in injury or equipment damage.
    © 2018 Schneider Electric. All rights reserved.
2                                                                                       EIO0000003361 12/2018
         Table of Contents
                      Safety Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                  5
                      About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                 9
            Chapter 1 Example Description. . . . . . . . . . . . . . . . . . . . . . . . . . . .                                    11
                           Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .   12
                           Setup Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .        18
            Chapter 2 Project Template Description . . . . . . . . . . . . . . . . . . . . .                                        19
                           Project Template Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .               20
                           Project Template Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .             23
       Appendices           .........................................                                                               31
         Appendix A Scaling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . .                                      33
                           Scaling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .         33
EIO0000003361 12/2018                                                                                                                3
4   EIO0000003361 12/2018
         Safety Information
Important Information
NOTICE
         Read these instructions carefully, and look at the equipment to become familiar with the device
         before trying to install, operate, service, or maintain it. The following special messages may appear
         throughout this documentation or on the equipment to warn of potential hazards or to call attention
         to information that clarifies or simplifies a procedure.
EIO0000003361 12/2018                                                                                       5
PLEASE NOTE
     Electrical equipment should be installed, operated, serviced, and maintained only by qualified
     personnel. No responsibility is assumed by Schneider Electric for any consequences arising out of
     the use of this material.
     A qualified person is one who has skills and knowledge related to the construction and operation
     of electrical equipment and its installation, and has received safety training to recognize and avoid
     the hazards involved.
BEFORE YOU BEGIN
     Do not use this product on machinery lacking effective point-of-operation guarding. Lack of
     effective point-of-operation guarding on a machine can result in serious injury to the operator of
     that machine.
                                                WARNING
      UNGUARDED EQUIPMENT
         Do not use this software and related automation equipment on equipment which does not have
          point-of-operation protection.
         Do not reach into machinery during operation.
      Failure to follow these instructions can result in death, serious injury, or equipment damage.
     This automation equipment and related software is used to control a variety of industrial processes.
     The type or model of automation equipment suitable for each application will vary depending on
     factors such as the control function required, degree of protection required, production methods,
     unusual conditions, government regulations, etc. In some applications, more than one processor
     may be required, as when backup redundancy is needed.
     Only you, the user, machine builder or system integrator can be aware of all the conditions and
     factors present during setup, operation, and maintenance of the machine and, therefore, can
     determine the automation equipment and the related safeties and interlocks which can be properly
     used. When selecting automation and control equipment and related software for a particular
     application, you should refer to the applicable local and national standards and regulations. The
     National Safety Council's Accident Prevention Manual (nationally recognized in the United States
     of America) also provides much useful information.
     In some applications, such as packaging machinery, additional operator protection such as point-
     of-operation guarding must be provided. This is necessary if the operator's hands and other parts
     of the body are free to enter the pinch points or other hazardous areas and serious injury can occur.
     Software products alone cannot protect an operator from injury. For this reason the software
     cannot be substituted for or take the place of point-of-operation protection.
6                                                                                       EIO0000003361 12/2018
         Ensure that appropriate safeties and mechanical/electrical interlocks related to point-of-operation
         protection have been installed and are operational before placing the equipment into service. All
         interlocks and safeties related to point-of-operation protection must be coordinated with the related
         automation equipment and software programming.
         NOTE: Coordination of safeties and mechanical/electrical interlocks for point-of-operation
         protection is outside the scope of the Function Block Library, System User Guide, or other
         implementation referenced in this documentation.
START-UP AND TEST
         Before using electrical control and automation equipment for regular operation after installation,
         the system should be given a start-up test by qualified personnel to verify correct operation of the
         equipment. It is important that arrangements for such a check be made and that enough time is
         allowed to perform complete and satisfactory testing.
                                                    WARNING
          EQUIPMENT OPERATION HAZARD
             Verify that all installation and set up procedures have been completed.
             Before operational tests are performed, remove all blocks or other temporary holding means
              used for shipment from all component devices.
             Remove tools, meters, and debris from equipment.
          Failure to follow these instructions can result in death, serious injury, or equipment damage.
         Follow all start-up tests recommended in the equipment documentation. Store all equipment
         documentation for future references.
         Software testing must be done in both simulated and real environments.
         Verify that the completed system is free from all short circuits and temporary grounds that are not
         installed according to local regulations (according to the National Electrical Code in the U.S.A, for
         instance). If high-potential voltage testing is necessary, follow recommendations in equipment
         documentation to prevent accidental equipment damage.
         Before energizing equipment:
          Remove tools, meters, and debris from equipment.
          Close the equipment enclosure door.
          Remove all temporary grounds from incoming power lines.
          Perform all start-up tests recommended by the manufacturer.
EIO0000003361 12/2018                                                                                       7
OPERATION AND ADJUSTMENTS
     The following precautions are from the NEMA Standards Publication ICS 7.1-1995 (English
     version prevails):
      Regardless of the care exercised in the design and manufacture of equipment or in the selection
        and ratings of components, there are hazards that can be encountered if such equipment is
        improperly operated.
      It is sometimes possible to misadjust the equipment and thus produce unsatisfactory or unsafe
        operation. Always use the manufacturer’s instructions as a guide for functional adjustments.
        Personnel who have access to these adjustments should be familiar with the equipment
        manufacturer’s instructions and the machinery used with the electrical equipment.
      Only those operational adjustments actually required by the operator should be accessible to
        the operator. Access to other controls should be restricted to prevent unauthorized changes in
        operating characteristics.
8                                                                                   EIO0000003361 12/2018
         About the Book
At a Glance
Document Scope
         This document describes how to acquire analog data and scale it to other limits—in particular back
         to the original physical values—by using multiple operations in a single Operation Block.
         The example described in this document is intended for learning purposes only. It must not be used
         directly on products that are part of a machine or process.
                                                   WARNING
          UNINTENDED EQUIPMENT OPERATION
          Do not include any wiring information, programming or configuration logic, or parameter values
          from any of the examples in your machine or process without thoroughly testing your entire
          application.
          Failure to follow these instructions can result in death, serious injury, or equipment damage.
         This document and its related EcoStruxure Machine Expert - Basic project file focus on specific
         instructions and function blocks provided with EcoStruxure Machine Expert - Basic, and on specific
         features available in EcoStruxure Machine Expert - Basic. They are intended to help you
         understand how to develop, test, commission, and integrate applicative software of your own
         design in your control systems.
         The example is intended for new EcoStruxure Machine Expert - Basic users who already have
         some degree of expertise in the design and programming of control systems.
Validity Note
         This document has been updated for the release of EcoStruxureTM Machine Expert - Basic V1.0.
EIO0000003361 12/2018                                                                                      9
Product Related Information
                                                  WARNING
        LOSS OF CONTROL
           The designer of any control scheme must consider the potential failure modes of control paths
            and, for certain critical control functions, provide a means to achieve a safe state during and
            after a path failure. Examples of critical control functions are emergency stop and overtravel
            stop, power outage and restart.
           Separate or redundant control paths must be provided for critical control functions.
           System control paths may include communication links. Consideration must be given to the
            implications of unanticipated transmission delays or failures of the link.
           Observe all accident prevention regulations and local safety guidelines.1
           Each implementation of this equipment must be individually and thoroughly tested for proper
            operation before being placed into service.
        Failure to follow these instructions can result in death, serious injury, or equipment damage.
       1For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety Guidelines for the
       Application, Installation, and Maintenance of Solid State Control" and to NEMA ICS 7.1 (latest
       edition), "Safety Standards for Construction and Guide for Selection, Installation and Operation of
       Adjustable-Speed Drive Systems" or their equivalent governing your particular location.
                                                  WARNING
        UNINTENDED EQUIPMENT OPERATION
           Only use software approved by Schneider Electric for use with this equipment.
           Update your application program every time you change the physical hardware configuration.
        Failure to follow these instructions can result in death, serious injury, or equipment damage.
                                                  WARNING
        UNINTENDED EQUIPMENT OPERATION
        Do not include any wiring information, programming or configuration logic, or parameter values
        from any of the examples in your machine or process without thoroughly testing your entire
        application.
        Failure to follow these instructions can result in death, serious injury, or equipment damage.
10                                                                                        EIO0000003361 12/2018
         EcoStruxure Machine Expert - Basic Example Guide
         Example Description
         EIO0000003361 12/2018
         Chapter 1
         Example Description
         Example Description
What Is in This Chapter?
         This chapter contains the following topics:
                                                            Topic   Page
            Overview                                                12
            Setup Description                                       18
EIO0000003361 12/2018                                                      11
Example Description
Overview
General
        This example guide and its corresponding project template, included with EcoStruxure Machine
        Expert - Basic, helps you to scale the analog inputs of the M221 Logic Controller by using multiple
        operands in a single Operation Block. It also shows the use of subroutines and multi-token Grafcet
        (SFC) POUs.
        The following graphic illustrates an analog scaling process:
        A sensor measures physical data, which is then converted to an electrical quantity. In this example,
        the physical data is mass and the electrical quantity is electrical potential (voltage). The converted
        data is then transmitted to a device, which processes and scales it.
        The data can be used within the application, for purposes such as sorting objects according to their
        weight, or it can be displayed in a human machine interface (HMI).
        In this example guide, the process is implemented as shown in the following graphic:
        A strain gauge in a weighing scale measures physical data, the mass, by its changing resistance.
        The resistance is then converted to an electrical quantity (electrical potential).
        The data is transmitted to an M221 Logic Controller, which processes and scales it. The M221
        Logic Controller sends commands to pneumatic jacks, which sort the objects according to their
        mass. At the same time, the data is displayed in an HMI.
12                                                                                         EIO0000003361 12/2018
                                                                                         Example Description
         These operations can be seen as a part of the machine process shown in the following graphic:
         The objective of this example guide and its associated template is to describe the data processing
         part of the process so that you can integrate the project template in your application.
Theoretical Background
         This part shows the logic behind the calculations made for scaling in the project template. See also
         the setup description (see page 18) or the example description (see page 11).
         The main objective in this guide is to explain linear scaling. However, you can find the theoretical
         background information in the appendix (see page 33) for other functions (exponential and second
         degree polynomial).
EIO0000003361 12/2018                                                                                     13
Example Description
Linear Variations
        A system is said to be linear if the output changes at a constant proportion as a function of the input.
        This is illustrated in the following graphic:
        In this example guide, the x-axis is the mass and the y-axis is the analog input of the M221 Logic
        Controller.
        A linear system is characterized by two parameters: the constant b and the slope a.
        However, in this example, there are two systems:
        1. Conversion form mass to resistance.
        2. Conversion from resistance to voltage. This is not linear, but can be approximated with a linear
           system.
14                                                                                           EIO0000003361 12/2018
                                                                                             Example Description
         This approach is called a linear trend line and it is illustrated in the following graphic:
         If you need more precision, you can consult the appendices (see page 33) for other types of
         scaling techniques to use.
         In this equation, the slope a is equal to -3.9005 and the constant b is 760.38.
         Before using the voltage values in an application, they must be scaled. Scaling involves converting
         the x or y values to another axis using a custom equation.
EIO0000003361 12/2018                                                                                        15
Example Description
        This is illustrated in the following graphic:
        The green line represents the equation to be used to pass from one set of axis values to another.
        In this template, both of these scaling systems are used. In the first system, the resistance values
        (x-axis) are converted to mass values (y-axis). In the second system, the voltage values (y-axis)
        are converted to resistance values (x-axis).
        A particular case of passing from y-axis to x-axis is to take the inverse of the function. In the
        template, this is when voltage values are converted to resistance values in the second system.
16                                                                                        EIO0000003361 12/2018
                                                                                       Example Description
Taking the Inverse of a Linear Equation
         Taking the inverse of a linear equation can be represented visually as the mirror image of the
         function with respect to the y = x line.
         This is illustrated in the following graphic:
         However, a visual representation such as this one does not allow you to calculate the actual
         values.
         The inverse of a linear equation of the form y = a*x+b is x = (y/a) - (b/a).
         In the project template, this calculation is used in subroutine 0.
EIO0000003361 12/2018                                                                                     17
Example Description
Setup Description
Setup Description
        The template is based on the machine mentioned in the overview (see page 12).
        The following graphic shows a more detailed description of the machine, with specific inputs and
        outputs shown:
        There are two weighing scales for sorting small boxes arriving from two conveyor belts. Depending
        on its mass, the pneumatic jacks push each small box right or left into larger boxes. The conveyor
        belts and the larger boxes are not in the scope of this example template.
18                                                                                      EIO0000003361 12/2018
         EcoStruxure Machine Expert - Basic Example Guide
         Project Template Description
         EIO0000003361 12/2018
         Chapter 2
         Project Template Description
         Project Template Description
What Is in This Chapter?
         This chapter contains the following topics:
                                                            Topic   Page
            Project Template Description                            20
            Project Template Structure                              23
EIO0000003361 12/2018                                                      19
Project Template Description
Project Template Description
Project Template Description
        Open the associated template in EcoStruxure Machine Expert - Basic and follow the explanations
        given in the template.
Configuration of Analog Inputs
        In this example, only the embedded analog inputs of the M221 Logic Controller are used:
        In EcoStruxure Machine Expert - Basic, embedded analog inputs are not configurable. For your
        application, therefore, you should consider using TMC2 cartridges or TM2/TM3 expansion
        modules. This allows you to:
           Use smaller intervals (min/max values) to trade precision for stability.
           Use filtering for more stability (the acquisition time is longer).
Implemented Features
        In this project template, the following EcoStruxure Machine Expert - Basic features are used:
           Multiple Operands
         Function Search
         Multitoken Grafcet (SFC)
         Subroutines
        Multiple Operands
        With EcoStruxure Machine Expert - Basic V1.0, it is possible to perform multiple operations in a
        single Operation Block:
20                                                                                      EIO0000003361 12/2018
                                                                                 Project Template Description
         Function Search
         With EcoStruxure Machine Expert - Basic V1.0, it is possible to search for a function, display its
         description, and insert it directly in an Operation Block.
         When typing in an Operation Block, you can click on the small icon on the right to access this
         feature.
         Clicking the icon displays the following window:
         In this window, you can select a function to insert.
         Multitoken Grafcet (SFC)
         In EcoStruxure Machine Expert - Basic, it is possible to have several Grafcet (SFC) POUs active
         at the same time. This feature is used in this project template to manage the two weighing scales
         simultaneously.
EIO0000003361 12/2018                                                                                     21
Project Template Description
        Subroutines
        In this project template, subroutines are used as functions and called multiple times from different
        parts of the code. This reduces redundancy.
22                                                                                        EIO0000003361 12/2018
                                                                                  Project Template Description
Project Template Structure
Overview
         The project template is organized into three POUs. POU 1 is a Ladder language POU. POU 2 and
         POU 3 are Grafcet (SFC) POUs. In these Grafcet POUs, there are multiple calls to 4 subroutines:
         The first POU initializes the scaling parameters. It is called only once at the beginning of the
         program.
         The second POU manages the first sorting machine.
         The third POU manages the second sorting machine.
         Refer also to Subroutines (see page 25).
EIO0000003361 12/2018                                                                                       23
Project Template Description
POU 2 and POU 3 - Grafcet (SFC) POUs to Manage the Sorting Machines
        The Grafcet (SFC) code in POU 2 and POU 3 is almost identical. The difference between them is
        that the transitions are validated on different digital inputs. From now on, they will be considered
        to be identical.
        Initially, the machine is in the first step and jumps directly to step 15. This is the error state when
        there is no method selected and the signal light is red. As described in Setup Description
        (see page 18), the red signal light is mapped to digital output %Q0.6.
        There are three methods to calculate the resistance values from the analog input. Each method is
        called in different Grafcet steps: 2, 3, and 4 (calls to subroutine 0, 1, and 2 respectively). When a
        method is chosen and a small box is detected on the weighing scale (%I0.2 and %I0.3), the
        signal light is green.
        After the resistance has been calculated, subroutine 3 is called to calculate the mass from the
        resistance values. This step is executed regardless of the chosen method. Depending on the mass
        value calculated with subroutine 3, one of the pneumatic jacks is activated to push the small boxes
        left or right.
24                                                                                           EIO0000003361 12/2018
                                                                                    Project Template Description
Subroutines
         The analog input voltage value changes according to the resistance of the weighing scale. In this
         template, the voltage values change as shown below:
         In the subroutines 0, 1 and 2, a trend line is taken into account and its inverse is used for
         calculations.
         A trend line is a mathematical technique for imitating the original data using mathematical
         functions. Using trend lines, it is possible to calculate the evolution of voltage with respect to
         resistance in a mathematical function.
         This mathematical function is:
         Voltage = f (Resistance).
         In the subroutines, f-1(Voltage) = Resistance is implemented, meaning the y-axis values are used
         to calculate the x-axis values.
EIO0000003361 12/2018                                                                                         25
Project Template Description
        SR0: This subroutine calculates the inverse of the following linear trend line (in red):
        The parameters are entered in %MF0 and %MF2 in the initialization POU and usually need to be
        modified for your application. This subroutine takes the input (y-axis values) from %MW500 and
        returns the output (x-axis values) in %MW501.
        The subroutine uses the following equation to find the return value:
        This method is simple but not precise.
26                                                                                         EIO0000003361 12/2018
                                                                               Project Template Description
         SR1: This subroutine calculates the inverse of the following second degree polynomial trend line
         (in red):
EIO0000003361 12/2018                                                                                   27
Project Template Description
        The parameters are entered in %MF10, %MF12, and %MF14 in the initialization POU and usually
        need to be modified for your application. This subroutine takes the input (y-axis) from %MW510 and
        returns the output (x-axis) in %MW511 and %MW512.
        It uses the following equation to find these two return values:
        Depending on your application, you should use either %MW511 or %MW512, then perform tests to
        verify your choice.
        This method is more complex and precise.
        SR2: This subroutine calculates the inverse of the following exponential trend line (in red):
28                                                                                        EIO0000003361 12/2018
                                                                                 Project Template Description
         The parameters are entered in %MF40 and %MF42 in the initialization POU and usually need to be
         modified for your application. This subroutine takes the input (y-axis) from %MW520 and returns the
         output (x-axis) in %MW521.
         It uses the following equation to find the return value:
         This method is a compromise in terms of complexity and precision.
         Select the method that is appropriate for the needs of your application. If you have a linear
         variation, then using a linear trend line may be appropriate.
         SR3: This subroutine scales (converts) the resistance values to match the mass values. It uses a
         linear equation: y = a*x+b
         This equation is illustrated below with the trend line (in red):
EIO0000003361 12/2018                                                                                     29
Project Template Description
        The parameters are entered in %MF50 and %MF52 in the initialization POU and usually need to be
        modified for your application. This subroutine takes the input (x-axis) from %MW530 and returns the
        output (y-axis) in %MW531.
        %MW531 can be used as the value to be displayed in the HMI.
30                                                                                       EIO0000003361 12/2018
         EcoStruxure Machine Expert - Basic Example Guide
         EIO0000003361 12/2018
         Appendices
EIO0000003361 12/2018                                       31
32   EIO0000003361 12/2018
         EcoStruxure Machine Expert - Basic Example Guide
         Scaling Techniques
         EIO0000003361 12/2018
         Appendix A
         Scaling Techniques
         Scaling Techniques
Scaling Techniques
Second Degree Polynomials
         A second degree polynomial is a function, illustrated in the following graphic:
         It can be inserted as a trend line for your values instead of a linear trend line for more precision.
         It has 3 parameters:
         A: Coefficient for the second degree
         B: Coefficient for the first degree
         C: The constant
         In the template, the second degree polynomial trend line is inserted, as shown in the graphic below:
EIO0000003361 12/2018                                                                                       33
Scaling Techniques
        The coefficients can be deduced as:
        A = 0.0272
        B = -6.7067
        C = 816.77
Taking the Inverse of a Second Degree Polynomial
        The scaling in the second method is based on taking the inverse of a function. If you use a second
        degree polynomial as the trend line, you have to take its inverse.
        This can be done by solving the equation for x. This produces two solutions, from which you must
        choose the appropriate solution by inserting a value, for example. The following equation is the
        result of the inversion:
        In the project template, the solution with the negative sign is used in the subroutine 1.
Exponential Function
        An exponential function is illustrated in the following graphic:
        An exponential function can be inserted as a trend line for your values instead of a linear trend line
        for more precision.
        It has two parameters:
        A: First coefficient
        B: Second coefficient
34                                                                                         EIO0000003361 12/2018
                                                                                           Scaling Techniques
         In the template, the exponential function trend line is inserted, as shown below:
         The coefficients can be deduced as:
         A = 788.21
         B = -0.007
Taking the Inverse of an Exponential Function
         The scaling in the second system is based on taking the inverse of a function. If you use an
         exponential function as the trend line you have to take its inverse.
         This can be done by solving the equation for x. The following equation is the result of the inversion:
         This solution is used in subroutine 2 of the project template.
EIO0000003361 12/2018                                                                                      35
Scaling Techniques
36                   EIO0000003361 12/2018