ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance...

23
ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes the frequency or period of oscillation of a timer circuit. A digital circuit then measures this change in the time period and displays an integer value between 0 to 99 (base 10) to indicate the amount of capacitance. A capacitance value of C min would be indicated by a value of 0 and a value of C max would be indicated by a value of 99. The current maximum value will be stored by the sensor circuit and displayed on the seven-segment LED displays on the DE2

Transcript of ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance...

Page 1: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

ECE 3450 M. A. Jupina, VU, 2015

Capacitance Sensor Project

Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes the frequency or period of oscillation of a timer circuit. A digital circuit then measures this change in the time period and displays an integer value between 0 to 99 (base 10) to indicate the amount of capacitance. A capacitance value of Cmin would be indicated by a value of 0 and a value of Cmax would be indicated by a value of 99. The current maximum value will be stored by the sensor circuit and displayed on the seven-segment LED displays on the DE2 board.

Page 2: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Capacitance Sensor Project

555 Timer

variablefrequency

or period

OUTPUT0 - 99

7-segment displays

d

r oCd

A

2

ln

effC Hba

H

a

b

Sports Applications Tank Application

ECE 3450 M. A. Jupina, VU, 2015

Page 3: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Application of Your Capacitance Sensor

• Assume that you are designing an impact sensor for a boxing glove where you want to capture only the maximum impact of the glove on a boxing bag during a training session.

• For a range of possible impacts, assume that no impact on the capacitance sensor is a value of Cmin, whereas the maximum possible impact on the capacitance sensor by a boxer such as Mike Tyson would be a value of Cmax. The display on the glove would indicate a value of 0 for no impact and a value of 99 if Mike Tyson hit a boxing bag with the glove.

• A reset button will also be available to clear the sensor so that the maximum impact value can again be captured.

ECE 3450 M. A. Jupina, VU, 2015

Page 4: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Specifications of Your Capacitance Sensor

• Assume that the capacitance of the sensor varies as a linear function of the impact applied to the boxing glove.

• The maximum capacitance that can be measured by the sensor is

Cmax = 4 Cmin

• Therefore, the range of capacitance that is to be measured is

C = Cmax - Cmin = 3 Cmin

• When C=Cmin, the period of the timer circuit will be Tmin, whereas when C=Cmax the period of the timer circuit is Tmax since the period of the timer circuit increases as the RC time constant time increases. The timer circuit will be a 555 timer.

ECE 3450 M. A. Jupina, VU, 2015

Page 5: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Specifications of Your Capacitance Sensor

• An 8-bit counter in the Timer_Count block will be used to measure the period of oscillation of the timer circuit.

• The clock frequency used by the 8-bit counter can be one of the following frequencies: 1 KHz, 10 KHz, or 100 KHz.

• Use the following Cmin values depending on your lab station #:

o Cmin = 0.001 F, for lab stations 1, 4, 7, 10, 13, & 16

o Cmin = 0.01 F, for lab stations 2, 5, 8, 11, 14, & 17

o Cmin = 0.1 F, for lab stations 3, 6, 9, 12, 15, & 18

• A subtraction circuit will be used to null the value of the counter when T=Tmin by offsetting the output value such that it equals 0 when T=Tmin. Thereby, a value of 99 at the output represents the time period T = Tmax – Tmin (Note: T is directly proportional to C).

ECE 3450 M. A. Jupina, VU, 2015

Page 6: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Block Diagram of the Capacitance Sensor

CLK_DIV

- Seven_Seg_Display

50 MHz Oscillator

2f, T f/2, 2T T

IME

R_C

OU

NT

OFFSET 0 to 99

1KHz10KHz

or100KHz

When C = Cmin, Output = 0When C = Cmax, Output = 99

Reset

ECE 3450 M. A. Jupina, VU, 2015

Page 7: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Quartus Block Diagram File to Verify Functionality

ECE 3450 M. A. Jupina, VU, 2015

Page 8: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Quartus II Simulation

?? ?

On this time scale, the details of this signal are not seen since its period is too small.

Counter in Timer_Countblock is counting Output in Timer_Count block

is again increasing sincecount_final > count_temp

count_temp < count_finalso count_temp valueis not captured since onlythe max value is captured

ECE 3450 M. A. Jupina, VU, 2015

Page 9: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Prelab AssignmentPre-Lab i. For your given Cmin and Cmax values, determine the possible values of T

(=RC) given that the R values will be either in the K10’s Kor low 100’s K range (possible resistor values are 1K, 2.2K, 3.3K, 4.7K, 10K, 22K, 33K, 47K, and 100K and can be combined in series or parallel configurations to achieve specific values). Given the possible T values and the fact that an 8-bit counter will be used, what clock periods are possible?

ii. For your possible T values, design a 555 timer circuit to meet the specifications described in slides 4 and 5. Select one of these circuits as your final design.

iii. Finish the Timer_Count VHDL code shown on the next page such thata. If the reset is LOW, clear all signal inputs (lines 24-26).b. On each rising edge of the clock signal, if the timer_2x input is

HIGH, then increment the count value by 1 and temporarily store the count (count_temp), otherwise clear the count value (lines 28-33).

c. Store only the maximum count value (count_final) (lines 35-39).d. The output of count value (count_out) is the final count value

(line 43).ECE 3450 M. A. Jupina, VU, 2015

Page 10: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Unfinished Timer_CountVHDL Code

ECE 3450 M. A. Jupina, VU, 2015

Page 11: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Additional Guidelines for the Timer Circuit Design

