a general interface for computer control in real...

83
2005:E01 2005-06-03 Department of Technology, Mathematics and Comcuuter Science A general interface for computer control in real time Ulla Carlsson DI02

Upload: others

Post on 23-Mar-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

2005:E01 2005-06-03

Dep

artm

ent o

f Tec

hnol

ogy,

Mat

hem

atic

s an

d C

omcu

uter

Sci

ence

A general interface for computer control in real time

Ulla Carlsson DI02

Page 2: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

DEGREE PROJECT

A general interface for computer control in real time Ulla Carlsson DI02

Summary This degree project completes a degree at the University of Trollhättan/Uddevalla, Department of Technology, Mathematics and Computer Science. The study program is Computer Engineering, Industrial IT.

The degree project is about communication between a PC (Personal Computer), a general purpose box and a pendulum system. The most important task in this project is to get the different parts to communicate between each other.

The general purpose box is built in a pre project, the communication between the general purpose box and a PC is solved. The programming is made in C for the AVRX real-time kernel environment. A literature study is done about the LQG-control with a Kalman filter.

Publisher: University of Trollhättan/Uddevalla, Department of Technology, Mathematics and Computer Science, Box 957, S-461 29 Trollhättan, SWEDEN Phone: + 46 520 47 50 00 Fax: + 46 520 47 50 99 Web: www.htu.se

Examiner: Doctor Anna-Karin Christiansson Advisor: Anna-Karin Christiansson, Hans Dahlin, HTU Subject: Computer Engineering, Industrial IT Language: English Level: Advanced Credits: 10 Swedish, 15 ECTS credits Number: 2005:E01 Date: June 3, 2005 Keywords Pendulum system, communication, real-in- time programming, task, LQG-control

i

Page 3: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

Preface I would like to thank everyone who helped or encouraged me through the project and under my education. Especially to Anna-Karin Christiansson for her support and help. Hans Dahlin for that I could share his hardware knowledge and life experience. Fredrik Danielsson and Mattias Ottosson for help with the C code. Christer Selvefors for using his scanning eyes to help me find the problem in the C code and the knowledge how to program he teach me in the JAVA course. I also will thank Lena Esser and Fredrik Gustavsson for their encourage.

A special thank to my husband Lars and my children Caroline and Hampus for their patience with me through my education.

ii

Page 4: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

Contents

Summary.............................................................................................................................i Preface .............................................................................................................................. ii 1 Introduction...................................................................................................................1

1.1 Purpose and Aim....................................................................................................1 1.2 Background............................................................................................................1 1.3 Delimitation ...........................................................................................................1 1.4 Software .................................................................................................................2 1.5 Hardware...............................................................................................................3

2 Hardware description....................................................................................................4 2.1.1 The Sensor HEDS-9100...................................................................................................... 4 2.1.2 Sensor for the Pendulum Arms Angle................................................................................. 5 2.1.3 Cart Position Sensor............................................................................................................ 5 2.1.4 Facts on the Cart and Pendulum Arms Encoder.................................................................. 5 2.1.5 Program Code for Reading the Encoders ............................................................................ 7

3 Communication between the System Parts...................................................................9 3.1 Initializing the Environments for Communication ..............................................10 3.2 Programming Real Time Application..................................................................10

3.2.1 Main Function ................................................................................................................... 11 3.2.2 Task1, Testing the DC-Motor ........................................................................................... 11 3.2.3 Task2, Reading the Encoders ............................................................................................ 12 3.2.4 Task3, The Communication .............................................................................................. 12

4 Control Design............................................................................................................12 4.1 Linear Quadratic Control....................................................................................12 4.2 The Pendulum System ..........................................................................................13 4.3 The Mathematic Model of the Pendulum System.................................................13 4.4 The Model used in Simulink.................................................................................14 4.5 Kalman Filter.......................................................................................................14

5 Result ..........................................................................................................................15 5.1 Result from the Communication Part ..................................................................15

5.1.1 Reading the Sensor Code .................................................................................................. 15 5.1.2 The Connection between Microcontroller Unit and HyperTerminal ................................ 15 5.1.3 Reading the Register and Write the Result in MATLAB.................................................. 15 5.1.4 Read Encoder and Control the Cart Movement ................................................................ 16 5.1.5 Summary of result ............................................................................................................. 16

6 Conclusions.................................................................................................................16 6.1 Recommendation for Possible Further Work ......................................................16

7 Personal Reflection .....................................................................................................17

Appendices

A Program Code for the microcontrol unit B MATLAB code C Flow Chart Task2 D User Guide about the Programming Environment E The General Purpose Box

iii

Page 5: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

Figure Figure 1 Parts of the Feedback hardware for the Pendulum system. ............................... 3 Figure 2 Principle for the encoder HEDS-9100, see appendix E. ................................... 5 Figure 3 The four states the channels could have............................................................. 7 Figure 4 The output of an encoder consists two signals denoted A and B, one shifted 90º

(electrical degrees) with respect to the other. ........................................................... 8 Figure 5 Block diagram of the communication between the system parts....................... 9 Figure 6 Communication between PC and general purpose box through the com port... 9Figure 7 Model of the pendulum system (Source electronic, see ref [2]). ..................... 13 Figure 8 Simulink model of the pendulum system in (2), see the UMICH homepage for

details...................................................................................................................... 14

Table Table1 Explanation of the relation between cycle, shaft rotation, electrical or

mechanical degree and bar or window pair. ............................................................. 5 Table 2 Translation between the value in the register for the angle from the

pendulumarm sensor and the cart movement from the motor sensor....................... 6 Table 3 The chosen parameters for initializing the communication port. ...................... 10 Table 4 Port configuration for the Atmega16 microcontroller unit................................ 11

iv

Page 6: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

List of symbols

AVRX – Program from the company Atmel, used to program in real time.

CPR - Counts Per Revolution

DIP - Dual In line Package

HTU - The University of Trollhättan/Uddevalla

IO – In and Out

LED - Light Emitting Diode

MCU - Micro Controller Unit

PC - Personal Computer

PCI - Peripheral Component Interconnect

UDR – Universal Data Register

USART – Universal Synchronous and Asynchronous Receiver and Transmitter

v

Page 7: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

1 Introduction This degree project completes a degree at the University of Trollhättan/Uddevalla, Department of Technology, Mathematics and Computer Science. The study program is Computer Engineering, Industrial IT.

1.1 Purpose and Aim The degree project is about communication between a PC (Personal Computer), a general purpose box and a pendulum system. The aim is to increase the knowledge of controlling a real system using modern tools. The most important task in this project is to get the different parts to communicate between each other.

1.2 Background The University of Trollhättan/Uddevalla (HTU) has since long an inverted pendulum system. The hardware and software used for this pendulum system is too old for efficient use with modern computers. The intention from the school is to replace these. The new hardware should also be able to work together with other equipment. The new box should be more general than the old one. The development of the general purpose box started in a project course as a preparation for the degree project. The general hardware box contains a MCU (Micro Controller Unit) with its driver circuits, and the intention is to use this instead of a PCI (Peripheral Component Interconnect) card connected to the PC. This makes the box movable between different PCs. The microcontroller unit will take care of the communication between the PC and the pendulum system. The box also includes a power supply, see appendix E. The old system has many functions, a crane system demonstration and an inverted pendulum demonstration. The new system should also have these functions, but for this degree project, the aim is at least to have a working crane system.

1.3 Delimitation The software program MATLAB with Simulink, see 1.4, is the program that should control the pendulum system. A linear quadratic regulator with a Kalman filter should be as controller. The communication should be able to solve with standard serial port IO commands from MATLAB.

1

Page 8: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

1.4 Software Software used in the degree project.

• Microsoft® Word 2002 is used to write the degree project report.

• MATLAB 6.5 version 13 is used for communication, simulation and modelling with

Control System Toolbox, version 5.2

Simulink version 5.0

• Programmers Notepad version 2.0.5.18-mingus is used to create the C-code.

• AVR® studio 4.0 is the environment for the program code used for programming an Atmel microcontroller unit ATmega16.

• AVR®-GCC 2.97 is the compiler used.

• AVRX version 2.6e is used for real in time programming

2

Page 9: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

1.5 Hardware Under the development phase the starter kit STK500 [10] has been used instead of a built in microprocessor for testing the programming of the microcontroller unit. In addition, a developer’s box (HTU) with DIP-switches (Dual In line Package, a series of tiny switches built into socket) and LED (Light Emitting Diode) have been used for different tests.

The pendulum system, see figure 1, from the company FEEDBACK [11] consists of:

• A cart with two hanging pendulum arms and a rail for the cart with a driving belt.

• A 24 [V] DC-motor for driving the belt for the cart on a rail.

• Two Incremental Optical Encoders, one for the cart location and the other for the pendulum arm angle.

• A hardware box, which will be replaced by a general purpose box, see appendix E.

Figure 1 Parts of the Feedback hardware for the Pendulum system.

Documentation about the inverted pendulum, see FEEDBACK documentation [11].

DC-motor Cart

Pendulum arms

Angle θ

Rotating wheel Driving belt

Rail

3

Page 10: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

2 Hardware description A description about the hardware used in this degree project see appendix E. The theory about how and what to know about the sensor HED-9100 is described below.

2.1.1 The Sensor HEDS-9100

Picture 1 The picture is from the cart showing the sensor with a codewheel assembled to the pendulum arms axis.

There are two optical incremental encoders, HEDS-9100A00 used with a codewheel for measuring angles. These modules detect rotary position. The modules consist of an emitter section and a detector section. Such encoders are often used in printers, plotters and factory automation equipment. They are not recommended for use in applications that are safety critical as ABS (Automatic Braking Systems) applications, life support systems and power steering. One of the encoders is indicating the cart position and the other the pendulum angle, see appendix E. Each optical sensor has an encoder with two digital channel outputs (channel A and channel B) and a single 5 [V] supply input accessed through five pins. Through the emitter section and detector section rotates the codewheel, see figure 2. The codewheel is a silver coloured plate marked with equally spaced bars or window pairs in two layers. When the codewheel moves, each bar in turn breaks a light beam, and the resulting pulses are counted. See figure 2. An incremental

4

Page 11: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

or relative encoder measures the distance of the movement. Therefore, it is important to note the start value of the position of the codewheel.

Figure 2 Principle for the encoder HEDS-9100, see appendix E.

2.1.2 Sensor for the Pendulum Arms Angle

The pendulum sensor reads the relative angular distance that the arm has moved since the encoder was reset. The sensor is assembled inside the cart and its output is available at a flat wire cable connected to the general purpose box.

2.1.3 Cart Position Sensor

The cart position sensor, assembled to the DC-motor axis, reads the distance that the cart has moved since the encoder was reset. The sensor is assembled to the motor axis and its output is available at a flat wire cable connected to the general purpose box.

2.1.4 Facts on the Cart and Pendulum Arms Encoder

The codewheels have 512 counts per revolution (CPR) or number of bar and window pairs. Table 1 explains the relation between cycle, shaft rotation, electrical or mechanical degree and bar or window pair.

Table 1 Explanation of the relation between cycle, shaft rotation, electrical or mechanical degree and bar or window pair.

Cycle Shaft rotation Electrical/mechanical degree Bar or window pair

1 360 electrical º 1

512 1 360 mechanical º 512

5

Page 12: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

One cycle has four states depending on the A and B channels: 00, 01, 11 and 10. The first position represents channel B and the second channel A. When value 01, channel B is low and has the value 0 and channel A is high and has the value 1. In program code, see appendix A, a register pendelA (pendulum angle) and motorA (cart position) are increased or decreased ones per cycle. The different registers used in program code are explained below. By manually rotating the pendulum arms 180º (mechanical degrees) the changes of the pendulum register pendelA or motorA were displayed on the LEDs on the additional developer’s box. The result 180º was equivalent to the value 256 in the register. The same type of test was made for the cart position sensor by turning round the driving wheel and measuring the movement. The result 0,16 [m] was equivalent to the value 512 in the register. Data useful for the calculating part of the system see table 2. It is a translation for the cart movement against the value in the register and also the pendulumarms movement.

Table 2 Translation between the value in the register for the angle from the pendulumarm sensor and the cart movement from the motor sensor.

Value of the register Angle [º] Length [m]

pendelA: 1 0,703

motorA: 1 3,1 10-4

