Note: This content is accessible to all versions of every browser. However, this browser does not seem to support current Web standards, preventing the display of our site's design details.

  
Main / Chugelimat

IfA 1.3 Lab Manual

by Oliver Kaiser, Urs Baumann, Tobias Geyer, Urban Mader, Ioannis Lymperopoulos, Akin Sahin, Stefan Richter

Chügelimat Process Control

In this experiment different balls are moved through a "ball exchange machine". The control logic which has to be developed is coded in Stateflow. Stateflow is a development tool based on Matlab/Simulink where state charts are drawn graphically and subsequently directly compiled. This allows a shorter control development time as compared with direct procedural logic languages (C/C++).

Figure 1: "Ball Exchange Machine" - Chügelimat

Contents

1.  Introduction

The automation of industrial processes can often be accomplished through structural logic design or "rule" control.

With Stateflow a tool is available in which it is possible to create state charts in an intuitive, graphical way and compile them directly. Stateflow is running in the Matlab/Simulink environment. In order to complete the lab practice efficiently, it's advisable to first read the "Introduction to Stateflow" and the "Getting Started with Simulink" manuals available on internet.

Stateflow is used in this experiment to control a model of a "coin exchange machine" named Chügelimat (Chügeli is swiss German and means little ball), where balls are used instead of coins. Balls with values of 1, 2, 5 and 10 are acceptable and appropriate exchange stock is handed out, however Chügelimat should ignore invalid balls.

The electromechanical setup of the Chügelimat is shown in Figure 1. During the exchange procedure the ball must go through different stations of Chügelimat: the entrance, the diameter measurement station, the weight measurement station (balance) and the sorting bins station. In the sorting bins station a valid ball is stored in one of the four magazines (1, 2, 5 and 10) and if possible exchange stock is handed out (see table 1). If insufficient exchange stock is available in the magazines or an invalid ball is thrown in, then the ball is ejected.

In the experiment, the processes for the entrance and the specification of the ball (diameter and weight measurement) should be coded in Stateflow. The remaining processes (sorting and exchanging the ball) to complete the control of Chügelimat already exist and have to be synchronized with the written processes. In the following sections the processes are explained more precisely. After this lab practice you will:

  • have designed a control for a simple process and
  • know the possibilities and limits of modern, graphical software tools.
Value of thrown in ballValue of ejected ball
1 x 1er1 x 1er
1 x 2er2 x 1er
1 x 5er2 x 2er + 1 x 1er
1 x 10er2 x 5er
Table 1: Ball classification at sorting bins

2.  Description of Chügelimat

The electromechanical setup of the Chügelimat, shown in Figure 1, consists of the following functional groups:

  1. entrance
  2. diameter measurement (DMS)
  3. weight measurement (balance)
  4. sorting bins
  5. magazines

The processes for the first three functional groups, namely, the entrance, DMS and balance sections should be coded in Stateflow. These functional groups are described in detail in the following sections.

The notations used in this chapter are the same as those in the prepared Stateflow model. All digital signals to and from Chügelimat work with logic levels where 0 = off and 1 = active.

Your task is to implement the following three functional groups and synchronize them to the existing ones as described in the following chapters.

2.1  Entrance

The slot where balls can be entered into Chügelimat is called "Entrance". A light barrier is used to detect when a ball is present and can be entered into the system.

Tables 2 and 3 illustrate the relationship between sensor and actuator signals of Chügelimat and the corresponding Stateflow variables.

SensorStateflow variableComment
Light barrier located at entranceinEntranceActivated approx. 1 sec. after ball is detected by light barrier. Deactivated as soon as ball is thrown out of entrance.
Table 2: Sensors at Entrance
ActuatorStateflow variableComment
Entrance gateejectEntranceBy activation the ball is sent to DMS section.

Table 3: Actuators at Entrance

The entrance gate should open when there is

  1. a ball in front of the entrance, and
  2. there is no ball in the diameter measurement station.

Hint: You should introduce a variable to determine if there is a ball in the DMS section, which may be set to 1 if there is a ball and reset to 0 if there is no ball.

2.2  Diameter Measurement Station (DMS)

This section describes the diameter measurement station. In figure 5 the setup of the DMS station is illustrated schematically. Three inductive sensors and two motors are used in this station. The sensors are on as soon as they are in the same height with a metal plate. The ball diameter is measured in terms of time.

Initially the lower plate of the bar driven by the stepper motor is at the level of the sensor at bottom and hence the sensorBottom is on. When the ball enters the DMS section the stepper motor moves the ball upwards. The sliding frame is pushed upwards until the sensorMeasure is turned on by the upper plate of the sliding frame. The time elapsed from the start of the stepper motor's operation to the instance when sensorMeasure is on should be assigned as the diameter of the ball. As soon as the sensorMeasure is on stepper motor moves downwards until the sensorBottom is on again. When the sensorBottom is on the ball is ejected by the ejection motor. SensorTop is used to stop the stepper motor in case it moves upwards without a ball.

