implementation example using matlab - wago … · implementation example using matlab ......

26
Application note Inverse Pendulum A500710 Implementation example using MATLAB ® and CODESYS V2.3 Version 1.0.0

Upload: dangdiep

Post on 12-Apr-2018

354 views

Category:

Documents


13 download

TRANSCRIPT

Page 1: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Pos: 2 /D okumentati on allgemein/Ei nband/Ei nband H andbuch - Deckbl att @ 9\mod_1285229289866_0.doc @ 64939 @ @ 1

Application note

Inverse Pendulum

A500710 Implementation example using MATLAB® and CODESYS V2.3

Version 1.0.0

Page 2: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

2 A500710 Inverse Pendulum

Application note Version 1.0.0

© 2014 by WAGO Kontakttechnik GmbH & Co. KG All rights reserved.

WAGO Kontakttechnik GmbH & Co. KG

Hansastraße 27 D-32423 Minden

Tel.: +49 (0) 571/8 87 – 0 Fax: +49 (0) 571/8 87 – 1 69

E-Mail: [email protected]

Web: http://www.wago.com

Technical Support

Tel.: +49 (0) 571/8 87 – 5 55 Fax: +49 (0) 571/8 87 – 85 55

E-Mail: [email protected]

Every conceivable measure has been taken to ensure the accuracy and completeness of this documentation. However, as errors can never be fully excluded, we always appreciate any information or suggestions for improving the documentation.

We wish to point out that the software and hardware terms, as well as the trademarks of companies used and/or mentioned in the present document are generally protected by trademark or patent.

Page 3: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Important Notes 3 A500710 Inverse Pendulum

Application note Version 1.0.0

Table of Contents 1 Important Notes ........................................................................................... 4 1.1 Copyright ................................................................................................... 4 1.2 Subject to Change ..................................................................................... 4 1.3 Personnel Qualification ............................................................................. 4 1.4 Limitation of Liability ............................................................................... 5

2 Application description ............................................................................... 6 2.1 Setup .......................................................................................................... 6 2.2 Implementation ......................................................................................... 7 2.3 Hardware ................................................................................................... 7 2.3.1 Pendulum and Rotary Transducer ........................................................ 8 2.3.2 Linear Unit, Step Motor and Servo Stepper Controller ........................ 9 2.4 Software .................................................................................................... 9

3 Observing the Example ............................................................................. 10 3.1 Download Files ....................................................................................... 10 3.2 Opening and Executing the MATLAB® Sample Script .......................... 11 3.3 Description of the MATLAB® Sample Script ........................................ 12 3.4 Opening and Executing the Simulink® Project Example ........................ 12 3.5 Description of the Simulink® project example ........................................ 13 3.5.1 Block 1: Simulation of the real system............................................... 14 3.5.2 Block 2: Continuous Luenberger Observer ........................................ 14 3.5.3 Block 3: Discrete Luenberger Observer ............................................. 14 3.5.4 Block 4: State Feedback ..................................................................... 14 3.5.5 Block 5: State Indicators .................................................................... 14 3.6 Generating the PLC Code ....................................................................... 15 3.7 Importing the PLC Code to CODESYS .................................................. 16 3.8 Description of the CODESYS Project Example ..................................... 20

4 Additional Information ............................................................................. 23 4.1 Simulink PLC Coder™ ........................................................................... 23 4.2 Literature ................................................................................................. 23

List of figures ....................................................................................................... 24

List of tables ......................................................................................................... 25

Page 4: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

4 Important Notes A500710 Inverse Pendulum

Application note Version 1.0.0

1 Important Notes 1.1 Copyright

This documentation, including all figures and illustrations contained therein, is subject to copyright protection. Any use of this documentation that infringes upon the copyright provisions stipulated herein is prohibited. Reproduction, translation, electronic and phototechnical filing/archiving (e.g., photocopying), as well as any amendments require the written consent of WAGO Kontakttechnik GmbH & Co. KG, Minden, Germany. Non-observance will entail the right of claims for damages.