The angle resolution presented in equation (1) is if the program code is written such that every state change is increasing or decreasing in the register.

][00307,020482 rad≈=∆πϕ (1)

6

Page 13: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

2.1.5 Program Code for Reading the Encoders

BA=XX 00 Increasing

10 01

11 Decreasing

Figure 3 The four states the channels could have.

The program code for the encoders is written in the language C on the PC and loaded into the microcontroller unit, see appendix A. Channel B is the first digit and channel A is the second digit in the state description. It is the change of state for channel A (the programmers choice) that is used as indication of a rotation, see figure 3. If the value of channel A is one and it was zero before, then it is interesting to know the value of channel B. This indicates the move of the pendulum arm or the cart. A variable is increased or decreased in a register depending on from which direction the pendulum arms or the cart comes. If the pendulum arms or the cart moves anticlockwise, the state changes from 00 to 11, passing through 10 then ”channel B is in lead” and the register is decreased. The opposite situation, clockwise, passing through 01 “channel A is in lead” and the register is increased, see figure 4. The text ‘Encoder moves right to left’ in figure 4 means an anticlockwise rotation and ‘Encoder moves left to right’ a clockwise rotation.

7

Page 14: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

Figure 4 The output of an encoder consists two signals denoted A and B, one shifted 90º (electrical degrees) with respect to the other.

Example of how the program code for determining how to handle the registers. Following names are used in the program code for the different registers:

Value reads from the sensors: pendel and motor.

The old value from the sensor saved in this register: opendel and omotor.

The registers that will be increased or decreased depending of the situation: pendelA and motorA.

if (motor = = 0x00) // If channel A and B is 00

if (omotor = = 0x20) // If the old value was 10

++motorA; // Increase motorA register

else if (omotor == 0x10) // If the old value was 01

--motorA; // else decrease motorA register

omotor = motor; // Remember the old value

8

Page 15: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

3 Communication between the System Parts The communication between the system parts are shown in figure 5.

General purpose box with the mcu Atmega16

Dc-motor OUT

Figure 5 Block diagram of the communication between the system parts.

The communication between the PC and the general purpose box (RXD and TXD) is through the microcontroller unit ATmega16 see appendix E with a RS232D port with a 9-pin socket, see ref. [6]. The American standard EIA-232D consists of Std ISO2110, instructions V.28 and V.24. ISO2110 describes the configuration of the 25-pin socket (DB-25). In this project, the DB-9 socket is used. V.28 defines voltage, current and resistance and V.24 defines the way circuits are set up for an interface between computers or other terminal equipment and data communications equipment.

The standardized method of sharing data USART (Universal Synchronous and Asynchronous Receiver and Transmitter) inbuilt in the microcontroller unit is used for the serial communication, see ref [7].

The MATLAB program in the PC, see appendix B, will use the information about the actual data from the encoders handled by the microcontroller unit, for calculating how the system should behave as inputs to the controller. This is done with the serial communication port. See figure 6.

Figure 6 Communication between PC and general purpose box through the com port.

PC with MATLAB and HyperTerminal

RXD

Sensors TXD IN

PC General purpose box

Atmega16 MATLAB Com1 Com1

9

Page 16: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

3.1 Initializing the Environments for Communication There is some initializing to do before it is possible to use the com port for communication between the PC and the general purpose box. This configuration should be identical for the serial port in MATLAB, the hardware file for the microcontroller unit and the port configuration for the PC. In this work, the communication parameters are chosen as in Table 3.

Table 3 The chosen parameters for initializing the communication port.

Baud rate / bits per second 19200

Data bits 8

Parity None

Stop bit 1

Flow control None

The microcontroller unit clock frequency is initialized to 8 [MHz].

3.2 Programming Real Time Application Programming for real time applications implies that a couple of processes are to run, as it looks like, at the same time, see ref [8]. However, since a simple microcontroller unit cannot work in real “real-time” or as a PC, the software AVRX solves this problem by using the Round Robin principle, see ref [8]. AVRX software supports ready-made functions to use as a timer delay, interrupts etc, see ref [12]. Three tasks are used in this project, Task1 Testing the DC-motor, Task2 Running the encoders and Task3 The communication. They run simultaneously in this application. The different tasks are running one at a time. After a while an interrupt occurs when a delay routine is running checking if a new task is waiting in the queue. This is the way for changing between the tasks. When a new interrupt appears, the information from the running task is stored on the stack, while the new task fetches its former information from the stack. This principle makes it possible to do many different things “simultaneously” on the microcontroller unit. This will not delay the process if something is waiting for an event. It is also possible to use priority but in this case, the three tasks are given the same priority. In this work, Task1 was used for manual setting the speed for the DC- motor using DIP-switches. Task2 was reading the sensors and Task3 was handling the communication part. See appendix D for a simple user guide about the programming environment.

10

Page 17: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

3.2.1 Main Function

The main function initializes the ports and their registers, the stack, allowed sleeping mode and sets timer interrupt. The function AvrXRunTask that starts up the tasks is also placed in the main function. PortA and PortB are used in the development phase and are thereafter free to be used for other things. See Table 4 for disposition of the microcontroller unit ports. If the development box (HTU’s own) not is used, then it is necessary to examine how PortD pin 0 and 1 should be configured depending of which hardware is used.

PortB is used under the development phase to display the value in the register on the LEDs. This is a way to see if the processes work as specified. When for example the pendulum arms stop moving, the LEDs should stop at the correct value. Table 4 shows how the port configuration is set up for the Atmega16 microcontroller unit. Inport is the same as input and outport is the same as output. These words are common for the microcontroller language.

Table 4 Port configuration for the Atmega16 microcontroller unit.

Port configuration Pin configuration Used for

PortA Pin 0 – 7, inport Under the development phase used for manual control of the motor speed

PortB Pin 0 – 7 ,outport Under the development phase used for the LED’s

PortC Pin 0 – 7, outport Voltage to the DC-motor

PortD Pin0, inport

Pin1, outport

Pin4, inport

Pin5, inport

Pin6, inport

Pin7, inport

USART, RXD

“ , TXD

Pend. sensor Channel A

“ “ “ B

Motor “ “ A

“ “ “ B

3.2.2 Task1, Testing the DC-Motor

This task was used for testing that the general purpose box could give the motor enough voltage to drive the cart forwards and backwards. Se appendix A and the comments what happened during the test.

11

Page 18: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

3.2.3 Task2, Reading the Encoders

See flowchart appendix C. Task2 will take care of the encoder information. The code first reads the value of the pins, masks the results for the cart sensor and stores it in the motor variable. Then a comparison is done, and after finding the right condition the specified action is performed. The same procedure applies for the pendulum arms sensor. See appendix A and the comments about the code.

3.2.4 Task3, The Communication

Task3 will take care of the communication part. The function read_USART is waiting until something appears in a register UDR (Univeral Data Register). In this project a code is written in MATLAB that sends the action to the UDR register through the com port. A character or a character with a numeric value will sometimes come from MATLAB, depending on what the specified action demands. See appendix A.

4 Control Design The control design is important in the development phase. A good control design demands a good mathematic model of the system, see any basic textbook on control design, e.g. [5].

4.1 Linear Quadratic Control A Linear Quadratic (LQ) control was developed by the space industries in the United States and of the Soviet Union in the 1960s to solve space related control problems. The Linear Quadratic Gaussian (LQG) control design method is optimized to reject white noise disturbance (Gaussian) at plant input and for measurements. It is a design method that simultaneously can take into consideration not only one plant input and output, but several, see [3], [4].

In order to make such a design it is of great importance to have a really good linear mathematical model of the plant at the operating point. For nonlinear plants it is therefore important to linearise the model. These details have not been in focus in this project. In cases where it is not possible to direct measure the state variables for the feedback they must be estimated in some way. Here the Kalman filter is the most well known, see brief information in next section.

12

Page 19: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

4.2 The Pendulum System The theory about the pendulum system is a well-known education example in control applications. There are many different types of a pendulum system studied: inverted pendulum, double arm inverted pendulum, as a traverse crane etc, see e.g. [3], [4] and [5]. For most applications, the control principle does not emphasize on how much the cart is moving but that the pendulum arms should be as still as possible in a down hanging position, the angle θ = 0 [rad] for the crane, and in upright position, the angle θ = π [rad] for the inverted pendulum.

4.3 The Mathematic Model of the Pendulum System The mathematical model is taken from UMICH (University of Michigan) Control Tutorials for MATLAB and Simulink, see ref [2]. The state variable for the model are cart position, cart velocity, the pendulum angle and its angular velocity, see figure 7.

Figure 7 Model of the pendulum system (Source electronic, see ref [2]).

Summing the forces of the cart in the horizontal direction, the result will be the following equation of motion:

(2)

For details, see ref [2].

13

Page 20: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

4.4 The Model used in Simulink Figure 8 display how the model is built in Simulink.

Figure 8 Simulink model of the pendulum system in (2), see the UMICH homepage for details.

4.5 Kalman Filter The Kalman filter, published by R.E. Kalman 1960, is a recursive solution to the discrete-time linear filtering problem. It is the optimal linear estimator. Peter S Maybeck see ref [9] writes there are many ways of defining optimal:

With respect to virtually any criterion that makes sense.

Incorporates all information than can be provided to it.

Processes all available measurements, regardless of their precision and estimate the current value of the variables of interest.

14

Page 21: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

5 Result All different communication parts, see figure 6, have been tested and work. The tests have been done in small steps so it should be possible to identify if there are any problems.

The communication between Simulink and the microcontroller unit does not work. It was not enough with time left for this part of the project.

5.1 Result from the Communication Part The communication between the PC, the general purpose box with a microcontroller unit, the DC-motor and the sensors have been tested. The part between the microcontroller unit and the pendulum hardware works both reading the cart sensor and the pendulum arms sensor. Driving the cart from the microcontroller also works without problem. The communication part between the microcontroller unit and the PC both tested with the HyperTerminal and MATLAB, have some problems when more than one task is running. The experience from the test phase is that there is some delay problem in the system. Handling both the communication part and reading the encoders in the microcontroller unit takes too long time.

5.1.1 Reading the Sensor Code

To check the code written for Task2, reading the sensors, the result from the register was sent out to the LED’s, see appendix A for code and appendix C for flowchart. This works without problems for both the pendulum arm and cart. The value in the register is shown on the LED’s. When the movement of the pendulum arms or the cart stops the LED’s also stop changing values.

5.1.2 The Connection between Microcontroller Unit and HyperTerminal Check of the connection between the microcontroller unit and the Microsoft inbuilt HyperTerminal in the PC is made with a C-program in the microcontroller unit, see appendix A Task3. An IF loop was written for the test. When the HyperTerminal sent an ‘a’ to the microcontroller unit, the microcontroller unit sends back an “A”. This part also works without problem.

5.1.3 Reading the Register and Write the Result in MATLAB

This test reads the value from the registers in the microcontroller unit to be displayed in MATLAB. See appendix A Task3.

First there were problems, the same value was written to MATLAB too often. A “sniffing” cable, connected to the cable from the microcontroller unit and the RS232 connection on the PC, was used to detect the traffic on the serial communication.

15

Page 22: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

It looks strange, after some hours of fault detecting, with help from the sniffing cable the reason was found. The problem was in the C-code. The old parameter value was initiated inside the while loop, which was wrong. After changing the code it worked when initiating in the main loop. This was the first time the delay problem appeared. If everything works, the register value should be written on the HyperTerminal like 4, 5, 6, 7, 6, 5, 4 and so on. However, this was written as 4, 5, 7, 3, 2, 1. Probably the reason for the problem is in AVRX where it needs to be a delay before switching tasks. The minimum of this delay time is 1 [ms]. The conclusion to this wasn’t solved.

5.1.4 Read Encoder and Control the Cart Movement This was the test to check the possibility to control the microcontroller unit from MATLAB. When coming to this point it was no time left of the project.

5.1.5 Summary of result

The aim with the degree project to solve the communication part of the system is working. The encoder information interpretation and how to translate the value in the register to measurable value to use in MATLAB is solved. How to handle the value in MATLAB and to send it back to the pendulum system correctly is not solved. The control of the pendulum system is also left to another student. There is not a working system done in Simulink.

6 Conclusions The conclusion from this project is that a general interface for computer control of arbitrary processes from a PC is working.

6.1 Recommendation for Possible Further Work Investigate software for programming in real time. Maybe AVRX is not the optimal software for the pendulum system.

A strategy for the pendulum system could be to use LQG-control with a Kalmanfilter to solve the control problems with the system.

The communication causes some delay problems. A solution in future project could be to use more than one microcontroller unit. Then let one of them work as the communication master ant the other to take care of reading the encoders, drive the DC-motor and drive a LCD (Liquid Crystal Display) with information about for example the temperature, angle position etc.

16

Page 23: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

7 Personal Reflection Finally the degree project ended up happily. The main goal to get the communication between the general hardware, sensors, microcontroller unit and the software MATLAB in a PC is solved. Unfortunately I started with the simulating part of the LQG-control of the pendulum system. With result in my hand; the communication part should have been solved first. Ten weeks is not so long time.

The good thing from this project is the experience of identification of a system. In the real world, simulation works fine but when the hardware is connected then a lot of problems appear. I really had learned a lot about hardware and communication but not so much about controlling as I thought from the beginning. I had read about the Kalman filter, different Linear Quadratic regulators and almost the whole help about serial communication and Simulink in MATLAB. My practice in the English language has increased.

17

Page 24: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time

References

1. Schmithbaur, Bengt (1999) Modellbaserade reglersystem. Lund: Studentlitteratur

2. University of Michigan (1997). Control Turtorials for Matlab. Example: Modelling an Inverted pendulum. [Electronic] Michigan: Univeristy of Michigan. Accessible: www.engin.umich.edu/group/ctm/examples/pend/invpen.html [2005-05-05]

3. Gopal, M (1993) Modern control system theory, second edition. New Delhi, India: Wiley Eastern Limited

4. Ogata, Katsuhiko (1997) Modern Control engineering. Upper Saddle River: Prentice-Hall, Inc

5. Lennartson, Bengt (2002) Reglerteknikens grunder, fjärde upplagan. Lund: Studentlitteratur

6. Jensen, Stig mfl. (2000) Data Kommunikation. Stockholm: Liber

7. Morton, John (2002) AVR An Introductory Course. Oxford: Newnes

8. Norström, Christer et al. 2000-08-18. Robusta realtidssystem Kompendium Version: rts-bok00-11

9. Maybeck, Peter S. (1979) Stochastic models, estimation and control. New York, San Francisco, London: Academic Press

Unknown references and manuals:

10. Atmel User Guide AVR® STK500 ,manual belong to the starter kit borrowed from HTU.

11. Feedback documentation. A manual for the old pendulum system from the company FEEDBACK stored in a binder at HTU.

12. Course RMB010 given at HTU spring 2004: Realtidsprogrammering 5 poäng.

18

Page 25: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

A Program Code for the microcontrol unit /*Program till kommunikationen mellan mikrodator och motor och Pc 2005-05-11 Måste kolla om varianten av myprocessor styr SIG_UART eftersom det heter USART och inte UART eller om det var så att det är AVRX egen definition DETTA SÅG UT ATT FUNGERAR ÄVEN FÖR ATMEGA16!! 2005-05-18 I task 2 lägger till om givarna alltså avläsning av dessa. Det fung. till slut. Vet ej om värdet i reg är rätt men det är en annan sak.... dvs skjut på problemen 2005-05-19 I Task 3 lägger jag kommunikationen mot hyperterminalen som får fungera som Matlab, jag vill att när skickar ett kommando till mikrodatorn så ska md skicka tillbaka antingen reg för pendelgivaren eller motorgivaren. Använder USART för överföringen av informationen. Fungerade!!! 2005-05-27 Fick hjälp med granskning av koden. Christer Selvefors, han hittade att jag init omotor på fel ställe vilket gjorde att samma värde kom väldigt många gånger. Fredrik Danielsson löste mitt fel med att jag inte fick in ett värde till att styra motor, jag läste bara in c och inte efter följande värde....illa..... Under test perioden: Förklaringar till Portarna: Port B=LEDS, används till kontrollbit, utgång på lådan4 Port C=MOTOR, används till styrning av motor direktkopplad till utrustn. Port A=LÄSA AV DIPPAR, används till farten till motorn, utgång5 på lådan Port D=LÄSA AV GIV + RXD OCH TXD,används till avläsn. direktkopplad till utrustn.*/ // Inkluderingar, definitioner och annat allmänt #include <C:/WinAVR/avr/include/avr/io.h> #include <c:/avrx/avrx/avrx-io.h> #include <c:/avrx/avrx/avrx-signal.h> #include <c:/avrx/avrx/Avrx.h> #include <stdlib.h> #include "hardware.h" AVRX_MUTEX(ReadReady); // AvrX Semaphore låser läsafunktionen RXC AVRX_MUTEX(WriteReady); // AvrX Semaphore låser skrivfunktionen TXC

AVRX_MUTEX(SerialTransmitMutex); // Tillåter delad användning av skriva funktionen

AVRX_GCC_TASK(task1,70,3); // Task1,2,3 deklareras

med stackstorlek 70 bytes och prio 3

AVRX_GCC_TASK(task2,70,3); AVRX_GCC_TASK(task3,70,3);

Appendix A:1

Page 26: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

TimerControlBlock Timer1,Timer2,Timer3; // Timers som används just nu

// Globala variabler unsigned char RxByte; // Receive buffer. int i,temp=0; //variabl. för allt möjl. int stilla=128,styra=0,varde=0; // variabler för

styra,varde,stilla till motorn

int motorgivare=0,pendelgivare=0; // variabler för att ha koll på ursprungsläget

int motor=0,motorA=0,omotor=0,pendel=0,pendelA=0,opendel=0;

// Variabler för avläsning av givarna

AVRX_SIGINT(SIG_OVERFLOW0) // Avbrottsrutinen för

timer0, ska alltid vara med.

IntProlog(); // Byter till "kernel

stack/context" TCNT0 = TCNT0_INIT; // Nollställer "timer

owerflow" räknaren AvrXTimerHandler(); // Anropar Timer kö

manager Epilog(); // Återvänder till tasken AVRX_SIGINT(SIG_UART_DATA) // UART0 Transmit Buffer

Empty ISR ger en signal när UDR är tom

cbi(UCSRB, UDRIE); IntProlog(); // Byter till "kernel

stack/context" AvrXSetSemaphore(&WriteReady); // Signalerar att redo

för mera. Epilog(); // Återvänder till RTOS AVRX_SIGINT(SIG_UART_RECV) // UART0 mottager UDR cbi(UCSRB, RXCIE); IntProlog(); // Byter till "kernel

stack/context" RxByte = UDR; // Läser in informationen

från UDR AvrXSetSemaphore(&ReadReady); // Signalerar redo sbi(UCSRB, RXCIE); Epilog(); // Återvänder till RTOS void init_USART(void) // Initierar uarten

AvrXSetSemaphore(&SerialTransmitMutex); // Sätter startvärde på semaforen ledig

UBRRL = UBRR_INIT; // UART baudrate hastighet för överföring, satt till 19200

Appendix A:2

Page 27: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

UCSRB = 0xD8; // Sätter TXCIE och RXCIE interrupt enable och RXEN,TXEN enable 0b11011000

void write_USART(unsigned char data) // Skriver till UDR AvrXWaitSemaphore(&SerialTransmitMutex);

// väntar att semaforen ska vara ledig

if ((UCSRB&0x20)==0) // Tittar om UDRE biten i USR registet är noll, alltså mottaglig för påfyllning

sbi(UCSRB, UDRIE); AvrXWaitSemaphore(&WriteReady);

// Väntar på besked att UDR är tömd dvs redo att fyllas igen

UDR = data; // Lägger data i UDR AvrXSetSemaphore(&SerialTransmitMutex);

// Sätter startvärde på semaforen ledig

unsigned char read_USART(void) // Läser från UDRn AvrXWaitSemaphore(&ReadReady); // Väntar på att mottagar

interrupt ska signalera kör...

return(RxByte); // Returnerar det som finns i RxByte

NAKEDFUNC(task1) // Läser in fart från

dippar värde ut till motorn

while(1) // Körs i evigheter

// Testar att köra motorn fram och tillbaka, gjort om det från asm kod

varde = PINA; // Läser in värdet på

PortA, ska styra farten styra = stilla + varde; // Ökar 128-värde för att

gå framåt PORTC = styra; // Ut till motorn

AvrXDelay(&Timer1,500); // Kort tidsfördröjning 0,5s

styra = stilla - varde; // Minskar 128-värde för

att gå tillbaka PORTC = styra; // Ut till motorn AvrXDelay(&Timer1,500); // Kort tidsfördröjning

0,5s

Appendix A:3

Page 28: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

NAKEDFUNC(task2) // Läser in givare motorn och pendel

// Reg motor; läser in pinvärde // Reg omotor; innehåller det föregående inlästa värdet // Reg motorA; används som räkne, matlab hämtar givar värde från denna

while(1) // Körs i evigheter motor = PIND & 0x30; // Läser in värdet på

PortD till reg motor och maskar bit 4(A) och 5(B)

// MOTORGIVAREN Kollar när A är ett, om A var noll värdet innan då adderas eller subtraheras reg beroende på B if(motor == 0x00) // Om kanal A och B är 00 omotor = motor; // Värde läggs som minne

i register omotor else if(motor == 0x10) // Om kanal A och A är 01

if(omotor == 0x00) // Om det gamla värdet var 00

++motorA; // Öka motor A register omotor = motor; else if(motor == 0x20) // Annars är A och B 10 omotor = motor; else if(motor == 0x30) // Om kanal A och B är 11 if(omotor == 0x20) // Om det gamla värdet

var 10 --motorA; // minska motor A register omotor = motor; //PENDELGIVAREN Kollar när A är ett, om A var noll värdet innan då adderas eller subtraheras reg beroende på B // Reg pendel; läser in pinvärde

// Reg opendel; innehåller det föregående inlästa värdet // Reg pendelA; används som räkne, matlab hämtar givar värde från denna

pendel = PIND & 0xC0; // Läser in värdet på

PortD till reg pendel och maskar bit 6(A) och 7(B)

if(pendel == 0x00) // Om kanal A och B är 00

Appendix A:4

Page 29: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

opendel = pendel; else if(pendel == 0x40) // Om kanal A och B är 01

if(opendel == 0x00) // Om det gamla värdet var 00

++pendelA; // Öka motor A register opendel = pendel; else if(pendel == 0x80) // Annars A och B är 10 opendel = pendel; else if(pendel == 0xC0) // Om kanal A och B är 11

if(opendel == 0x80) // Om det gamla värdet var 10

--pendelA; // minska register opendel = pendel; //PORTB=motorA; AvrXDelay(&Timer2,1); // Kort tidsfördröj. 1ms NAKEDFUNC(task3) // Har koll på om en

instruktion kommer från hyperterminalen, utför rätt åtgärd

//Variant1 om den inte används så kommentera bort den while(1) // Körs i evigheter char buf[10]; // Initierar en buffert

för att läsa in från USART

int ii = 0; // Variabel while((buf[ii]=read_USART())=='\n') // Loopar tills

sluttecknet kommit = allt överskickat

if(ii>=sizeof(buf)) ii=0; //char info = read_USART(); // läser in if(buf[0] == 'a') // Om ett kommando kommer

från hyper utför order

write_USART(pendelA+48); write_USART(10); // lf

Appendix A:5

Page 30: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

else if(buf[0] == 'b') // Om ett kommando kommer från hyper utför order

write_USART(motorA+48); write_USART(10); // lf else if(buf[0] == 'c') // Ska läsa in värde från

matlab, ut till motor varde = atoi(buf); // Läser värde från matlab PORTB = varde; AvrXDelay(&Timer3,1); // Kort tidsfördröj. 1ms //Variant 2 om den inte används så kommentera bort den while(1) char buf[10]; // Initierar en buffert

för att läsa in från USART

int ii = 0; // Variabel while((buf[ii]=read_USART())=='\n') // Loopar tills

sluttecknet kommit, allt överskickat

if(ii>=sizeof(buf)) ii=0; switch(buf[0]) case 'a': // Skicka värdet av

pendelgivaren till matlab write_USART(pendelA+48); // Lagt

på 48 för att få ut ett ngl läsbart värde på hyperterm.

write_USART(10); // lf break; case 'b': // Skicka

värdet av motorgivaren till matlab

write_USART(motorA+48); write_USART(10); // lf break;

Appendix A:6

Page 31: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

case 'c': // Ut till motorn

varde = atoi(buf); //varde = atoi(buf[1]); // Måste

nog göra en loop här för att få ut rätt värde

PORTB = varde; // Hade för att kolla om det kom rätt värde

styra = stilla + varde; // Ökar 128-värde för att gå framåt

PORTC = styra; // Ut till motorn

break; case 'd': // Ut

till motorn

varde = atoi(buf); PORTB = varde; // Hade

för att kolla om det kom rätt värde

styra = stilla - varde; // Minskar 128-värde för att gå bakåt

PORTC = styra; // Ut till motorn

break; styra = stilla; // motor stilla PORTC = styra; // Ut till motorn break; AvrXDelay(&Timer3,1); // Kort

tidsfördröjning 1ms för att kunna skifta mellan tasken

int main(void) // Huvudprogrammet

Appendix A:7

Page 32: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix A Program Code for the Micro Control Unit

AvrXSetKernelStack(0); // Initizerar stacken till aktuellt SPL/SPH

outp((1<<SE),MCUCR); // Tillåter "sov" instr. outp(TCNT0_INIT,TCNT0); // Nollställer "timer

owerflow" räknaren outp(TMC8_CK256,TCCR0); // Timer0 för 256 klocktick outp((1<<TOIE0),TIMSK); // Tillåter Timer0 owerflow

avbrott outp(0,DDRA); // PortA inport, värde som ska

reglera farten, dipparna outp(0,PORTA); // Nollar porten outp(255,DDRB); // PortB används under testning

för att se om det sker något, outp(0,PORTB); // Visas på LED's nollar porten outp(255,DDRC); // PortC utport, kopplad till hw

ger spänning PORTC = stilla; // Motorn ska stå stilla från början outp(0x02,DDRD); // PortD bit:PEND in 7 kanB, 6 PendA,

MOT in 5 kanB, 4 kanA, 1 TXD ut, 0 RXD in

outp(0,PORTD); // Nollar porten init_USART(); // Initierar uarten motorgivare = PIND & 0x30; // Läser in ett initvärde var

vagnen står från början,görs 1:a gången

pendelgivare = PIND & 0xC0; // Läser in ett initvärde var pendeln står från början,görs 1:a gången

omotor = motorgivare; // Initierar det värde som fanns vid start och lägger i gamla motor

opendel = pendelgivare; // Initierar det värde som fanns vid start och lägger i gamla pendel

AvrXRunTask(TCB(task1)); // Task1 anropas AvrXRunTask(TCB(task2)); // Task2 anropas AvrXRunTask(TCB(task3)); // Task3 anropas Epilog(); // Startar upp tasken och lämnar

huvudprogrammet

Appendix A:8

Page 33: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix B MATLAB code

B MATLAB code This is an example of MATLAB code used for testing the system.

s2 = serial('COM2', 'BaudRate', 19200); fopen(s2); fprintf(s2,'a') % utdata till "motor" mgiv = fscanf(s2); % indata från "encoderar" fprintf(s2,'b'); pgiv = fread(s2); fclose(s2);

Appendix B:1

Page 34: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix C Flow Chart Task2

C Flow Chart Task2

Read Pin 4,5 (motor sensor)

Read Pin 6,7 (pend. sensor)

00 Old value = value

Old value = value

10

01

11

00

10

Increase reg

Decrease reg

Old value = value

Old value = value

Old value = value

Old value = value

Old value = value

Old value = value

Increase reg

Decrease reg

01

11

delay

00

00

10

10

Old value = value

Old value = value

Old value = value

Old value = value

No

Yes01 BA

Appendix C:1

Page 35: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

A general interface for computer control in real time Appendix D User Guide about the Programming Environment

D User Guide about the Programming Environment This a simcule user guide from the writer to start up quickly using the software AVRX. The following software is used:

Pn (Programmer Notepad) found under C:Program/AVR

Cmd (Command window), opened from Start – drive write cmd <enter>

AVR studio 4.0 if installed on the PC, opened from Start – All program

This files needs to be updated for the project:

Hardware.h - the correct data for the used microcontrol unit is written here

Makefile – information to the GCC comcuiler, imcuortant that the correct filename is specified here

M16.def – information about the microcontrol unit like port configuration etc, fetch this file either from the comcuany at www.Atmel.com or www.ELFA.se

Here is an explanation what too do:

Pn – Here is the code written, it is imcuortant that the file is saved as the file type .c

Cmd – Here is the comcuilation of the code done. First go to the working directory use the commands: cd - change directory, ls – list directory

AVR – There is two or more way to program the microcontrol unit. If using the ST500 starter kit. If not using the starter kit check another alternative.

Go to File – open file in AVR, a dialog appears, write *.cof in File name then press the open button. Click on the file that appeared, press open button again.

The object file is loaded

Go to Tools – STK500/AVRISP/JTAG ICE

Choose the correct DEVICE, Mark Use Current Simulator/Emulator FLASH Memory, the press the button Program

If it does not work, see fault message for reason

Appendix D:1

Page 36: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

PROJEKTARBETE 2005-03-26

Inst

itutio

nen

för t

ekni

k, m

atem

atik

och

dat

avet

ensk

ap –

TM

D

Hårdvarugränssnitt för datorreglering av inverterad pendel

Ulla Carlsson Di02 ,2005-06-15 utgåva 2

E The General Purpose Box

Page 37: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

PROJEKTARBETE

Hårdvarugränssnitt för datorreglering av inverterad pendel Ulla Carlsson Di02

Sammanfattning Den hårdvara som idag tillhör pendelsystemet har identifierats. En ny hårdvara som ska vara mer generell har byggts. Från den nya hårdvaran är det möjligt att ta 5, 12 eller 24 [V] enligt önskemål. Hårdvaran har testats tillsammans med skolans utvecklingsmaterial STK 500 med en mikroprocessor 8515. En enkel kod har används för att testa så att givarna kan läsas av. Detta projekt har avslutats i examensarbetet där det även har testats så att vagnen kan köras fram och tillbaka.

Utgivare: Högskolan Trollhättan/Uddevalla, Institutionen för teknik, matematik och datavetenskap, Box 957, 461 29 Trollhättan Tel: 0520-47 50 00 Fax: 0520-47 50 99 Web: www.htu.se

Examinator: Doktor Anna-Karin Christiansson Handledare: Anna-Karin Christiansson Nivå: Projektarbete nivå C Poäng: 5 Datum: 2005-01-19, utgåva 2 2005-06-15 Nyckelord: Hårdvara, spänningsförsörjning, intelligenta delen, ytterhölje, givare, motor, pendel

i

Page 38: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Innehållsförteckning

Sammanfattning..................................................................................................................i 1 Inledning .......................................................................................................................1

1.1 Bakgrund................................................................................................................1 1.2 Syfte och mål..........................................................................................................1 1.3 Mjukvara................................................................................................................1

2 Förutsättningar ..............................................................................................................1 2.1 Detaljbeskrivning...................................................................................................1 2.2 Avgränsningar .......................................................................................................2

3 Identifikation av den befintliga lådan och kringutrustning...........................................2 3.1 Lådans ytterhölje ...................................................................................................2 3.2 Innehåll i den befintliga lådan...............................................................................4 3.3 Motorn till pendeln ................................................................................................4 3.4 Givarna till motor och pendel................................................................................5

4 Nya lådans innehåll.......................................................................................................6 4.1 Spänningsförsörjning.............................................................................................6 4.2 Intelligenta delen .................................................................................................15 4.3 Ytterhölje..............................................................................................................15 4.4 Lådans utsida.......................................................................................................16

5 Mätningar....................................................................................................................16 5.1 Spänningsdelen ....................................................................................................17 5.2 Drivkretsdelen......................................................................................................17 5.3 Intelligenta delen .................................................................................................17

6 Resultat .......................................................................................................................17 7 Slutsatser.....................................................................................................................17

7.1 Rekommendationer till fortsatt arbete .................................................................17 Källförteckning................................................................................................................18

Bilagor

A Kod för avläsning av givare till pendelarm. (3 sid) B Apparatintag (3 sidor) C Transformator (3 sidor) D Likriktarbrygga (3 sidor) E Elektrolytkondensator (3 sidor) F Switchregulator_L4970A (22 sidor) G Drivkrets (12 sidor) H Atmel Atmega16 (20 sidor) I Givaren i pendeln (8 sidor)

ii

Page 39: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Figurer Figur 1 Skiss över innehållet i befintlig låda.................................................................... 4 Figur 2 Principen för givare HEDS-9100 (Källa: elektronisk se ref. [4]) ....................... 5 Figur 3 De olika ingående delarna av lådan ..................................................................... 6 Figur 4 Transformatorns färgmärkning på ledare (Källa ELFA datablad)....................... 7 Figur 5 Schema över spänningsstabilisatorn med komponenter (Källa: se ELFA

datablad bilaga F figur 35) ..................................................................................... 10 Figur 6 Schematillägg för att få ut fast 24 [V] ............................................................... 10 Figur 7 Kopplingsschema motordrivkrets ...................................................................... 12 Figur 8 Kopplingsschema PWM modulator................................................................... 12 Figur 9 Princip hur PWM modulering fungerar. ............................................................ 13 Figur 10 Mönster på givarna, tid längs X-axel och ett eller noll längs Y-axel. ............. 15 Figur 11 Stiftens innehåll i uttaget som kommer från pendelsystemets givare.............. 16 Bilder Bild 1 Framsida på befintlig låda. .................................................................................... 2 Bild 2 Baksida på befintlig låda. ...................................................................................... 3 Bild 3 Likriktare med ledare monterade från transformator och vidare till

elektrolytkondensator. .............................................................................................. 8 Bild 4 Kretskortet med den switchade spänningsstabilisatorn. ........................................ 9 Bild 5 Motordrivkrets. .................................................................................................... 11 Bild 6 Kretskort med PWM modulering. ....................................................................... 13

iii

Page 40: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

1 Inledning Projektarbetet går ut på att ersätta redan befintlig utrustning som skolan använder till en inverterad pendel i form av en anpassningslåda för mät/reglerbehov, i rapporten benämnd som ”lådan”. En fortsättning för detta projekt är ett examensarbete på tio poäng, vilket förutsätter att lådan fungerar.

1.1 Bakgrund Den hård-/mjukvara som idag används till den inverterade pendeln är föråldrad och långsam. Det finns ingen dokumentation vad systemet innehåller. Tanken är att en ny generell låda ska ersätta den föråldrade lådan.

1.2 Syfte och mål Syftet med projektarbetet är att förbereda för ett examensarbete. Målet är att praktiskt prova på hur det är att identifiera ett fungerande system genom dokumentation av vilka komponenter den nuvarande inverterade pendeln innehåller. Rapporten skall dokumentera hur den nya lådan är uppbyggd och vilka inbyggda funktioner den har.

1.3 Mjukvara • Microsoft Word 2000 för rapportskrivning

• AVR studio 4.0 för programmering av mikrodator

• Visio 5.0 för att rita figurer i rapporten

2 Förutsättningar Den generella lådans önskemål specificeras av avdelning Elektro, HTU. Alla specifikationerna kommer inte att uppfyllas i detta projektarbete. Lådan ska byggas av standardkomponenter som finns färdiga på marknaden. Den inverterade pendeln är av typ Feedback 33-200.

2.1 Detaljbeskrivning Motorn som styr vagnen är en 24 [V] permanent-magnetiserad likströmsmotor. Till motorn finns det en givare som indikerar vagnens läge, pendeln har en givare som visar position på armen i form av en vinkel. Lådan är en länk mellan pendeln och datorn som idag använder en gammal version av MATLAB (4.2).

1

Page 41: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

2.2 Avgränsningar Lådan kommer inte att göras komplett. Framtida studenter kommer att kunna fortsätta utvecklingen. Konstruktion av elektroniken, uppbyggnad av kretskort samt dimensioneringar kommer Hans Dahlin att hjälpa till med.

3 Identifikation av den befintliga lådan och kringutrustning

Den befintliga lådans, Feedback 33-200, innehåll har studerats, även kringutrusning som motor och givare till pendel/motor. Identifikationen har gjorts både utvändigt och invändigt. Den nya lådan som ska utvecklas kommer i vissa delar att likna den gamla.

3.1 Lådans ytterhölje Framsidan se bild 1 består av:

• På/av knapp, med lampa

• Startknapp, ger spänning till motor och givare

• Stoppknapp, stoppar motorn

Bild 1 Framsida på befintlig låda.

2

Page 42: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Baksidan se bild 2 består av:

• Strömuttag till motorn

• 240 [V] anslutning

• Uttag för givare, motor Enkoder (Ribbon cable)

• Uttag för PC interface kort (Narrow ribbon cable (20))

• Uttag för PC interface kort (Wide ribbon cable (40))

• Effektsteg

Bild 2 Baksida på befintlig låda.

3

Page 43: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

3.2 Innehåll i den befintliga lådan Innehållet i den befintliga lådan visas i figur 1, en skiss av de olika komponenterna i lådan. Lådan ses uppifrån, vänster sida i figur 1 motsvarar framsidan på lådan och höger motsvarar baksidan.

D

C

B

I

A

E

F

G

H 131211

10

8 9

5 6 7

3

4

21

1: Relä till lampor

I: Kylning till effektstegH: Power (lampa)G: StartdonF: StoppdonE: Lampor(klar,int.fuse)D: SpänningsanslutningC: VoltvalB: MotorstyrA: Kort I/O pendel info

13: Säkring12: Motstånd11: Motstånd10: Säkring

9: Kondensator8: Kondensator7: Transformator6: Likriktarbrygga5: Relä till start/stopp

3: Koppl.punkt jord2: Motstånd 15 W

Figur 1 Skiss över innehållet i befintlig låda.

3.3 Motorn till pendeln Tillverkare till motorn är PECCAUD. Ersättningsmodeller till denna motor kan vara 82800.8 eller 82830.0 mer data se Crouzet hemsida [1].

• Crouzet likströmsmotor 24 [V]

• Effekt 100 [W], 5 [A]

• 3000 varv/min.

4

Page 44: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

3.4 Givarna till motor och pendel Givarna är två stycken vinkelgivare HEDS-9100A00 med kodhjul till. Se figur 2 och figur 11 för hur givaren fungerar med kodhjulet, för mer information se appendix I Givaren i pendeln som är hämtat elektroniskt [3]. Signalen ettställs vid + 2,4[V] och nollställs vid +0,4 [V]. Kanal A och B växlar med att ligga ”före” eller ”efter” den andra, beroende på om kodhjulet går åt höger eller vänster.

Figur 2 Principen för givare HEDS-9100 (Källa: elektronisk se ref. [4])

3.4.1 Motor

Givaren sitter på motorn och dess utsignal motsvara sträckan som vagnen rört på sig i förhållandet till när avkodaren nollades.

3.4.2 Pendelarm

Givaren läser av positionen som armen rört på sig i förhållandet till när avkodaren nollades.

5

Page 45: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

4 Nya lådans innehåll I rapporten kommer lådan att redovisas som tre områden, spänningsförsörjning, intelligenta delen och ytterhölje. Datablad som hänvisas till i rapporten är hämtade elektroniskt på ELFA’s hemsida [2] och ligger som bifogat material. Figur 3 visar de olika delarna av den byggda lådan.

Koppling för sladd till motor

Spole

PWM modulering

DA omvandlare med spännings nivå justering

Spännings stabilisator

Kopplingsplint 5, 12, 24 [V]

Spänningsdel

Figur 3 De olika ingående delarna av lådan

4.1 Spänningsförsörjning Lådan skall matas med 240 V, 50 Hz och olika ingående delar behöver olika likspänningar, varför spänningsförsörjningen består av flera delar, se nedan.

4.1.1 Apparatintag med filter

Apparat intag till lådan, med ett filter sorterar bort transienter och andra störningar från nätet. Se bilaga B Apparatintag.

• ELFA artikelnummer 69-666-67, fabrikat Schaffner

6

Page 46: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

• Ström 10 [A], induktans 0.13 [mH]

4.1.2 Transformator

Transformatorn ska transformera spänningen från 240 [V] till 24 [V], 50 Hz. Se bilaga C Transformator. Transformatorn är dimensionerad att klara att driva åtminstone två motorer.

• ELFA artikelnummer 56-137-32, fabrikat Toroid

• 2 x 24 [V], 10 [A]

Figur 4 visar färgmärkning på ledarna från transformatorn. I lådan är ledarna parallellkopplade grön – brun och röd – blå till likriktaren.

Figur 4 Transformatorns färgmärkning på ledare (Källa ELFA datablad)

7

Page 47: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

4.1.3 Likriktare

En helvågslikriktare som likriktar växelspänning till likspänning. Se bilaga D Likriktarbrygga.

• ELFA artikelnummer 70-070-57, fabrikat Taiwan Semiconductor

• 4 till 10 [A]

Bild 3 visar likriktaren med ledarna från transformatorn och vidare till elektrolytkondensator.

Bild 3 Likriktare med ledare monterade från transformator och vidare till elektrolytkondensator.

4.1.4 Elektrolytkondensator

Använd som filterkondensator i nätaggregatet. Se bilaga E Elektrolytkondensator.

• ELFA artikelnummer 67-544-44, fabrikat Jamicon, typ LPW

• 15000 [µF], 50 [V]

8

Page 48: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

4.1.5 Switchad spänningsstabilisator

En universell regulator i BCD-teknologi (bipolär, CMOS och DMOS på samma chip) som har hög verkningsgrad (låg effektförlust). Se bilaga F Switchregulator_L4970A.

• ELFA artikelnummer 73-097-19, L4970A fabrikat ST microelectronics

Bild 4 visar kretskortet där switchad spänningsstabilisator är monterad med omgivande komponenter enligt kretsschema figur 5 och figur 6.

Bild 4 Kretskortet med den switchade spänningsstabilisatorn.

9

Page 49: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Figur 5 visar kopplingsschema över spänningsstabilisatorn med omgivande komponenter som den ser ut om 5,1 [V] ska plockas ut.

Figur 5 Schema över spänningsstabilisatorn med komponenter (Källa: se ELFA datablad bilaga F figur 35)

Spänningen 24 [V] ska driva motorn till pendeln. Figur 6 visar tillägg mot kopplingsschema i figur 5. Två stycken resistorer och en kondensator, det som finns till höger om den röda markeringen visar skillnaden mot figur 4.

Figur 6 Schematillägg för att få ut fast 24 [V]

10

Page 50: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

R2 väljs till 4,7 [kΩ], uin = 24[V], uut = 5,1 [V] . R1 beräknas med formel (1) (spänningsdelning).

inut uRR

Ru *21

2

+= (1)

][5,1710*7,41,5

24*10*7,4* 33

22

1 Ω≈−=−= kRu

uRR

ut

in

Kondensatorn 33 [nF] som är rekommenderad i databladet har en något deriverande funktion (reglerteknik).

4.1.6 Motordrivkrets

En motordrivkrets med PWM - Puls Width Modulationsprincip ska användas. Om högre switchfrekvens än ca 2000 Hz väljs så räcker motorns egeninduktans, inga extra induktanser behövs. Om en frekvens över 20000 Hz väljs undviks störande ljud. En drossel/spole används för att filtrera ström och undvika högfrekventa störningar i motorledningen. En krets för styrning och direktdrivning av DC- och stegmotorer har valts se figur 6. Mer fakta se bilaga G Drivkrets.

• ELFA artikelnummer 73-303-84, LMD18200T, fabrikat Intersil

• 3 [A] kontinuerlig ström och upp till 6 [A] toppström

Bild 5 visar kretskortet för drivkretsen med tillhörande komponenter enligt figur 7.

Bild 5 Motordrivkrets.

11

Page 51: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

C2

0,001mF

C3

0,22mF

C4

10nF

C5

10nF

C6

0,63mF

97531108642

11

Matning till motorVCC

Från PWM modulatorn

321

L4970

L78L12

LMD18200

Figur 7 Kopplingsschema motordrivkrets

4.1.7 PWM modulator

PWM modulatorn ger PWM signal till motordrivkretsen se figur 8 för kretsschema och bild 6 för monterat kretskort. Pin3 ger pulsbredden till drivkretsen. Vid 6 V ska motorn stå stilla, 4V eller 8V så ska motorn vara i rörelse åt något håll. En slutgiltig lösning för lösningen på hur signalen ska tas hand om från mikrodatorn kommer senare.

VCC 12V

R1 Från D/A omvandlare,

R5

detta är inte helt löst ännu.

R3 1 Idag 4-6-8V, +

_ 3

R6 22 -

+Till pin3 3

R2 1 R4

R1 100kΩ R2 100kΩ C1 R3 100kΩ R4 15kΩ R5 2.2kΩ R6 4.7kΩ C1 2.2nF

Figur 8 Kopplingsschema PWM modulator

12

Page 52: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Principen hur PWM fungerar illustreras i figur 9. Signalen u1 är plus-ingång och u2 minus-ingång till en OP-förstärkare, OP-förstärkaren jämför och får utsignalen u3.

u1

u2

u3

6V

8V

4V

Figur 9 Princip hur PWM modulering fungerar.

Bild 6 visar kretskortet för PWM modulatorn, En fyrdubbel komparator LM339N med öppen kollektorutgång används.

Bild 6 Kretskort med PWM modulering.

13

Page 53: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

4.1.8 DA omvandlare

En DA omvandlare med spänningsnivå justering används. DA omvandlaren är gjord av en operationsförstärkare som tar hand om matningsspänningen, diverse motstånd och ett motståndsnät med R/2R-stege. Ett reglerbart motstånd finns för finjustering.

• ELFA artikelnummer 60-370-06, Motståndsnät R/2R-stege, fabrikat BI Technologies

• ELFA artikelnummer 73-291-05, operationsförstärkare LM324N, fabrikat ?

Figur 10 visar schemat över DA omvandlaren. Enheterna på R1 – R19 stämmer inte med vad som finns på kortet. Resistor R3 är justerbart, detta eftersom det visade sig att möjligheten att justera behövdes. Beroende på vad som kopplades in visade ut olika värden.

Msb

Kopplas til l en port i mikrodatorn

6V 12V

X1

1K

R1 1K

R2

1K

R3

1K

R4

1K

R5 1K

R6 1K

R7 1K

R8 1K

R9 1K

R10 1K

R11

1K

R12

1K

R13

1K

R14

1K

R15

1K

R16

1K

R17

1K

R18

1K

R19

Vcc

vcc

Figur 10 DA omvandlare med en opförstärkare LM324 och ett motståndsnät R/2R-stege.

4.1.9 Spänningsstabilisering

En spänningsstabiliering görs mha tre bens regulatorer. Spänning på 24 [V] regleras till 12 [V] och sedan till 5 [V].

• ELFA artikelnummer 73-262-42, L7805CV, fabrikat ST Microelectronics

• ELFA artikelnummer 73-090-16, L7812CV, fabrikat ST Microelectronics

4.1.10 Kopplingsplint

Kopplingsplinten består av 7 anslutningar. En är 5 [V], en 12 [V], två är 24 [V] och tre av anslutningarna är jord.

14

Page 54: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

4.2 Intelligenta delen Den intelligenta delen av lådan kommer att bestå av en 8-bits enchipsdator Atmel Atmega16 se bilaga H. I första hand ska enchipsdatorn ta hand om kommunikationen med den programvara som ska användas till pendeln, samt värden från givarna i pendeln och motorn. Det som är gjort hittills är en programkod som läser av pendel givaren.

4.2.1 Hårdvarumiljö

Skolan hårdvara AVR STK 500 med microprocessor At90s8515 samt två boxar med lysdioder som indikerat varsitt register, low byte och high byte har används till att testa avläsning av givare.

4.2.2 Principen för avläsning av givare

När ett oscilloskop kopplas in på givaren, kan följande mönster identifieras se figur 11. Varje kanal skiftar mellan värde 0 och 1. Beroende på om pendelarmen går åt höger eller vänster kommer mönstret att förändras. Pilarna i figur 11 visar vändningar. Först ligger kanal B ”före” vid nästa pil ligger kanal A ”före” osv.

Kanal A

Kanal B

Figur 11 Mönster på givarna, tid längs X-axel och ett eller noll längs Y-axel.

4.2.3 Programkod för avläsning av givare till pendelarm

Koden till avläsning av givare till pendelarm är programmerat i assembler. Se appendix A för kod.

4.3 Ytterhölje Denna del är ej klar. Den student som tar över projektet får slutföra denna del.

4.3.1 Anslutning till pendelsystemets givare

Den sladd på pendelsystemet som idag tillhör givarna är konfigurerad på följande sätt:

15

Page 55: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

1. Jord

2. Index

3. Kanal A för givaren till motorn

4. + 5 [V]

5. Kanal B för givaren till motorn

6. Kanal B för givaren till pendelarm

7. + 5 [V]

8. Kanal A för givaren till pendelarm

9. Index

10. Jord

Figur 12 visar innehållet vad varje stift har för betydelse på uttaget till givarna på pendelsystemet.

Figur 12 Stiftens innehåll i uttaget som kommer från pendelsystemets givare.

4.4 Lådans utsida Denna del är ej klar. På lådans utsida ska det på sikt finnas:

• In- och utgångar både analoga och digitala. För pendeln behövs???

• Display

• Start- och stoppströmställare för pendelfunktionerna

• På och av knapp för matningsspänning

• Kontaktdon till motor, kommunikation för givarna och styrning av motor (som i befintlig låda)

• Seriekommunikationsport till en PC där programvaran till den inverterade pendeln kommer att finnas

5 Mätningar Mätningar har gjorts när varje delmoment är färdigt.

1

10 9 6 7 8

2 4 3 5

16

Page 56: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

5.1 Spänningsdelen När spänningsdelen var ihop monterad, verifierades att transformatorn, likriktare, kondensator och spänningsstabilisatorn levererade en likspänning på 24 [V]. Ett motstånd behövs över utgången för test. När yttre komponenter är inkopplade kommer detta inte att behövas. Då kommer tryckdonen att ur systemets synpunkt betraktas som ett motstånd.

5.2 Drivkretsdelen Drivkretsen testades så att den levererade puls – paus runt 6 [V]. En motsvarande motor som används till pendeln kopplades in till drivkretsen. Vid 6 [V] står motorn still, spänningen < 6 [V] går motorn åt vänster, spänningen > 6 [V] går motorn åt höger. Variationen ligger mellan 4 – 8 [V] sedan ökar inte motorns varvtal mer.

5.3 Intelligenta delen Koden är testad på pendeln. När pendelarmen sätts i rörelse blir det samma värde i registren som ursprungsvärdet.

6 Resultat Hårdvaran fungerar, motorn kan köras fram och tillbaka. Detta gjordes i examensarbetet som var en fortsättning på detta projekt. Se examensarbetet för kod. Det levereras 5, 12 och 24 [V] från spänningsdelen enligt specifikation.

7 Slutsatser Det har fungerat bra att monterar ihop de olika delarna av hårdvaran. Lådan fungerar men mikrodatorn är inte monterad.

7.1 Rekommendationer till fortsatt arbete Fortsätt med skalet runt hårdvaran. Strömställare och uttag skall monteras. Den intelligenta delen ska slutföras. Mikrodatorn ska monteras på ett kort. Display och temperaturmätning är ytterligare delar att satsa på.

17

Page 57: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel

Källförteckning 1 Crouzet katalog över motorer [Elektronisk].

Tillgänglig: <http://www.crouzet.com> [2005-03-26]

2 Datablad till diverse komponenter som i rapporten hänvisar till ELFA’s hemsida [Elektronisk]. Tillgänglig: <http://www.ELFA.se> [2005-03-26]

3 Datablad till HEDS-9100 A00: optisk två kanalig pulsgivare som finns i vagnen till pendeln [Elektronisk]. Tillgänglig: <http://www.home.agilent.com/USeng/ nav/-536893643.536884880/pd.html> [2005-02-04]

4 Bild på hur givaren fungerar [Elektronisk]. Tillgänglig: <http://www.ostergrens.se/katalog/1-1-451a.asp> [2005-03-26]

18

Page 58: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga A Kod för avläsning av givare till pendelarm

A Kod för avläsning av givare till pendelarm. ;*******************************************************************

; By Ulla Carlsson, Trollhättan Projektarbete lp 3 2005

;*******************************************************************

; Definition

.include"8515def.inc"

.def temp =r16

.def chA_lb =r26 ;kanalA på enkoder pendel

.def chA_hb =r27

; Interrupt Vector Table

rjmp reset ;Reset handle

reti ;External interrupt 0 handle

reti ;External interrupt 1 handle

reti ;T/C1 capture event interrupt handle

reti ;T/C1 compare A interrupt handle

reti ;T/C1 compare B interrupt handle

reti ;T/C1 Overflow interrupt handle

reti ;T/C0 Overflow interrupt handle

reti ;SPI Transfer complete interrupt handle

reti ;UART Rx complete interrupt handle

reti ;UART Data Register empty interrupt handle

reti ;UART Tx complete interrupt handle

reti ;Analog Comprator

; Initiate stack pointer (SP)

reset:

ldi temp,low(RAMEND) ;Store low byte of stack address

out spl,temp ;Load temp to SP low

ldi temp,high(RAMEND) ;Store high byte of stack address

out sph,temp ;Load temp to SP high

; Initiate Ports

; PortC is connected to LEDs ,box entrance 5 HIGHBYTE register

; PortB is connected to Pin0 = kanalA, Pin1 = kanalB input from encoder

; PortA is connected to LEDs ,box entrance 5 LOWBYTE register

clr chA_lb ;nollar

clr chA_hb

clr temp ;Bit0-1 input from encoder

out DDRB,temp ;Temp to DDRB

clr temp ;Clearing temp

out PortB,temp ;Temp to PortB

ser temp

out DDRA,temp ;PortA outport reg 26

clr temp

Bilaga A:1

Page 59: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga A Kod för avläsning av givare till pendelarm

out PortA,temp

ser temp

out DDRC,temp ;PortC outport reg 27

clr temp

out PortC,temp

rjmp start

start:

in temp,PinB

andi temp,0b00000011

out PortA,chA_lb ;Display value in reg26 on LED's lowbyte

out PortC,chA_hb ;Display value in reg27 on LED's highbyte

cpi temp,0b00000000

breq loop00

cpi temp,0b00000001

breq loop01

cpi temp,0b00000010

breq loop10

cpi temp,0b00000011

breq loop11

loop00:

out PortA,chA_lb ;Display value in reg26 on LED's lowbyte

out PortC,chA_hb ;Display value in reg27 on LED's highbyte

in temp,PinB

andi temp,0b00000011

cpi temp, 0b00000000

breq loop00 ; Läser in tills ändring finns

cpi temp,0b00000001 ; Jmf om B=0, A=1

breq loopa ; Hoppa till label loopa

sbiw chA_lb,1 ; annars minska reg med 1

rjmp loop10 ; Nästa steg möjligt efter 1

loopa:

adiw chA_lb,1

rjmp loop01

loop01:

out PortA,chA_lb ;Display value in reg26 on LED's lowbyte

out PortC,chA_hb ;Display value in reg27 on LED's highbyte

in temp,PinB

andi temp,0b00000011

cpi temp, 0b00000001

breq loop01

cpi temp,0b00000011

breq loopb

Bilaga A:2

Page 60: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga A Kod för avläsning av givare till pendelarm

sbiw chA_lb,1

rjmp loop00

loopb:

adiw chA_lb,1

rjmp loop11

loop10:

out PortA,chA_lb ;Display value in reg26 on LED's lowbyte

out PortC,chA_hb ;Display value in reg27 on LED's highbyte

in temp,PinB

andi temp,0b00000011

cpi temp, 0b00000010

breq loop10

cpi temp,0b00000000

breq loopc

sbiw chA_lb,1

rjmp loop11

loopc:

adiw chA_lb,1

rjmp loop00

loop11:

out PortA,chA_lb ;Display value in reg26 on LED's lowbyte

out PortC,chA_hb ;Display value in reg27 on LED's highbyte

in temp,PinB

andi temp,0b00000011

cpi temp, 0b00000011

breq loop11

cpi temp,0b00000010

breq loopd

sbiw chA_lb,1

rjmp loop01

loopd:

adiw chA_lb,1

rjmp loop10

Bilaga A:3

Page 61: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

2002-05-28

PRODUKTINFORMATIONVi reserverar oss mot fel samt förbehåller oss rätten till ändringar utan föregående meddelande

ELFA artikelnr69-666-00 Filt.nätbrunn FN9223 1A FN9223-1/0669-666-26 Filt.nätbrunn FN9223 3A FN9223-3/0669-666-42 Filt.nätbrunn FN9223 6A FN9223-6/0669-666-67 Filt.nätbrunn FN9223 10A FN9223-10/06

Bilaga B: Apparatintag

Page 1 of 3

Page 62: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Filter selection table

Choose the family FN xxx with the required body style and features, and add -?? to

determine current rating, and /?? for output connections. Example: FN 9223-1/06 is a

horizontal screw-mounting filter, rated for 1A, with fast-on outputs.

All standard types

B types (medical)

-1 -3 -6 -10

2.8 0.75 0.3 0.13

Current ratingsA at 40°C (25°)

1 (1.2) 3 (3.5) 6 (6.9) 10 (11.6)

Inductance L mH

FN 9223 -?? /??

Family

/06 /07*

Output connection

-

Housing

Weight

g

47 2.2

47 -

Capacitance

Cx Cy nF nF

2000 1700

2500 1700

Filter type

-

1

Res.

RMΩ

35*

35*

190

2

Maximumleakage

µA/phase

250 50/60

250 50/60

Maximumoperating volt.

VAC Hz

Hipot test voltage

PNE PNVAC VDC

Operatingfrequency

Hz

DC to 400

DC to 400

MTBF at 40°C, 230V, per Mil-HB-217F: 2,200,000 hours */07 outputs add 5g

Additional specifications

Approvals

-1 -3 -6 -10FN 9223S -?? /?? /06 /07* -

EN133200IEC60939

Electrical schematics

See tables for component values

N

2xLCx

FN 9223

LIN

E

LOAD

2xCy

E

P

N'

E'

P'

N

2xLCx

FN 9223B

LIN

E

LOAD

R

E

P

N'

E'

P'

FN 9223

• up to 10A current ratings• IEC 950-compliant• optional medical version (B type)• snap-in version (S type)

• Nennstrom bis 10A• IEC 950 konform• Für medizinische Geräte als Option (Typ B)• Snap-in Version (Typ S)

• courants de service pouvant atteindre 10A• conforme à CEI 950 • version médicale en option (type B)• version snap-in (type S)

Compact power entry module

74

Bilaga B: Apparatintag

Page 2 of 3

Page 63: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

FN 9223 insertion loss

Per CISPR 17; A = 50Ω/50Ω sym, B = 50Ω/50Ω asym, C = 0.1Ω/100Ω sym, D = 100Ω/0.1Ω sym

1 amp types 10 amp types3 amp types 6 amp types

51.52640

34.45.5

Ø3.312.5R≤321.5

FN 9223

28.5M390º

AWG 18160

Tol.mm

± 0.5± 0.3± 0.3± 0.3± 0.3± 0.3

-+0

0.1

+00.1

-± 1-

± 5

3422.527.5

20.8

34.7 37.7

6

30.8

5.512.5

R≤1.5

AWG 18160

panel thickness 0.5-2mm

FN 9223S/06 /07

Tol.mm

± 0.5± 0.3± 0.2± 0.3± 0.3

-± 0.3

-± 0.2± 0.2

---

± 5

ABCDFJMNPTWYZ

ABCDFHJMNPRSYZ

/06 types

/07 types

FRONT SIDE

PANEL CUT-OUT

A

B

F

T

J C

D

TY

W

NM

P

ZD

F

A

C

C

MNR

P

BH

D

S

J

F

FRONT SIDE

PANEL CUT-OUT

Mechanical data

Snap-in version FN 9223S(Possible thickness of mounting panels see page 100)

75

All dimensions in mm; 1 inch = 25.4mm

Bilaga B: Apparatintag

Page 3 of 3

Page 64: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Sida 1(3)

Customer: ELFA AB

yellow green

U = 24V 125 VA S1 Uo = 25,8V

6,3A

red230V P1

48-60Hzbrown

U = 24V 125 VA S2 Uo = 25,8V

6,3A

yellow blue

ClassificationProtection against electrical shock: Isolating TransformerProtection index: IP00Protection against short-circuit and abnormal use: Non-short-circuit proofTime of operation: ContinouslyIntended use: IncorporatedAmbient temperature / Material Classification: Ta40/E

Assembling: Centre potted with a drilled centre hole with an insert nut type M6.A rubber pad is glued at the bottom of the transformer.

Dimensions: OD = 115 mmH = 55 mm

Terminations: Prim: Multistranded Wire Style 3266. Awg 20

Sec: Solid Copper insulated with tubes of Natvar.

Label on the paper box.

Transf.No.

ELFA P/N:

Label on transformer.

Transf.No.Prim. 230V 48-60Hz ye-ye IP00 ta40/E

250 VA

L = 200mm

External fuse:

External fuse:

Sec. 2x 24V

Toroid International ABAA-98041

56-137-32

Toroid International ABAA-98041

gn-re/bn-bu

AA-980411999-04-14 / ts

Transf. No.

L = 200mm

56-137-32 Designed:

Bilaga C: Transformator

Page 1 of 3

Page 65: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Sida 2(3)

Customer:Customer Part No:

This transformer is CSA- and UL-Recognized, File No. E115159, according to following standards:

UL1950 & CAN/CSA C22.2 No. 950-95Standard for safety for Information Technology Equipment, including Electrical Business Equipment.

The construction of this transformer also fulfill the requirements according to IEC 601.1,EN 61558-1, EN 60 950, EN 60 065, UL 2601.1, UL 6500, UL 1411.

Core.The core is tapewound with cold-rolled grainoriented silicon steel.

mm

Core Protection.The core is insulated with min. four layers of 0,05mm thick Polyesterfilm.UL-Approved under Guide QMFZ2. Flame Class UL 94VTM-2. Approved for 130°C.

Copper Wire.Polyesterimid enamelled copper wire, according to IEC 317-13.Approved for min. 180°C.

Primary Termination.Stranded wire:UL-Approved under Guide AVLV2, Style 3266. Approved for 300V and 125°C.Plus an extra insulation tube. UL-Approved under Guide YDPU2. Approved for 105°C.

Secondary Termination.The wire ends are insulated with insulation tubes.UL-Approved under Guide YDPU2. Approved for 300V and 105°C.

Insulation Primary - Secondary.The insulation between the primary and the secondary consists of min. six layers of0,05mm thick Polyester film (total thickness min. 0,3mm).UL-Approved under Guide QMFZ2. Flame Class UL 94VTM-2. Approved for 130°C.

Two of these layers withstands together 4000Vac for one minute. The creep distanceexceeds 8mm and the insulation resistanceis more than 5000 Megohm.

Final Insulation.The outer insulation consists of min. two layers of 0,05mm thick Polyester film.UL-Approved under Guide QMFZ2. Flame Class UL 94VTM-2. Approved for 130°C.

Potted Centre.The centre hole is filled with self-extingushing Polyurethane.UL-Approved under Guide QMFZ2. Approved for 120°C. Flash point: Over 200°C.

56-137-32

AA-98041ELFA AB

Awg 20

Core Dimensions: 100x60x35

Declaration of Insulation Transformer No.

Bilaga C: Transformator

Page 2 of 3

Page 66: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Sida 3(3)

Type of equipment:

Brand name:

Part no:

Customer:

Manufactures: Toroid International (Pvt) Ltd Toroid International ABPO Box 15, Phase 2, FTZ Box 3Katunayake, Sri-Lanka 351 03 Växjö, Sweden

Toroid India Pvt Ltd Manufacture´s representativeTechnopark Campus within EEA: Toroid International ABTrivandrum 695 581 Box 3Kerala, India 351 03 Växjö, Sweden

As the manufacturer´s authorised representative established within EEA, we declare that theproduct is in conformity with the provision of the EC directives: Low Voltage Directiven (LVD)73/23/EEG, 93/68/EEG

The product fulfils the requirements according to the following harmonised standards:EN 61558-1, EN 60 950, EN 60 065 and IEC 601-1.

All transformers have been inspected and tested with approved result according to thefollowing:

The product is to be regarded as a modular component to be used in an electric apparatusthat in turn has to fulfil the EMC - directives.

The product itself does not need to be EMC approved for CE marking according to directive89/336/EEG, 92/31/EEG and 93/68/EEG

Date:

Thomas Svensson / Design engineer

2003-05-07

56-137-32

3. No-load secondary voltage 4. Dielectric strength between primary an

AA-98041

ELFA AB

1. Ocular inspection 2. No-load input current

Toroid

EC/EEA Declaration of conformity

Isolating Transformer

Bilaga C: Transformator

Page 3 of 3

Page 67: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

2001-12-20

PRODUKTINFORMATIONVi reserverar oss mot fel samt förbehåller oss rätten till ändringar utan föregående meddelande

ELFA artikelnr70-044-92 KBU1004 Brygga 10A 400V70-045-00 KBU1007 Brygga 10A 1kV70-070-57 KBU1003 Brygga 10A 200V70-042-94 KBU1006 brygga 10A 800V

Bilaga D: Likriktarbrygga

Page 1 of 3

Page 68: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

- 460 -

KBU1001 THRU KBU1007Single Phase 10 AMPS. Silicon Bridge Rectifiers

Voltage Range50 to 1000 Volts

Current10.0 Amperes

Features

UL Recognized File # E-96005 High surge current capability Ideal for printed circuit board Reliable low cost construction technique

results in inexpensive product High temperature soldering guaranteed:

250°C / 10 seconds / 0.375” ( 9.5mm )lead length at 5 lbs., ( 2.3 kg ) tension

Weight: 8 grams

KBU

Dimensions in inches and (millimeters)

Maximum Ratings and Electrical CharacteristicsRating at 25°C ambient temperature unless otherwise specified.Single phase, half wave, 60 Hz, resistive or inductive load.For capacitive load, derate current by 20% Type Number KBU

1001KBU1002

KBU1003

KBU1004

KBU1005

KBU1006

KBU1007

Units

Maximum Recurrent Peak Reverse Voltage 50 100 200 400 600 800 1000 VMaximum RMS Voltage 35 70 140 280 420 560 700 VMaximum DC Blocking Voltage 50 100 200 400 600 800 1000 VMaximum Average Forward Rectified Current@TA = 55°C 10.0 APeak Forward Surge Current, 8.3 ms SingleHalf Sine-wave Superimposed on Rated Load(JEDEC method )

300 A

Maximum Instantaneous Forward Voltage@ 10A

1.1 V

Maximum DC Reverse Current @ TA=25°Cat Rated DC Blocking Voltage @ TA=100°C

10500

uAuA

Operating Temperature Range TJ -55 to +125 °CStorage Temperature Range TSTG -55 to +150 °C

Bilaga D: Likriktarbrygga

Page 2 of 3

Page 69: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

- 461 -

RATINGS AND CHARACTERISTIC CURVES (KBU1001 THRU KBU1007)

FIG.4- TYPICAL REVERSE CHARACTERISTICSPER BRIDGE ELEMENT

INS

TA

NTA

NE

OU

SR

EV

ER

SE

CU

RR

EN

T.(

A)

0 20 40 60 80 100 120 1400.1

1

10

100

PERCENT OF RATED PEAK REVERSE VOLTAGE. (%)

Tj=100 C0

Tj=25 C0

FIG.2- MAXIMUM FORWARD CURRENT DERATINGCURVE

AV

ER

AG

EF

OR

WA

RD

CU

RR

EN

T.(A

)

0 50 100 1500

10

12

2

4

6

8

AMBIENT TEMPERATURE. ( C)o

MOUNTED ON 4X4 INCHCOPPER PC BOARD0.5"(12.7mm)LEAD LENGTH

FIG.1- MAXIMUM NON-REPETITIVE FORWARDSURGE CURRENT PER BRIDGE ELEMENT

PE

AK

FO

RW

AR

DS

UR

GE

CU

RR

EN

T.(A

)

102 51 5020 100

150

50

0

100

200

250

350

300

NUMBER OF CYCLES AT 60Hz

8.3ms Single Half Sine Wave

Tj=25 C0

FIG.3- TYPICAL INSTANTANEOUS FORWARDCHARACTERISTICS PER BRIDGE ELEMENT

INS

TA

NTA

NE

OU

SF

OR

WA

RD

CU

RR

EN

T.(A

)

0.6 0.7 0.8 0.9 1.0 1.1 1.31.2

0.1

0.4

4.0

40

0.2

2.0

20

1.0

10

100

INSTANTANEOUS FORWARD VOLTAGE. (V)

8.3ms Single Half Sine Wave

Tj=25 C0

Bilaga D: Likriktarbrygga

Page 3 of 3

Page 70: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Vinyl sleeve

L+2 (max) 6.3±1

10

2-φ2

7.8

1.5

0.8

3.1

2.5

0.85

φD+1(max)

Vinyl Sleeve

L+2 (max) 9±1

P

9.5

5.0

4.5

2.0

3.0

3.5

0.85

φd+1(max)

Vinyl Sleeve

L+2 (max) 9±1

φD+1(max)7.5

3-φ2

45o

Vinyl sleeve

φD+1(max)

L+2 (max) 9±1

45o

7.5

3-φ2

4.0

1.5

6.0

10

0.85

TERMINAL TYPEP.C.B. TERMINAL (SNAP IN)SYMBOL:W(φ22~35)

Location of P.C.B. holes

P.C.B. TERMINALSYMBOL:V(φ25~35)

(φ35)A.B. blank terminals

(φ25)

LUG TERMINALSYMBOL:G(φ22~35)

(φ30)

11.2

5

BA

L+2 (max) 9±1

φD

+1

(ma

x)

Vinyl sleeve

4- φ2

30O

• Three kinds of terminal are available for your use.

• Withstanding 2000 hours application of high ripple current at 85oC.

ItemOperation Temperature Range

Rated Working Voltage

Capacitance Tolerance (120Hz 20oC)

Leakage Current (20oC)

Surge Voltage (20oC)

Dissipation Factor (tan δ)

(120Hz 20oC)

Low Temperature Stability

Load Life

Characteristic

±20%(M)

450W.V.

500S.V.

Rated Voltage (V)

tan δ

Rated Voltage (V)

-40oC / +20oC

-25oC / +20oC

After 2000 hours application of W.V. at +85oC, the capacitor shall meet the following limits.Capacitance Change

Dissipation Factor

Leakage current

At +85oC no voltage application after 1000 hours, the capacitor shall meet the limits for load lifecharacteristics. (with voltage treatment)

±20% of initial value

150% of initial specified value

initial specified value

Impedance ratio at 120Hz

SPECIFICATION

LP Series Snap-in Terminal Type, Standard

Shelf Life

LARGE CAN TYPE

-25 ~ +85oC

160 ~ 450VDC

I 0.03CV or 3 ( mA ) *Whichever is smaller after 5 minutes

I : Leakage Current( µA) C : Rated Capacitance( µF) V : Working Voltage(V)

400

450

350

400

250

300

200

250

160

200

100

125

63

79

50

63

35

44

25

32

16

20

10

13

0.50

0.60

10~100

-40 ~ +85oC

10 ~ 100VDC

0.40

0.50

0.35

0.45

0.25

0.35

0.25

0.30

0.25

0.30

0.20

0.25

0.20

0.20 0.25

CV 100,000

CV > 100,000

0.25

10 16 25 35 50 63 100 160~250 350~450

160~250 350~450

4 6 8

15 __ __

RIPPLE CURRENT COEFFICIENTSTemperature(oC)Multiplier 1.55 1.30 1.20

45 7060

60Multiplier

120 10K

0.90 1.00 1.05 1.10

1KFrequency(Hz)W.V.

10~35V0.90 1.00 1.15 1.2050~100V0.80 1.00 1.35 1.45160~250V0.90 1.00 1.30 1.40350~450V

1.0085

100K

1.101.201.501.45

φDP 8 10 10 14

22 25 30 35

LP HPHV

Bilaga E: Elektrolytkondensator

Page 1 of 3

Page 71: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

LP Series

Case size : D x L (mm)Max ripple current : A(rms) 85oC 120Hz

3300

4700

6800

8200

10000

12000

15000

22000

33000

47000

68000

332

472

682

822

103

123

153

223

333

473

683

µF Code ItemV(Code)

CASE SIZE & MAX RIPPLE CURRENT

DxL

22x2525x2522x3025x2522x3030x2522x3530x2522x4530x3025x4535x3030x4535x4035x50

R.C.

2.392.462.692.572.812.843.142.973.793.454.994.895.976.548.64

10 (1A)DxL

22x2525x2522x2525x2522x3030x2522x3530x2522x4030x3022x4535x2525x4535x3030x4535x4035x45

35x60

R.C.

1.812.212.402.472.702.733.002.843.303.163.623.554.254.375.486.017.53

10.24

16 (1C)DxL

22x2525x2522x3025x2522x3530x2522x4030x3022x4530x3022x5035x3025x4535x3030x5035x4035x50

35x60

R.C.2.032.092.432.312.872.723.163.033.453.143.743.753.783.894.945.176.95

8.97

25 (1E)DxL

22x2525x2522x3030x2522x4030x3022x4535x3025x4535x3025x5035x3530x4535x4035x45

35x70

R.C.2.042.102.412.442.982.863.253.423.413.513.683.844.084.475.68

8.42

35 (1V)

820

1000

1500

2200

3300

4700

6800

8200

10000

12000

15000

821

102

152

222

332

472

682

822

103

123

153

µF Code ItemV(Code)

DxL

22x2525x2522x3530x2522x4035x2525x4535x3025x5035x3530x4535x3535x45

35x50

R.C.

1.921.982.512.382.892.993.373.463.623.793.723.864.53

5.30

50 (1H)DxL

22x2525x2522x2530x2522x3030x2522x4535x2525x4535x3030x4535x3530x5035x4035x50

35x60

R.C.

1.421.461.741.812.082.102.812.763.113.203.543.683.813.994.48

5.13

63 (1J)DxL

22x3025x2522x3030x2522x4035x3025x4535x3030x4535x3535x45

35x60

35x70

35x70

R.C.1.551.541.712.202.382.542.772.853.273.394.01

4.85

5.30

5.49

100 (2A)

Bilaga E: Elektrolytkondensator

Page 2 of 3

Page 72: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

LP Series

220

330

470

560

680

820

1000

1500

221

331

471

561

681

821

102

152

µF Code ItemV(Code)

DxL

22x2525x2522x3530x2522x3530x2522x4030x3022x5030x3025x4535x3030x45

R.C.

1.111.141.531.451.671.581.951.872.362.052.552.623.28

160 (2C)DxL

22x2525x2522x3025x2522x4030x2522x4530x3025x4030x3525x5035x3030x4535x3535x50

R.C.0.971.001.291.231.741.552.001.822.142.142.592.552.872.994.24

200 (2D)DxL

22x2025x2522x4030x2522x5030x3525x4535x3030x4035x3530x4535x4035x45

R.C.1.141.091.581.422.091.932.292.222.462.682.833.113.60

250 (2E)

47

100

150

220

330

470

560

470

101

151

221

331

471

561

µF Code ItemV(Code)

DxL

22x3025x2522x3530x2522x4530x3025x5035x3530x5035x4035x45

R.C.

0.660.630.860.821.171.061.531.601.922.012.31

350 (2V)DxL

22x2525x2522x3025x2522x4030x2522x5025x4030x4535x3535x45

R.C.0.430.450.680.650.950.851.271.171.591.652.19

400 (2G)DxL

22x2525x2522x3525x3022x5030x3025x5035x3535x45

R.C.0.360.370.610.590.880.761.081.131.53

450 (2W)

Case size : D x L (mm)Max ripple current : A(rms) 85oC 120Hz CASE SIZE & MAX RIPPLE CURRENT

Bilaga E: Elektrolytkondensator

Page 3 of 3

Page 73: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga F Switchregulator_L4970A

F Switchregulator_L4970A

Dokumentation finns på:

http://www.elfa.se/pdf/73/730/07309719.pdf

Kommentar: Filen är skyddad och kan därför inte infogas i rapporten.

Bilaga F:1

Page 74: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga G Drivkrets

G Drivkrets Dokumentation finns på

http://www.elfa.se/pdf/73/732/07328834.pdf

Kommentar: Filen är skyddad och kan därför inte infogas i rapporten.

Bilaga H:1

Page 75: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Hårdvarugränssnitt för datorreglering av inverterad pendel Bilaga H Atmel Atmega16

H Atmel Atmega16

Dokumentation finns på:

Som Summary på 20 sidor:

http://www.atmel.com/dyn/resources/prod_documents/2466S.pdf

och som fullständig på 351 sidor:

http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf

Kommentar: Filerna är skyddade och kan därför inte infogas i rapporten.

Bilaga H:1

Page 76: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

Two Channel OpticalIncremental Encoder Modules

Technical Data

Features• High Performance• High Resolution• Low Cost• Easy to Mount• No Signal Adjustment

Required• Small Size• -40°C to 100 °C Operating

Temperature• Two Channel Quadrature

Output• TTL Compatible• Single 5 V Supply

DescriptionThe HEDS-9000 and the HEDS-9100 series are high performance,low cost, optical incrementalencoder modules. When used witha codewheel, these modulesdetect rotary position. Themodules consist of a lensed (LED)source and a detector IC enclosedin a small C-shaped plasticpackage. Due to a highly col-limated light source and uniquephotodetector array, thesemodules are extremely tolerant tomounting misalignment.

The two channel digital outputsand the single 5 V supply inputare accessed through five 0.025

inch square pins located on 0.1inch centers.

Standard resolutions for theHEDS-9000 are 500 CPR and1000 CPR for use with a HEDS-6100 codewheel or equivalent.

ESD WARNING: NORMAL HANDLING PRECAUTIONS SHOULD BE TAKEN TO AVOID STATIC DISCHARGE.

HEDS-9000HEDS-9100

Package Dimensions

26.67 (1.05)

HEDS-9X00

15.2 (0.60)

CL

17.27 (0.680)

20.96 (0.825)

1.85 (0.073)

8.64 (0.340) REF.

ALIGNING RECESS 2.44/2.41 DIA. (0.096/0.095) 2.16 (0.085) DEEP

1.02 ± 0.10 (0.040 ± 0.004)

5.1 (0.20)

X00

YY

XX

OPTION CODE

0.63 (0.025) SQR. TYP.

2.54 (0.100) TYP.

DATE CODE

1.0 (0.04)

3.73 ± 0.05 (0.147 ± 0.002)

2.67 (0.105) DIA. MOUNTING THRU HOLE 2 PLACES

2.44/2.41 X 2.79 (0.096/0.095 X 0.110)

2.16 (0.085) DEEP

OPTICAL CENTER

1.52 (0.060)

20.8 (0.82)

11.7 (0.46)

8.6 (0.34)

1.78 ± 0.10 (0.070 ± 0.004)

2.92 ± 0.10 (0.115 ± 0.004)

10.16 (0.400)

5.46 ± 0.10 (0.215 ± 0.004)

OPTICAL CENTER LINE

2.54 (0.100)

2.21 (0.087)

5.8 (0.23)

6.35 (0.250) REF.

ALIGNING RECESS 2.44/2.41 X 2.79 (0.096/0.095 X 0.110) 2.16 (0.085) DEEP

4.11 (0.162)

ALIGNING RECESS 2.44/2.41 DIA. (0.096/0.095) 2.16 (0.085) DEEP

OPTICAL CENTER

45°

8.81 (0.347)

11.9 (0.47)

4.75 ± 0.10 (0.187 ± 0.004)

2.9 (0.11)

1.8 (0.07)

6.9 (0.27)

VC

C

GN

D

5 C

H. B

4 V

CC

3 C

H. A

2 N

.C.

1 G

ND

SIDE A SIDE BTYPICAL DIMENSIONS IN

MILLIMETERS AND (INCHES)

Bilaga I, Givaren i pendeln

Page 1 of 8

Page 77: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

2

For the HEDS-9100, standardresolutions between 96 CPR and512 CPR are available for usewith a HEDS-5120 codewheel orequivalent.

ApplicationsThe HEDS-9000 and 9100provide sophisticated motiondetection at a low cost, makingthem ideal for high volumeapplications. Typical applicationsinclude printers, plotters, tapedrives, and factory automationequipment.

Note: Agilent Technologiesencoders are not recommendedfor use in safety criticalapplications. Eg. ABS brakingsystems, power steering, lifesupport systems and critical caremedical equipment. Pleasecontact sales representative ifmore clarification is needed.

Theory of OperationThe HEDS-9000 and 9100 are C-shaped emitter/detector modules.Coupled with a codewheel, theytranslate the rotary motion of ashaft into a two-channel digitaloutput.

As seen in the block diagram,each module contains a singleLight Emitting Diode (LED) as itslight source. The light iscollimated into a parallel beam bymeans of a single polycarbonatelens located directly over theLED. Opposite the emitter is theintegrated detector circuit. ThisIC consists of multiple sets ofphotodetectors and the signalprocessing circuitry necessary toproduct the digital waveforms.

The codewheel rotates betweenthe emitter and detector, causingthe light beam to be interrupted

Block Diagram

by the pattern of spaces and barson the codewheel. Thephotodiodes which detect theseinterruptions are arranged in apattern that corresponds to theradius and design of the ode-wheel. These detectors are alsospaced such that a light period onone pair of detectors correspondsto a dark period on the adjacentpair of detectors. The photodiode

outputs are then fed through thesignal processing circuitryresulting in A, A, B, and B. Twocomparators receive these signalsand produce the final outputs forchannels A and B. Due to thisintegrated phasing technique, thedigital output of channel A is inquadrature with that of channel B(90 degrees out of phase).

Output Waveforms

Bilaga I, Givaren i pendeln

Page 2 of 8

Page 78: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

3

Absolute Maximum RatingsStorage Temperature, TS ..................................................................... -40°C to 100°COperating Temperature, TA ................................................................ -40°C to 100°CSupply Voltage, VCC ...................................................................................... -0.5 V to 7 VOutput Voltage, VO ........................................................................................ -0.5 V to VCCOutput Current per Channel, Iout ................................................. -1.0 mA to 5 mA

DefinitionsCount (N): The number of barand window pairs or counts perrevolution (CPR) of thecodewheel.

1 Shaft Rotation = 360mechanicaldegrees,

= N cycles.

1 cycle (C) = 360electricaldegrees (°e),

= 1 bar andwindow pair.

Pulse Width (P): The number ofelectrical degrees that an outputis high during 1 cycle. This valueis nominally 180°e or 1/2 cycle.

Pulse Width Error (∆P): Thedeviation, in electrical degrees ofthe pulse width from its idealvalue of 180°e.

State Width (S): The number ofelectrical degrees between a

transition in the output of channelA and the neighboring transitionin the output of channel B. Thereare 4 states per cycle, eachnominally 90°e.

State Width Error (∆S): Thedeviation, in electrical degrees, ofeach state width from its idealvalue of 90°e.

Phase (φ): The number of elec-trical degrees between the centerof the high state of channel A andthe center of the high state ofchannel B. This value is nominally90°e for quadrature output.

Phase Error (∆φ): The deviationof the phase from its ideal valueof 90°e.

Direction of Rotation: When thecodewheel rotates in the directionof the arrow on top of themodule, channel A will leadchannel B. If the codewheelrotates in the opposite direction,channel B will lead channel A.

Optical Radius (Rop): The dis-tance from the codewheel’s centerof rotation to the optical center(O.C.) of the encoder module.

Recommended Operating Conditions

Parameter Symbol Min. Typ. Max. Units Notes

Temperature T -40 100 °CSupply Voltage VCC 4.5 5.5 Volts Ripple < 100 mVp-p

Load Capacitance CL 100 pF 3.3 kΩ pull-up resistor

Count Frequency f 100 kHz Velocity (rpm) x N60

Note: The module performance is guaranteed to 100 kHz but can operate at higher frequencies.

Encoding CharacteristicsEncoding Characteristics over Recommended Operating Range and Recommended Mounting Tolerances.These Characteristics do not include codewheel/codestrip contribution.

Description Sym. Typ. Case 1 Max. Case 2 Max. Units Notes

Pulse Width Error ∆P 30 40 °eLogic State Width Error ∆S 30 40 °ePhase Error ∆φ 2 10 105 °e

Case 1: Module mounted on tolerance circle of ± 0.13 mm (± 0.005 in.).Case 2: HEDS-9000 mounted on tolerances of ± 0.50 mm (0.020").

HEDS-9100 mounted ontolerances of ± 0.38 mm (0.015").

Bilaga I, Givaren i pendeln

Page 3 of 8

Page 79: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

4

Electrical CharacteristicsElectrical Characteristics over Recommended Operating Range, typical at 25°C.

Parameter Symbol Min. Typical Max. Units Notes

Supply Current ICC 17 40 mA

High Level Output Voltage VOH 2.4 Volts IOH = -40 µA max.

Low Level Output Voltage VOL 0.4 Volts IOL = 3.2 mA

Rise Time tr 200 ns CL = 25 pF

Fall Time tf 50 nsRL = 11 kΩ pull-up

Derating Curves over Extended Operating Frequencies (HEDS-9000/9100)Below are the derating curves for state, duty, phase and VOH over extended operating frequencies of up to240 kHz (recommended maximum frequency is 100 kHz). The curves were derived using standard TTL load.–40°C operation is not feasible above 160 kHz because VOH will drop below 2.4 V (the minmum TTL for logicstate high) beyond that frequency.

120 220

FREQUENCY (kHz)

-40

0

CH

AN

GE

IN P

UL

SE

WID

TH

ER

RO

R

(EL

EC

TR

ICA

L D

EG

RE

E)

240

-30

-20

160

-10

140 200180

100°C

25°C

-40°C

-50120 220

FREQUENCY (kHz)

10

50

CH

AN

GE

IN S

TA

TE

WID

TH

ER

RO

R

(EL

EC

TR

ICA

L D

EG

RE

E)

240

20

30

160

40

140 200180

100°C

25°C

-40°C

0

120 220

FREQUENCY (kHz)

-10

0

CH

AN

GE

IN P

HA

SE

ER

RO

R

(EL

EC

TR

ICA

L D

EG

RE

E)

240

-5

160140 200180

100°C

25°C

-40°C

120 220

FREQUENCY (kHz)

3

5

CH

AN

GE

IN V

OH

(V

OL

TS

)

240

4

160140 200180

100°C25°C

-40°C

2

1

0

Bilaga I, Givaren i pendeln

Page 4 of 8

Page 80: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

5

Recommended Codewheel Characteristics

Figure 1. Codestrip Design

Codewheel Options

OpticalHEDS CPR RadiusSeries (N) Option mm (in.)

5120 96 K 11.00 (0.433)5120 100 C 11.00 (0.433)5120 192 D 11.00 (0.433)5120 200 E 11.00 (0.433)5120 256 F 11.00 (0.433)5120 360 G 11.00 (0.433)5120 400 H 11.00 (0.433)5120 500 A 11.00 (0.433)5120 512 I 11.00 (0.433)

6100 500 A 23.36 (0.920)6100 1000 B 23.36 (0.920)

Parameter Symbol Minimum Maximum Units Notes

Window/Bar Ratio φw/φb 0.7 1.4

Window Length LW 1.8 (0.071) 2.3 (0.09) mm (inch)

Absolute Maximum RC ROP + 1.9 (0.0075) mm (inch) Includes eccentricityCodewheel Radius errors

Bilaga I, Givaren i pendeln

Page 5 of 8

Page 81: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

6

Mounting Considerations

Figure 2. Mounting Plane Side A. Figure 3. Mounting Plane Side B.

Figure 4. Mounting as Referenced to Side A. Figure 5. Mounting as Referenced to Side B.

Bilaga I, Givaren i pendeln

Page 6 of 8

Page 82: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

7

01 02 03 04 05 06 08 09 10 11 12 13 14

HEDS-6100 A * * *

B * * * *

MountingManufacturer Part Number Surface

AMP 1203686-4 Both640442-5 Side B

DuPont 65039-032 with Both4825X-000 term.

HP HEDS-8902 Side Bwith 4-wire leads (see Fig. 6)

Molex 2695 series with Side B2759 series term.

Figure 6. HEDS-8902 Connector.

Connectors

A B C D E F G H I J K L S T U

HEDS-9000 * * * * *

HEDS-9000 Option HEDS-6100 Option0 0

Ordering Information

Resolution(Cycles/Rev)

A - 500 CPRB - 1000 CPRJ - 1024 CPRT - 2000 CPR*U - 2048 CPR*

Shaft Diameter

06 - 1/4 in. 10 - 5/8 in.08 - 3/8 in. 12 - 6 mm09 - 1/2 in. 13 - 8 mm

Bilaga I, Givaren i pendeln

Page 7 of 8

Page 83: A general interface for computer control in real timehv.diva-portal.org/smash/get/diva2:214959/FULLTEXT01.pdf · A general interface for computer control in real time 1.4 Software

01 02 03 04 05 06 08 09 10 11 12 13 14

HEDS-5120 A * * * * * * * * *

C * * * * * *

D *

E * *

F *

G * * * * * *

H * * * * *

I * * * * * *

K * *

HEDS-910 0 Option HEDS-5120 Option0 0

Shaft Diameter

01 - 2 mm 11 - 4 mm02 - 3 mm 14 - 5 mm03 - 1/8 in. 12 - 6 mm04 - 5/32 in. 13 - 8 mm05 - 3/16 in.06 - 1/4 in.

Resolution(Cycles/Rev)

S - 50 CPRK - 96 CPRC - 100 CPRE - 200 CPRF - 256 CPRG - 360 CPR

H - 400 CPRA - 500 CPR I - 512 CPRB - 1000 CPR*J - 1024 CPR*

Lead

0 - Straight Leads1 - Bent Leads

A B C D E F G H I J K S T U

HEDS-9100 * * * * * * * * * * *

HEDS-9101 * * * *

www.agilent.com/semiconductorsFor product information and a complete list ofdistributors, please go to our web site.For technical assistance call:Americas/Canada: +1 (800) 235-0312 or(408) 654-8675Europe: +49 (0) 6441 92460China: 10800 650 0017Hong Kong: (+65) 6271 2451India, Australia, New Zealand: (+65) 6271 2394Japan: (+81 3) 3335-8152(Domestic/Interna-tional), or 0120-61-1280(Domestic Only)Korea: (+65) 6271 2194Malaysia, Singapore: (+65) 6271 2054Taiwan: (+65) 6271 2654Data subject to change.Copyright © 2002 Agilent Technologies, Inc.Obsoletes 5988-5857ENMay 8, 20025988-6712EN

Bilaga I, Givaren i pendeln

Page 8 of 8