A lecture for Arduino Course, Winter 2017/18 A few useful circuits Boris van Sosin, Commissar-Engineer A lecture for Arduino Course, Winter 2017/18 Technion, IIT
Voltage Divider 𝐼= 𝑉 𝑅 Ohm’s Law: 𝐼= 𝑉 𝑅 𝐶𝑢𝑟𝑟𝑒𝑛𝑡= 𝑉𝑜𝑙𝑡𝑎𝑔𝑒 𝑅𝑒𝑠𝑖𝑠𝑡𝑎𝑛𝑐𝑒
Voltage Divider Assume: When open: Voltage reader has R=∞ to ground 𝐼= 𝑉 𝑅 Assume: Voltage reader has R=∞ to ground When open: V read = 0V 𝑉=0𝑉 𝐼=0 𝑉= 𝑉 𝐺𝑁𝐷 =0𝑉
Voltage Divider Assume: When closed: Voltage reader has R=∞ to ground 𝐼= 𝑉 𝑅 Assume: Voltage reader has R=∞ to ground When closed: V read = 5V 𝑉=5𝑉 𝐼= 𝑉𝐶𝐶 𝑅1 𝑉= 𝑉 𝐺𝑁𝐷 =0𝑉
Generalized Voltage Divider 𝐼= 𝑉 𝑅 Total current: 𝐼= 𝑉𝐶𝐶 𝑅1+𝑅2 Equal to current over each resistor 𝐼= 𝐼 𝑂𝑣𝑒𝑟 𝑅2 Therefore: 𝑉 𝑂𝑣𝑒𝑟 𝑅2 = 𝐼 𝑂𝑣𝑒𝑟 𝑅2 ⋅ 𝑅 2 =𝑉𝐶𝐶⋅ 𝑅 2 𝑅 1 + 𝑅 2 𝐼= 𝑉𝐶𝐶 𝑅1+𝑅2 𝑉= 𝑉 𝐺𝑁𝐷 =0𝑉 𝑉 𝑂𝑣𝑒𝑟 𝑅2 =𝑉𝐶𝐶⋅ 𝑅 2 𝑅 1 + 𝑅 2
Voltage Divider Uses: Lots of Arduino inputs
Low-Pass Filter Charging a capacitor through a resistor Initially capacitor is empty 𝑉 𝑟𝑒𝑎𝑑 =0𝑉 As capacitor charges, 𝑉 𝑟𝑒𝑎𝑑 rises
Low-Pass Filter Charging a capacitor through a resistor RC Law: 𝑉 𝑡 = 𝑉 𝑚𝑎𝑥 ⋅ 1− 𝑒 −𝑡⋅𝐶𝑜𝑛𝑠𝑡 𝑉 𝑡 Chart by desmos.com
Low-Pass Filter Charging a capacitor through a resistor RC Law RC Constant depends on resistor and capacitor 𝑉 𝑡 = 𝑉 𝑚𝑎𝑥 ⋅ 1− 𝑒 − 𝑡 𝑅⋅𝐶 Greater resistance and/or capacitance means slower charge
Low-Pass Filter Uses: Smoothing a signal
Low-Pass Filter Uses: Smoothing a signal Smoothing digital waveform to (nearly) analog Smoothing high frequency analog Noise filtering
H-Bridge Recall first tutorial: Powering a DC motor: Reversing a motor:
H-Bridge Control direction via logic? Simplified solution: Switches
H-Bridge Control direction via logic Close diagonal pair of switches to power motor Close other pair to reverse
H-Bridge Control direction via logic Problem: illegal states Short circuit!
H-Bridge Connecting to logic: Replace switches with transistors HIGH (or PWM) to D5 HIGH (or PWM) to D6 for reverse direction NEVER POWER BOTH! What is missing?
H-Bridge Connecting to logic Diodes, capacitor, protection against illegal state
H-Bridge Can be contained in a chip L293D 4x Half H-Bridge L298 2x Full H-Bridge
Increasing No. of Outputs Arduino UNO has 20 I/O pins TX/RX 12 digital I/O 6 digital Out + Analog In How can this be increased?
Shift Register Shift register Recall from Digital Systems / Logic Design Convert Serial to parallel
Shift Register Shift register Demo: Write 1100 to a 4-bit shift register Strategy: Write in reverse order
Shift Register Shift register Write 0 ? ? ?
Shift Register Shift register Write another 0 ? ?
Shift Register 1 1 Shift register Write 1 ?
Shift Register 1 1 Shift register Write another 1 1
Shift Register Problem: look at previous state Current output is 100 Is it valid? ?
Shift Register Problem: Intermediate output states Solution: second layer of registers Requires “Latch out” control