webee.technion.ac.ilwebee.technion.ac.il/control/info/projects/students/2012... · web viewtechnion...

45
Project report Design a digitally controlled analog PID controller Designer Idan Yahav Supervisor: David Gidony Semester: Winter Year: 2012 – בבב"ב1 TECHNION - ISRAEL INSTITUTE OF TECHNOLOGY Department of Electrical Engineering Control and Robotics Lab

Upload: phungkhue

Post on 12-May-2018

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Project reportDesign a digitally controlled analog PID controller

Designer

Idan Yahav

Supervisor: David Gidony

Semester: Winter

Year: 2012 – תשע"ב

1

TECHNION - ISRAEL INSTITUTE OF TECHNOLOGY

Department of Electrical EngineeringControl and Robotics Lab

Page 2: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Table of Contents

Abstract.......................................................................................................................................................3

Introduction:...............................................................................................................................................4

Part a - Analog.....................................................................................................................................5

Part b – digital:....................................................................................................................................5

Specifications...........................................................................................................................................6

Implementation:......................................................................................................................................7

Chapter 1: designing the amplifiers:............................................................................................................9

Gain amplifier (P and K):..........................................................................................................................9

Simulations:.......................................................................................................................................10

Differentiator amplifier (D):...................................................................................................................13

Simulations:.......................................................................................................................................14

Integrator amplifier (I):..........................................................................................................................18

Simulations:.......................................................................................................................................19

Summing amplifier................................................................................................................................22

Chapter 2: Digital interface........................................................................................................................26

1. LCD screen.....................................................................................................................................26

2. Digital potentiometer – next project.............................................................................................30

3. Microcontroller..............................................................................................................................31

Intro...................................................................................................................................................31

Interrupts...........................................................................................................................................31

The main program:............................................................................................................................31

3. DE bounce......................................................................................................................................32

Chapter 3: Calibration – next project........................................................................................................34

Chapter 4: protection – next project.........................................................................................................35

Measurements..........................................................................................................................................36

Next project tasks:.....................................................................................................................................36

References.................................................................................................................................................37

2

Page 3: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Abstract

In the control and Robotics studies in the Technion there is a lab that focuses on a PID controller. The tuning of the PID amplifiers is done using trimmers. This method makes it difficult for the student to learn how each element in the PID controller affects the final outcome.

The purpose of this project is to design a digital controlled analog PID controller. The tuning of this controller will be done using push buttons. This controller will include an LCD screen that will enable the user to see and compare the gain of each amplifier. In addition, since it is a digital controlled controller, the steps of the different gains are at a known resolution.

3

Page 4: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Introduction:

The PID controller is everywhere - temperature, motion, flow controllers - and it's available in analog and digital forms. It helps get your output (velocity, temperature, position) where you want it, in a short time, with minimal overshoot, and with little error.

PID stands for: P -Proportional, I - Integral, D - Derivative. These terms describe three basic mathematical functions applied to the error signal, Verror = Vset - Vsensor. This error represents the difference between where you want to go (Vset), and where you're actually at (Vsensor). The controller performs the PID mathematical functions on the error and applies their sum to a process (motor, heater, etc.).

Tuning a system means adjusting three multipliers Kp, Ki and Kd, adding in various amounts of these functions to get the system to behave the way you want. The table below summarizes the PID terms and their effect on a controlled system.

Term Math Function Effect on Control SystemPProportional

KP x VerrorTypically the main drive in a control loop, KP reduces a large part of the overall error.

IIntegral

KI x ∫ Verror dtReduces the final error in a system. Summing even a small error over time produces a drive signal large enough to move the system toward a smaller error.

DDerivative

KD x dVerror / dtCounteracts the KP and KI terms when the output changes quickly. This helps reduce overshoot and ringing. It has no effect on final error.

Table 1 - PID terms

In the following figure you can see an abstract flow of the PID controller

4

Page 5: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Figure 1 - abstract flow of the PID controller

This project is divided to two parts:

Part a - AnalogDesigning four basic amplifiers: integrator, differentiator, gain amplifier and a summing amplifier. The design will be according to the given spec.

Part b – digital:Writing a code to a microcontroller that will enable the user to change the different gains with push buttons. The outputs of the microcontroller are the LCD screen and a digital potentiometer that will enable us to create amplifiers with a variable gain.

In addition a calibration method needs to be set in order to cancel the effect of the error that that analog components have.

5

Page 6: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Specifications