1.2 Subject to Change WAGO Kontakttechnik GmbH & Co. KG reserves the right to make any alterations or modifications that serve to increase the efficiency of technical progress. WAGO Kontakttechnik GmbH & Co. KG owns all rights arising from granting patents or from the legal protection of utility patents. Third-party products are always mentioned without any reference to patent rights. Thus, the existence of such rights cannot be excluded.

1.3 Personnel Qualification The use of the product described in this document is exclusively geared to specialists having qualifications in PLC programming, electrical specialists or persons instructed by electrical specialists who are also familiar with the appropriate current standards.

Moreover, the persons cited here must also be familiar with all of the products cited in this document, along with the operating instructions. They must also be capable of correctly predicting any hazards which may not arise until the products are combined.

WAGO Kontakttechnik GmbH & Co. KG assumes no liability resulting from improper action and damage to WAGO products and third-party products due to non-observance of the information contained in this document.

Page 5: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Important Notes 5 A500710 Inverse Pendulum

Application note Version 1.0.0

1.4 Limitation of Liability This documentation describes the use of various hardware and software components in specific example applications. The components may represent products or parts of products from different manufacturers. The respective operating instructions from the manufacturers apply exclusively with regard to intended and safe use of the products. The manufacturers of the respective products are solely responsible for the contents of these instructions.

The sample applications described in this documentation represent concepts, that is, technically feasible application. Whether these concepts can actually be implemented depends on various boundary conditions. For example, different versions of the hardware or software components can require different handling than that described here. Therefore, the descriptions contained in this documentation do not form the basis for assertion of a certain product characteristic.

Responsibility for safe use of a specific software or hardware configuration lies with the party that produces or operates the configuration. This also applies when one of the concepts described in this document was used for implementation of the configuration.

WAGO Kontakttechnik GmbH & Co. KG is not liable for any actual implementation of the concepts.

Page 6: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

6 Application description A500710 Inverse Pendulum

Application note Version 1.0.0

2 Application description This application note demonstrates how a model developed using MATLAB® or Simulink® can be implemented in an automation application implemented with a WAGO PLC. Implementation is made using the example of an inverse pendulum.

2.1 Setup

Figure 1: Structure of the inverse pendulum

Table 1: Legend for “Structure of inverse pendulum” figure Marking Description PND Pendulum, consisting of rod and head SL Sledge PLC WAGO PLC with state controller and servo stepper controller CTR State controller SRV Servo Stepper Controller u Specified sledge velocity w Pendulum angle x Position of the sledge

A weight is attached to the top of the rod, whose lower end is connected to the axle of a rotary transducer. The rotary transducer in turn is attached to a sledge that can be moved using a step motor. This setup represents an inverse pendulum. In an upright position the pendulum is in a state of transient equilibrium and will begin swinging downward with the smallest deflection.

Page 7: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Application description 7 A500710 Inverse Pendulum

Application note Version 1.0.0

Angular momentum can be applied to the pendulum by accelerating the sledge, for example to counteract a downward motion.

The control task here is to return the inverse pendulum to an upright position after deflection such that the sledge is moved in a suitable manner. Other tasks can involve moving the pendulum harmonically along set, defined paths.

2.2 Implementation The inverse pendulum is modeled using a Luenberger observer in MATLAB® or Simulink®. Using the Simulink PLC Coder™ a corresponding code is generated for the Structured Text (ST) programming language in the IEC 61131-3 from the model.

The generated PLC code is integrated into a CODESYS application for the PFC200 (750-8204) PLC controller which links the model to the real hardware.

Evaluation of the position of the rotary transducer is performed using the 750-630 SSI transmitter interface, actuation of the step motor using the 750-673 servo stepper controller.

2.3 Hardware Table 2: Hardware – list of components Function Component Manufacturer PLC PFC200, 750-8204 WAGO Step motor power element 750-673 Servo stepper

controller WAGO

Input for rotary transducer 750-630 SSI transmitter interface

WAGO

Rotary transducer for pendulum

Absolute encoder, GM401 Baumer

