/elec/propeller-clock

To get this branch, use:
bzr branch http://bzr.ed.am/elec/propeller-clock

« back to all changes in this revision

Viewing changes to electronics-information

  • Committer: Dan
  • Date: 2011-11-03 00:54:13 UTC
  • Revision ID: dan@waxworlds.org-20111103005413-miheyjsrpm3a0r1e
modified notes

Show diffs side-by-side

added added

removed removed

1
 
Why can't I use a potentiometer to get a different voltage?
2
 
===========================================================
3
 
 
4
 
Suppose that you have 12V and you need 6V.  Why can't you use an
5
 
arrangement like this to get your 6Vs?
6
 
 
7
 
    +12V -------+---------
8
 
                |
9
 
               |¯|
10
 
               |_| R
11
 
                |
12
 
                +--------o  6V, yes?
13
 
                |
14
 
               |¯|
15
 
               |_| R
16
 
                |
17
 
     GND -------+---------
18
 
 
19
 
You *do* get 6V, but it isn't actually practical to do this.  The
20
 
problem is that, when R is suitably high, you've limited the current
21
 
at the 6V pin so much that it isn't really useful.
22
 
 
23
 
And when R is suitably low, there isn't enough resistance between the
24
 
+12V and GND rails to prevent a lot of current flowing.  Lets work
25
 
this out (lets suppose that R is 1 ohm).
26
 
 
27
 
        V = IR, therefore I = V/R
28
 
        P = VI = V(V/R) = (V^2)/R = ( 12 ^ 2 ) / 1 = 144W
29
 
        P = VI, therefore I = P/V = 144/12 = 12A
30
 
 
31
 
That's a lot of current and a lot of power, flowing continuously, just
32
 
to provide 6V!
33
 
 
34
 
Also, fluctuations in resistance and current drawn on the 6V pin would
35
 
actually change the ratio of the potentiometer, so you wouldn't get 6V
36
 
anyway.
37
 
 
38
 
The solution is to use a voltage regulator.  The 7805 will give out 5V
39
 
(so long as you can supply it with at least 7V).  But the arduinos
40
 
already have something similar on-board and they can take an input
41
 
voltage in the range 6-20V (although 7-12V is recommended).
42
 
 
43
 
 
44
 
Wiring up multiple LEDs in series to a single arduino pin
45
 
=========================================================
46
 
 
47
 
First, lets think about a single LED.
48
 
 
49
 
             |
50
 
    Arduino  |     ___      ,,
51
 
            o-----|___|-----►|---- GND
52
 
             |      R       D
53
 
             |
54
 
 
55
 
The arduino pin, when raised high, is at 5V and no more than 20mA can
56
 
be taken from it.  The LED will take about 10mA and wants about 1.5V.
57
 
 
58
 
You can think of this as a potentiometer arrangement, with the
59
 
resistance of R and D proportionally splitting the voltage between the
60
 
two components.  We want 1.5V across the LED, so we need 3.5V (that's
61
 
5 - 1.5) across the resistor.  Now, we don't know the resistance of
62
 
the LED, but we don't need to.  If we know that we want 10mA through
63
 
the whole series (the resistor and the diode), then we can use V=IR as
64
 
follows...
65
 
 
66
 
    V=IR, therefore R=V/I
67
 
    R = 3.5 / .01 = 350Ω
68
 
 
69
 
Which is why the standard resistor you'd use with one LED is orange,
70
 
orange, brown (actually, 340 ohms).
71
 
 
72
 
Now lets consider more than one LED in series.
73
 
 
74
 
             |
75
 
    Arduino  |     ___      ,,     ,,
76
 
            o-----|___|-----►|-----►|---- GND
77
 
             |      R       D1     D2
78
 
             |
79
 
 
80
 
Ok, so now you still need 10mA through the whole series, but you want
81
 
1.5V across the first diode and 1.5V across the second as well.  That
82
 
leaves 2V across R, the resistor (5 - 1.5 - 1.5).
83
 
 
84
 
    R = V/I = 2 / .01 = 200Ω
85
 
 
86
 
You can see that beyond three or perhaps, at a push, four LEDs you're
87
 
not going to get the required 1.5V across each LED. So three (or four)
88
 
is the limit to how many LEDs you can drive in series from one pin on
89
 
the arduino.
90
 
 
91
 
 
92
 
Wiring up multiple LEDs in parallel to a single arduino pin
93
 
===================================--======================
94
 
 
95
 
Imagine we have this
96
 
 
97
 
             |
98
 
    Arduino  |     ___        ,,
99
 
            o-----|___|---+---►|---.
100
 
             |       R    |   D1   |
101
 
             |            |        |
102
 
             |            |   ,,   |
103
 
             |            '---►|---+--- GND
104
 
             |                D2
105
 
 
106
 
This wouldn't work. We can't use one resistor in series with the two
107
 
LEDs because the resistance of the two LEDs wont actually be exactly
108
 
the same.  You'll end up running one brighter than the other and burn
109
 
one out quicker.
110
 
 
111
 
