Unformatted text preview:

6.081, Spring Semester, 2007—Assignment for Week 7 1MASSACHVSETTS INSTITVTE OF TECHNOLO GYDepartment of Electrical Engineering and Comp uter Science6.081—Introduction to EECS ISpring Semester, 2007Assignment for Week 7• Software Lab for March 20th• Prelab exercises due T hursday March 22th before lab• Lab on designing and using a virtual oscilloscope.• Post-lab due Tuesday April 3rd in Lecture.The constraints view of circuitsIn this problem set you will learn about resistor networks both as constraint systems and froma more intuitive perspective. The former is more useful wh en writing p rograms to determine thebehavior of circuits, the latter is more helpful during design. You will get a chance to use yourunderstanding of resistor networks to design a virtual oscilloscope, and then use that oscilloscopeto investigate the behavior of a lego motor.This problem set has four parts:1. Post-Lecture lab on using a constraint resolver to s olve circuit problems.2. Tutor problems on analyzing resistor networks.3. Lab on designing and using a virtual oscilloscope.4. Post-lab problem on generating constraints for a neuron model.Note, we are still having some issues with the software for Thursday’s lab, so we will post the finalversion of Thursday’s lab Wednesday evening. We will also bring paper copies to Thursday’s lab.Tuesday Post-lecture Software LabYou will be downloading and using resolveconstraints.py, which contains programs for creatinglists of constraints and their associated variables, and then once the list of constraints and variableshas been generated, determining values for the variables so that the constraints are satisfied. Inparticular, a user must first create an instance of the class constraintlist. Then the user invokesconstraintlist’s function add constraint multiple times, once for each of the constraints. The func-tion addconstraint appends a constraint and the constraint’s associated variables to the instance.By calling the instance’s function resolveconstraints, values are determined for the variables so thatthe constraints are satisfied. The values of the variables can be printed by calling constraintlist’sfunction display.There are two arguments to the function addconstraint. The first is a procedu re whose input is atuple of variable values, and the second is a lists of strings which are the labels for the variablesused in the constraint. The order of th e strings should match the order of the variables in th e tuple.The procedure that is passed to addconstraint should return zero when the inp ut tuple satisfi es the6.081, Spring Semester, 2007—Assignment for Week 7 2constraint, and if the tuple does not satisfy the constraint, the procedur e should return a floatingpoint number which indicates how far the tuple is from satisfying the constraint.As an example, consider the problem of finding values for x and y which satisfy the two constraints5 ∗ x − 2 ∗ y = 3and3 ∗ x + 4 ∗ y = 33.Of course, x = 3 and y = 6 satisfy the above two constraints.To use th e constraint class and the function resolveconstraints to find the constraint-satisfyingvalues of x and y, first define functions which generate the two constraint procedu res:def firstEqn():# Enforces 5*x - 2*y = 3, assumes [x,y]return lambda x : 5.0*x[0] - 2.0*x[1] - 3.0def secondEqn():# Enforces 3*x + 4*y = 33.0, assumes [x,y]return lambda x : 3.0*x[0] + 4.0*x[1] - 33.0Second, create an instance of constraintlist and add th e two constraints, being careful to providevariable labels in the same order as used in the constraint procedures:linSys = constraint_list()linSys.add_constraint(firstEqn(),[’x’, ’y’])linSys.add_constraint(secondEqn(),[’x’, ’y’])Finally, call resolveconstraints and display the solution:solution = resolve_constraints(linSys())linSys.display(solution)In order to u s e resolveconstraints for circuit problems, on e needs an organized approach for gen-erating the variables and constraints for a circuit. In class we discussed the nodal approach foraccomplishing this task. The steps in the nodal approach were1. Label all the circuit node voltages and element currents (noting direction), and select areference node.2. For each element, write constitutive equations that relate element currents to the voltages atthe element’s terminals.3. For each circuit n ode, except the r eference node, write a conservation law. That is, insist thatthe sum of currents entering a node should be equal to the sum of currents leaving a node.6.081, Spring Semester, 2007—Assignment for Week 7 3In order to use the constraint resolver to solve circuit pr oblems, it is helpful to have functions whichreturn constraint pr ocedures associated with a circuit’s constitutive equations and conservationlaws. In the file circuitconstraints.py, there are functions to generate pr ocedures that implementcircuit related constraints. The resistor and vsrc functions return procedur es which implement theconstitutive relations associated with a resistor and a voltage source, the kcl function returns aprocedure which implements the constraint that the signed sum of currents must equal zero, andthe set ground returns a procedure which implements a constraint forcing a value to zero (typicallyused to force the reference node voltage to be zero).Download and test the constraint SystemThe software for this prelab is at the 6.081 web site. Download and unzip constraint resolversoftware, and note that there are four python files: resolve constraints.py and circuit constraints.pydescribed above, as well as two example circuit files, circuit.py and circuit2.py. Try running thetwo example circuit files, and notice the second example generates an err or. Fix the error in thesecond example circuit file (the reference node voltage has not been set), then draw the resistorand voltage source circuit diagrams associated with the two examples.Checkpoint: 4:00 PM• Show your LA your circuit diagrams, and d emonstr ate that you have fixed the problemin the circuit file.Use the constraint resolverUse the constraint resolver to find the node voltages in the following circuit, assumin g V s = 5.0and R1 = R2 = R3 = R4._+VsR1V1R2V2R3V3R46.081, Spring Semester, 2007—Assignment for Week 7 4Checkpoint: 4:30 PM• Show your LA your input file for the constraint resolver and demonstrate that theresolver generates the correct result.Add the non-ideal voltage sourceThe voltage source is an idealized model of


View Full Document

MIT 6 01 - Assignment for Week 7

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 Assignment for Week 7
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 Assignment for Week 7 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 Assignment for Week 7 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?