Linear axis Linear axis, Duoline 50 Z (incl. rotary transducer for linear axis)

R&K

Step motor Step motor, ST8918M4508 Nanotec Pendulum, sledge (own design) WAGO

Page 8: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

8 Application description A500710 Inverse Pendulum

Application note Version 1.0.0

Comments on setup:

• Friction losses, as non-linear stick-slip effects can make modeling and control of the setup extremely difficult. It was therefore attempted to keep friction losses as low as possible when selecting and assembling the components.

• The servo stepper controller (750-673) implements a control for the step motor, linear drive and sledge. Consequently, certain properties of the mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for the pendulum model.

Each of the components used in the setup are described briefly below.

2.3.1 Pendulum and Rotary Transducer

The pendulum consists of an aluminum rod and an aluminum head in the form of a hemisphere. The following properties are pertinent to the application note:

Table 3: Hardware – properties of pendulum Property Value Weight, rod 0.02 kg Weight, head 0.04 kg Length of rod 0.3 m Center of gravity of pendulum 0.25 m Moment of inertia 0.0045 kgm² Friction coefficient 0.0257 Natural frequency 0.92 Hz The pendulum is attached directly to the axle of the rotary transducer.

Table 4: Hardware – properties of rotary transducer Property Value Resolution 4096 lines per revolution The rotary transducer is attached to the linear unit sledge.

Page 9: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Application description 9 A500710 Inverse Pendulum

Application note Version 1.0.0

2.3.2 Linear Unit, Step Motor and Servo Stepper Controller

Table 5: Hardware – properties of the linear unit Property Value Maximum speed 5.5 m/s Maximum acceleration 20 m/s² Maximum friction 8 N Transmission ratio 0.135 m/revolution The linear unit sledge is moved by the step motor.

Table 6: Hardware – properties of the step Motor Property Value Nominal current 4.5 A Max. torque 6 Nm Angle 1.8° per complete step The step motor is actuated by the 750-673 servo stepper controller.

Table 7: Hardware – settings for the servo stepper controller Parameter Set Value Nominal current 4.5 A Prescaler for maximum velocity ("Freq_Div")

4

Factor for maximum acceleration ("Acc_Fact")

4000

Effective resolution of the rotary transducer ("Encoder_Resolution")

8000 (4x evaluation)

An incremental encoder on the motor shaft provides the return signal for position detection. The resolution of the encoder is 2000 pulses/revolution.

2.4 Software Table 8: Software – list of components Function Component (Version) Manufacturer Development environment CODESYS (2.3) 3S Development environment MATLAB® (2013a) MathWorks Development environment, extension

Simulink® (2013a) MathWorks

Development environment, extension

Simulink PLC Coder™ MathWorks

Page 10: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

10 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

3 Observing the Example The following steps are required in order to observe the model of the implemented example:

• Downloading of the files for the example. • Opening and executing the MATLAB® sample script. • Opening the Simulink® example project.

The properties of the model can then be customized as required and the response simulated.

The following steps are required to implement the example on the WAGO PLC:

• If properties of the model have been modified, the parameters for the feedback vector must be recalculated.

• Generate the PLC code in Simulink®. • Open the CODESYS example project. • Import the generated PLC code. • Where required, enter the parameters for the feedback vector.

These steps are listed and explained in more detail below.

3.1 Download Files Before you can observe the example in the development environments you must download all the associated files and save them in a common directory on your PC (working directory). You can download these files, together with this document as application note A500710 from the WAGO Website (www.wago.com).

Table 9: Files for the application note File Type Wago_CODESYS_MATLAB_example_01.pro CODESYS project example Wago_MATLAB_CoDeSys_example_01.m MATLAB® sample script Wago_Simulink_CoDeSys_example_01.slx Simulink® project example

Page 11: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 11 A500710 Inverse Pendulum

Application note Version 1.0.0

3.2 Opening and Executing the MATLAB® Sample Script Open the MATLAB® sample script in the MATLAB® user interface.

1 2

Figure 2: MATLAB® sample script

