0% found this document useful (0 votes)
1 views42 pages

Bogatin Arduino - Workshop - 2017 02 08

The document outlines a crash course on Arduino and electronics led by Eric Bogatin, focusing on building confidence and understanding key concepts. It covers essential topics such as setting up the Arduino IDE, creating sketches, and experimenting with components like LEDs, tone functions, and servo motors. The course also emphasizes hands-on learning and encourages participants to explore additional resources for Arduino projects.

Uploaded by

Perrelis Ashu
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)
1 views42 pages

Bogatin Arduino - Workshop - 2017 02 08

The document outlines a crash course on Arduino and electronics led by Eric Bogatin, focusing on building confidence and understanding key concepts. It covers essential topics such as setting up the Arduino IDE, creating sketches, and experimenting with components like LEDs, tone functions, and servo motors. The course also emphasizes hands-on learning and encourages participants to explore additional resources for Arduino projects.

Uploaded by

Perrelis Ashu
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/ 42

2/8/2017

Arduino and Electronics Crash Course


with Eric Bogatin, Tinkermill ([email protected])
• Goals: Who’s here
today:
 Get you from the ground floor to the second floor Eric
Newton
 Build your confidence

• Objectives for today:


 Talk to your Arduino, see what it can do
 Learn some important principles
 Have fun

• My approach:
 I do
 We do
 You do
www.EricBogatin.com slide 1

Three Sections

• Arduino from the ground floor


 Light: LED Heartbeat (Hello world)
 Sound: tone and music
 Motion: servo arms
• Electronics
 Voltage, current, resistance
 Measuring with DMM
 Engineering LED circuits
 Resistor pots and voltage dividers
• Projects:
 3 color LEDs
 Sensors
 Motors, and more

www.EricBogatin.com slide 2

1
2/8/2017

Vocabulary

• IDE: Integrated development environment


• Arduino: family of boards, compatible with the IDE
• Microcontroller: the actual specialized processor chip on the board
(Uno uses Atmel 328)
• Sketch: the actual program that runs on the microcontroller
• Upload: the process of moving the sketch from the IDE on your PC
to the microcontroller on the Arduino board.
• Shield: add on board that just plugs into the specific form factor
of the pins on the Arduino board
• Library: special drivers that allow us to use high level commands to
drive special features in the shields

www.EricBogatin.com slide 3

Experiments Section 1

• Installing the IDE


• Running a blank sketch
• Creating a heartbeat
• Tone() and buzzer
• Servo motors
• Where to find new sketches

www.EricBogatin.com slide 4

2
2/8/2017

Experiment: Setting up the Arduino IDE


(Integrated Development Environment)

• Goal: install and get familiar with the IDE


• Download from Arduino.cc
• Install
• Run
• Sketch format: void setup(), void loop()
• Preferences file:
• Tools/auto format
• Help/references
www.EricBogatin.com slide 5

Experiment: NEW Sketch-1

• Goal: Run your first Arduino sketch


• File/new
• Review the elements
 1st step: save as
 File name
 Verify check
 Upload arrow
 Void setup()
 Void loop()
 {…}
 // comments

www.EricBogatin.com slide 6

3
2/8/2017

Experiment: NEW Sketch-2


• Test connection to Arduino:
 Tools/boards: select Uno
 Tools/boards: com# checked

• Upload the code with right pointing arrow


 Any errors?
 Any lights flashing on board?
 Uploading blank sketch will “erase” the Arduino

• If port is greyed out:


 Is the power light lit on the Arduino?
 Disconnect and re-connect USB cable on both ends
 Is correct port selected AND checked?
 Try another com port
 Unplug USB, Close and open IDE, plug in USB
 Check device manager for comm port error:
 Unplug USB, Reinstall IDE, plug in USB
 Unplug USB, reboot computer, plug in USB
 May need to manual upgrade the UART driver
 Try another Arduino board

www.EricBogatin.com slide 7

Experiment: Heartbeat-1

• Goal: create a first sketch


