The simulation of a non-linear unstable system of motion, utilising the Solid-Works and Matlab/Simulink extended libraries/toolboxes

. This text discusses the use and integration of various support software tools for the purpose of designing the motion control law governing mechanical structures with strongly non-linear behaviour. The detailed mathematical model is derived using Lagrange Equations of the Second Type. The physical model was designed by using SolidWorks 3D CAD software and a SimMechanics library. It extends Simulink with modelling tools for the simulation of mechanical “multi-domain” physical systems. The visualization of Simulink outputs is performed using the 3D Animation toolbox. Control law - designed on the basis of the mathematical model, is tested for both models (i.e. mathematical and physical) and the regulatory processes’ results are compared.


Introduction
Nowadays, a large amount of support software tools is available.These tools facilitate our work in analysing, modelling, simulating and designing a control law for complex mechanical structures.By connecting these resources a considerable simplification of the synthesis can be achieved as well as clarity by using visualisation in 3D space directly in the regulation process, or creating a physical model in Simulink directly from CAD software (SolidWorks), without the need to derive the equations of motion.
The system which is the object of our interest is called "Ball and beam", and the description of the dynamic behaviour is derived in the most general way as possible for use in the control of a real model.The ball and beam are mass objects and are thus situated in the 3D space -only the movement is limited to planar.The system is located in the Earth's gravitational field and has two degrees of freedom.The mass of the ball is chosen to have a significant impact on the movement changes of the beam; the beam may be unbalanced.The ball position is measured from the axis of rotation of the beam (i.e. the axis of the shaft of the driving motor).The Denavit-Hartenberg (DH) notation/method of placement for coordinate systems is used to determine the ball's position in a selected global coordinate system.
First, the whole system is sketched-out for the purpose of compiling a transformation matrix to determine the position of the ball in the global coordinate system.Using this transformation, the equations of motion of the system are derived -which include the moments of inertia, and the centrifugal/centripetal and Coriolis generalized forces or linear friction.Than, a 3D model was constructed in the a e-mail: zatopek@fai.utb.czCAD design software SolidWorks suite, including all kinematic constraints and the mass distribution of the whole assembly.This model is also useful for detecting the masses or matrices/moments of inertia of complex objects, which cannot be determined analytically.The subsequent CAD model is then export into the SimMechanics format in Matlab/Simulink, which leads to a physical model -including its kinematic link and the distribution of the mass of the whole assembly.This model subsequently tests the proposed control algorithm and compares the outputs with a mathematical model.

"Ball and beam" -the mathematical description 2.1 Transformation of coordinate systems
Figure 1.Model with the selected coordinate system placement Figure 1 shows the system drawn for the purpose of determining the transformation matrix from the local coor-dinate system (x 2 , y 2 , z 2 ) to the global system (X 0 , Y 0 , Z 0 ).Rotation of the beam is only possible around the global axis Z 0 ; rolling the ball only in direction of local axis z 1 is ideal.The connection of the beam with the frame in the place where the torque actions provide controlled tilting of the beam (i.e. the first degree of freedom) is shown schematically.The second degree of freedom is the movement of the ball on the beam.
The resulting homogeneous transformation matrix between the coordinate systems is: For determining the homogeneous coordinates of the ball position relative to the origin of the global coordinate system, the equation is: In order to determine the square-size of the absolute speed vector (in the global coordinate system), it is: Note, the Ball and beam is only planar in this model (processes take place in 2D).

Motion equations
To be able to use Lagrange equations of the second kind, it is therefore necessary to determine the kinetic and potential energy of the whole system.
The kinetic energy of the balls is comprised of its translational and rotational motion: The potential energy of the ball is: The Beam is cuboid in shape, with an optionally-stored rotation axis as shown in Figure 1.Its inertia matrix has 3x3 moments of inertia, and is defined as: in which ρ(x, y, z) is the density of the material body.If a new coordinate system is selected such that all the deviance moments will be zero; the torques to the individual axes of the system will be equal to the polar moments of the inertia matrix with respect to these axes.A well established system already meets this assumption, it is not necessary to introduce a new coordinate system and the moment of inertia relative to the axis of rotation (axis Z 0 ) will be equal to the polar moment J zz .
The kinetic energy of the beam is: The relationship between the mass element and the length element can be expressed as: The potential energy of the beam element is: The potential energy of the whole beam is: The total kinetic and potential energy of the system is the sum of their partial energies: The Lagrangian calculation is: The linear friction -dependent upon the generalised speed (i.e.sliding friction with a friction factor k 1 and rolling resistance with a friction factor k 2 ) will be added to the system.The equations of motion are therefore: After modification, we can write: in which: The block diagram in Simulink that corresponds to the derived non-linear mathematical model was created from the Equation (19).The modified equations of motion are part of the r" and fi" functional blocks, and it is also possible to choose non-zero initial conditions of the mathematical model.For the state vector: [r v ϕ ω] T = [x 1 x 2 x 3 x 4 ] T and input signal: Q = u the state-space representation will correspond to the shape of: From these equations, it can be determined that the system has only one unstable singular point and its steadystate is only given by the ball position on the lever/beam x 1 .
All remaining state variables are zero in singular point.The singular (stationary) point is: The Steady state is: Linearisation in the working point x s 1 (i.e.steady state) can be obtained from the transmission of the linear model:  Linearization is derived in the general position of the working point, so it is possible to continuously recalculate it.