So, imagine we have this instead
112
 
 
113
 
             |
114
 
    Arduino  |        ___     ,,
115
 
            o----+---|___|----►|---.
116
 
             |   |     R1     D1   |
117
 
             |   |                 |
118
 
             |   |    ___     ,,   |
119
 
             |   '---|___|----►|---+--- GND
120
 
             |         R2     D2
121
 
 
122
 
This is ok.  R1 and R2 are just the usual 340 ohms.  But we have to
123
 
bare in mind that each LED requires 10mA.  So the total current drawn
124
 
from the arduino pin will be 20mA, which is the most you're allowed to
125
 
draw.  So two LEDs is the most that we can drive, in parallel, directly
126
 
from a pin.
127
 
 
128
 
 
129
 
Using a transistor to drive multiple LEDs
130
 
=========================================
131
 
 
132
 
In both of the following diagrams, the resistor on the arduino pin,
133
 
R1, just needs to be something suitably high to provide a small
134
 
current on the base of the transistor. So, R1 could be 1kΩ.
135
 
 
136
 
Here's an "in series" set up
137
 
 
138
 
                           .----- 12V
139
 
                           |
140
 
                          |¯|
141
 
                          |_| R2
142
 
                           |
143
 
                           |
144
 
                           ▼  D1
145
 
                           ¯``
146
 
                           |
147
 
                           |
148
 
             |             ▼  D2
149
 
             |             ¯``
150
 
             |             |
151
 
             |             |
152
 
             |             ▼  D3
153
 
             |             ¯``
154
 
             |             |
155
 
    Arduino  |    ___    ,-|
156
 
            o----|___|--(|< ) T
157
 
             |     R1    `-|
158
 
             |             |
159
 
             |             '----- GND
160
 
 
161
 
This is fine. D1, D2 and D3 will require a total of 4.5V across them
162
 
(1.5V each), leaving plenty of headroom (you've got 12V to play with).
163
 
R2 would be
164
 
 
165
 
    R2 = V/I = ( 12 - 1.5 - 1.5 - 1.5 ) / 0.01 = 750Ω
166
 
 
167
 
So the limit here is about 8 LEDs.
168
 
 
169
 
Something else to consider here is that the transistor actually also
170
 
requires 0.7V across it.  So in that calculation, the desired voltage
171
 
across R2 should actually be 12 - 1.5 - 1.5 - 1.5 - 0.7, but we can
172
 
safely ignore it in this example.
173
 
 
174
 
Here's an "in parallel" set up
175
 
 
176
 
                           .-------+-------+----- 12V
177
 
                           |       |       |
178
 
                          |¯|     |¯|     |¯|
179
 
                          |_| R3  |_| R4  |_| R5
180
 
             |             |       |       |  
181
 
             |             |       |       |
182
 
             |             ▼  D1   ▼  D2   ▼  D3
183
 
             |             ¯``     ¯``     ¯``
184
 
             |             |       |       |
185
 
             |             +-------+-------'
186
 
             |             |
187
 
    Arduino  |    ___    ,-|
188
 
            o----|___|--(|< ) T
189
 
             |     R1    `-|
190
 
             |             |
191
 
             |             '----- GND
192
 
 
193
 
Here, R3 = R4 = R5 = 340Ω, as usual.  The numbher of LEDs is limited
194
 
only by the current that can be drawn from the power supply.
195
 
 
196
 
 
197
 
RC CIRCUITS
198
 
===========
199
 
 
200
 
An RC (resistor capacitor) curcuit is a basic low-pass filter. Here
201
 
we're talking about giving it a pulse wave signal (a voltage that
202
 
oscillates between 0V and approx. 5V).
203
 
              ___
204
 
    Vin o----[___]----+-----o Vc
205
 
                R     |
206
 
                      |
207
 
                     ===
208
 
                      | C
209
 
                      |
210
 
     0V o-------------+-----o
211
 
 
212
 
If the resistor weren't there, the capacitor on it's own would act
213
 
like an open circuit to a pulse wave (or to an AC power supply). This
214
 
is because the capacitor would charge to the voltage supplied across
215
 
it and discharge almost immediately. The purpose of the resistor is to
216
 
limit the current that is available to charge the capacitor, so it
217
 
charges slowly and it takes some time before Vc becomes almost equal
218
 
to Vin.
219
 
 
220
 
With a pulse wave on Vin, Vc would look something like this:
221
 
 
222
 
    5V
223
 
             _           _           _           _
224
 
          ,'' \       ,'' \       ,'' \       ,''
225
 
         /     \     /     \     /     \     /
226
 
    0V  /       ',,_/       ',,_/       ',,_/
227
 
 
228
 
If you were to draw the tangent to the curve at time=0 (so, the
229
 
initial rate of change of charging), and you note the time that this
230
 
line crossed 5V, then this time is T. That is to say, time T is the
231
 
time it would take the capacitor to charge to the target voltage if it
232
 
charged constantly at the rate it actually initially charges at. Then
233
 
this equation applies
234
 
 
235
 
    T = RC
236