Table 10: Legend for the figure “MATLAB® sample script” Pos Description 1 MATLAB® file window 2 MATLAB® command window

After opening the sample script, the files for the Application Note must be displayed in the MATLAB® file window. Next, execute the sample script. Ensure here that the script is run error-free, i.e., that no error messages are displayed in the MATLAB® command window.

In the model selected here, the control properties can be represented by the feedback vector “Kfb”. You can calculate this vector using the MATLAB® sample script by entering “Kfb” in the MATLAB® command window.

Page 12: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

12 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

3.3 Description of the MATLAB® Sample Script The properties of the hardware components used in the setup are stored in the top section of the MATLAB® sample script (Section “Modelldaten”).

The derived properties for the pendulum are initially calculated from these known properties (Section “Das Pendel”).

The subsystem for regulating the velocity of the sledge, consisting of the servo stepper controller, step motor and linear drive, is available as an actual PT2 element. This element is also simulated in the script as a PT2 element for observing the simulation in Simulink® (Section “Der reale Geschwindigkeitsregler”). It is, however, simply taken as a PT1 element with regard to further calculations for control of the overall system, i.e., represented only by its time constant tau.

The state model (Section “Das Zustandsmodell”) contains the linear description of the velocity-regulated sledge and of the pendulum. The order of the state variables is sledge velocity, sledge travel, angular velocity and angle. In this part of the script the system matrix A, the coupling and decoupling vectors b and c and feedthrough d are generated.

The continuous state controller (Section “Der Regler”) and the Luenberger observer (Section “Der Luenberger-Beobachter”) are then generated on the basis of the state model. Representation of these steps in the script is very compact. Their understanding requires familiarity with the specified literature and of the documentation for the MATLAB® “place” command.

The final step of the script is the discretization of the Luenberger observer (Section “Diskretisierung des Luenberger Beobachter”); in this part of the script, the system matrices are converted to the configured PLC cycle (here: 5 ms).

All of the variables required for control and simulation are available in the MATLAB® workspace after the script has been executed. The Simulink® sample script can access these variables via symbolic names.

3.4 Opening and Executing the Simulink® Project Example Start Simulink® by double-clicking in the MATLAB® file window to open the Simulink® example project.

You can run the simulation as usual using the "Play" button once the simulation has opened. In this way you can test, for example, how the model responds after model parameters are changed.

Page 13: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 13 A500710 Inverse Pendulum

Application note Version 1.0.0

Figure 3: Starting the simulation

3.5 Description of the Simulink® project example

1

2

3

4

5

Figure 4: Simulink® project example

Table 11: Legend for the figure “Simulink® project example” Pos Description 1 Simulation of the real system 2 Continuous Luenberger observer 3 Discrete Luenberger observer 4 State feedback 5 State indicators

The individual elements of the model are described in the following sections.

Page 14: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

14 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

3.5.1 Block 1: Simulation of the real system

This block models the current state of the real system, consisting of pendulum, sledge and sledge drive. It is subdivided internally into the following blocks:

• Block “Motor_Schlitten” This block models the hardware subsystem, consisting of the servo stepper controller, step motor, linear axis and sledge. The properties of the servo stepper controller are mapped by the model parameters dead time, velocity limiting and system transfer function of the controller.

• Block “Pendel” This block models the hardware subsystem consisting of the pendulum elements. The trigonometric relationships and other properties of the pendulum are mapped in the model as non-linear differential equations.

You can open Block 1 by double-clicking on it to view descriptions of its contents.

3.5.2 Block 2: Continuous Luenberger Observer

This block contains the equation of state typical for an observer. It linearizes the real system by generating an estimation for the derived state values, that is the sledge and angular velocity, on the basis of the output signals from the first block.

3.5.3 Block 3: Discrete Luenberger Observer

The structure of this block is identical to that of the second block, but which instead of using continuous integrators uses discrete delay elements.

3.5.4 Block 4: State Feedback

This block closes the control circuit by supplying weighted output from the discrete Luenberger observer back to the real system using the “Kfb” feedback vector.