As mentioned in the Abstract, the main purpose of the project is to design 4 amplifiers according to the following spec:

Input will be a Sin or a step voltage. Output preferred is analog and PWM. The card should be “student proof” meaning that if the student will connect one of the pins to

the wrong voltage the card won’t be damaged. The user will be able to control the gain of each amplifier and the values of the amplifiers will be

displayed on an LCD screen.

Parameter DetailsRequirement

Unit NoteMin Nom Max

Operating voltage (analog signal)

14.25 15 15.75 [V] ±5%

Input voltage

peak to peak voltage 0.1 [V]

Since we use electrolyte capacitors the user must make sure that the input is positive

Bandwidth 0.01 200 [Hz]

The active area will be around 10[Hz].

Because the controller is connected to an engine there should be unwanted poles in frequency lower the 1 [Hz]

Accuracy of the amplifiers

Gain range 0 10

Gain step size 0.1

Resolution for calibration

0.05

Resolution for display

0.05

Table 2 - The specification of the card

6

Page 7: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Implementation:

After reviewing several implementations and similar cards on the internet the conclusion was:

1. There is only 1 implementation offered to sale : http://www.thinksrs.com/products/SIM960.htm2. This implementation is expansive (about 1800$ per unit without the computer interface).3. Every other method of implementation is similar to the one CRL lab already has.

In conclusion: there isn’t a good reference to use.

The analog implementation was done in two planes:

1. Design a gain amplifier, a differentiator and an integrator using articles that were found.All of them will have a gain=1.The differentiator and the integrator will have before them a gain amplifier (identical to the P amplifier) with variable gain.

2. The variable gain amplifier will be implemented in one of the following ways:a. Using a transistor (in the linear region) as a resistor. And a DAC that will convert the

digital code sent from the PIC controller to the Vgs of the transistor.b. Using a digital potentiometer.

Since the second method is easier to implement and the error of each step is known with a better accuracy we chose the digital potentiometer method.

The digital implementation will be done using a PIC controller that will receive +1 or -1 from the user and will write the appropriate code to the LCD screen and the digital potentiometer.

The following figure describes the top design:

7

Page 8: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Figure 2 - a top level description of the card

8

Page 9: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Chapter 1: designing the amplifiers:

All of the amplifiers are implemented using an op amp of analog devices: op77. Datasheet attached

Gain amplifier (P and K):

Implementation of a gain amplifier can be found in the attached file.

The selected gain amplifier is described in figure 3. The transfer function of this amplifier is:

. R2 was chosen as the digital potentiometer in order to get a linear function (gain wise).

The digital potentiometer that were found, with error are . In order to reduce noise the smaller potentiometer was chosen. The second resister’s value was chosen in order to get maximum gain of 10.

The chosen values are:

Figure 3 - The gain amplifier

9

Page 10: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Simulations:

Rout:Simulation showed that Rout of the amplifier in the range 0-200 [Hz], with input =0.1 [V] is less than 1ohm.

Bench:

Figure 4 - bench of Rout of the P amplifier

Results:

Figure 5 – Rout of P amplifier

10

Page 11: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Stability: PM is 87 Open loop gain is 120[dB] UGB=55K.

Bench

Figure 6 –bench for stability check on P amplifier

11

Page 12: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Results:

Figure 7 - stability results of P amplifier

Close loop simulation results: Up to 2K[hz] gain doesn’t change BW=19K[Hz]

Frequency

10mHz 1.0Hz 100Hz 10KHz 1.0MHz 100MHz1.0mHz 1.0GHzDB(V(vout_total))

-100

-50

0

50

(19.307K,17.065)

(2.2721K,20.001)

Figure 8 - close loop simulation resuls of the P amplifier

12

Page 13: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Differentiator amplifier (D):

Implementation of a differentiator amplifier can be found in the attached file.

Since the differentiator has a higher gain in high frequency (noise appears in high frequency) we will narrow the range of frequency where the amplifier functions as a differentiator by adding a serial resistor to the capacitor. A more accurate explanation regarding the stability can be found here:

The selected gain amplifier is described in figure 9. The transfer function of this amplifier is:

. A pole was added to improve stability in . According to the spec,

.

In order to get a gain =1 we will chose RC=0.1 and use the summing amplifier to amplify the signal X10. That is because we want to stay stable and in close loop the pole appears before 200[Hz].In order to choose the specific RC a few iterations were done on the open loop until stability achieved.

The chosen values are:

Figure 9 - Differentiator amplifier

