engg1015: lab 7 - university of hong kongengg1015/fa12/handouts/lab7.pdf · engg1015 lab 7 in...

8
ENGG1015: Lab 7 In Search of Light 1 st Semester 2012-13 The goal of this lab is to complete the basic construction of the last stage of your project — a light tracker. By doing so, you will learn to use an analog-to-digital converter (ADC) to bridge between the digital logic world of an FPGA and the analog circuit world. You will then combine the ADC circuit with the DAC circuit from last week to form the complete signal path. This lab is part of your project. The circuit you construct in this lab will be used directly in the project. Therefore: the equipment you will be using in the lab (breadboard, hardware tools, FPGA board, etc.) is also equipment for your project. the circuits and software design for this lab will be reused in the project. Equipment you’ll use in this lab AND in project. Do not return them after this lab. You need to sign an equipment loaning form to keep them. (a) Multi-meter (b) Wire Kit (c) Breadboard (d) ADC Module (e) DAC Module 2 × (f) FPGA Cable Figure 1: Materials for this lab

Upload: others

Post on 30-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015: Lab 7

In Search of Light

1st Semester 2012-13

'

&

$

%

The goal of this lab is to complete the basic construction of the last stage of your project — alight tracker.By doing so, you will learn to use an analog-to-digital converter (ADC) to bridge between thedigital logic world of an FPGA and the analog circuit world.You will then combine the ADC circuit with the DAC circuit from last week to form the completesignal path.

'

&

$

%

This lab is part of your project. The circuit you construct in this lab will be useddirectly in the project. Therefore:

• the equipment you will be using in the lab (breadboard, hardware tools, FPGA board,etc.) is also equipment for your project.

• the circuits and software design for this lab will be reused in the project.

Equipment you’ll use in this lab AND in project. Do not return them afterthis lab. You need to sign an equipment loaning form to keep them.

(a) Multi-meter (b) Wire Kit (c) Breadboard

(d) ADC Module (e) DAC Module

2 ×(f) FPGA Cable

Figure 1: Materials for this lab

Page 2: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

Equipment you will use in this lab, but need to return after lab.

(a) Light Tracking Head (b) FPGA Connector (c) Poten-tiometer

Figure 2: Materials for this lab that must be returned.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 You already know your lab partner

You will be working with your project groupmate. To find your assigned lab partner and theassigned table,

1. Log in to Moodle.

2. Select the assignment Lab 7 Partner

Please proceed to your assigned table.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2 Getting the Files

Download the files for this lab from

http://www.eee.hku.hk/~engg1015/fa12/labs/lab7.zip

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 Analog-to-Digital Conversion

In this lab, you will connect an analog-to-digital converter (ADC) to the FPGA board. Incontrast to the digital-to-analog converter (DAC) from last week, an ADC converts the value ofan input analog signal to a digital representation for use in the system.

Figure 3(a) shows the ADC module you will use for this lab. It has two connectors. The J1connector on the ADC module should be inserted into JC I/O port of the Basys2 board. TheJ2 connector should be connected to the breadboard using an FPGA connector.

(a) ADC Module

Pin Name Description

6 A0 Analog Input A05 GND Ground4 A1 Analog Input A13 GND Ground2 GND Ground1 VCC 3.3V

(b) Pinout for J2 on the ADC module

Figure 3: ADC module used to convert analog signals into digital values in the FPGA

Page 2 of 8

Page 3: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

DO NOT connect to the FPGA yet.You will get the board once your TA has checked your circuit.

1 5

10

15

20

25

30

35

1 5

10

15

20

25

30

35

ab

cd

ef

gh

ij

Pin 1

Figure 4: Connection of the ADC module on the breadboard.

3.1 Hardware Construct the circuit in Figure 4 on the breadboard. Then connect the ADCmodule to the breadboard using an FPGA connector. Note the following:

• VCC of the FPGA connector is connected to the “+” row on top of the breadboard;

• GND of the FPGA connector is connected to the “–” row on top of the breadboard

• The “–” row at the top and bottom are connected together.

3.2 Getting the FPGA Board

Show your constructed circuit on the breadboard to your TA and answer the followingquestions:

• The analog input of the ADC module is located at pin A0. Where is that connectedto on the breadboard?

• What is the maximum value and minimum value of the analog input?

Minimum Voltage: Maximum Voltage:You can take an FPGA from the TAs once you can answer the above questions.

3.3 Loading Software Open the file adc.xise in Xilinx ISE tools. It has the necessary con-troller for the ADC module (adctls8 already included).

The adctls8 controls the ADC module to read the analog voltage value at the input A0. Thevoltage is represented digitally as an 8-bit data. The value of the 8-bit data n is computed suchthat

Vin ≈ n× Vcc256

where Vcc is the power supply to the ADC. In your case, it is 3.3V.

Page 3 of 8

Page 4: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)that shows the value n in one of the 2 ways. By default, it displays the value n as a numberbetween 0 and 255. When button 3 is pressed, it displays the voltage that should be present atthe input.

Now, using the Xilinx ISE tools, implement and download the design to the FPGA. Use a DMMto measure the input voltage Vin on the breadboard. Adjust the potentiometer and completethe following table:

