Download Slide - Anne Roudaut

Document related concepts

Analog-to-digital converter wikipedia , lookup

Tektronix analog oscilloscopes wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Transistor–transistor logic wikipedia , lookup

Josephson voltage standard wikipedia , lookup

Integrating ADC wikipedia , lookup

Test probe wikipedia , lookup

TRIAC wikipedia , lookup

CMOS wikipedia , lookup

Valve RF amplifier wikipedia , lookup

Power electronics wikipedia , lookup

Operational amplifier wikipedia , lookup

Power MOSFET wikipedia , lookup

Trionic T5.5 wikipedia , lookup

Multimeter wikipedia , lookup

Schmitt trigger wikipedia , lookup

Electrical ballast wikipedia , lookup

Current source wikipedia , lookup

Voltage regulator wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Surge protector wikipedia , lookup

Current mirror wikipedia , lookup

Ohm's law wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Rectiverter wikipedia , lookup

Opto-isolator wikipedia , lookup

Charlieplexing wikipedia , lookup

Transcript
Anne Roudaut
hci2: building
interactive devices
hasso-plattner institute
tangible & electronic
assignment
•design, prototype, and laser cut a robotic
vehicle that you can control by projecting on it
•upload sketches, drawings, & photos to the wiki
light sensors, to allow sending
commands to the tangible
shape allows
users to pick up
and move
your task:
(onmi) wheels
and motor, so it
can move itself
design & built a motorized tangible object
electronic part with an arduino board
and a set of components (battery / motors /
photoresistors / chips / resistors …)
arduino
board
program on PC (simplified C++)
upload to the board
separate and run independently
main advantage of Arduino!
some LEDs
when programming
and testing
pins
usb plug
(5V)
reset button
processor
external power
(max 12v)
to run
independently
pins
some LEDs
pins
usb plug
(5V)
reset button
processor
external power
(max 12v)
pins
pins:
to plug in components such as…
+
long leg is the +
-
LEDs
the LED blinks
continuously
pin “gnd” (ground)
what’s happening?
(we will see later why
we need the resistor)
pin “12”
step by step
configure
pin “gnd” (ground)
pin “12”
pluging in
e.g. all these pins are connected
It is the same here etc.
test board
compiling
uploading
it is blinking: the board is uploading the binary code
(1 = light on / 0 = light off)
uploading
1st
loop
executing
executes setup ()
reseting
test 1 (5 mn)
blinking LED
1. plug in a resistor and an LED in pin 12
pin gnd
-
Blue LED
+
pin 12 (5 V)
82 ohm
2. launch the File/Examples/Basic/Blink arduino files
3. modify the code to make the LED says “SOS” in Morse
(3 shorts, 3 longs, 3 shorts)
don’t forget your programming skills!
write functions
test 2 (5 mn)
more blinking
(with the same circuit)
1. upload File/Examples/Basic/Blink to the board
2. change the first delay value to 1 and the second to 1.
upload the code to the board
3. change the first delay value to 1 and the second to 10.
upload the code to the board
4. compare the three cases and tell me more!
1
delay(1000) … delay(1000)
HIGH
LOW
2
3
blink
bright
blink
less
bright
blink
even less
bright
delay(1) … delay(1)
delay(1) … delay(10)
1
delay(1000) … delay(1000)
HIGH
LOW
2
voltage is either 0 or 5v
delay(1) … delay(1)
voltage is ½ of 5V
3
delay(1) … delay(10)
voltage is a 1/11 of 5 V
pulse width modulation ::
technique using a rectangular pulse wave whose pulse width is modulated
resulting in the variation of the average value of the waveform
it serves to create an analog signal from a digital one
digitalWrite("pin number", HIGH or LOW)
or
analogWrite("pin number", "value in [0;255]") (% of voltage)
there are special pins that produce PWM signals
(in addition to digital signals)
test 3 (5 mn)
smooth blinking
1. change your circuit to use a PMW pin
1. write code with analogWrite() to make the led smoothly
blink (the brightness progressively increases)
pins are input
and output
digitalWrite("pin number”,”HIGH or LOW”)
digitalRead("pin number”) -> 1 or 0 (0 if voltage < 3v)
digital pins are for input and output
analogWrite("pin number”,[0;255])
PWM pins are analog output
analogRead("pin number”) -> [0;1023]
(1023 being the maximum voltage in the board)
analog pins are for analog input
both digital and analog pins deal with voltages
reading input works with every components
that generate voltages
battery
by the way, components that generate
high voltage will damage the board, be careful!
pin “gnd”
pin “A0”
1.5V battery on A0 pin to read it voltage
digitalWrite(A0,HIGH)
Monitor display
Serial.print() Serial,println()
305
305
305
305
305
305
305
305
305
305
305
305
305 of [0;1023] so 305x5/1023 = 1,49V
so it works with components that generate voltages such as…
voltage increases when the
intensity of light increases
photodiode
voltage increases when pressure increases
piezoelectric cells
but also with components that generate resistance
(and we will see the trick later)
material in what components are plug in
it removes electrostatic charges
conductive foam
it lets the charge passing
thought: it conduces charges
the more you squeeze it, the less it
resists to the travel of the charges
conductive foam
pin “gnd”
pin “A0”
let’s play with a piece of conductive foam
test 4 (5 mn)
read pins
1. plug in two wires and a piece of foam between pin A0
and GND
1. write code to display the change of voltage on pin A0
1. write code to make an LED more or less bright when
you squeeze the foam
it is a simple way to make a pressure sensor
at this point you know the basics of arduino
you are almost ready to go
what remains now is some math in order to understand…
1
why do we need a resistor with the LED?
2
how does an input pin read different values of
resistance whereas we said it reads voltage?
let’s forget arduino for a moment
battery
+
resistor
3 electric quantities voltage / current / resistance
battery
+
voltage is the amount of cars
it is measured in Volt
resistor
10 Kilo OHM vs. 60 OHM vs
highways let more cars
passing through
resistance defines the type of road
it is measured in Ohm (Ω)
current is the amount of cars that pass through the
circuit per units of time (the flow)
it is measured in Ampere
Voltage
Current
the smaller the road is (resistance increases),
the slower the flow of cars is (current decreases)
the harder a pipe is pressed,
the smaller the water flow is
the relation between these 3 quantities is given by Ohm’s law
U=RxI
Volt
Ohm Ω
Ampere
Current (I)
U=RI works for resistors
1 Ω resistor
color code = value
resistors
1 meter silver (1.59×10−8 Ω)
Current (I)
1 meter sea water (0.2 Ω)
1 Ω resistor
conductors
insulators
1 meter air (1.3×1016 Ω)
Voltage (U)
more generally, U=RI works for ohmic materials
most components are not ohmic
e.g. light bulb / LED / motor
I
U
the resistance of the filament
increases with its temperature
ligh bulb
I
U
works in a small interval of voltage
steep slope:
small variations of voltage
= large variations of current
LED
I
max current indicated on the spec
working voltage interval indicated on the spec
U
LED off
LED on
LED blows
(brightness increasing)
5V
battery
+
Red LED
[1.8;2.2] V
0,02 A
+
(5-2.2) = R x 0,02
R = 140Ω
to reduce current we put a resistor in serie
to know it value, we use Ohm’s law
2V
battery
+
Red LED
[1.8;2.2] V
0,02 A
+
we can also adapt the voltage but …
I
steep slope:
when the voltage decreases a
little bit, the current dramatically
decreases, thus decreasing the
brightness
U
LED off
LED on
LED blows
(brightness increasing)
Red LED
[1.8;2.2] V
0,02 A
5V
battery
+
+
140Ω
the resistor also regulates the LED
voltage, that stays almost constant
so LEDs must always be mounted with a resistor in serie
5V
battery
+
Red LEDs
[1.8;2.2] V
0,02 A
+
+
30Ω
(5-2x2.2) = R x 0,02
R = 30Ω
true for several LEDs in serie
5V
battery
-
-
-
+
+
Red LEDs
[1.8;2.2] V
0,02 A
+
140Ω
140Ω
(5-2.2) = R x 0,02
R = 140Ω
true for several LEDs in parrallel
(voltage is the same in each branch)
-
5V
battery
-
-
+
+
Red LEDs
[1.8;2.2] V
0,02 A
+
0.04 A is drained
from the battery
70Ω
(5-2.2) = R x (2x0,02)
R = 70Ω
if LEDs are the same, we can also serialize
the resistor (current splits in each branch)
1
2
why do we need a resistor with the LED?
done and we know how to compute it value
how does an input pin read different values of
resistance whereas we said it reads voltage?
squeezing the foam changes the resistance
but the voltage of A0 pin was changing
Battery
5V
+
conductive foam
the resistance changes and thus the current
(Ohm’s law) but still not the voltage
so there must be a trick somewhere …
we must use a tension divider circuit layout
Vin
+
pull-up
resistor
Vout
Rfoam
x Vin
Vout =
Rfoam+ Rpullup
tension divider
e.g. 10 KΩ
(to have precise A0 value)
pin GND
pull-up
resistor
pin 5V
pin A0
Rfoam
X5
A0 =
Rfoam+ Rpullup
so the arduino circuit can look like that
pin GND
Optional if internal
pull up resistor is
enabled
pull-up
resistor
pin 5V
pin A0
but arduino also have an internal pull-up resistor
-> we can plug in the foam between A0 and gnd
by the way, a potentiometer is
a tension divider circuit
adjustable
Vout
Vin
resistor
gnd
potentiometer
1
2
why do we need a resistor with the LED?
done and we know how to compute it value
how does an input pin read different values of
resistance whereas we said it reads voltage?
done and we know how to compute it value
use multimeter (in the shop) to check
voltage: in parrallel
current: in serie
more
components
M
motor
resistance decreases when
the intensity of light
increases
photoresistor
to switch on higher voltage
relays
a small current at the Base can control
or switch a much larger current
between the Collector and Emitter
It serves as a switch or current amplifier
transistors
they store electric charge
capacitors
capacitors
(the notch shows the
orientation when reading
the spec)
chips
or integrated circuits
A
B
out
= 4 NAND GATES
example:
A
0
B
0
out
1
0
1
1
1
0
1
1
1
0
chips
7400 serie
• Gleichrichter
It can inverse the polarity of two motors
(one on each side)
It doesn't control the amount of voltage
(i.e. the speed). For that, you must reduce
or increase the voltage sent on pin 8
chips
H-BRIDGE
chips
H-BRIDGE
• Pin 8 is the power for the chip. It has to be max 5V. Just plug in it to a
digital pin always HIGH
• Pin 6 is the control pin for the left motor. If it is HIGH the left motor do
something, otherwise nothing (same principle for the pin 7 controlling
the motor on the right)
• If pin 2 LOW pin 3 HIGH, then the left motor will turn in one direction
• If pin 2 HIGH pin 3 LOW, the left motor will turn in the other direction
• If both pin 2 and 3 have the same value the left motor stop (same
principle for right motor and pin 4 and 5)
chips
H-BRIDGE
• 555 timer (e.g. toaster timer)
• 741 operational amplifier (amplify current)
• Accelerometers
•…
chips
etc.
without the
computer
max 40mA per pins
external power
max 12 V
(some versions can handle more)
max 50mA on 3.3V pin
for your 9V battery
assignment
Go!
design, prototype, and laser cut a robotic vehicle
that you can control by projecting on it
upload sketches, drawings, & photos to the wiki
be sure your design is feasible :
- check materials before
- ask Professor or TA