híng dÉn ®äc toµn v¨n b¸o c¸o KQNC ! B¹n muèn ®äc nhanh nh÷ng th«ng tin cÇn thiÕt ? ! H∙y ®äc qua Môc lôc bªn tay tr¸i b¹n tríc khi ®äc b¸o c¸o ( víi Acrobat 4.0 trë lªn, cho trá chuét vµo mçi ®Ò môc ®Ó ®äc toµn bé dßng bÞ che khuÊt ) ! Chän ®Ò môc muèn ®äc vµ nh¸y chuét vµo ®ã ! B¹n muèn phãng to hay thu nhá trang b¸o c¸o trªn mµn h×nh ? ! Chän, nh¸y chuét vµo 1 trong 3 kÝch th thíc cã s½n trªn thanh Menu , hoÆc ! Më View trªn thanh Menu, Chän Zoom to ! Chän tû lÖ cã s½n trong hép kÝch th thíc muèn,, NhÊn OK hoÆc tù ®iÒn tû lÖ theo ý muèn Chóc b¹n hµi lßng víi nh÷ng th«ng tin ®®îc cung cÊp UNIVERSITÄT SIEGEN Institut für Embedded Systems Master Thesis Development and Realization of a distributed control algorithm for an inverted rotary pendulum using FreeRTOS with TTCAN communication Submitted by: Bui, Hoang Dung Matr.: 976477 Supervised by: Prof. Roman Obermaisser Dr.2014 Master Thesis’s Report Development and Realization of a distributed control algorithm for an inverted rotary pendulum using FreeRTOS with TTCAN communication i Table Content 1 Introduction.2 Master thesis objectives .3 2 Basic concepts and Related Works.1 The mechanical design .2 The results from the student work.1 Basic concepts in Embedded C .3 Pointer, Arrays and Structures .2 Used FreeRTOS Library Classes .4 CAN and Time Trigger CAN .1 Controller Area Network – CAN .2 Time Trigger CAN – TTCAN .5 AT90CAN128 Microcontroller .1 The specific knowledge about AT90CAN128.2 CAN Controller in AT90CAN128. 28 3 Modeling and Microcontroller’s Structures .1 The nonlinear IRP Model .2 Time Trigger Matrices.3 TTCAN_Scheduler Task and CAN ISR .1 Nonlinear IRP model.2 The common parts .1 Specific External Interrupt Service Routines .2 Data_Preparation() Task. 63 Data_Reception() Task.
63 LCD_Display() Task. 65 PWM_Calculation() Task. 65 PushedButton_Detection() Task.1 Timer/Counter 3 Compare Match Interrupts .2 DC-motor Control Tasks .1 The IRP parameters .3 PWM and Sampling frequencies. 77 5 Results and Discussion .1 The nonlinear IRP model behavior .2 The IRP machine Operation.1 Sampling and PWM frequency.
90 iii Chapter 1 Introduction 1 Introduction The Inverted Rotary Pendulum - IRP is a machine which is invented in 1992 by Katsuhisa Furuta. It contains a driven arm and a pendulum which is attached on the arm. Both the arm and pendulum can rotate freely in the horizontal and vertical plane respectively. In order to control the IRP, it is needed the cooperation of several different fields such as mechanics, control theory and microcontroller science.
From the mechanical field, the IRP is a machine which transmits the energy by an input – the DC-motor to control two rotations. In the control system theory’s view, the IRP is nonlinear system and only two states can be measured directly. From the microcontroller science side, microcontrollers should be fast enough to produce appropriate actions to response any variation of the IRP. The IRP is considered to work well if its pendulum can stays at upright position forever.
Therefore this project’s goal is step by step to find a solution which makes the IRP operating well in the specific requirements. In this chapter would give an overview idea about the real IRP machine, the master thesis goal in detail and the report’s structure.1Overview This master thesis project is the step to go further from the student work “Modeling and Simulation of an Inverted Rotary Pendulum” [Bui, 2013]. In the student work, the approximate linear model of the IRP had built. Moreover, the control theory which controls IRP had also established, it was State Space method.
That method was applied to the Simulink model then the model’s response was stable and worked at upright position. However, there are differences between the model and the machine. That is the built model was linear model whereas the machine contains nonlinear parts. That issue would be solved in this thesis.
Moreover, this project would go deeper to the control problem of the machine. The IRP machine is shown on the figure 1.1 the IRP Overview 1 Chapter 1 Introduction On the figure 1.1, the main parts of the IRP can be seen: the pendulum/mass M, the gearbox and DC-motor, belt transmission, the Frame, tow sensor and the foundation. The IRP movement begins from the DC-motor. The movement is transferred to the Frame via the gearbox and belt transmission.
When the Frame rotates, it makes the mass/pendulum swinging up to the upright position. The two movements which are measured by two encoders are the angle positions of the Frame and the mass M. The two measured angles are called Arm angle and Pendulum angle respectively. Signals from both encoders which are primitive processed by circuit 1 are sent to the integrated circuit 2.
The integrated circuit 2 is a compound circuit board which consists of four microcontrollers AT90CAN128 and several equipment such as a LCD DOGS102-6, pushed button matrix, LEDs, signal ports, fours PCA82C250, L6205D. The four microcontrollers process the data which are used to control DC-motor. The pushed button matrix and LCD DOGS102 are used to communicate with users (Human Machine Interface – HMI). The LCD shows the information of the IRP system.
The button matrix receives the commands from users then manipulates the state of the IRP system. Four PCA82C250s are the bridge between the CAN controller and the CAN Bus. The L6205D receives the signal PWM from I/O port of microcontroller and add more energy to control DC-motor directly. There are four microcontrollers used to control the IRP.
The first microcontroller detects the movements of Arm angle and Pendulum angle and transmits the new angles to other microcontroller. The second microcontroller displays all the IRP information on the LCD. The third one receives signal from the button matrix and control the IRP working or stopping. The last microcontroller controls the rotation of DC motor, thereby control the IRP movement.2 Master thesis objectives As mentioned earlier, this thesis is completed the work-in-progress from the student work.
The basic and critical duty is to write the codes for four microcontrollers to control the IRP machine working at upright position and is stable there. In order to implement that duty, some minimum objectives should be fulfilled. They are: - Build nonlinear model of IRP. - Define constraint times which can keep the system working stable.
- Handle with the sensor signal and the backlash. - Check capacity of Microcontrollers to meet the IRP control requirements. 2 Chapter 1 Introduction - Write the program to control the IRP working at upright position with the stability time about 5 seconds. As the basic objectives are completed, the master thesis goals are extended.
There are some extra parts which would be added to the system to make it friendly to human. The additional objectives are: - Establish two separate programs to control IRP in two phases: Swing up phase and Upright phase. - Human – Machine Interface (HMI): show IRP information on LCD, and some buttons to control IRP - Be able to change the reference input of arm angle. - Be able to transmit the signal of IRP angles to computer, and shown it graphically.
That is the objectives of this master thesis project. Subsequently, the report structure would be introduced.3 Report’s structure The report included six chapters. Chapter sequence was formed to assist reader in understanding step by step how the student’s work was implemented. Knowledge was presented in appropriate chapters and described how they can be applied to this specific IRP.
Chapter 1 presents general knowledge about IRP, objectives and report’s structure. Chapter 2 describes the related works and basic concepts which would be used to control the IRP machine. Chapter 3 introduces the designed work on each microcontroller. It starts with the general structures in the four microcontroller such as the Scheduler, the CAN message, TTCAN_Scheduler task and CAN ISR.
Then it works with the specific tasks which are for the specific microcontrollers. Chapter 4 would implement the design in the programming language. In this chapter, the description of the microcontroller structures are converted to the Embedded C, FreeRTOS code and they will actually control the IRP machine. It also describes the parameter estimation process.
Chapter 5 would present the results from chapter 4. The response in the nonlinear model and the IRP machine will be shown and discussed. The learned knowledge is also discussed here. Chapter 6 concludes about the master thesis project.
The achieved goals were reached in this work. In the end of the work, the declaration, reference and appendix – the program codes in detail of the former chapters are presented. 3 Chapter 1 Introduction The aforesaid information plays as a key role to assist readers in having an overview of this master thesis. The second chapter hereafter presents some basic concepts and related works regarding the IRP.
4 Chapter 2 Basic Concepts and Related Works 2 Basic concepts and Related Works This chapter presents the knowledge which is the foundation to develop the IRP operation. The first section of chapter would recall the related works, which are already completed and their results will be applied in this master thesis. The second section presents the basic concepts which are deployed to program the IRP control code such as Embedded C, FreeRTOS, TTCAN and AT90CAN128 microcontroller. Because of the enormous knowledge of those fields, only the specific knowledge will be introduced.1 Related Work In order to carry out the controlled works of IRP machine in upright position, that is obviously essential to have a foundation.
The first foundation is the existence of a real IRP machine, which is outlined the first chapter. The technical parameters, the engineering drawings would be described in detail in the section 2. The second foundation is the control theory, which is responsible to keep the mass of IRP machine at upright position. That theory was established in my student work [Bui, 2013], and was applied in the IRP model.
The response of that model was satisfied the control requirements in the response time and the stable. The key points of both foundations would be the following sections.1 The mechanical design This section presents the engineering draws of IRP machine’s structure. The overview of the IRP in design phase is shown in the figure below.1: The 3-D draw of the IRP 5 Chapter 2 Basic Concepts and Related Works In this draws the blue item represent for the DC-motor. The belt transmission and the bearing are missing.
From the 3-D view, it is projected in the front and top direction. The results are the top view and front view draws with more detail about the IRP. From the front view of the IRP, its height is 400 mm, the length is 350 mm and the width is 200 mm.2 Front view of the IRP Figure 2.3 Top view of the IRP The front view and the top view give the image of dimension of the IRP, the distance among components. It also gives a visual view of the mechanical structure about the machine.
Based on the dimension, the procurement of the components such as DC-motor, gearbox, belt transmission can perform to meet the requirements. The engineering draws then are sent to the mechanical shop, which is charge of the production and assembly the foundation and other components. 6 Chapter 2 Basic Concepts and Related Works 2.2 The results from the student work The works which were accomplished in the student work would be recalled in this section. In the student work, the linear IRP model was built.
Moreover, the adequate control theory was also found that was State Space Control method. In this method, the system equations were set to become the equation system of the first order. The system states and inputs were set to be respective vectors.