13

Page 14: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Simulations:

Stability (open loop analysis):

According the math that was presented

in the .mht file we have in open loop:

With an extra pole due to the amplifier (there are more poles in higher frequency).

Open loop simulation produced:

PM=87 DC gain=141[dB] UGB=4.8K

Bench:

Figure 10 - Bench of the D amplifier

14

Page 15: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Results:

Frequency

10mHz 1.0Hz 100Hz 10KHz 1.0MHz 100MHz1.0mHzDB(V(v_open_loop))

-200

-100

0

100

200

(4.8761K,53.936m)(1.1351m,141.314)

P(V(v_open_loop))

-193d

-0d

-400d

180d

SEL>>

(4.8761K,87.426)

Figure 11 - open loop results of the D amplifier

15

Page 16: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Close loop simulation:We can see the 0 [dB] in 1.6 [Hz] = 10 [rad/sec] as expected and the pole is in ~200 [Hz]

Frequency

1.0mHz 10mHz 100mHz 1.0Hz 10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHzDB(V(v_out))

-80

-40

0

40

80

(190.907,38.927)

(776.982,41.906)

(1.6050,72.927m)

Figure 12 - close lop simulation of the D amplifier

16

Page 17: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Time domainSince we have RC=0.1 we get for a signal with slope=1 an output =-0.1 [V]

Time

0s 20ms 40ms 60ms 80ms 100ms 120ms 140ms 160ms 180ms 200msV(v_out)

-100mV

-50mV

-0mV

50mV

(57.692m,-99.977m)

V(v_in)0V

50mV

100mV

SEL>>(10.000m,0.000)

(110.000m,100.000m)

Figure 13 - time domain results of the D amplifier

17

Page 18: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Integrator amplifier (I):

Implementation of an integrator amplifier can be found in the attached file.

The op amp has a constant offset voltage that with the infinite amplification of the op amp causes the output voltage to reach saturation. In order to avoid that problem we lower the gain of the amplifier in low frequency.

Extra material and methods to avoid the saturation problems can be found here

The selected gain amplifier is described in figure 14. The transfer function of this amplifier is:

.The pole will be at . We will chose the same RC as the differentiator (for RC=1) and choose R’ to be 20 times R. let say that we insert a constant input to the

integrator. When the capacitor is charged and the output stop rising. Since the maximum

input voltage of the integrator is 1[V] and Vdd=15, Vee=-15 if we will choose it won’t matter because the output cannot be higher or lower than Vdd, Vee accordantly.

According to the implementation file:

The chosen values are:

Figure 14 - The integrator amplifier in s plane

18

Page 19: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

19

Page 20: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Simulations:

Stability (open loop analysis): (the integrator is unstable by definition).

Open loop analysis showed that the output is :

Meaning:

With an extra pole due to the amplifier (there are more poles in higher frequency).

PM=20. unstable need to solve

Close loopWe can see the 0 dB in f=0.16 [Hz] =1 [rad/sec], the pole is ~10 [mHz] and that the zero is further than 200 [Hz]

20

Page 21: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Frequency

1.0mHz 10mHz 100mHz 1.0Hz 10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHzdB(V(Vout))

-100

-50

0

50

(8.1463m,22.908)

(1.1345m,25.933)

(160.502m,-83.854m)

Figure 15 - results of the close loop simulation I amplifier

21

Page 22: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Time domainSince we have RC=16 we get for 0.1 sec an integration on 1 [V] will give an output = 1/RC*0.1=6.25[mV]

Time

0s 20ms 40ms 60ms 80ms 100ms 120ms 140ms 160ms 180ms 200msV(Vout)

-10mV

-5mV

0V

5mV

(10.202m,-52.628u)

(110.162m,-6.2704m)

(10.154m,-49.597u)(10.154m,-49.597u)

V(vin)0V

0.4V

0.8V

1.2V

SEL>> (110.162m,0.000)

(10.154m,1.0000)

Figure 16 - Time domain results of the I amplifier

22

Page 23: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Summing amplifier

Implementation of a gain amplifier can be found in the attached file.

The selected gain amplifier is described in figure 3. The transfer function of this amplifier is:

.

We will use a Rf=20K and Ri (i=1,2,3) will be correlated to the amplifier connected to it.

Figure 17 - summing amplifier

Stability:PM=87

UGB=47 K[Hz]

DC gain=119 [dB]

23

Page 24: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Bench:

Figure 18 - Bench of the summing amplifier

