Unformatted text preview:

6.01, Spring Semester, 2008—Design Lab and Homework 10, Issued Thursday, April 17 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.01—Introduction to EECS ISpring Semester, 2008Design Lab and Homework 10, Issued Thursday, April 17This handout contains design lab 10 as well as homework problems that are to bewritten up and handed in, together with questions from software lab 10, in yourdesign lab on Thursday or Friday, April 24 or 25.Please write up and hand in answers to the following questions: 7, 11, 12, 13, 14 and15 from the design lab. Also, write up and hand in answers to homework questions17 and 19.Design Lab: Computer-based controlDo athrun 6.01 update and you will find the relevant files in the lab10 directory.This lab requires a laptop, a NIDAQ box, your head from last week, a power supply, and the usualcircuit-building and testing stuff.Warning: As you’ve seen in previous labs, some of the clip leads are bad. Make sure to test theones you are using. You can just set your meter to the “sound” setting, and touch both ends ofthe clip-lead with the leads from the meter; the meter will beep if it’s good.Python to NIDAQ Input/OutputIn this lab, and then in the final-project labs, we will be using the NIDAQ box for both input andoutput, between a Python program and a circuit. The NIDAQ box has the following ports thatwill be of interest to us:• AIGND: analog input ground• AI0—AI7: analog inputs 0 through 7• AOGND: analog output ground• AO0: analog output 0The NIDAQ box can read voltage differences between AIGND and AI0, between AIGND and AI1,etc. It can actually set a voltage difference between AO0 and AOGND. It can actually read andset voltages between −10V and +10V, but we will only use voltages in the range 0V to +10V.You might wonder why, if the NIDAQ box can generate voltage differences, we need to use thepower supply. The answer is that the NIDAQ box can only generate relatively small currents,but not necessarily large enough ones to drive our motor. Luckily, we know a way to convert avoltage sustained by a low-current source to that same voltage, but with more current: an op-ampconnected to a voltage source that can supply more current. So, we’ll use the 0V and +12V fromthe power supply as the supply rails for op-amps in our circuit.6.01, Spring Semester, 2008—Design Lab and Homework 10, Issued Thursday, April 17 2Staying GroundedThings can get very confused here, very easily, because we have three wires labeled “ground”:NIDAQ AIGND, NIDAQ AOGND, and 0V from the power supply. You cannot necessarily dependon them all being at the same voltage level (unless all of the devices are plugged into the thewall with a three-pronged plug). To keep all your “grounds” equal, you should start by connectingNIDAQ AIGND, NIDAQ AOGND, and power supply 0 together on the bottom board of your head.And you might as well connect the black lead of your meter to this value, while you’re at it.Read and writingIn lab 7, we read voltages from the NIDAQ box in a Python program. Now we’ll see how we canuse Python to command voltages to outputs on the NIDAQ box.1. Connect a wire to the AO0 port of your NIDAQ box2. Start the NIDAQ server by opening a new terminal window and typing> ./ NIDAQserve r -- outputNow, wait a somewhat uncomfortably long time, and numbers should start streaming out.Just leave that window alone.If you see a “fatal error”” message before the numbers start streaming, just ignore it.3. Now, from IDLE, open the file test.py, and run it to load its definition. Type writeTest()at IDLE’s shell prompt.Here is the text of part of the test.py file. The writeNIDAQ procedure takes a voltage value and“writes” it out on the port AO0 of the NIDAQ box.# Wri te va lues from 0 up to 9.5 volts to NID AQ AO0# Go in s teps of 0.5 , ev ery 2 secondsdef writeTest ():v = 0.0while True :print vwriteNIDAQ ( v )time . sleep (2.0)v = v + 0.5if v > 9.5: v = 0.0You should see the voltage on the meter increment from 0V, in 0.5-Volt steps, every 2 seconds, untilit reaches 9.5V, and then wraps around. You may notice that occasionally one of the commands ismissed; this is a known problem, which won’t affect subsequent parts of this lab, when we will besending commands very frequently.Python phototaxisNow, let’s see if we can replicate what we did in lab 9, having the head turn to follow the light, butwith a Python program in control. It will be useful to put the photo-sensors in a resistor-dividerconfiguration, like this:6.01, Spring Semester, 2008—Design Lab and Homework 10, Issued Thursday, April 17 3Question 7: Design a circuit that will let you read the two values from the two photo-sensorson your head assembly, so they can be read in Python via the NIDAQ box. Remember thatthey need to be in the range 0V to +10V. You don’t need more than the three wires thatwe have going up to the head; if you have a problem seeing how to do this, talk to an LA.CheckpointShow your circuit design to your LAIt will simplify the process of doing this lab if you unwire the circuits that you havecurrently built on the bottom board of your head and start fresh. (You should leavethe op-amp chips where they are; we’ll be using those).Question 8: Build your circuit on the bottom board of your head. Connect the AI0 and AI1ports to the photo-sensor circuit outputs.Question 9: The code below (included in test.py) repeatedly reads a list of 8 numbers fromthe NiDAQ box and prints the first two, which are the voltages between AI0 and AIGNDand between AI1 and AIGND.def readTest ():while True :values = readNIDAQ ()print values [0] , values [1]time . sleep (1.0)Run the program and try it. Observe how the output voltages change, and how they areaffected when you shine a light on the head.CheckpointDemonstrate reading the light sensors to your LANow that you can read the photo-sensors, it’s time to turn to the task of driving the motor so thatyou can create feedback loop. Your program will read the sensors and use NIDAQ box to producea voltage for the motor.But there’s a complication: The NIDAQ box can generate outputs in the range 0–+10V and themotor needs to turn in both directions. So, you’ll need to generate a “virtual ground” again, thistime, at +5V, and connect that to one side of the motor. Recalling tutor problem PS.10.1.5, youcan use a 15KΩ resistor and a 10KΩ resistor to get the appropriate ratio in your


View Full Document

MIT 6 01 - HOMEWORK - 6.01

Documents in this Course
Week 1

Week 1

3 pages

Op-Amps

Op-Amps

8 pages

Op-Amps

Op-Amps

6 pages

Syllabus

Syllabus

14 pages

Planning

Planning

14 pages

Load more
Download HOMEWORK - 6.01
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view HOMEWORK - 6.01 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view HOMEWORK - 6.01 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?