"Ball and beam" -support software tools 3.1 SolidWorks
Figure 3.The complete assembly in SolidWorks The considered system consists of three basic parts: the base, the beam and the ball.All of these parts are material.Ideally, a rigid base is connected to the frame so its physical properties are not relevant to the dynamic behaviour of the system.The SolidWorks 3D CAD model (Figure 3) was exported in SimMechanics second generation xml format and then imported into the MATLAB/Simulink environment as a Simulink scheme (Figure 5).The link were revised because -between SolidWorks and SimMechanics; some are unknown or illicit.This model is also exported from the SolidWorks suite -but in the wrl format , which is loaded into a special block through the 3D Simulation toolbox.As inputs to this block are used, outputs from the mathematical model are converted through the transformation matrix (HD notation) into the translational and rotational motions of the individual parts of the assembly.Visualisation has more visualising options, e.g. a Web browser can also be used (Figure 6).

The "Ball and beam" -control
The large numbers of trigonometric functions and multiples of rounded state variables it contains leads to the generation of cumulative numerical error.Thus, despite placing the ball in equilibrium, the system will set itself into motion -as is apparent from Figure 7.The system is controlled by a linear regulator with 1DOF designed by the pole placement with a continuous linearisation.The controller parameters -resulting from the transfer function, are derived generally so that they can be updating continuously.The final regulator then, has the form: s) p(s) = q 4 s 4 + q 3 s 3 + q 2 s 2 + q 1 s + q 0 s p 3 s 3 + p 2 s 2 + p 1 s + p 0 (26) The step-changes in the reference value will be followed by step-changes in the control deviation; then there will be a problem with the physical realisation of a step  changes in the torque -and thus to the rapidly-changing tilt of the beam.In combination with the centrifugal forces and inertia of the system, the process will oscillate; and often will be an unmanageable state.Therefore, a filter that prevents such step-changes was introduced into the system.
As shown in Figure 9, the control processes (i.e mathematical and physical) of both models are nearly identical.The controller is designed to compensate for disturbance and the reference value is in the shape of a step-change, so a lag fault will appear in the transition part of the pro-cess at the ramp-shaped reference value.The trend of the reference value however, replicates very well.

Conclusion
This article contains a complete control design solution of a system known as a "Ball and beam" system, substantial part of the article relate to the derivation of systems motion equations from their energy balance.The model was -through to the definition of transmission, derived in a quite general manner and corresponds to motion equations linearised at the operating point.Therefore, it is possi- ble to carry out a continuous linearisation efficiently -and with low computational effort.This description however, applies only in the area surrounding the working point.When this point changes, linearisation is needed again.
Linking with 3D CAD software and Matlab/Simulink, while using toolboxes for physical modelling (SimMechanics) and 3D visualisation outputs (3D Animation) is a very and effective control tool for the presentation of the results.In real time, it is possible to observe dynamic processes occurring in the system and for instancefor to slow then down or to pause them for the purpose of detailed motion analysis or the exploration of the energy interactions between system components.
The control methods designed a described herein are tested on a unbalanced system with variable reference course and disorders.To achieve the desired quality of regulation, it is necessary to eliminate a step-change in the control deviation and to stabilize the course of the regulatory process.

Figure 2 .
Figure 2. The non-linear mathematical model in Simulink

Figure 4 .
Figure 4.A Real-time visualisation using the SimMechanics Second Generation suite

Figure 6 .
Figure 6.Visualisation using a 3D Animation Toolbox in a webbrowser