Results:

Frequency

10mHz 1.0Hz 100Hz 10KHz 1.0MHz 100MHz1.0mHz 1.0GHzDB( V(v_open_loop))

-200

0

200

SEL>>

(1.9660m,119.038)(47.742K,99.253m)

P(V(v_open_loop))-387d

-193d

-0d

180d

(47.742K,87.488)

Figure 19 - Simulation results of the summing amplifier (open loop)

24

Page 25: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Rin

Bench:

Rin of 20K input:

Frequency

1.0mHz 10mHz 100mHz 1.0Hz 10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHzV1(V_in)/ I(V_in)

20K

22K

24K

26K

28K

(10.000K,20.015K)

Figure 20 - Rin of the summing amplifier

Rin of 2K input

Frequency

1.0mHz 10mHz 100mHz 1.0Hz 10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHzV1(V_in)/ I(V_in)

0

4K

8K

12K

16K

20K

24K

(4.8697K,2.0087K)

Figure 21 - Rin2 of the summing amplifier

25

Page 26: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Close loop simulation: Works up to 1K[Hz] BW=17K[Hz]

Frequency

10mHz 1.0Hz 100Hz 10KHz 1.0MHz 100MHz1.0mHz 1.0GHzDB(V(vout_total))

-60

-40

-20

-0

20

(50.119K,17.038)(979.285,19.998)

Figure 22 - Close loop simulation results of the summing amplifier

26

Page 27: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Chapter 2: Digital interface

1. LCD screenThe LCD screen has 14 pins as described in the following Table.

Table 3 - The LCD pins list

Vdd should be 5[V] ±5%. Vss is gnd.

VLC determines the contrast and should be in the range of VSS to VSS-2[V].

The function pins are described in the next Table:

27

Page 28: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Table 4 - Terminal function

The timing operation is described in the following figure:

28

Page 29: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Figure 23 - Data write to the LCD screen

Before writing to the LCD an initialization needs to be done as described in Figure 16. After each line we need to raise the enable. Since we work in 4 bits mode we need to raise enable after each line so the LCD will read the whole data.

29

Page 30: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Figure 24 - Initialization flow

After the initialization we can start writing the LCD screen. An example flow is described in figure 17.

30

Page 31: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Figure 25 - An example of a writing flow

The entire operation flow and code chart can be found in the attached document .

2. Digital potentiometer – next project

The interface of the digital potentiometer is done using I2C protocol

. Since the writing is done using an enable line we can use the same data and clock lines of the protocol to all the digital potentiometers in the card and differ them from one another using different enable lines.

The voltage drop must be < Vdd = 5[V]. Since the input of the card is 0.1 [V] a maximum gain =10 will be ok.

31

Page 32: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

The code for the potentiometer is not done. Data sheet can be found here.

3. Microcontroller

IntroA microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. A Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.

InterruptsMicrocontrollers must provide real time (predictable, though not necessarily fast) response to events in the embedded system they are controlling. When certain events occur, an interrupt system can signal the processor to suspend processing the current instruction sequence and to begin an interrupt service routine (ISR, or "interrupt handler"). The ISR will perform any processing required based on the source of the interrupt before returning to the original instruction sequence. It is important to understand that after the interrupt ends the main program will continue from the command that was supposed to occur and not from the begging of the program. Due to that flow we often write the program with an endless loop .Possible interrupt sources are device dependent, and often include events such as an internal timer overflow, completing an analog to digital conversion, a logic level change on an input such as from a button being pressed, and data received on a communication link.

In this project we used the PIC18f4431 microcontroller and wrote the code with MPLAB using a CCS

compiler. Datasheet of the PIC18f4431 can be found here

The main program:The main program includes 2 main commends:

1. Writing the screen the values of PID K.2. Writing the digital potentiometer the values of PID K.

Using a selector of 4 outputs we can determine which of the PID,K gains we want to change. For each of the 2 buttons (a plus and a minus button) there are 2 main interrupts that occur after a button was pressed:

1. For a single press: count = count ± 0.1 (depend on the button that was pressed).2. For a long press: count = count ± 0.9 the first time and count = count ± 1 on the rest.

32

Page 33: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

The second interrupts uses a built in timer in the microcontroller that when overflows an interrupt occurs. When a button is pressed we get count = count ± 0.1 and if it’s a long press count = count ± 0.9 bringing us to a ± 1 jump the first time and count = count ± 1 in the rest.

