Analog Scaling
Analog Scaling
Analog Scaling
EIO0000002475 12/2016
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.
No part of this document may be reproduced in any form or by any means, electronic or
mechanical, including photocopying, without express written permission of Schneider Electric.
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.
© 2016 Schneider Electric. All Rights Reserved.
2 EIO0000002475 12/2016
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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Appendices ......................................... 29
Appendix A Scaling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Scaling Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
EIO0000002475 12/2016 3
4 EIO0000002475 12/2016
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.
EIO0000002475 12/2016 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.
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.
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.
6 EIO0000002475 12/2016
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.
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.
EIO0000002475 12/2016 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 EIO0000002475 12/2016
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 the code from this example in your machine or process and put into service 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 SoMachine Basic project file focus on specific instructions and
function blocks provided with SoMachine Basic, and on specific features available in SoMachine
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 SoMachine 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 SoMachine Basic V1.5.
EIO0000002475 12/2016 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 the code from this example in your machine or process and put into service without
thoroughly testing your entire application.
Failure to follow these instructions can result in death, serious injury, or equipment damage.
10 EIO0000002475 12/2016
SoMachine Basic Example Guide
Example Description
EIO0000002475 12/2016
Chapter 1
Example Description
Example Description
EIO0000002475 12/2016 11
Example Description
Overview
General
This example guide and its corresponding project template, included with SoMachine 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 EIO0000002475 12/2016
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 31) for other functions (exponential and second
degree polynomial).
EIO0000002475 12/2016 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 EIO0000002475 12/2016
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 31) 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.
EIO0000002475 12/2016 15
Example Description
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 EIO0000002475 12/2016
Example Description
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.
EIO0000002475 12/2016 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 EIO0000002475 12/2016
SoMachine Basic Example Guide
Project Template Description
EIO0000002475 12/2016
Chapter 2
Project Template Description
EIO0000002475 12/2016 19
Project Template Description
In SoMachine 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 SoMachine Basic features are used:
Multiple Operands
Function Search
Multitoken Grafcet (SFC)
Subroutines
Multiple Operands
With SoMachine Basic V1.5, it is possible to perform multiple operations in a single Operation
Block:
20 EIO0000002475 12/2016
Project Template Description
Function Search
With SoMachine Basic V1.5, 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.
EIO0000002475 12/2016 21
Project Template Description
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 24).
22 EIO0000002475 12/2016
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.
EIO0000002475 12/2016 23
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.
24 EIO0000002475 12/2016
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:
EIO0000002475 12/2016 25
Project Template Description
SR1: This subroutine calculates the inverse of the following second degree polynomial trend line
(in red):
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.
26 EIO0000002475 12/2016
Project Template Description
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):
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.
EIO0000002475 12/2016 27
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.
28 EIO0000002475 12/2016
SoMachine Basic Example Guide
EIO0000002475 12/2016
Appendices
EIO0000002475 12/2016 29
30 EIO0000002475 12/2016
SoMachine Basic Example Guide
Scaling Techniques
EIO0000002475 12/2016
Appendix A
Scaling Techniques
Scaling Techniques
Scaling Techniques
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:
EIO0000002475 12/2016 31
Scaling Techniques
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
32 EIO0000002475 12/2016
Scaling Techniques
In the template, the exponential function trend line is inserted, as shown below:
EIO0000002475 12/2016 33
Scaling Techniques
34 EIO0000002475 12/2016