Somachine Basic Example Guide: Importing Twido Drive Macros To M221 Xsample - Twido - Macro - Drive - Conversion - Smbe
Somachine Basic Example Guide: Importing Twido Drive Macros To M221 Xsample - Twido - Macro - Drive - Conversion - Smbe
EIO0000002402 06/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 EIO0000002402 06/2016
Table of Contents
Safety Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 1 Example Description. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Automatic Conversion of Twido Drive Macros to SoMachine Basic . . 15
Modifying the Converted Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Appendices ......................................... 29
Appendix A Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Operating Principles of Drive Macros . . . . . . . . . . . . . . . . . . . . . . . . . 31
EIO0000002402 06/2016 3
4 EIO0000002402 06/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.
EIO0000002402 06/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 EIO0000002402 06/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.
EIO0000002402 06/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 EIO0000002402 06/2016
About the Book
At a Glance
Document Scope
This document describes how to convert a TwidoSuite application that contains drive macros to
SoMachine Basic. It also explains how to adapt this converted SoMachine Basic project to various
setups.
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 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.4 SP1.
EIO0000002402 06/2016 9
Related Documents
You can download these technical publications and other technical information from our website
at http://download.schneider-electric.com
10 EIO0000002402 06/2016
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 without thoroughly testing
your entire application.
Failure to follow these instructions can result in death, serious injury, or equipment damage.
EIO0000002402 06/2016 11
12 EIO0000002402 06/2016
SoMachine Basic Example Guide
Example Description
EIO0000002402 06/2016
Chapter 1
Example Description
Example Description
EIO0000002402 06/2016 13
Example Description
Overview
General
The Example guide and its corresponding project template, included with SoMachine Basic, help
you to understand the code generated after importing a Twido project containing Twido drive
macros into SoMachine Basic. This allows you to have an understanding of how variable speed
drives work. If your configuration changes, it also shows how to modify the generated code to adapt
it to a modified configuration.
This document describes:
The conversion of a TwidoSuite project to a SoMachine Basic project for the M221 Logic
Controller.
How to modify the resulting program to adapt it to a modified configuration.
The operating principles of the drive macros.
14 EIO0000002402 06/2016
Example Description
The project focuses on how to use drive macros. It consists of rungs that call macros. Before being
deployed in the field, it would also need to manage operating modes.
EIO0000002402 06/2016 15
Example Description
Below are some graphics from the Program editor of the Twido example.
Turning the motor in different directions, stopping, or reinitializing:
Sending the speed value found in %MW84 (used with the animation table to set modifiable speeds):
16 EIO0000002402 06/2016
Example Description
This project:
Calls the D_Manager macro at each execution cycle to pass implicitly from one state to another.
Turns the motor in the forward direction when %M1 is set to TRUE.
Turns the motor in the reverse direction when %M2 is set to TRUE.
Stops the motor when %M3 is set to TRUE.
Clears the detected errors when %M4 is set to TRUE. This reinitializes the drive so that the other
commands can be sent.
Sends the speed value found at %MW84 when %M5 is set to TRUE.
Sets the speed to 150 rpm when %M6 is set to TRUE.
Sets the speed to 1500 rpm when %M7 is set to TRUE.
Modifies the speed to the preset value 1 when %M8 is set to TRUE.
EIO0000002402 06/2016 17
Example Description
Hardware Configuration
Verify that the hardware configuration displayed in the Configuration tab of SoMachine Basic
matches the physical configuration of your logic controller. In particular, verify the reference of the
logic controller, and that all expansion module and cartridge references match those used in the
physical configuration, and appear in the correct sequence. Adapt the SoMachine Basic
application as necessary.
18 EIO0000002402 06/2016
Example Description
Software Configuration
Verify that the serial line configuration of the M221 Logic Controller matches the previous settings
in TwidoSuite. To do so, choose MyController → SL1 (Serial line) on the Configuration tab as
shown below:
NOTE: If you are not using the same serial line, for example, you have switched from SL1 to SL2
or vice versa, you must modify each EXCH instruction and MSG function block to use the other serial
line.
To do so, you can use the Search and Replace tool under the Tools tab in SoMachine Basic. This
figure shows Search and Replace options:
EIO0000002402 06/2016 19
Example Description
( ) in the top left corner, click the Templates button, select xSample_Twido_Mac-
ro_Drive_Conversion.smbe, and click Open Template.
Conversion Result
The program in the template is functionally equivalent to the Twido program. However, as
SoMachine Basic does not support macros, each macro is replaced by a rung with equivalent
instructions, and one subroutine (SR0).
The following graphics present the result of this conversion:
20 EIO0000002402 06/2016
Example Description
This figure shows how the subroutine D_Manager macro equivalent is called:
This figure shows turning the motor in forward and reverse directions. D_Run_Fwd and
D_Run_Rev equivalents:
Setting to TRUE the bit 8 of %MW108 turns the motor in the forward direction. Setting bit 9 to TRUE
turns it in the reverse direction.
EIO0000002402 06/2016 21
Example Description
Clearing the detected errors so that the drive is reinitialized. D_Clear_Errd equivalent:
Setting to TRUE the bit 10 of %MW108 clears the detected errors present in the ATV.
22 EIO0000002402 06/2016
Example Description
EIO0000002402 06/2016 23
Example Description
Setting to TRUE the bit 6 of %MW108 means that a new speed value needs to be sent, either as a
preset speed or a modifiable speed.
The subroutine SR0 corresponds to the D_Manager macro in the TwidoSuite program. All other
macros are converted to a rung that sets one bit to TRUE in the word Modbus_init (%MW108).
This word is then used inside the subroutine to determine to which state the drive must go. The
details on this subroutine can be found in Operating Principles of Drive Macros (see page 31).
24 EIO0000002402 06/2016
Example Description
Introduction
Although the conversion works for the drive macros as they appeared in the original Twido project,
if you modify your configuration you need to modify certain parameter values in your application.
NOTE: Each rung, with the exception of the shared subroutine, is independent from the others. So
if you modify one of them, the others are not affected. For more information on how to modify
settings, refer to Operating Principles of Drive Macros (see page 31).
EIO0000002402 06/2016 25
Example Description
26 EIO0000002402 06/2016
Example Description
Replace the value 41 with the new number at these locations to modify the slave address.
Bit Name/Use
0 Refer to Operating Principles of Drive Macros
1
(see page 31).
2
3
4
5
6 Select Speed
7 Stop
8 Run Forward
9 Run Reverse
10 Clear Error
EIO0000002402 06/2016 27
Example Description
Bit Name/Use
11 Refer to Operating Principles of Drive Macros
12
(see page 31).
13
14
15
The speed values, as in Twido, are modified in memory word %MW84 (5th word of the macro) and
the speed modes are modified in memory word %MW83.
To re-use the macros for other purposes in your application, you can copy and paste a rung from
the first POU and modify the speed values, or specify different contact addresses.
28 EIO0000002402 06/2016
SoMachine Basic Example Guide
EIO0000002402 06/2016
Appendices
EIO0000002402 06/2016 29
30 EIO0000002402 06/2016
SoMachine Basic Example Guide
EIO0000002402 06/2016
Appendix A
Appendices
Appendices
Introduction
This section presents advanced adaptations beyond converting and using Twido drive macros in
SoMachine Basic.
Each TwidoSuite macro is converted into rungs in SoMachine Basic. In this section, you will obtain
a better understanding of the operating principles of the drive macros.
From this point onwards, the memory words are referenced by their relative position within the
macro. This means that %MW80 mentioned previously is now %MW0, %MW91 is now %MW11, and so
on. This representation is used to allow the same references to be used across multiple instances
of macros.
Additionally, the D_Select_Speed macro modifies the values in Select_Mode (%MW3) and
Select_Point (%MW4), which are subsequently taken into account by the D_Manager macro.
EIO0000002402 06/2016 31
Altivar Operating Principles
This document focuses on the role of the certain memory words of the ATV 61 and their values. It
does not describe in detail the electrical operating principles, nor its communication with the motor.
Altivar drives have a common structure of memory words which can be shared using the same
principles.
32 EIO0000002402 06/2016
An Altivar drive has different operating states. The following state chart shows the different states
of the Altivar drive and the conditions for passing from one state to another:
Passing from one state to another is done using the command word (CMD). Each state has a mask
used for reading its status (ETA).
EIO0000002402 06/2016 33
A simple description of this machine is:
When the motor is running normally, the ATV is in state Operation enabled (5).
To switch to this state, the command word 000F hex must be sent when the ATV is in state 4.
When the ATV is shut down (not braking), it is in state Ready to switch on (3).
To switch to this state, the command word 0006 hex must be sent when the ATV is in either
state 5 or state 2. The motor stops due its own friction.
When the ATV is switched on, it is in state Switched on (4).
To switch to this state, the command word 0007 hex must be sent when the ATV is in either
state 3 or state 5.
When in state 5, the command word 0002 hex activates the quick stop causing the ATV to go
to the Quick stop active state (6). It stops the motor faster than a normal stop, but it requires the
motor to be reinitialized and the drive must pass through states 3 and 4 to start again.
From all states, a detected error forces the ATV to go to state Fault (8).
The ATV must then pass to state 2 with the command word 0080 hex.
By using the EXCH instruction or the Read Var and Write Var function blocks, it is possible to
manage an ATV, as shown in the template xSample_ATV_Modbus_SL_M221.
Refer to Altivar Parameters (see page 35) where are described the memory words used by the
D_Manager macro for reading and writing.
It is also necessary to know the role of memory words used within the macro. A drive macro uses
30 memory words (%MW0 to %MW29). Seven memory words (D_STATE, D_CANSTATE, D_ERROR,
D_SETPOINT_MODE, D_SETPOINT, D_MODBUS_INIT_PHASE) are named explicitly and
described in the TwidoSuite online help. The others are reserved for the D_Manager macro and
used internally by this macro. The memory word %MW28 is used as a messenger between the other
macros and also between the rungs within the D_Manager macro itself.
In summary, a drive macro works with:
The parameters used by the ATV (see page 35)
The 30 memory words used by the macro (see page 36)
The 16 bits of the memory word %MW28 (see page 41)
34 EIO0000002402 06/2016
Altivar Parameters
The parameters of the ATV 61 are detailed in the document ATV61_communication_parame-
ters_EN_V5.8_IE29 (see page 10). However, this table summarizes these parameters and also
which ones the D_Manager macro reads or writes to:
8602 This is the commanded speed value. The value written in D_Setpoint (%MW4) is
written to this logic address.
The value can be converted to a frequency using the following formula:
w = 2 x f x 60 / n
Where w is the speed in rpm, f is the frequency and n is the number of poles.
With a 4-pole motor, the formula becomes:
f = w / 30
By reading the address 8604 (output velocity), you can verify whether the drive has
reached the speed value you requested.
8603 This is the aforementioned ETA value, that is, the present state of the ATV. It is used
with a mask and the masked value is stored somewhere else. Depending on the
state of the ATV, the D_Manager macro sends the appropriate CMD words. Refer
to ATV61_communication_parameters_EN_V5.8_IE29 (see page 10) to understand
the meaning of the value found in this word.
8606 Contains the ERRD value. It shows the detected error and it is cleared by sending
the command 0080 hex.
8413 This logic address selects the type of the first channel. In the template, it contains
the value 164, which means Modbus.
11401, 11402 and These are the preset speed values. They are initialized with 173, 174, and 175
11403 respectively. If no preset values are set, using modifiable preset speeds is not
possible.
3320 This is the part number of the ATV. Its value can be used to detect whether it is an
ATV 31, ATV 61, or ATV 71.
EIO0000002402 06/2016 35
Macro Memory Words
This table describes the memory words used in the macro:
%MW11
%MW12
%MW13
%MW14
%MW15
%MW16
%MW17
%MW18
%MW19
%MW20 Second Exchange Table
%MW21 Writing 1 Word
%MW22
%MW23
%MW24
%MW25
%MW26
%MW27
%MW28 Messenger
%MW29 –
For more information, refer to the reference documents on Modbus communication, and the EXCH
instructions (see SoMachine Basic, Generic Functions Library Guide).
36 EIO0000002402 06/2016
First Exchange Table
This table is used to read 4 words from the drive. It uses 11 words and has the following format:
An exchange table is called by using the EXCH instruction within an operation block:
EXCH1 %MW89:11
where 11 is the total number of words in the exchange table.
EIO0000002402 06/2016 37
You can see the configuration of this table in rung 9 and its use in rungs 9, 13, and 26.
38 EIO0000002402 06/2016
Second Exchange Table
This table is used to write one word to the drive, and is used in the macro.
An exchange table is called by using the EXCH instruction within an operation block:
EXCH1 %MW100:8
where 8 corresponds to the total number of words in the exchange table.
EIO0000002402 06/2016 39
The configuration is in rungs 10, 21, and 30 and it is used in rungs 3, 4, 5, 7, 8, 10, 21, and 30.
40 EIO0000002402 06/2016
Memory Word %MW28
The following table shows the purpose of each bit of the memory word %MW28:
Bit Name
0 Error
1 %S6 of logic controller
2 –
3 ATV reference (0 for ATV61/71)
4 –
5 Order to send Speed Value
6 Select Speed
7 Stop
8 Run Forward
9 Run Reverse
10 Clear Error
11 Order to send a command
12 –
13 –
14 Frame is sent
15 –
EIO0000002402 06/2016 41
42 EIO0000002402 06/2016