3. DE bounceContact bounce (also called chatter) is a common problem with mechanical switches and relays. Switch and relay contacts are usually made of springy metals that are forced into contact by an actuator. When the contacts strike together, their momentum and elasticity act together to cause bounce. The result is a rapidly pulsed electric current (as shown in figure 8) instead of a clean transition from zero to full current. The effect is usually unimportant in power circuits, but causes problems in some analogue and logic circuits that respond fast enough to misinterpret the on-off pulses as a data stream.

Contact circuits can be filtered to reduce or eliminate multiple pulses. In digital systems, multiple samples of the contact state can be taken or a time delay can be implemented so that the contact bounce has settled before the contact input is used to control anything. Another method is using an RC filter that will filter out the hazard.

In addition since most of the interrupts are triggered by more the one pin in the microcontroller we need to make sure that all the unused pins are grounded.

Figure 26 - Output voltage of a pressed button

33

Page 34: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Using the RC equation . If we choose RC= 1 u we will get for Vo=90% x Vdd,

. In addition a de bounce function was implemented in the c code to ensure we avoid chatters.

34

Page 35: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Chapter 3: Calibration – next project

The calibration of the card is divided to 3 parts.

1. Calibration of the integrator and the differentiator:The calibration here will be done manually. In order to calibrate the integrator and the differentiator one will need to insert a sin in the desired frequency .The input needs to be inserted with an offset to insure that the output is positive (see the note for input voltage in the spec).Using trimmers that are located next to each resistor the gain needs to be 1.The measurement will be done from the input of the integrator/differentiator to the output of the summing amplifier.

2. Calibration of the 4 adjustable amplifiersThe method is inserting an input of 0.1[V] to each amplifier and write a code in the microcontroller that will go over all the codes. In order to measure the gain there are two options:

The last preferred option is to sample the output using an external scope and a Matlab script. Once you are done you have a table that consists out of two columns: The digital potentiometer input value and the gain achieved. Then by sorting it and comparing it to a known table of gains (0.1:0.1:10) we will need to create a new table which links a gain to its corresponding resistor input. In the end we need to insert this table in a form of an array to the proper function in the controller’s code.

The better option is to do the whole procedure using a dedicated code and the internal ADC that the microcontroller has.

35

Page 36: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Chapter 4: protection – next project

Since there is a demanded to make the card student proof, a protection solution needs to be implemented in the output and input of the card.

We need to protect the card from the following errors:1. A negative input (in case we use electrolytic capacitors). Before implementing the error we need

to make sure that we really use electrolytic capacitors2. Input is larger than 0.5 [V]. The input signal enters a block that contains the digital

potentiometer. The digital potentiometer cannot have a voltage larger than Vdd on its terminals.

3. Output protection – in case the card won’t have a dedicated power supply. A student can insert Vdd or more to the output. A similar protection will be needed on the power supply pins.

Optional : make an indicator (a led or a message on the LCD screen) that there is an error.

36

Page 37: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

Measurements

The measurements are done with an Agilent scope. File attached.

Since the input impedance of the scope is 1 MΩ ±1% in parallel with 18 pF ± 3 pF we should expect some error while measuring some of the amplifiers. In order to avoid a large error one will need to measure the performance of the amplifiers in the output of the summing amplifier.

Next project tasks:

1. Stabilize the integrator.2. Design a power supply: ±15 [V], gnd, 5[V] and an adjustable voltage down to -5 [V].3. Implement a code for the digital potentiometer.4. Design protection blocks for the card.5. Calibration solution.6. Measurements on the card.7. Design a printed card.8.

37

Page 38: webee.technion.ac.ilwebee.technion.ac.il/control/info/Projects/Students/2012... · Web viewTECHNION - ISRAEL INSTITUTE OF TECHNOLOGYDepartment of Electrical EngineeringControl and

References

http://en.wikipedia.org/wiki/Microcontroller

http://en.wikipedia.org/wiki/Switch

http://electronics.stackexchange.com/questions/22209/calculating-resistor-and-capacitor-values-for-an-op-amp-differentiator-circuit-dhttp://www.ecircuitcenter.com/circuits/opdfr/opdfr.htmhttp://www.ecircuitcenter.com/circuits/opdfr_OL/opdfr_open_loop.htm

http://www.ecircuitcenter.com/circuits/pid1/pid1.htm

 

http://circuitalley.phpnet.us/circuit4.html

http://www.underwar.co.il/14-IT-Security/d318/

38