3.5.5 Block 5: State Indicators

This block enables the simulation of the model to be observed using oscilloscope screens.

Page 15: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 15 A500710 Inverse Pendulum

Application note Version 1.0.0

3.6 Generating the PLC Code You can easily generate (export) PLC code from the model. To do this, just right-click on the discrete Luenberger observer (Block 3) and select “PLC Code” > “Generate Code for Subsystem” from the contextual menu.

Figure 5: Contextual menu for generating the PLC code

Once the PLC code has been successfully generated, a dialog window is displayed containing the name and path of the defined export file (*.exp).

Figure 6: Export file dialog window

Page 16: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

16 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

3.7 Importing the PLC Code to CODESYS First, open the CODESYS sample project.

If the elements contained in the PLC code to be imported (function block “LuenbergerBeobachterDiskret”, additional list of global variants) are already included, delete these before continuing.

You can use the CODESYS import function to integrate the generated PLC code into the example project. To do this, select the “Import” function from the “Project” menu.

Figure 7: Selecting the CODESYS import function

Next, a dialog window for selecting an export file will open.

Page 17: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 17 A500710 Inverse Pendulum

Application note Version 1.0.0

Figure 8: Selecting an export file in CODESYS

In the file system navigate to the directory in which the export file generated in Simulink® was saved and open this file.

This adds the “LuenbergerBeobachterDiskret” function block to the existing function blocks of the example project.

Figure 9: Function block after import

Page 18: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

18 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

A new global variant list will also be generated.

Figure 10: Variable list after import

The PLC code generated by Simulink PLC Coder™ also utilizes the data type LREAL. To ensure that the code can be executed on the WAGO PLC the data type must be converted when the project is compiled. To do this, open “Project” > “Options…” > “Compiling options”.

Figure 11: Opening the project options

Check this setting in the section “Compiling options”.

Page 19: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 19 A500710 Inverse Pendulum

Application note Version 1.0.0

Figure 12: Compiling options

The check-box for the option “Compile LREAL as REAL” must be marked.

Page 20: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

20 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

3.8 Description of the CODESYS Project Example All of the function blocks are executed in the main program PLC_PRG. Execution of this program is performed as a task with a cycle time of 5 ms.

The figure below illustrates the simplified call tree for the CODESYS example project.

Figure 13: Function blocks of the CODESYS example project

The function blocks “FbAufschwingen” and “FbRotieren” move the pendulum in controlled, non-regulated operation. The upward swinging motion can be used for example to move the suspended pendulum to the operating range of the control system.

Control proper takes place in the “FbControlPendulum” function block. This function block operates using the pendulum model, whose state is determined by the Luenberger observer – that is, the imported function block “LuenbergerBeobachterDiskret”. Input parameters “rP1” to “rP4” represent the feedback vector “Kfb”.

Page 21: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Observing the Example 21 A500710 Inverse Pendulum

Application note Version 1.0.0

Figure 14: “FbControlPendulum” function block

The “FbPendelstrecke” function block forms the abstraction layer between the model and the real process. For this, the function blocks converts, for example, process variables for the servo stepper controller to a concrete sledge position, or measured values for the rotary transducer to pendulum angles.

Figure 15: “FbPendelstrecke” function block

The function blocks whose names contain “MC3” or “Stepper” are used for configuring, actuating and state indication for the servo stepper controller.

Among other things, they also provide velocity regulation for the subsystem composed of the sledge, linear unit and step motor. This function can be selected using the “JobType” of the “MC3_ModeSelect” function block.

Figure 16: “MC3_ModeSelect” function block

Page 22: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

22 Observing the Example A500710 Inverse Pendulum

Application note Version 1.0.0

The “MC3_StepperControlBasic” function block forms the interface for velocity control.

Figure 17: “MC3_StepperControlBasic” function block

The configuration can be tailored to different setups using the “MC3_ConfigurationTable” function block.

Figure 18: “MC3_ConfigurationTable” function block