Vin 0 0.5 1 1.5 2 2.5 3

dout (dec)

3.4 Checkoff 1

Demonstrate the working ADC circuit to your TA and answer the following questions:• Are the voltage values you measured the same as the display? Why/Why not?

• If the input voltage at Vin is Vcc/2, what is the value of dout?

• If the value of dout is 2, what is the voltage in Vin?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4 Seeing the World

In this section, you will experiment with a special laser head that you will use in the project asthe final stage. A laser head is shown in Figure 5.

Figure 5: Photo of a Laser Head

There are two photoresistors located on the laser head. These photoresistors are the same as theone used in the ball counting tunnel from Lab 4. As a reminder, the resistance of a photoresistordecreases when the light intensity shining on it increases. Also included in the laser head isa laser module that you will use in the project. Figure 6 shows the schematic of the laser headas well as the connector pin assignment.

4.1 Left or Right? With the two photoresistors positioned at 90 to each other they are used asa way to detect the direction of a light source. In the following space, the “laser head connector”is shown with the 2 photoresistors on the laser head connected.

Page 4 of 8

Page 5: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

RR

RL

100 Ω

RR

COM

RL

L+

L-

9 10

1 2

Laser Head InternalLaser Head CableCable Connector

Figure 6: Connector pin assignment of the laser head

Label the pin with VCC, GND, and VIN such that:

• When the light source is 0 in front of the laser head, Vin should be Vcc/2;

• When the light source is 45 to the RIGHT of the head, Vin should be 0V;

• When the light source is 45 to the LEFT of the head, Vin should be Vcc.

RR

RL

4.2 Connect it up Remove the POT from your breadboard. Based on your circuit above,connect the laser head to the breadboard such that VIN is connected to the input of the ADCmodule.

4.3 Relating Angle to Voltage Complete the following table that relates the angle of the lightsource and Vin. The polarity of the angle is defined in Figure 7.

Page 5 of 8

Page 6: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

4545

θ

Figure 7: Defining angle of light source relative to the laser head

Angle θ (degree) −45 −30 −20 −10 0 10 20 30 45

dout (dec)

Plot the results in the following graph:

Page 6 of 8

Page 7: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

4.4 Checkoff 2

Show to your TA your complete circuit and the measurements above. Answer the fol-lowing questions:

• In what range of θ is the voltage Vin linearly proportional to θ?• Assume Vin = ks×θ, what is the approximate value of ks from your measurement?

'

&

$

%

Part 5 and Part 6 can be proceeded in parallel. Split your group into 2 such that your groupcan work on both parts at the same time.The goal for these two parts is to connect the ADC circuit your have constructed so far withthe DAC circuit from lab 6. The result will be a complete system that can control the speed ofa motor by the angle of the light on the laser head.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5 Driving Motor — Software

This part is an extension to the FPGA design from last week. Open the project file adda.xise

using Xilinx ISE tools. In this project, open the schematic file adda.sch.

adda.sch contains the same ADC controller from above. Your task is to pass the digital valuedout directly as din to the DAC from last week. Recall that you need to use the block dactls

to control the DAC module.

Display the value dout to the display module displaydecm like before.

Refer to the project dac.xise from last week’s lab for reference.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

6 Driving Motor — Hardware

This part is almost identical to the hardware part of last week’s lab. The goal is to connectthe DAC module to the breadboard, and use an op-amp to drive a motor. Instead of using theswitches to serve as input to the DAC, your partner is using the input from the ADC module tocontrol the speed of the motor.

Figure 8 shows a similar breadboard connection to the one from last week. Construct the circuitas an extension to the ADC circuit already on the breadboard. A few points to remember:

• Connect only VCC from FPGA to the top row marked “+”. It is 3.3V.

• Connect only 6V to the bottom row marked “+”. Only the op-amp requires 6V as power.

• Connect the “–” row from top and bottom. They represent GND.

• Use a separate motor without the laser head in this step to test the connection. You willeventually connect to the motor of the laser head next week.

Page 7 of 8

Page 8: ENGG1015: Lab 7 - University of Hong Kongengg1015/fa12/handouts/lab7.pdf · ENGG1015 lab 7 In adc.sch, the output from adctls8 is connected to the special display module (displaydecm)

ENGG1015 lab 7

1 5

10

15

20

25

30

35

1 5

10

15

20

25

30

35

ab

cd

ef

gh

ij

To Power Supply

CH2 (6V)

1 2 3 4

6 58 7

Pin 1Pin 1

Pin 1

Figure 8: Full circuit with ADC, DAC, laser head, and motor connections.

6.1 Checkoff 3

Show to your TA the complete circuit with ADC and DAC working to drive a motor.Answer the following questions:

• When the light source is on the LEFT side of the laser head, what direction is themotor turning?

• Suggest one way to reverse the rotation direction of the motor by changing theconnection on the breadboard.

• Without changing the breadboard connection, can you reverse the direction ofrotation of the motor?

'

&

$

%

Save all your work!• ISE project files• breadboard connection

They will be used in your project.

Page 8 of 8