• Each digital pin has a pin number
• Pin 13 is special: has an on-board LED attached
• Changing state of digital pin is 2 steps:
• In void setup()
 pinMode(pin#, OUTPUT, INPUT) //sets up the pin for output

• In void loop()
 digitalWrite(pin#, HIGH, LOW) //changes state

• Where to find information about commands?


 References
 Highlight a term and right mouse click

www.EricBogatin.com slide 8

4
2/8/2017

void setup() { // put your setup code here, to run once: pinMode(13,OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(13,HIGH

Heartbeat-2

• Turning on and off the LED on pin 13

www.EricBogatin.com slide 9

Heartbeat-3
• Waiting using the delay() function
• Delay(500) waits for 500 msec = ½ second
• Hint: use tools/auto format to clean up the code
• Turning LED off and on with delay

www.EricBogatin.com slide 10

5
2/8/2017

Heartbeat-4

• Make LED thump like heartbeat: thump-


thump…thump-thump….
• How fast can you turn the LED off and on
and still see it flash?
• How short a flash can you see?
• How short an off can you see?

www.EricBogatin.com slide 11

Experiment Variables-1
• Variable: a place in memory to hold a piece of data
• Location identified with a name
• Two common types of numbers:
 Integers (whole numbers, -3, -2, -1, 0, 1, 2, 3)
 Floating point (with a decimal point: 3.1415 x 103)

• Declare at beginning, all variables and their type


 Long (rather than int) iName1 //iName1 is the variable name
 Float V_sensor1_v // V_sensor1_v is the sensor name

• Long: can count from +/- 2,140,000,000

www.EricBogatin.com slide 12

6
2/8/2017

Variables-2

• Declare them in the beginning


• Use smart names- “self documenting”
 for an integer, use an ‘i’ in front
 Default is float
 Add units at the end

• Declare them at beginning and they are “global”


 Can be used inside all functions

www.EricBogatin.com slide 13

Variables-3

www.EricBogatin.com slide 14

7
2/8/2017

Experiment: Connect External LED


• Goal: get familiar with electrical properties
of LEDs
• LED: Light emitting diode
• Important properties:
 Current only flows thru it in one direction.
Which direction?
 Symbol for a diode is an arrow (points in
direction of current flow)
 Physical diode has a flat side (short leg) (low
voltage side)
 Max current rating ~ 20 mA
 May carry > 40 mA before damage
 Typical design current ~ 10 mA

www.EricBogatin.com slide 15

External LED -2

• Plug low side of LED (short lead) to


gnd
• Plug in high side, long lead, to pin 13
• There will be a lot! Of current thru
LED
• May blow out LED, may blow out
Arduino pin, but probably not.
• What limits the current through the
LED?
 Hint: output resistance of pin is about 50 Ohms

www.EricBogatin.com slide 16

8
2/8/2017

LED -3

• Measure the current


thru the LED with
DMM
• DMM is in series
with the LED current
• May need to keep
LED on for more
than 4 sec to get
stable reading

www.EricBogatin.com slide 17

Experiment: Tone-1

• Goal: do some coding


 Get familiar with tone() function
 Use “for loops”
 Use “random() function”
 Write your own functions

• The tone() function:


 tone(pin, frequency, duration (optional))
 noTone(pin) (turns off the tone function)
 Frequency in Hz
 Duration in msec (optional)
www.EricBogatin.com slide 18

9
2/8/2017

Experiment: Tone-2

• Testing tone:
 Open up and use a NEW sketch to exercise any function
 On pin 11, play a note for 2 second, then a different one

www.EricBogatin.com slide 19

Tone-3

• Connect up a buzzer
• Pin spacing between the buzzer
leads = 3 pins
• One side to pin 11 with tone, pin 8
as other pin
• Pin 8 set to HIGH or to LOW
• Remember pinMode

www.EricBogatin.com slide 20

10
2/8/2017

Tone-4

• Simple exercises:
 Play a single frequency for 0.3 sec
 Play multiple tones

• Use the random() function to play random notes


• The random() function:
 Integer (use long)
 random (100) returns random integers from 0 to 100
 Play random frequencies. For 0.3 seconds each

www.EricBogatin.com slide 21

Tone-5

• The for loop:


 Using For loop, play rising frequencies
from lowest to highest freq
 Sit at each note for 100 msec
 Hard code values, then make them
variables

www.EricBogatin.com slide 22

11
2/8/2017

Tone-6

• Use function to ramp tone up


• Call a function with
func_RampUp()
• Define a function by:
• Void func_RampUp () {

 }

• Good habits:
 name your functions with func_ as the
beginning of the name
 Initialize all variable at beginning of sketch
(as global variables)

www.EricBogatin.com slide 23

Experiment Servo Motors


• Geared down DC motor with a shaft encoder (resistor pot)
• Transistor current amplifier to drive motor
• Pot on shaft senses absolute position (% of Vcc)
• Input signal to motor is a PWM signal
• IC compares average input voltage to pot ref value
• Motor spins to match pot position to average input voltage
value
 Proportional control
 Pulse period = 20 msec
 0 deg = 1.5 msec (1.5/20 = 7.5% of Vcc)
 -90 deg = 1 msec = (1/20 = 5% of Vcc)
 +90 deg = 2 msec = (2/20 = 10% of Vcc)
 (brown = gnd, red = +5, orange = pulses)

www.EricBogatin.com slide 24

12
2/8/2017

Servo Motors-2

0 degrees

180 degrees

www.EricBogatin.com slide 25

Servo Motors-3

• Need to install servo library


 Define servo object: Servo
myservo
• In setup():
 myservo.attach(9), defines
pin for servo input
• In loop():
 Myservo.write(angle in
degrees (0 to 180))
• File/example/servo/Knob

www.EricBogatin.com slide 26

13
2/8/2017

Servo Motors-4

• Examples:
 Use for loop to sweep servo back and forth like
a radar sweep
 How fast can you sweep?
 How to adjust the sweep time?
 Use servo with arrow as analog voltage meter

www.EricBogatin.com slide 27

Experiment: Find new sketches


• Goal: be aware of other places to get starting code
• “Sketches” tell Arduino what to do
• Fastest way to a solution:
 use someone else’s code (code re-use) or hacking!
• Where to get code?
 File/examples…
 www.Arduino.cc
 www.SparkFun.com
 www.AdaFruit.com
 http://www.instructables.com/howto/ardunio/
 google search: “Arduino sketches”

EricBogatin.com 28

14
2/8/2017

Section 2

• Electronics

www.EricBogatin.com slide 29

Experiment: An Electricity Analogy


• Goal: build some intuition about voltage,
current, resistance
• Water in a pipe analogy:
 Pipes = wires (conductors)
 Water = free charges
 Pressure difference = voltage difference (volts)
 Water flow = current (Amps)
 Pipe geometry = resistance (Ohms)

• In conductors, current flows from higher


pressure (voltage) to lower pressure
(voltage)
 Label the lowest voltage point: ground (gnd)

• Two points of confusion:


http://www.windows2universe.org/physical_science/physics/electricity/circuit_analogy_water_pipes.html
 Current is moving charge carriers
 Inside pumps (batteries), current flows from
lower pressure to higher pressure
EricBogatin.com slide 30

15
2/8/2017

An Electricity Analogy-2

• Questions
 What is the sign of the charge carriers?
 What direction does current flow in a
circuit?
 What direction does current flow in a
battery?
 What drives the current?
 What limits the current?
 What is the resistance in a wire?
 If the voltage increases, what happens to the
current in a circuit?
 If resistance increases, what happens to the
http://www.windows2universe.org/physical_science/physics/electricity/circuit_analogy_water_pipes.html

current in a circuit?
 What is ground?
EricBogatin.com slide 31

An Electricity Analogy-3

• Questions
 What would happen if:

5v =

There are “real: elements and “ideal” elements. Be


aware of the difference and limitations to real ones.

EricBogatin.com slide 32

16
2/8/2017

Experiment:
Using DMM to measure voltages-1
• Goal: get comfortable with voltage
measurements
• Principles:
 Voltage is always the voltage difference
between two points
 Voltage difference is the “pressure” that
drives current
 How much current depends on the voltage
and series resistance
 “gnd” is the label for the lowest voltage in
circuit, usually a pin of the power supply
• Good habits:
 Black is always com
 Red is always multi function
 Use the most sensitive scale that is still
not off scale
www.EricBogatin.com slide 33

Using DMM to measure voltages-2


• Use DMM on voltage scale to
measure voltage of Arduino
pins
 Measure voltage difference
between gnd (low voltage side)
and…
5v
 3.3 v
 Vin
 Pin 13
 Others?
 What if you only connect one pin?
 What if you reverse the leads?
www.EricBogatin.com slide 34

17
2/8/2017

Experiment: Use DMM continuity to check


solderless breadboard connections
Goal: check out connections in solderless breadboard
A good conductor (low resistance) makes buzzer beep

• Note: the labels on solderless breadboard are purely arbitrary and


don’t mean anything
www.EricBogatin.com slide 35

Experiment: Resistor Properties-1

• Goal: get comfortable with the properties of resistors


• The relationship between the voltage across a resistive device
and the current through it (Ohm’s Law)

I
+ -
DV
V V IR
V  IR V
I V
V
R I R R 
I
R I
V
R
I
www.EricBogatin.com slide 36

18
2/8/2017

Resistor Properties-2

• V = 5 v supply
 R = 100 Ohms, What is I?
V
 R = 15 Ohms, what is I?

• I = 100 mA
 R = 100 Ohms, what is V? I R
 R = 0.1 Ohms, what is V?

• R = 1 Ohm
 V = 0.2 v, what is I?
 V = 10 v, what is I?

HackingPhysics.com slide 37

Experiment: Resistor Properties-3


I V V
+ - V IR I R
DV R I

 In words: the higher the voltage, the higher the current, or as we


increase the current through a device, the voltage across it increases
proportional to the current
 In a graph:

V  R I
voltage

Slope of the line = R,


defines the parameter of the resistor
current

www.EricBogatin.com slide 38

19
2/8/2017

Resistor Properties-4

• Find a resistor (~ 300 Ohms)


• Measure the resistance with DMM (Ohms scale)
• Calculate the resistance by measuring voltage across a resistor
and the current thru it
• Need 2 DMMs (find a partner)
 Before you do a measurement, ALWAYS anticipate what you expect to see.
 With 5 V across resistor, how much current do you expect to flow?

V V 5V
R I  
I R 330
www.EricBogatin.com slide 39

Resistor Properties-5

current
V
voltage R
I

How well does your estimate


match your measurement?

Does it matter where the


ammeter is inserted?

What if you reverse the leads?

www.EricBogatin.com slide 40

20
2/8/2017

Experiment: Controlling Current in LED


• Goal: get familiar with electrical properties of
LEDs
• LED: Light emitting diode
• Important properties:
 Current only flows thru it in one direction. Which
direction?
 Symbol for a diode is an arrow (points in direction
of current flow)
 Physical diode has a flat side (short leg) (low
voltage side)
 Max current rating ~ 20 mA
 May carry > 40 mA before damage
 Typical design current ~ 10 mA

• DOES NOT obey Ohm’s law


 With 10 mA thru it, voltage drop is 2 V
 With 40 mA thru it, voltage drop is about 2 v

www.EricBogatin.com slide 41

Experiment: Controlling Current in LED-2

• Measure Current thru and


Voltage across LED
current
• Need to create voltage source:
pin 13 (high) voltage

• Need to adjust current: 330


Ohm resistor
• Measure current thru LED,
voltage across it
• Then remove resistor and
connect pin 13 directly to LED-
 what is the current?
 What is voltage drop across LED?
 What is limiting the current?
 What is voltage out of pin 13?

www.EricBogatin.com slide 42

21
2/8/2017

Experiment
Engineer an LED Circuit
• Goal: Engineer a circuit to drive 10
mA thru LED
• What value resistor to use?
• When the LED is on, voltage across
it is about 2 V, independent of the
current.
• If pin voltage is 5 V, what is the
voltage across the resistor?
• For 10 mA, what resistance do you
need?
V 5  2V 3V
• Build it, measure it R    300 
I 0.01A 0.01A
www.EricBogatin.com slide 43

Experiment: Double or half the current


through an LED
• Goal: Make the current twice as much or half thru the
LED using combinations of resistors
• Two important properties of resistors:
 Equivalent resistance of two in series, is higher than either one

Requiv  R1  R 2 Requiv  R1  R1  2  R1

 Equivalent resistance of two in parallel is lower than either one

1 1 1
 
R equiv R1 R 2 1
Re quiv  R1
1 1 1 2 2
  
Requiv R1 R1 R1
www.EricBogatin.com slide 44

22
2/8/2017

Double or half the current through an LED-2

• Verify these relationships


Requiv  2  R1
• Build a circuit with two 330 Ohm resistors in series.
 What do you expect the resistance to be?
 Measure each one separately with a DMM
 Measure the series combination with a DMM

• Build a circuit with two resistors in parallel


 What do you expect the resistance to be?
 Measure each one separately with a DMM
 Measure the parallel combination with a DMM

• Replace the single resistor with the two in series or 1


two in parallel Requiv  R1
2
• In each case,
 What do you expect the current to be?
 What should happen to the LED brightness?
 Try it and see.

www.EricBogatin.com slide 45

Experiment Introducing the Scope


Voltage

Time

• Basically graphs how the voltage changes over time


• A DMM measures and displays the voltage, but
measured every ~ 1 sec.
• A scope can measure the voltage every 1 usec or faster.
www.EricBogatin.com slide 46

23
2/8/2017

Introducing the Scope-2


• Many low end scope Old, analog scopes: $50  $200

options:
Analog, or digital
Bandwidth: 10 MHz
 1 GHz
Standalone, USB
Old, new Recommended, best
value first scope:
PicoScope 2204A
1 channel  4 https://www.picotech.com/

channel products/oscilloscope

www.EricBogatin.com slide 47

Introducing the Scope-3

• 2204A specs: (lowest end scope)


 2 channels
 5 instruments in one: scope, spectrum analyzer,
arbitrary waveform generator, frequency
response analyzer, serial link decoder,
 8 bit vertical resolution, +/- 50 mV full scale
(0.4 mV/bit)
 Up to 10 MHz bandwidth, 100 MSps (10 nsec/
sample)
 Up to 8 kS buffer memory
 Strip chart mode
 Export data to csv file
 Decode 15 serial protocols as standard
 USB connected and powered
 Windows, Linux and Mac software

www.EricBogatin.com slide 48

24
2/8/2017

Introducing the Scope-4


• Measuring tone signals
 The frequency, the amplitude

www.EricBogatin.com slide 49

Projects

www.EricBogatin.com slide 50

25
2/8/2017

Experiment: Print to Serial Monitor

• Goal: get familiar with serial monitor displays


• Use AnalogInOutSerial
• In void setup()
 Serial.begin (9600);

• In void loop():
 Serial.print(iVar1);
 Serial.println(iVar2); (as the last line)
 Delay (100);

• To view serial monitor: Open tools/serial monitor


• Debug tip: Make sure baud rate at bottom right of
screen matches Serial.begin()
EricBogatin.com
51

Print to Serial Monitor-2

• Serial.print(number)
• Serial.print(“text”) // prints on same line
• Serial.println(number) // line feed
• Exercises:
 Print the integers from 1 to 32000
 (hint, use iValue=iValue++)
 How fast a baud rate can you go?
 Print the random frequency values generated in 10-150 Tone, as it
plays
 Copy and paste numbers into an excel spreadsheet
 Open serial plotter

EricBogatin.com
52

26
2/8/2017

Experiment
PWM (Pulse Width Modulation) output

• Goal: get familiar with analog output function


• analogWrite pins with a “~” in front: 3, 5, 6, 9, ..
• Output signal is string of pulses
 Average value = analog value
 8 bit resolution: 0  28 -1 = 255 (adu)

• What converts the pulses into an average value?


 DMM
 Our eye looking at LED
 Inertia of a motor
 NOT a speaker
 NOT a scope

www.EricBogatin.com slide 53

PWM (Pulse Width Modulation) output-2

• Use analogWrite(pinLED,255) // uses 0 to 255 values,


no need use pinMode()
• start with new sketch
• Add analogWrite(9,200);
• We refer to the analog value, 0  255 in units of adu
(analog digital units)
• Vary voltage level
• Can be very simple code
• Don’t be intimidated about writing quick, simple code

www.EricBogatin.com slide 54

27
2/8/2017

Experiment: A Throbbing Heartbeat

• Goal: use PWM to modulate LED brightness


making it “throb”
 Instead of blinking on and off, throb
 Get brighter, peak, dimmer, pause, repeat, wait.
 Ramp up, damp down, off, repeat
 Note: won’t work on pin 13.
 Hard code numbers initially
 Re-write with functions, variables
 Try making heart beat throb
www.EricBogatin.com slide 55

10-160 A Throbbing Heartbeat-2

www.EricBogatin.com slide 56

28
2/8/2017

Experiment: 10-170 3-color LED


• Goal: drive a 3-color LED to
make any color
 Control max current with a
resistor to each LED
 Make any color by using
combinations of each color
 Select a different pin to control
each color
 What will the wiring diagram look
like? For 10 mA max current, 20
mA, max current?

www.EricBogatin.com slide 57

10-170 3-color LED-2

• Open examples/10 starter


kit/p04_colorMixingLamp

www.EricBogatin.com slide 58

29
2/8/2017

10-170 3-color LED-3

Set up wiring
Try color coding the wires
9
11
10

Experiment: 10-180 Measuring Temperature


• Goal:
 Read an analog voltage
 Print to serial monitor
 Display on serial plotter

• Arduino uno ADC is 0 to 5v, 10 bit


 0 to 1023 steps in 5v
 1 step = 1 adu = 5v/1023 = 5 mV

• If sensor outputs voltage, read it directly


• Use temperature sensor:
• Serial plotter:
 Each variable separated by “,”

https://www.sparkfun.com/products/10988

www.EricBogatin.com slide 60

30
2/8/2017

10-180 Measuring Temperature-2

• Resolution
 At 10 bit: 0  1023 adu and 0 v  5 v
 1 bit = 1 adu is 5 V/1023 adu ~ 5 mV/bit= 5 mV/adu = 0.005 V/adu
 Temperature sensor is 10 mV/deg C = 0.01 V/degC, or 100 degC/V
 Resolution is 100 degC/V x 0.005 V/adu = 0.5 degC/adu
 Sketch: read A0, convert to temperature

• Types of variables
 Integers: long, -2,147,483,648 to 2,147,483,647, whole numbers
 Float: -3.4028235E+38 to 3.4028235E+38

• Adu should be as integers, long


• Voltage, temperature should be as float

www.EricBogatin.com slide 61

10-180 Measuring Temperature-3

Scaling:

0 V = -50 degC, 100 degC/V

T[degC] =(V x 100 degC/V) - 50 degC

T[degF] = T[degC]*9/5 + 32

www.EricBogatin.com slide 62

31
2/8/2017

10-180 Measuring Temperature-4

• Algorithm
 Read the analog channel (A0): analogRead(A0)
 Add the units to the end of the variable
 Convert adu  voltage
 Convert voltage  temperature degC
 Convert temperature degC  temperature degF
 Print to serial monitor: Serial.println(temp_degF)
 Look on serial plotter (plots variable on strip chart)

www.EricBogatin.com slide 63

10-180 Measuring Temperature-5

www.EricBogatin.com slide 64

32
2/8/2017

Experiment:
10-190 The Resistance Potentiometer (pot)

• Resistor pot as special component


• Goal:
 Measure resistance properties of pot

• Measure resistance between pins with


DMM, rotate knob
 What is A B?
 What is A  C?
 What is B C?

• How to connect it to make it a voltage


source?
www.EricBogatin.com slide 65

10-190 The Resistance Potentiometer (pot)-2

• Convert a resistance to a voltage


V2 = R1 x I
Vsource
• Goal: generate a variable voltage
source V1 = R1 x I
• The voltage divider:
Vsource R1
• Resistor pot DV1  R1  I  R1
R1  R2
 Vsource
R1  R2

 Connect up resistor pot


 Measure voltage across 2 pins
 Read voltage with analogRead(A0);
 Print monitor
 Plot monitor

www.EricBogatin.com slide 66

33
2/8/2017

Experiment 10-200
Turn a Resistive Sensor into a Voltage
• Sensors: flex, pressure, thermistor

Rsensor
Vout  Vsource
R1  Rsensor

What’s the best value of R1 to use?

If Rsensor >> R1, then V1 is small voltage

If Rsensor << R1, then not much change in voltage


• Measure flex sensor with DMM
• Measure A0, convert to voltage Best value is R2 ~ R1

• Convert to R of sensor
Vout
• Print R sensor Rsensor  R1
Vsource  Vout
• Plot R of sensor

EricBogatin.com slide 67

Experiment 10-210 Boosting output current


with a transistor

• Max rated output current from Arduino pin = 40 mA


• Output impedance ~ 55 Ohms
 If shorted, current is I = 5 V/55 Ohms = 90 mA

• A load resistance can be low:


 Small dc motor ~ @ 5 v, 10-50 Ohms  require ~200 mA
 Small light bulb ~ @ 2.5 v, 10 Ohms  require 250 mA
 Large LED ~ 10 W is 3 A of current!
 Speaker ~ 10 Ohms I ~ 250 mA

• What do we do?

www.EricBogatin.com slide 68

34
2/8/2017

10-210 Boosting output current with a


transistor-2
• 2n3904 NPN transistor
• https://www.sparkfun.com/datasheets/Components/2N
3904.pdf

www.EricBogatin.com slide 69

10-210 Boosting output current with a


transistor-3
Ic Essential principles:
• Voltage between B and E ~ 0.6 v, a diode drop)
• IE ~ h x IB
• h is the current gain ~ 50 -100
IB IE • IE = IB + IC ~ IC
• A transistor is like a current valve

• Basic “follower” amplifier (simple model)


 Vin= 0.6 V + Vout
 Vout = Vin – 0.6 V ( output “follows” input with small offset)
 But, IE = h x IB
 Current through R2 can be 50-100x current into base
 Current gain: great for driving low impedance loads that run at 5 V

• Like:
 Motors
 Speakers
 Big LEDs (still need current limiting resistor)
 Large relays

www.EricBogatin.com slide 70

35
2/8/2017

10-210 Boosting output current with a


transistor-4

• Driving a motor
• Normally rated at 5 v, but needs 100 mA- 200 mA
• Arduino digital pin ~ 40 mA-90 mA (can’t drive the motor)
• Use transistor follower circuit
• Add R1 = 1k Ohms as safety- limits max pin current to 5 V/ 1 kOhm = 5 mA
• Now motor can get art least 5 mA x 50 = 250 mA current

www.EricBogatin.com slide 71

Experiment: 10-230
What the Heck is Ground?
• The is no such thing as an absolute voltage.
• There is only voltage difference.
• We measure the voltage of one node relative to or “with
respect to” another location
• We call the low voltage side of a circuit, “circuit ground.”
• All circuit ground nodes in a circuit are connected together.
• Voltages in a circuit are really voltage differences from the
low side as the reference.
• There are really 3 kinds of “ground”. Each are different.

HackingPhysics.com slide 72

36
2/8/2017

10-230 What the Heck is Ground? -2

• Earth Ground
• Earth ground is literally the connection to the physical
ground, with a copper stake in the ground.
 Voltage difference between different stakes typically very small
 Defines a convenient reference point

• Earth ground wire connects to the round hole in 3 hole AC


wall mount panels
• Generally, most metal things you encounter are connected
to earth ground-
 Parts of the house, pipes, duct work…
 Appliance with metal housing
 Most metal surfaces
• Earth ground is a safety feature. If all metal you encounter
is connected to earth ground, you will never see a voltage
difference, and not get shocked.

HackingPhysics.com slide 73

10-230 What the Heck is Ground? -3

• Chassis Ground
• If the enclosure is metal, there
is a screw drilled into it
connected to a wire.
• Can be connected to earth
ground (required by UL), but
doesn’t have to be.
• Sometimes connected to circuit
ground, but not always.
• Plastic enclosures do not have a
chassis ground.

HackingPhysics.com slide 74

37
2/8/2017

10-230 What the Heck is Ground? -4

• Floating Ground
• “Circuit ground” is often the low voltage side in a circuit or power supply
• If the circuit ground is not connected to earth ground, we say, the low side is “ground”
but “floats” above earth ground.
• Floating grounds are in:
 Cars
 Planes
 Satellites
 Cell phones
 Battery powered devices
 Devices plugged into the wall with two prong plugs
 Devices plugged into wall with “wall adapters”
 Watch out!

HackingPhysics.com slide 75

Experiment 10-240 Input Resistance of a


Voltmeter
• What is the ”input resistance” of a voltmeter?
• Use DMM with Ohmmeter to measure the
output resistance of real voltmeter.
 What is source resistance?
 What is measured voltage?
 On each voltage scale?
real
ideal

Input resistance of
an ideal voltmeter
= infinite R = 1 MegOhm

slide 76

38
2/8/2017

Experiment 10-250 How an Ammeter Works

• What is internal series resistance of sense resistor?


• Put a resistor in series with a voltage source (battery,
Arduino pin…)
• Measure voltage across ammeter
• What is the internal resistance?
V
Rinternal 
I
• What is the typical voltage drop (voltage load), on each
current scale?

slide 77

Experiment 10-260 How an Ohmmeter Works


• How does Ohmmeter work:
 Attach resistor, measure voltage across it, measure current
thru it.

• What is open circuit voltage of meter? V


• What is internal resistance of meter?
 Measure open circuit voltage.
 Attach external resistor and measure new voltage- a voltage
divider I
Re Vopen  Vmeas
Vmeas  Vopen Ri  Re
Re  Ri Vmeas

Rinternal
• What is internal R?
• How does it vary with scale?
Rexternal

slide 78

39
2/8/2017

Experiment 10-270 Measure the Output


impedance of a Voltage Source
• Goal: measure the output resistance of any power
source like:
 A battery Rinternal
 A wall wart supply Vopen
 The USB pin
 An Arduino digitial pin
 Other?

• Measure the open circuit voltage Vopen Vloaded


• Connect a known resistive load
I Rload
• Measure the loaded voltage
• Calculate the voltage drop
• Calculate the internal R

slide 79

10-270 Output impedance of Voltage Source-2


• Measure the open circuit voltage
• Connect a known resistive load
• Measure the loaded voltage Rinternal
Vopen
• Calculate the voltage drop
• Calculate the internal R

Vopen Vloaded Vloaded


Vopen  Vloaded  Rint ernal  I  Rint ernal 
Rload
I Rload

Vopen  Vloaded
Rint ernal  Rload
Vloaded Vloaded
I
Rload

slide 80

40
2/8/2017

10-270 Output impedance of Voltage Source-3

• Measure the Vopen, internal resistance of:


Vopen Vloaded
 A battery
 A wall wart supply
I Rload
 The USB pin
 An Arduino digital pin
 Other?

Vopen  Vloaded
Rint ernal  Rload
Vloaded

Arduino digital pin 8:


Vopen = 5.24 V 5.24  4.88
Rload = 329 Ohms Rint ernal  329  24
4.88
Vloaded = 4.88
Rinternal= 24 Ohms

slide 81

10-270 Output impedance of Voltage Source-4

Arduino USB powered power supply


Vopen = 5.256 V Vopen Vloaded
Rload = 329 Ohms
Vloaded = 5.235 I Rload
Rinternal= 1.32 Ohms

Vopen  Vloaded
Rint ernal  Rload
Vloaded

5.256  5.235
Rint ernal  329  1.32
5.235

slide 82

41
2/8/2017

10-270 Output impedance of Voltage Source-5

Voltage source:
Vopen = Vopen Vloaded
Rload =
Vloaded = I Rload
Rinternal=

Vopen  Vloaded
Rint ernal  Rload
Vloaded

slide 83


84
EricBogatin.com

42

You might also like