0% found this document useful (0 votes)
56 views53 pages

Lecture 37 Exam 3 Review-F24

ECE 1004 Exam 3 review

Uploaded by

eggzactness
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views53 pages

Lecture 37 Exam 3 Review-F24

ECE 1004 Exam 3 review

Uploaded by

eggzactness
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Exam 3 Review

1
ECE 1004

❖ Today’s class: Exam 3 review


➢ On coding, 7.6, and 13.1 to 13.5
➢ Lectures 26 through 37 + Labs
➢ Programming
➢ Sequential logic
➢ Op-amps

Lab 5 due next Wednesday


Exam 3 is Friday
Final exam is a week from Friday
7-9 PM in Surge 104B and 104C 2
5 problems with 10 multiple choice / short-
answer questions

Covers coding, section 7.6, and Ch. 13.1 to


13.5

Lectures 26 through 37 + Coding Labs

Exam 3 It will be held just like previous exams

Don’t forget your calculator, pencil & eraser

Redo all homework and in-class problems for


practice. Book also has additional problems.

Last semester’s exam and key are posted for


you
AD return
• Return your AD2/3 on Dec. 12 from 12-3 pm or 12/11 from 12-6
• In Whittemore 219
• If you do not return the unit, your university account will be put
on hold. Return the whole thing...
Final Lab Day Monday!

For this in-class lab you need to have the following


with you, at a minimum:

• Laptop - fully charged.


• Breadboard
• AD2 (or AD3) with its USB cable
• DMM
• (2) 8.2k resistors
• (1) 1.5k resistor
• (1) 2.7k resistor
• (2) LF356 op-amps
• At least 8 jumper wires of assorted colors

5
Arduino coding

Review the coding you had to write for each


of the Arduino labs. Think about the syntax
used and how you implemented each
solution.

6
Like any programmable
computer, you need to use data
types.

Arduino Data types allow the computer to


Data ”know” how much space is
needed for each piece of data.

Types Common data types allow for


whole numbers, decimal
numbers, character data,
Boolean, to name a few.
Numeric
Data
Types
Numeric Data Types
• For decimal numbers, uses Floating point
numbers (think scientific notation)
• float –Range:
-3.4028235x1038 to 3.4028235x1038
• double command has the same range
• Both are stored in 4 bytes, so double does
not add more precision on the Uno, but
will on more complex platforms
Programming the All inputs are
Uno is done via scaled to 10 bits
the Arduino IDE • This means minimum
• “Integrated resolution is Vin /
Development 2^10
Environment”

Programming
the Uno analogWrite
output is limited
to 8 bits digitalWrite only
• Only 256 values
outputs high or
available for PWM low
duty cycle
• In general, there are 4 • Sequence
4 Ways to ways we can organize • Selection
our code
Organize • Iteration
• Function
Code
Defining a function: declaration
pieces
Type of return Function name
value List of parameter
(if function types and names
doesn’t return a (inputs)
value, the type is void BlinkAndWait(int pin_number)
void)
{
digitalWrite(pin_number, HIGH);
delay(1000);
digitalWrite(pin_number, LOW);
delay(1000);
Curly brackets
}
(braces)
required to
define the
beginning and
end of function
Defining a
function
• Return type: If the function returns a value, the
return type is the type of the returned value, which
can be any C data type, e.g., int, long, double,
Boolean
• If there isn’t any value returned, the return
type is “void” (nothing)
• Not returning a value just means that the
function performs a task without outputting a
value, which is fairly common, especially for
tasks that are performed repeatedly
• Functions that return values should
have a last step of ‘return some_variable’
where some_variable is of the same type
as the function
Defining a function

Parameters: If the function has input Each parameter must be given a


name and a type
variables, they must be in a comma-
Functions that do not have any
separated list in parentheses after parameters just have an empty list,
the function name. e.g., loop()

