Sketching 2013 - PARC - Tod E. Kurt

advertisement
Abusing
microcontroller features
for profit and fame
Sketching 2013 - PARC - Tod E. Kurt
Constrained Engineering
or, using hacks in production
■ I/O pins as power supplies
■ LED matrices with few pins by abusing LED diode
characteristics
■ Adding a full keypad when only one I/O pin left
■ Solving two-serial input, one-UART
■ Bringing PICs into 21st century by breaking SPI
Digital I/O as Pwr & Gnd
■ Problem: Want a low-current switchable power supply
■ Solution: Make an I/O pin a power supply!
Digital I/O as Pwr & Gnd
use any pin as a switchable power supply
on AVR: 40 mA, enough for RGB LED + MCU
http://blinkm.com/
http://blinkm.com/
Charlieplexing
■ Problem: Need to control a bunch of LEDs,
only have a few pins
■ Solution: Use pin tri-state to Charlieplex LEDs,
get N*(N-1) LEDs with N pins
images from: http://www.instructables.com/id/Charlieplexing-LEDs--The-theory/
also see: http://www.maximintegrated.com/app-notes/index.mvp/id/1880
Charlieplexing
1. LEDs have a defined turn-on voltage
2. Choose resistors for voltage drop
to turn on one LED but not two
3. Set HIGH & LOW pins to turn on LED,
tri-state all others
http://www.instructables.com/id/Creating-a-charlieplexed-LED-grid-to-run-on-ATTiny/
http://www.instructables.com/id/Creating-a-charlieplexed-LED-grid-to-run-on-ATTiny/
Charlieplexing
5 lines gives you 5*(5-1) = 20 LEDs
So ATtiny85 can control 20 LEDs
no extra h/w
http://www.instructables.com/id/Creating-a-charlieplexed-LED-grid-to-run-on-ATTiny/
http://www.instructables.com/id/Creating-a-charlieplexed-LED-grid-to-run-on-ATTiny/
Charlieplexing
6 lines gives you 6*(6-1) = 30 LEDs
So ATtiny2313 can control 30 LEDs
plus a speaker, and some buttons
http://wiki.032.la/nsl/NSL_Cylon_II
http://wiki.032.la/nsl/NSL_Cylon_II
Multiple Buttons,
One Analog Pin
■ Problem: Need to add FIVE more buttons
(4-way D-pad + select) and only have ONE input left
■ Solution: Voltage Dividers, Transform!
Ri
Rp
Multiple Buttons,
One Analog Pin
Each button is its own voltage divider
Ri
1k
10k
5k
47k
100k
Vin = Rp / (Ri + Rp)
A
B
C
D
E
MCU
…
Ri
1k
5k
10k
47k
100k
n/a
analogIn
analogRead()
button
930
682
511
179
93
0
A
B
C
D
E
none
Rp
10k
Multiple Buttons,
One Analog Pin
http://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad/
http://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad/
One Pin,
Multiple Serial Inputs
■ Problem: Have only one UART, need to receive from
two serial devices, no space for more logic
■ Solution: Use diode logic!
V+
diode-AND
R
D1
SerialA In
Serial Out
(pulls LOW if any input is LOW)
SerialB In
D2
One Pin,
Multiple Serial Inputs
Need to coordinate senders
(or design it so they don’t collide)
t1
t3
t1
t2
t3
t4
Sender A
t2
t4
Sender B
"B,send at t=2,4,6"
"A,send at t=1,3,5"
diode
AND
Receiver
Diode-Logic
& Serial Input
Why this works
TTL serial idles at Vcc
Start transmission by
lowering to 0V
V+
diode-AND
R
D1
SerialA In
Serial Out
(pulls LOW if any input is LOW)
SerialB In
D2
One Pin,
Multiple Serial Inputs
using Diode Logic
In this case,
two 8kB Arduinos:
- GPS data logger
- UI + sensor
GPS + SD + UI +
I2C > 8kB
http://makezine.com/2009/02/27/maker-workshop-personal-flight-reco/
http://makezine.com/2009/02/27/maker-workshop-personal-flight-reco/
https://www.youtube.com/watch?v=lrUWAPj4FaE
SPI for Nanosecond
Pulse Generator
■ Problem: Need sub-microsecond pulses for wacky
async shift-register protocol and MCU is too slow*
■ Solution: SPI bus! (only data pin, no clock)
* or developer too lazy to learn assembly
* or programmer too lazy to learn assembly
WS2811 “smart pixel”
Same size (5x5mm PLCC) as in BlinkM MinM
But now with logic die
http://propaneandelectrons.com/blog/the-difference-between-ws2811-and-ws2812
WS2811 “smart pixel”
Getting close to my original hope
for an LED with I/O built-in
+5yrs
from my talk
“Smart Interface Components”
I’ve been harping about this *forever*. Glad to see it’s getting closer to reality.
For my talk, see:
http://todbot.com/blog/2007/07/03/smart-interface-components-my-sketching07-talk/
WS2811 “smart pixel”
Unfortunately, very dumb logic (shift register + PWM)
Interestingly, a shift register with clockless data
Easy to
wire up
DI
DO
DO
DI
DO
DI
MCU
ws2811
ws2811
300ns
But data
format is
tricky &
timesensitive
DI
"0"
T0H
600ns
"1"
T1H
ws2811
1000ns
T0L
700ns
T1L
1300ns
Timing vary on the data sheets. Looks like bit T0H,etc. are +/- 150ns
ws2811
DO
Using SPI for WS2811
Microchip PIC16F1455
Great chip, slow PIC internals
Complete USB circuit, no oscillator needed
Using SPI for WS2811
SPI bit timing
0
1
2
3
4
300ns
"0"
T0H
600ns
"1"
T1H
1000ns
0
1
2
6
0
7
1300ns
~80ns
280ns
ws2811 “0”
5
1020ns
3
4
5
6
7
0
T0L
1300ns
560ns
700ns
660ns
T1L
1300ns
ws2811 “1”
0
1
2
3
4
5
6
7
1300ns
Timing vary on the data sheets. Looks like bit T0H,etc. are +/- 150ns
0
Using SPI for WS2811
280ns
ws2811 “0”
0
1
2
1020ns
3
4
ws2811 “1”
1
2
3
6
7
1300ns
560ns
0
5
4
5
6
0
660ns
7
1300ns
Timing vary on the data sheets. Looks like bit T0H,etc. are +/- 150ns
0
The Result
Announcing our update to blink(1):
blink(1) mk2
Please back it!
http://is.gd/blink1mk2
blink(1) mk2
PIC16F1455 + 2xWS2811 = simple
Did I mention it has
two independent LEDs?
http://is.gd/blink1mk2
Morale
Hacks aren’t hacks if they work reliably*
* that’s the story I’m sticking to, at least
woah...
it’s only launched about 12 hours ago
Thank You
@thingm / @todbot
http://thingm.com/
http://todbot.com/blog/
Please feel free to contact me if you’d like to learn more. Thank you!
Related documents
Download