More information about this function block and other function blocks associated with the servo stepper controller is given in the documentation in the “Stepper_03.lib”, which you can download from the WAGO Website.

Page 23: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Additional Information 23 A500710 Inverse Pendulum

Application note Version 1.0.0

4 Additional Information 4.1 Simulink PLC Coder™

A detailed description of the Simulink PLC Coder™ software and further information about the MathWorks products used here can be obtained directly from MathWorks.

On publication of this application note, more details about the Simulink PLC Coder™ can be obtained at the following address:

http://www.manualslib.com/manual/392933/MATLAB-Simulink-Plc-Coder-1.html

4.2 Literature More information about the control technology methods applied for modeling is given in the following books:

• H. P. Geering: “Regelungstechnik” Springer Verlag, ISBN 3-540-40507-0

• B. Berger: “Realisierung einer prototypischen Hardwarelösung für ein inverses Pendel” / “FPGA-only based control for a very compact inverted pendulum” Grin Verlag, ISBN 978-3640723034

=== Ende der Liste für Textmar ke Inhalt_mitte ===

Page 24: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

24 List of figures A500710 Inverse Pendulum

Application note Version 1.0.0

Pos: 49 /D okumentation allgemei n/Verzeichnisse/Abbil dungsverzeichnis - ohne Gliederung - und Verzeichnis @ 3\mod_1219222916765_6.doc @ 21079 @ @ 1

List of figures Figure 1: Structure of the inverse pendulum ........................................................... 6 Figure 2: MATLAB® sample script ...................................................................... 11 Figure 3: Starting the simulation ........................................................................... 13 Figure 4: Simulink® project example .................................................................... 13 Figure 5: Contextual menu for generating the PLC code ...................................... 15 Figure 6: Export file dialog window ..................................................................... 15 Figure 7: Selecting the CODESYS import function ............................................. 16 Figure 8: Selecting an export file in CODESYS ................................................... 17 Figure 9: Function block after import ................................................................... 17 Figure 10: Variable list after import ...................................................................... 18 Figure 11: Opening the project options ................................................................. 18 Figure 12: Compiling options................................................................................ 19 Figure 13: Function blocks of the CODESYS example project ............................ 20 Figure 14: “FbControlPendulum” function block ................................................. 21 Figure 15: “FbPendelstrecke” function block ....................................................... 21 Figure 16: “MC3_ModeSelect” function block .................................................... 21 Figure 17: “MC3_StepperControlBasic” function block ...................................... 22 Figure 18: “MC3_ConfigurationTable” function block ........................................ 22

Page 25: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

List of tables 25 A500710 Inverse Pendulum

Application note Version 1.0.0

List of tables Table 1: Legend for “Structure of inverse pendulum” figure ................................. 6 Table 2: Hardware – list of components ................................................................. 7 Table 3: Hardware – properties of pendulum .......................................................... 8 Table 4: Hardware – properties of rotary transducer .............................................. 8 Table 5: Hardware – properties of the linear unit ................................................... 9 Table 6: Hardware – properties of the step Motor .................................................. 9 Table 7: Hardware – settings for the servo stepper controller ................................ 9 Table 8: Software – list of components ................................................................... 9 Table 9: Files for the application note ................................................................... 10 Table 10: Legend for the figure “MATLAB® sample script” ............................... 11 Table 11: Legend for the figure “Simulink® project example” ............................. 13

Page 26: Implementation example using MATLAB - WAGO … · Implementation example using MATLAB ... mechanical setup (e.g., the mass of the sledge) no longer have to be taken into account for

Pos: 53 /D okumentation allgemei n/Einband/Einband H andbuch - R ückseite @ 9\mod_1285229376516_6.doc @ 64942 @ @ 1

WAGO Kontakttechnik GmbH & Co. KG Postfach 2880 • D-32385 Minden Hansastraße 27 • D-32423 Minden Telefon: 05 71/8 87 – 0 Telefax: 05 71/8 87 – 1 69 E-Mail: [email protected] Internet: http://www.wago.com

=== Ende der Liste für Textmar ke Ei nband_hinten ===