In order to take correct measurements, the motor must always be switched off when the sensorBottom is on. Tables 4 and 5 illustrate the relationship between sensor and actuators signals of Chügelimat and the corresponding Stateflow variables.

Ejection out of the diameter measurement station is allowed, when:

  1. a ball is in the diameter measurement station,
  2. the sensorBottom is on and
  3. there is no ball in the balance area.

Hint: You should introduce a variable to determine if there is a ball in the balance section, which may be set to 1 if there is a ball and reset to 0 if there is no ball.

Figure 5: Side view of the diameter measurement station
SensorsStateflow VariableComments
SensorBottomsensorBottomActivated when a metal plate is detected
SensorTopsensorTopActivated when a metal plate is detected
SensorMeasuresensorMeasureActivated when a metal plate is detected
DiameterdiameterThe time elapsed from the start of the motor's upwards motion until the sensorMeasure is on should be assigned as the diameter of the ball

Table 4: Sensors of DMS Station

ActuatorsStateflow VariableComments
Ejector DMSejectDMSActivation causes the ball to be ejected.
Stepper motor on/offmotorEnable0 <=> motor off, 1 <=> motor on
Stepper motor directionmotorDirection0 <=> upwards, 1 <=> downwards

Table 5: Actuators of DMS Station

2.3  Balance

Here the weight of the ball is determined. The value can be read in by Stateflow via the "analog" variable weightMeasured.

Tables 6 and 7 illustrate the relationship between sensor and actuator signals of Chügelimat and the corresponding Stateflow variables.

SensorsStateflow VariableComments
WeightweightMeasuredThis analog input can be read in by Stateflow as soon as a ball is on the balance.
Table 6: Sensors of Balance
ActuatorsStateflow VariableComments
Ejector balanceejectBalanceActivation causes the ball to be ejected.

Table 7: Actuators of Balance

Ejecting a ball is allowed, when

  1. a ball is in the balance,
  2. the sorting transaction of the last ball is finished and
  3. the sorting flaps in the next section are set.

To fulfill the last two conditions the program has to communicate with the sort algorithms already implemented in Stateflow. This communication is treated in the next section.

3.  Interface to Chügelimat Framework

A part of the flow chart to control Chügelimat, containing the sorting and the balance sensor and stepper motor initialization algorithms is already prepared (see figure 6). For communication with the corresponding processes the following variables and events have been globally predefined in the Stateflow chart.

  1. setFlaps (event): Must be generated, as soon as the ball weight is determined. Required by the sort algorithm, i.e. initiates the setting of the sort flaps.
  2. flapsPositioned (event): Generated by the sort algorithm as soon as the sort flaps are positioned for a measured ball in the balance.
  3. diameter (variable): Diameter determined in the DMS station must be stored in this variable.
  4. weight (Variable): Weight determined in the balance must be stored in this variable.
Figure 6: Prepared framework in Stateflow with initialization and simple sort algorithms.

4.  Problem formulation

4.1  Homework

  1. Read the "Introduction to Stateflow". Users unpracticed in Simulink should read "Getting Started with Simulink" too.
  2. Make yourself familiar with the framework (see Figure 6). Try to understand the flow of a ball passing through Chügelimat (i.e. which signals occur, what commands must be generated). The framework can be downloaded from here.
  3. Sketch a possible state chart for control of the entrance, the diameter and the weight measurement. Consider the specifications in the previous chapters. Additional hints:
  • The three processes should run parallel.
  • Ensure that the sensorBottom is ON in the DMS station when a ball is rolling in (especially for the first ball).
  • Be careful to overwrite the values for diameter and weight of the old ball with the values of the new ball.
  • Use the variables and events defined in chapter 3 to communicate with the framework.
  • Stateflow syntax:
*Place conditions and comparisons on transitions
*Place assignments inside the states of the flow chart
The opposite is not implicitly prohibited but in practice causes errors.

4.2  Lab Practice

  1. Turn on the PC.
  2. Double click the desktop link called "Ifa 1.3 Chuegelimat". This will start Matlab, and download all the necessary framework files to C:/Scratch/Chuegelimat. Open the Simulink model "chuegelimat.mdl" which contains the control blocks. This is the file in which you will write your new control algorithms (beside the existing ones Sort/, Balanceinit/ and Motorinit). If Matlab crashes, run the script "Ifa 1.3 Chuegelimat restart" on your desktop.
  3. Before implementing your algorithm run the Simulink model "chuegelimat" to initialize the balance sensor and the stepper motor. TURN ON THE DAQ CARD BEFORE YOU RUN THE SIMULINK FILE "chuegelimat.mdl"!
  4. Implement your processes for the entrance, the diameter and the weight measurement. How to define new variables is described in the "Introduction to Stateflow". Build the model after each coded process to eliminate errors subsequently (how is described in the next point).
  5. While implementing your algorithm the stepper motor may get stuck, which may damage the motor severely. Whenever that happens you should run the Simulink file "initialize.mdl", which first brings the motor back to sensorBottom position and then stops it.
  6. Put different balls at the entrance of Chügelimat and check if they are sorted properly.
Page last modified on October 09, 2009, at 01:54 PM