Anda di halaman 1dari 3

Stateflow a Useful Tool for Developing New Logic Algorithms. Case Study: Building A State Machine for Windscreens.

Hardware System
Claudiu Munteanu, Gheorghe Livin and Constantin Nita
Department of Electrical Engineering Technical University of Iai 700050, Iai, Romania E-mail: clau_matrix_00@yahoo.com The chart is only a for loop which search the source of interrupt. When the source is finding the interrupt event calls the subsystem function and inhibit the other subsystems. Because we always have a subsystem which is running forever (the counter subsystem) is necessary to enable two subsystems in the same time: the timer function and other called function. The pattern has in addition a default state when is no interrupt enabling and all subsystems are activated. In Fig. 2 we should see the behavior of ISR chart when PWM enable bit is activate.

Abstract This paper treads a case study about a windows power system. It reveals how Stateflow helps us to work with different s systems: in one hand with software systems and in the other hand with hardware systems. The model is made in Matlab/Simulink and this paper treats different methods to connect matlab language with C and C++ programming language. It includes some charts like: Interrupt Service Routine chart, Interrupt Priority chart. It is necessary to have some knowledge about programming knowledge and V-cycle. Keywords Interrupt Service Routine, Interrupt Priority, Input-Output, Output Compare, Input Capture, C++.

I. INTRODUCTION The bit information is transmitted throughout bus signal which has many branches: Interrupt Service Routine (ISR) bus, Interrupt Priority (IP) bus, Timer bus, Input-Output bus, Input Capture bus, Output Compare bus, Pulse Width Modulation (PWM) bus. The ISR signal is converted into an array ant than enters into a chart. The ISR chart controls the interrupt of every peripheral module. This action is depicted in Fig. 1 as we see.

Figure 2. ISR chart

The Interrupt Priority function is built in Stateflow either and is formed from a three state subchart wich call a graphical function. The last mentioned part is in fact a for loop pattern which is ment to find if the priority has level one or two. The default interrupt for single interrupt has default number four priority level. If the number sets in bit field is greater than four and smaller than seven then the source of interrupt has level two of interruption. In the same the algorithm support two source of interruption with different level of interruption. The system doesn`t support three or a greater number of sources of interruption and nor two source of interruption which has the same level.
Figure 1. Microcontroller Architecture

and the graphic is showed in the Simulink timer scope ( Fig. 5)

Figure 3. IP chart

The timer subsystem is built from a chart with two states which represents the functionality modes: saw mode and updown counter. Every mode is implemented with a time function named tick. For example if we use the saw teeth we increment by one to threshold and then we pass to the other state and initialize the increment in zero. We detach his functonality if we take a view of the Fig. 4.

Figure 5. Counter scope

II. VEHICLE MODEL The implementation of chart system is depicted in the following picture (Fig. 6).

Figure 4. Counter chart

Figure 6. Window chart

The saw and up-down mod are made in m file and are enumerate classes. The connection between m file and Simulink environment is doing with an interface class. This is a useful usage of this method because we totally read easier and understand faster his functionality. In the same the timer function is used as system clock and his purpose is to drive all peripheral. If we enable the bit field mode of timer with one we choose in fact the saw mode

There are four states which representing the four windows and every state has two states: one state is no acting state which is default and the other state calls an m-function. In m-function is programmatically developed up and down states. In addition the chart has two states: parent control and if the sensor detects an object the chart commands the actuator to retract the window.

The model itself is made to be a test bench because it contains in the same environment the software and the hardware. We could test the code in a test software tool or we can make different test charts to view the reaction of our ANSI-C chart, Microcontroller charts and windows chart. For verification faze we only have to change the embedded m-file function with C/C++ function and then to simulate to see if the behavior of the exchanged model is the same with the initial model.

The C++ class is depicted in above picture (Fig. 7). It is no need to generate code because we already develop and integrate the code into Stateflow. III. CONCLUSIONS Stateflow is a great environment to develop and research new methods of testing, modeling and to simulate because it can interacts with C and C++ programming languages. Stateflow represents a good way for debugging and offer in the same time a good prediction of the system behavior. Is an easy way to predict next state and supports trigger events, embedded m-function, graphical functions, truth tables, Simulink functions and so on. I want to improve the microcontroller subsystem by adding new peripheral and to add a stack pointer, a memory subsystem or even a CPU. REFERENCES
[1] [2] [3] [4] MATLAB Stateflow Toolbox Users Guide [Online]. MATLAB SimDriveline Users Guide [Online]. www.mathworks.com http://ocw.mit.edu/courses/

Figure 7. C++ class window

Anda mungkin juga menyukai