T = R * C where the time period T  is also equal to 99 clock periods (possible clock periods, Tclk, are 1s, 10s, or 100s).  Depending on the C value (3*Cmin) given to you and the R value that you choose will determine which Tclk values are possible.

2.  Once possible T values are known, possible Tmin and Tmax values are thereby known.  Given a certain Tmin or Tmax value, you should be able to design a 555 timer circuit that oscillates with a period of Tmin or Tmax depending on the C value in the circuit.  The R values in these timer circuits will be approximately the same value (or at least the same-order-of-magnitude) as the R value that was first determined in guideline 1.

3.  For the 555 timer circuit, use the formulas for the period of oscillation (T) from the topic 5 class lecture ppt file.

ECE 3450 M. A. Jupina, VU, 2015

Page 12: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Lab ProcedureWork to be preformed in the Lab:1) Compile and simulate a sensor circuit like the one shown in

slide 7 (call it capsensor1.bdf). Your simulation should be similar to the one depicted in slide 8.

2) Start a new project. Add a timer input signal, a Reset signal (KEY3), offset value (SW7-SW0), a CLOCK signal (derived from the 50 MHz signal and the clk_div block), a block to drive the seven segment LED output displays, and pin assignments to the previous design (call it capsensor2.bdf now) and compile it (no need to simulate this design since you verified its functionality in capsensor1 project). After successful compilation, download the design to the DE2 board and then verify the operation of your capacitance sensor over a range of capacitance values.

ECE 3450 M. A. Jupina, VU, 2015

Page 13: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Simple ADDER VHDL Code

ECE 3450 M. A. Jupina, VU, 2015

Page 14: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Figure 6.25. A BCD-to-7-segment

display code converter.

ECE 3450 M. A. Jupina, VU, 2015

c e

1 0 1 1

1 1 1

w 0 a

1

b

0 1

1 1

1

0 1

1 0 1

0

0

w 1

0 1 1

0

0

w 2

0 0 0

0

1

w 3

0 0 0

0

0

c

1 0 1 0

0 1 1 0

1 1 1 0

0 0 0 1

1 0 0 1

1 1 1 1

0 1 1

0

1 1

1 1

1

1 1

0 1 1

1

d

0

1 0

0

1 0

e

1 0 1

1

1

0 1

0

0 1

0 0 0

1

f

1

0 0

1

1 1

g

1 0 1

1

1

1 1

1

0 1

(c) Truth table

(a) Code converter

w 0

a

w 1

b c d w 2

w 3 e f g

a

g

b f

d

(b) 7-segment display

Page 15: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Figure 6.47. Code that represents a BCD-to-7-segment decoder.

ECE 3450 M. A. Jupina, VU, 2015

LIBRARY ieee ;USE ieee.std_logic_1164.all ;ENTITY seg7 IS

PORT ( bcd : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;leds : OUT STD_LOGIC_VECTOR(1 TO 7) ) ;

END seg7 ;ARCHITECTURE Behavior OF seg7 ISBEGIN

PROCESS ( bcd )BEGIN

CASE bcd IS -- abcdefgWHEN "0000" => leds <= "1111110" ;WHEN "0001" => leds <= "0110000" ;WHEN "0010" => leds <= "1101101" ;WHEN "0011" => leds <= "1111001" ;WHEN "0100" => leds <= "0110011" ;WHEN "0101" => leds <= "1011011" ;WHEN "0110" => leds <= "1011111" ;WHEN "0111" => leds <= "1110000" ;WHEN "1000" => leds <= "1111111" ;WHEN "1001" => leds <= "1110011" ;WHEN OTHERS => leds <= "-------" ;

END CASE ;END PROCESS ;

END Behavior ;

Page 16: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

ECE 3450 M. A. Jupina, VU, 2015

Hexadecimal to

7-Segment Decoder

ETC.

Input

Outputs

Page 17: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Unfinished Seven_Seg_

Display VHDL Code

ECE 3450 M. A. Jupina, VU, 2015

Page 18: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

ECE 3450 M. A. Jupina, VU, 2015

Clock Divider for DE2

The clock_50MHz input is connected to pin number N2.

Page 19: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

DE2_pin_assignments.csv File

ECE 3450 M. A. Jupina, VU, 2015

Page 20: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

Lab Measurement Details1) Measure the values of the capacitors that you are using for

testing on a capacitance meter. 2) On the scope, also measure the period of oscillation (T) of the

output signal from the timer circuit under the different capacitance values.

3) Make a table showing the C value, T value, and the output value shown on the display. Demonstrate through calculations that the C, T, and the output values are correct. If slight differences exist, what are the possible sources of error?

4) Demonstrate that if the capacitance value is reduced, the output display does not change (i.e., only the max value is displayed). After pressing the reset button, does the display now show a value consistent with the current capacitance value?

5) Finally, verify the functionality of your design by capturing the same signals within your design as shown on slide 8 using the Signal Tap II Logic Analyzer.

ECE 3450 M. A. Jupina, VU, 2015

Page 21: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

ECE 3450 M. A. Jupina, VU, 2015

Settings for Signal Tap II Logic Analyzer

@1: EP2C35 (0x020B 40DD)

Page 22: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

ECE 3450 M. A. Jupina, VU, 2015

Example of Signals Displayed in Signal Tap II

@1: EP2C35 (0x020B 40DD)

Page 23: ECE 3450 M. A. Jupina, VU, 2015 Capacitance Sensor Project Goal: Creation of a digital capacitance sensor circuit where a variation in capacitance changes.

An Example Design Illustrating the Mapping of Multi-Bit Connections

ECE 3450 M. A. Jupina, VU, 2015