Example: float MyFunction(int x, int Returns a floating point number


y) { …. Has two integers as parameters
Function examples
Function definition: • Return type is bool
(Boolean)
bool CheckValue(int check, int threshold)
{ • Has two integer inputs:
if (check > threshold) check and threshold
return true;
else • Returns a Boolean value of
return false; either true or false
}
Function examples
Function definition:
• Return type is int (integer)
int MultiplyAdd(int x, int y, int z)
{ • Has three integer inputs: x,
int total; y, and z
total = x*y + z;
if (total < 0) • Returns an integer, either
return 0; 0, 255, or total, depending
else if (total > 255) on the value of total
return 255;
else
return total;
}
Function examples
void setup() { • Whole program
// put your setup code here, to run once:
} showing how the
void loop() {
// put your main code here, to run repeatedly: MultiplyAdd()
sensorValue0 = analogRead(A0);
sensorValue1 = analogRead(A1);
function is defined
sensorValue2 = analogRead(A2);
writeValue = MultiplyAdd(sensorValue0, sensorValue1, sensorValue2);
and used
analogWrite(9,writeValue);
delay(500); • For the Arduino,
}
functions can be
int MultiplyAdd(int x, int y, int z)
{
defined outside
int total;
total = x*y + z;
setup() and loop(),
if (total < 0)
return 0;
either before or
else if (total > 255)
return 255;
analogWrite is limited after them
else to 8 bits
return total;
}
Looping
Another common pattern for breaking a
problem down into smaller sub-problems
is iterating (looping) through the sub-
problems

Each iteration of a loop repeats the same


tasks for each of the sub-problems
Two main forms of looping:
for and while Getting the loop starting/ending
conditions wrong is a common
error (“off by one”)
• for loop syntax:
for (initialize expression; condition; update expression) {
//steps
}
• Example: for (i = 0; i < 10; i++) { … // i++ means i =i+1
• while loop syntax:
while (Boolean condition) {
// steps
}
• Example: while (sensorValue != 42) { …
Some notes on for loop
The “update expression” in the
for loop syntax is typically an
increment by 1 (e.g., i++), but it
isn’t limited to that.

• for (i = 0; i < LIMIT; i +=n) // i += n is the same


Increment by n:
// as i = i+n

Decrement from higher elements


• for (i = 10; i >0; i--)
to lower ones:

Increase by a multiplicative
• for (i = 0; i < LIMIT; i=i*2)
factor:
Two main forms of looping:
for and while
• As a general guideline:
• use a for loop when you have to iterate for a specific
number of times, and
• use a while loop when you don’t know beforehand how
many times the loop must execute before a condition is
true or false
• Examples:
• Step through every element of an array: use a for loop
• Do a certain set of tasks until some external condition
become true: use a while loop
void loop() {
BlinkAndWait(3);
BlinkAndWait(4);
BlinkAndWait(5);

Looping BlinkAndWait(6);
} ORIGINAL

• Here’s the main loop of the original BlinkAndWait


program re-written using iteration:
void setup() {
}
// LEDs are connected to digital output pins 3, 4, 5, and 6
void loop() {
int i;
for (i=3; i < 7; i++){
BlinkAndWait(i);
}
}
// BlinkAndWait function definition not shown..see earlier slides
BlinkAndWait is called once with each
iteration of the for loop indexed by the pin
number to be blinked…
Sequential Logic

23
Combinational logic
gates
No memory: output
depends only on current
inputs.

These operate
asynchronously
Sequential Logic
Circuits

• Until now, all of our logic circuits have


depended only on their current inputs.
• They have no ”memory” of past
input values
• Sequential logic circuits depend not only
on the current input values, but also on
past input values.
• Therefore they are said to
remember or have memory.
• Often sequential logic circuits are
synchronized using a clock signal.
• These are said to be synchronous.
• The clock is a set of periodic logic-1
pulses.
Latches

• Most basic building block of sequential


circuit.
• Have two stable states: 0 and 1
• Capable of storing 1 bit of
information.
• Many useful variations exist.
• Constructed using two inverters.
• The output from 1 inverter is tied to the
input of the other, and vice versa.
The truth table and symbol for the
SR Latch.
This means “previous
state held until input
changes”
Clocked SR Latch

• The previous SR was asynchronous


• Meaning it occurs w/o reference to
a clock
• We can also attach a clock signal to
trigger the SR to read the inputs when
the clock indicates.
• Additionally, at times it might be
necessary to clear or set the latch off of
the clock.
• So many clocked SR’s include this
ability as well.
Clocked SR Latch
Output can only be high
when clock is high

If clock is low, previous state is retained.


The SR Latch differs from the SR Flip Flop in how the
clock is treated.

The latch can output high (be enabled) any time


the clock is high

The flip flop can output high only on the edge of


the clock signal to allow for precise
synchronization
Flip-Flops
Some memory elements
These edge-triggered elements
react to the change of the are called flip-flops.
clock

They can be positive, or Leading edge means the clock is


going from 0 to 1 (rising).
leading edge; or negative, Trailing edge means the clock is
or trailing edge, triggered. going from 1 to 0 (falling).

A Delay flip-flop, or D flip-flop, is an example of an


edge triggered flip-flop.
A positive-edge-triggered D flip-
flop.

Triangle on clock input


indicates this device is
a flip-flop (edge-triggered)
D flip-flop example
• Output Q of positive edge triggered D flip-flop samples the
input D only on rising clock edge
• Input D can change multiple times between clock edges without
affecting output (like the latches shown last time)
• Changes on Q are synchronous with the rising edge of clock

clock

Changes on D in between rising clock


edges have no effect on output Q
Flip-flop application example:
two-bit binary counter
• A counter goes through a specific sequence of
outputs, e.g., 00, 01, 10, 11, 00, 01, 10, 11
• Current state = current value of flip-flop outputs
• Next state = value that flip-flop outputs should
become after the next rising edge of clock
State Table
Current state Next state
Q1 Q0 Q1 Q0
0 0 0 1
0 1 1 0
1 0 1 1
1 1 0 0
State Table
Current state Next state
Two bit binary counter Q1 Q0 Q1 Q0
0 0 0 1
0 1 1 0
• Next Q1 = Q1  Q0 1 0 1 1
• Next Q0 = Q0’ (prime is same as not) 1 1 0 0

NextQ1 Q0
Q1 NextQ0 D Q
D Q

QB QB

clock
Op-Amps

38
Op-amp equivalent Circuit
• Input resistance is assumed to be infinity
• Output resistance is assumed to be zero
• Voltage difference at input is greatly amplified at the
output by
gain factor “A”
Op-amp gains
• Open-loop voltage gain: AV = big number
• Closed-loop voltage gain: You design gain to be what you
want it to be (⍺ Rfeedback/Rinput)
• Current gain is similar arrangement
• Power gain is the product of AV and AI (Ohm’s Law)
Two main op-amp implementations
1. Comparator 2. Amplifier
Op-amp with No Op-amp With feedback
feedback Rf = some finite value
“open loop” “closed-loop”
Here we have a Comparator
It only outputs one of two values:

”High” output when +


input is greater than –
input. Output is
supply/rail maximum
(saturation)

”Low” output when - input


is greater than + input.
Output is supply/rail
minimum (zero or
negative)
https://www.electr onics-notes.com/article s/ana logue_circuits/opera tion al-amplifier-op-amp/comparator.php
Here we have an amplifier

Thanks to Negative
Op-amp With feedback
Feedback, we can now
Rf = some finite value control its gain, and
you design therefore control the
output to have any value
between the rails.

The op-amp can source


(or sink) current via its
output pin such that both
input voltages equal each
other.
So now we have two different gains…
You don’t want to confuse them as they are totally
different.

Gain A: This gain is the open-loop gain. It is internal to


the op-amp. It is fixed. There’s nothing that changes it.
It’s always present, and there isn’t much we can do with
it.

Gain Av: This gain is the closed-loop gain. It is external


to the op-amp and its value is designed by the engineer
(you). It makes the open-loop gain “invisible.” Closed-
loop gain is much more useful since it’s a lot smaller than
open-loop gain.
The two rules of op-amplifiers

Virtual Short Circuit: Through


the use of negative feedback,
Virtual Open Circuit: No
the op-amp will ensure that
current flows into the input
both input voltages are equal.
pins
Therefore, the input difference
voltage equals zero.

Remembering these two statements is the


key to solving op-amp circuit problems.
The two classic op-amp gain circuits
Inverting

These are two different


Noninverting ways of using an op
amp. They each have
their specific uses.

k = 1 + Rb/Ra

Recall no current into inputs. Vx is ≈ 0.


HW10 0V – (1k*2mA)

13.20

5V – 6V
= -1V
Another classic: Voltage follower (buffer)
 The output follows the input (no voltage gain)
 However the buffer provides a lot of current gain
 If the Rin of the op-amp is 1 MΩ, and the Rout is
10Ω, and we know that I = V/R, and V is the same at
the input as output (since it’s a buffer), then:

𝑉
𝐼𝑜𝑢𝑡 𝑅𝑜𝑢𝑡
𝐴𝑖 = = =
𝐼𝑖𝑛 𝑉
𝑅𝑖𝑛
𝑅𝑖𝑛
𝐴𝑖 = = 100,000!
𝑅𝑜𝑢𝑡
http://www.learningaboutelectronics.com/Articles/Voltage-follower
Cascaded op-amps: Buffer and amplifier
Fifth circuit: Summing op-amp
 Using inverting op-amp, multiple voltages can be
added up together
 Vout is the negative total of the inputs, times the gain
 IF is the sum of input currents.
RF
Vout =− Vin
Rin
RF
− Vout = (V1 + V2 + V3 )
Rin

Note: Rin doesn’t


have to be the same
for all inputs
http://www.electronics-tutorials.ws/opamp/opamp_4.html/
Summing amplifier
Sixth circuit: Difference Amplifier
• Subtraction is very useful in many applications
• You will likely need this circuit in 2804
• If you make all the resistors equal, then you get:

𝑣0 = (𝑣2 − 𝑣1 )
• Practice redoing problems, and doing
other book problems, and reviewing
the programming labs.

• Study hard to do well.

• See you on Friday!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy