First version of submodule implementation

Based on ATTiny2313 / ATTiny4313
This commit is contained in:
Mark van Renswoude 2018-11-18 11:16:33 +01:00
parent 3a8b22fc4a
commit 5f89b3efd2
42 changed files with 6904 additions and 1 deletions

4
.gitignore vendored
View File

@ -3,4 +3,6 @@
bin
*.sublime-workspace
node_modules
src/secret.h
src/secret.h
/kicad/Stairs.kicad_pcb-bak
/kicad/Stairs.bak

387
kicad/Stairs-cache.lib Normal file
View File

@ -0,0 +1,387 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# AMS1117-5.0_AMS1117-5.0
#
DEF AMS1117-5.0_AMS1117-5.0 U 0 40 Y Y 1 L N
F0 "U" -400 220 50 H V L BNN
F1 "AMS1117-5.0_AMS1117-5.0" -401 -321 50 H V L BNN
F2 "SOT229P700X180-4N" 0 0 50 H I L BNN
F3 "Sot223/Pkg 1-Amp 5-Volt Low Drop Out Voltage Regulatator" 0 0 50 H I L BNN
F4 "Unavailable" 0 0 50 H I L BNN
F5 "Advanced Monolithic Systems" 0 0 50 H I L BNN
F6 "None" 0 0 50 H I L BNN
F7 "None" 0 0 50 H I L BNN
F8 "AMS1117-5.0" 0 0 50 H I L BNN
DRAW
S -400 200 400 -200 0 1 0 f
X ADJ/GND 1 600 -100 200 L 40 40 0 0 W
X VOUT 2 600 100 200 L 40 40 0 0 O
X VIN 3 -600 100 200 R 40 40 0 0 I
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x02
#
DEF Connector_Generic_Conn_01x02 J 0 40 Y N 1 F N
F0 "J" 0 100 50 H V C CNN
F1 "Connector_Generic_Conn_01x02" 0 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 50 50 -150 1 1 10 f
X Pin_1 1 -200 0 150 R 50 50 1 1 P
X Pin_2 2 -200 -100 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x04
#
DEF Connector_Generic_Conn_01x04 J 0 40 Y N 1 F N
F0 "J" 0 200 50 H V C CNN
F1 "Connector_Generic_Conn_01x04" 0 -300 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 150 50 -250 1 1 10 f
X Pin_1 1 -200 100 150 R 50 50 1 1 P
X Pin_2 2 -200 0 150 R 50 50 1 1 P
X Pin_3 3 -200 -100 150 R 50 50 1 1 P
X Pin_4 4 -200 -200 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x06
#
DEF Connector_Generic_Conn_01x06 J 0 40 Y N 1 F N
F0 "J" 0 300 50 H V C CNN
F1 "Connector_Generic_Conn_01x06" 0 -400 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -295 0 -305 1 1 6 N
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 205 0 195 1 1 6 N
S -50 250 50 -350 1 1 10 f
X Pin_1 1 -200 200 150 R 50 50 1 1 P
X Pin_2 2 -200 100 150 R 50 50 1 1 P
X Pin_3 3 -200 0 150 R 50 50 1 1 P
X Pin_4 4 -200 -100 150 R 50 50 1 1 P
X Pin_5 5 -200 -200 150 R 50 50 1 1 P
X Pin_6 6 -200 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_02x03_Counter_Clockwise
#
DEF Connector_Generic_Conn_02x03_Counter_Clockwise J 0 40 Y N 1 F N
F0 "J" 50 200 50 H V C CNN
F1 "Connector_Generic_Conn_02x03_Counter_Clockwise" 50 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_2x??_*
$ENDFPLIST
DRAW
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 150 150 -150 1 1 10 f
S 150 -95 100 -105 1 1 6 N
S 150 5 100 -5 1 1 6 N
S 150 105 100 95 1 1 6 N
X Pin_1 1 -200 100 150 R 50 50 1 1 P
X Pin_2 2 -200 0 150 R 50 50 1 1 P
X Pin_3 3 -200 -100 150 R 50 50 1 1 P
X Pin_4 4 300 -100 150 L 50 50 1 1 P
X Pin_5 5 300 0 150 L 50 50 1 1 P
X Pin_6 6 300 100 150 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_C
#
DEF Device_C C 0 10 N Y 1 F N
F0 "C" 25 100 50 H V L CNN
F1 "Device_C" 25 -100 50 H V L CNN
F2 "" 38 -150 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
C_*
$ENDFPLIST
DRAW
P 2 0 1 20 -80 -30 80 -30 N
P 2 0 1 20 -80 30 80 30 N
X ~ 1 0 150 110 D 50 50 1 1 P
X ~ 2 0 -150 110 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_Crystal_Small
#
DEF Device_Crystal_Small Y 0 40 N N 1 F N
F0 "Y" 0 100 50 H V C CNN
F1 "Device_Crystal_Small" 0 -100 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Crystal*
$ENDFPLIST
DRAW
S -30 -60 30 60 0 1 0 N
P 2 0 1 15 -50 -30 -50 30 N
P 2 0 1 15 50 -30 50 30 N
X 1 1 -100 0 50 R 50 50 1 1 P
X 2 2 100 0 50 L 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Device_R
#
DEF Device_R R 0 0 N Y 1 F N
F0 "R" 80 0 50 V V C CNN
F1 "Device_R" 0 0 50 V V C CNN
F2 "" -70 0 50 V I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
R_*
$ENDFPLIST
DRAW
S -40 -100 40 100 0 1 10 N
X ~ 1 0 150 50 D 50 50 1 1 P
X ~ 2 0 -150 50 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# MAX485_MAX485
#
DEF MAX485_MAX485 U 0 40 Y Y 1 L N
F0 "U" -401 301 50 H V L BNN
F1 "MAX485_MAX485" -401 -301 50 H V L BNN
F2 "" 0 0 50 H I C CNN
F3 "Maxim Integrated" 0 0 50 H I L BNN
F4 "None" 0 0 50 H I L BNN
F5 "Unavailable" 0 0 50 H I L BNN
F6 "None" 0 0 50 H I L BNN
F7 "MAX485" 0 0 50 H I L BNN
$FPLIST
DIL08
SO08
$ENDFPLIST
DRAW
S -400 300 400 -200 0 1 0 f
X RO 1 -600 200 200 R 40 40 0 0 B
X RE 2 -600 100 200 R 40 40 0 0 B I
X DE 3 -600 0 200 R 40 40 0 0 B
X DI 4 -600 -100 200 R 40 40 0 0 B
X GND 5 600 -100 200 L 40 40 0 0 W
X A 6 600 0 200 L 40 40 0 0 B
X B 7 600 100 200 L 40 40 0 0 B
X VCC 8 600 200 200 L 40 40 0 0 W
ENDDRAW
ENDDEF
#
# MCU_Microchip_ATtiny_ATtiny2313A-SU
#
DEF MCU_Microchip_ATtiny_ATtiny2313A-SU U 0 20 Y Y 1 F N
F0 "U" -500 1050 50 H V L BNN
F1 "MCU_Microchip_ATtiny_ATtiny2313A-SU" 100 -1050 50 H V L TNN
F2 "Package_SO:SOIC-20W_7.5x12.8mm_P1.27mm" 0 0 50 H I C CIN
F3 "" 0 0 50 H I C CNN
ALIAS ATtiny2313-20SU ATtiny2313A-SU ATtiny4313-SU
$FPLIST
SOIC*7.5x12.8mm*P1.27mm*
$ENDFPLIST
DRAW
S -500 -1000 500 1000 0 1 10 f
X PA2/~RESET 1 -600 800 100 R 50 50 1 1 T
X GND 10 0 -1100 100 U 50 50 1 1 W
X PD6 11 600 -700 100 L 50 50 1 1 T
X PB0 12 600 800 100 L 50 50 1 1 T
X PB1 13 600 700 100 L 50 50 1 1 T
X PB2 14 600 600 100 L 50 50 1 1 T
X PB3 15 600 500 100 L 50 50 1 1 T
X PB4 16 600 400 100 L 50 50 1 1 T
X PB5 17 600 300 100 L 50 50 1 1 T
X PB6 18 600 200 100 L 50 50 1 1 T
X PB7 19 600 100 100 L 50 50 1 1 T
X PD0 2 600 -100 100 L 50 50 1 1 T
X VCC 20 0 1100 100 D 50 50 1 1 W
X PD1 3 600 -200 100 L 50 50 1 1 T
X PA1/XTAL2 4 -600 400 100 R 50 50 1 1 T
X PA0/XTAL1 5 -600 600 100 R 50 50 1 1 T
X PD2 6 600 -300 100 L 50 50 1 1 T
X PD3 7 600 -400 100 L 50 50 1 1 T
X PD4 8 600 -500 100 L 50 50 1 1 T
X PD5 9 600 -600 100 L 50 50 1 1 T
ENDDRAW
ENDDEF
#
# PCA9685-TSSOP_PCA9685-TSSOP
#
DEF PCA9685-TSSOP_PCA9685-TSSOP U 0 40 Y Y 1 F N
F0 "U" 0 -100 50 H V C CNN
F1 "PCA9685-TSSOP_PCA9685-TSSOP" 0 100 50 H V C CNN
F2 "MODULE" 0 0 50 H I C CNN
F3 "DOCUMENTATION" 0 0 50 H I C CNN
DRAW
S -450 -850 450 850 1 0 0 f
X A0 1 -750 650 300 R 50 50 1 1 I
X LED4 10 -750 -250 300 R 50 50 1 1 O
X LED5 11 -750 -350 300 R 50 50 1 1 O
X LED6 12 -750 -450 300 R 50 50 1 1 O
X LED7 13 -750 -550 300 R 50 50 1 1 O
X GND 14 -750 -650 300 R 50 50 1 1 I
X LED8 15 750 -650 300 L 50 50 1 1 O
X LED9 16 750 -550 300 L 50 50 1 1 O
X LED10 17 750 -450 300 L 50 50 1 1 O
X LED11 18 750 -350 300 L 50 50 1 1 O
X LED12 19 750 -250 300 L 50 50 1 1 O
X A1 2 -750 550 300 R 50 50 1 1 I
X LED13 20 750 -150 300 L 50 50 1 1 O
X LED14 21 750 -50 300 L 50 50 1 1 O
X LED15 22 750 50 300 L 50 50 1 1 O
X OE 23 750 150 300 L 50 50 1 1 I
X A5 24 750 250 300 L 50 50 1 1 I
X EXTCLK 25 750 350 300 L 50 50 1 1 I
X SCL 26 750 450 300 L 50 50 1 1 I
X SDA 27 750 550 300 L 50 50 1 1 B
X VCC 28 750 650 300 L 50 50 1 1 I
X A2 3 -750 450 300 R 50 50 1 1 I
X A3 4 -750 350 300 R 50 50 1 1 I
X A4 5 -750 250 300 R 50 50 1 1 I
X LED0 6 -750 150 300 R 50 50 1 1 O
X LED1 7 -750 50 300 R 50 50 1 1 O
X LED2 8 -750 -50 300 R 50 50 1 1 O
X LED3 9 -750 -150 300 R 50 50 1 1 O
ENDDRAW
ENDDEF
#
# Switch_SW_Push
#
DEF Switch_SW_Push SW 0 40 N N 1 F N
F0 "SW" 50 100 50 H V L CNN
F1 "Switch_SW_Push" 0 -60 50 H V C CNN
F2 "" 0 200 50 H I C CNN
F3 "" 0 200 50 H I C CNN
DRAW
C -80 0 20 0 1 0 N
C 80 0 20 0 1 0 N
P 2 0 1 0 0 50 0 120 N
P 2 0 1 0 100 50 -100 50 N
X 1 1 -200 0 100 R 50 50 0 1 P
X 2 2 200 0 100 L 50 50 0 1 P
ENDDRAW
ENDDEF
#
# Transistor_FET_IRLB8721PBF
#
DEF Transistor_FET_IRLB8721PBF Q 0 0 Y N 1 F N
F0 "Q" 250 75 50 H V L CNN
F1 "Transistor_FET_IRLB8721PBF" 250 0 50 H V L CNN
F2 "Package_TO_SOT_THT:TO-220-3_Vertical" 250 -75 50 H I L CIN
F3 "" 0 0 50 H I L CNN
ALIAS IRF3205 IRF540N IRF740 IRLB8721PBF IRLZ34N IRLZ44N
$FPLIST
TO?220*
$ENDFPLIST
DRAW
C 65 0 111 0 1 10 N
C 100 -70 11 0 1 0 F
C 100 70 11 0 1 0 F
P 2 0 1 0 10 0 -100 0 N
P 2 0 1 0 30 -70 100 -70 N
P 2 0 1 10 30 -50 30 -90 N
P 2 0 1 0 30 0 100 0 N
P 2 0 1 10 30 20 30 -20 N
P 2 0 1 0 30 70 100 70 N
P 2 0 1 10 30 90 30 50 N
P 2 0 1 0 100 -70 100 -100 N
P 2 0 1 0 100 -70 100 0 N
P 2 0 1 0 100 100 100 70 N
P 3 0 1 10 10 75 10 -75 10 -75 N
P 4 0 1 0 40 0 80 15 80 -15 40 0 F
P 4 0 1 0 100 -70 130 -70 130 70 100 70 N
P 4 0 1 0 110 20 115 15 145 15 150 10 N
P 4 0 1 0 130 15 115 -10 145 -10 130 15 N
X G 1 -200 0 100 R 50 50 1 1 I
X D 2 100 200 100 D 50 50 1 1 P
X S 3 100 -200 100 U 50 50 1 1 P
ENDDRAW
ENDDEF
#
# power_+12V
#
DEF power_+12V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "power_+12V" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +12V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# power_+5V
#
DEF power_+5V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "power_+5V" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +5V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# power_GND
#
DEF power_GND #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -250 50 H I C CNN
F1 "power_GND" 0 -150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 -50 50 -50 0 -100 -50 -50 0 -50 N
X GND 1 0 0 0 D 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# power_PWR_FLAG
#
DEF power_PWR_FLAG #FLG 0 0 N N 1 F P
F0 "#FLG" 0 75 50 H I C CNN
F1 "power_PWR_FLAG" 0 150 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
DRAW
P 6 0 1 0 0 0 0 50 -40 75 0 100 40 75 0 50 N
X pwr 1 0 0 0 U 50 50 0 0 w
ENDDRAW
ENDDEF
#
#End Library

2350
kicad/Stairs.kicad_pcb Normal file

File diff suppressed because it is too large Load Diff

581
kicad/Stairs.net Normal file
View File

@ -0,0 +1,581 @@
(export (version D)
(design
(source P:\Electronics\Stairs\kicad\Stairs.sch)
(date "11-11-2018 20:15:56")
(tool "Eeschema (5.0.1)-3")
(sheet (number 1) (name /) (tstamps /)
(title_block
(title "Stairs submodule")
(company "Mark van Renswoude")
(rev 1)
(date 2018-09-02)
(source Stairs.sch)
(comment (number 1) (value ""))
(comment (number 2) (value ""))
(comment (number 3) (value ""))
(comment (number 4) (value "")))))
(components
(comp (ref PCA9685)
(value PCA9685-TSSOP)
(footprint Housings_SSOP:TSSOP-28_4.4x9.7mm_Pitch0.65mm)
(datasheet DOCUMENTATION)
(libsource (lib PCA9685-TSSOP) (part PCA9685-TSSOP) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AD5C2))
(comp (ref U2)
(value MAX485)
(footprint Housings_SOIC:SO-8_5.3x6.2mm_Pitch1.27mm)
(datasheet "Maxim Integrated")
(fields
(field (name Field4) None)
(field (name Field5) Unavailable)
(field (name Field6) None)
(field (name Field7) MAX485))
(libsource (lib MAX485) (part MAX485) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AD72A))
(comp (ref P6)
(value PWR_IN)
(footprint Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AD8CA))
(comp (ref P5)
(value PWR_OUT)
(footprint Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8ADA74))
(comp (ref P3)
(value SENSOR)
(footprint Terminal_Blocks:TerminalBlock_bornier-6_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x06) (description "Generic connector, single row, 01x06, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AE6A5))
(comp (ref P1)
(value DATA_IN)
(footprint Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AE987))
(comp (ref P2)
(value DATA_OUT)
(footprint Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x02) (description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AE9DD))
(comp (ref AMS1117)
(value AMS1117-5)
(footprint AMS1117-5.0:SOT229P700X180-4N)
(datasheet AMS1117-5.0)
(fields
(field (name Field4) None)
(field (name Field5) Unavailable)
(field (name Field6) "Sot223/Pkg 1-Amp 3.3-Volt Low Drop Out Voltage Regulatator")
(field (name Field7) "Advanced Monolithic Systems")
(field (name Field8) None))
(libsource (lib AMS1117-5.0) (part AMS1117-5.0) (description ""))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AFB24))
(comp (ref C3)
(value 10µF)
(footprint Capacitors_Tantalum_SMD:CP_Tantalum_Case-D_EIA-7343-31_Hand)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8B090B))
(comp (ref C4)
(value 100nF)
(footprint Capacitors_SMD:C_1206_HandSoldering)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8B1267))
(comp (ref U1)
(value ATTINY2313A-SU)
(footprint Housings_SOIC:SOIC-20W_7.5x12.8mm_Pitch1.27mm)
(libsource (lib MCU_Microchip_ATtiny) (part ATtiny2313A-SU) (description "20MHz, 2kB Flash, 128B SRAM, 128B EEPROM, SOIC-20"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8AD3B8))
(comp (ref C2)
(value 33pF)
(footprint Capacitors_SMD:C_1206_HandSoldering)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8B93C9))
(comp (ref C1)
(value 33pF)
(footprint Capacitors_SMD:C_1206_HandSoldering)
(libsource (lib Device) (part C) (description "Unpolarized capacitor"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8B9824))
(comp (ref XTAL1)
(value "8 Mhz")
(footprint Crystals:Crystal_HC49-U_Vertical)
(libsource (lib Device) (part Crystal_Small) (description "Two pin crystal, small symbol"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8B9A62))
(comp (ref R1)
(value 10K)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5B8C2380))
(comp (ref P7)
(value SSD1306)
(footprint Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm)
(libsource (lib Connector_Generic) (part Conn_01x04) (description "Generic connector, single row, 01x04, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8C32B0))
(comp (ref Q1)
(value IRLB8721PBF)
(footprint TO_SOT_Packages_THT:TO-220-3_Horizontal)
(libsource (lib Transistor_FET) (part IRLB8721PBF) (description "62A Id, 30V Vds, N-Channel MOSFET, TO-220"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8C8EA8))
(comp (ref R2)
(value 150)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5B8CAD1E))
(comp (ref R3)
(value 150)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5B8CAE68))
(comp (ref Q2)
(value IRLB8721PBF)
(footprint TO_SOT_Packages_THT:TO-220-3_Horizontal)
(libsource (lib Transistor_FET) (part IRLB8721PBF) (description "62A Id, 30V Vds, N-Channel MOSFET, TO-220"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8CB00E))
(comp (ref P4)
(value LED)
(footprint Terminal_Blocks:TerminalBlock_bornier-4_P5.08mm)
(libsource (lib Connector_Generic) (part Conn_01x04) (description "Generic connector, single row, 01x04, script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5B8CBF27))
(comp (ref R4)
(value 10K)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5B8C6BF9))
(comp (ref R5)
(value 10K)
(footprint Resistors_SMD:R_0603_HandSoldering)
(libsource (lib Device) (part R) (description Resistor))
(sheetpath (names /) (tstamps /))
(tstamp 5B925FBE))
(comp (ref J1)
(value PROG)
(footprint Pin_Headers:Pin_Header_Straight_2x03_Pitch2.54mm)
(datasheet ~)
(libsource (lib Connector_Generic) (part Conn_02x03_Counter_Clockwise) (description "Generic connector, double row, 02x03, counter clockwise pin numbering scheme (similar to DIP packge numbering), script generated (kicad-library-utils/schlib/autogen/connector/)"))
(sheetpath (names /) (tstamps /))
(tstamp 5BEBD38C))
(comp (ref SW1)
(value Button)
(footprint SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_:SW4-SMD-5.2X5.2X1.5MM)
(libsource (lib Switch) (part SW_Push) (description "Push button switch, generic, two pins"))
(sheetpath (names /) (tstamps /))
(tstamp 5BF329CF)))
(libparts
(libpart (lib AMS1117-5.0) (part AMS1117-5.0)
(fields
(field (name Reference) U)
(field (name Value) AMS1117-5.0)
(field (name Footprint) SOT229P700X180-4N)
(field (name Datasheet) "Sot223/Pkg 1-Amp 5-Volt Low Drop Out Voltage Regulatator")
(field (name Field4) Unavailable)
(field (name Field5) "Advanced Monolithic Systems")
(field (name Field6) None)
(field (name Field7) None)
(field (name Field8) AMS1117-5.0))
(pins
(pin (num 1) (name ADJ/GND) (type power_in))
(pin (num 2) (name VOUT) (type output))
(pin (num 3) (name VIN) (type input))))
(libpart (lib Connector_Generic) (part Conn_01x02)
(description "Generic connector, single row, 01x02, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x02))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))))
(libpart (lib Connector_Generic) (part Conn_01x04)
(description "Generic connector, single row, 01x04, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x04))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))))
(libpart (lib Connector_Generic) (part Conn_01x06)
(description "Generic connector, single row, 01x06, script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_1x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_01x06))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))
(pin (num 5) (name Pin_5) (type passive))
(pin (num 6) (name Pin_6) (type passive))))
(libpart (lib Connector_Generic) (part Conn_02x03_Counter_Clockwise)
(description "Generic connector, double row, 02x03, counter clockwise pin numbering scheme (similar to DIP packge numbering), script generated (kicad-library-utils/schlib/autogen/connector/)")
(docs ~)
(footprints
(fp Connector*:*_2x??_*))
(fields
(field (name Reference) J)
(field (name Value) Conn_02x03_Counter_Clockwise))
(pins
(pin (num 1) (name Pin_1) (type passive))
(pin (num 2) (name Pin_2) (type passive))
(pin (num 3) (name Pin_3) (type passive))
(pin (num 4) (name Pin_4) (type passive))
(pin (num 5) (name Pin_5) (type passive))
(pin (num 6) (name Pin_6) (type passive))))
(libpart (lib Device) (part C)
(description "Unpolarized capacitor")
(docs ~)
(footprints
(fp C_*))
(fields
(field (name Reference) C)
(field (name Value) C))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib Device) (part Crystal_Small)
(description "Two pin crystal, small symbol")
(docs ~)
(footprints
(fp Crystal*))
(fields
(field (name Reference) Y)
(field (name Value) Crystal_Small))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib Device) (part R)
(description Resistor)
(docs ~)
(footprints
(fp R_*))
(fields
(field (name Reference) R)
(field (name Value) R))
(pins
(pin (num 1) (name ~) (type passive))
(pin (num 2) (name ~) (type passive))))
(libpart (lib MAX485) (part MAX485)
(footprints
(fp DIL08)
(fp SO08))
(fields
(field (name Reference) U)
(field (name Value) MAX485)
(field (name Datasheet) "Maxim Integrated")
(field (name Field4) None)
(field (name Field5) Unavailable)
(field (name Field6) None)
(field (name Field7) MAX485))
(pins
(pin (num 1) (name RO) (type BiDi))
(pin (num 2) (name RE) (type BiDi))
(pin (num 3) (name DE) (type BiDi))
(pin (num 4) (name DI) (type BiDi))
(pin (num 5) (name GND) (type power_in))
(pin (num 6) (name A) (type BiDi))
(pin (num 7) (name B) (type BiDi))
(pin (num 8) (name VCC) (type power_in))))
(libpart (lib MCU_Microchip_ATtiny) (part ATtiny2313V-10SU)
(aliases
(alias ATtiny2313-20SU)
(alias ATtiny2313A-SU)
(alias ATtiny4313-SU))
(description "10MHz, 2kB Flash, 128B SRAM, 128B EEPROM, debugWIRE, SOIC-20")
(docs http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2543-AVR-ATtiny2313_Datasheet.pdf)
(footprints
(fp SOIC*7.5x12.8mm*P1.27mm*))
(fields
(field (name Reference) U)
(field (name Value) ATtiny2313V-10SU)
(field (name Footprint) Package_SO:SOIC-20W_7.5x12.8mm_P1.27mm))
(pins
(pin (num 1) (name PA2/~RESET) (type 3state))
(pin (num 2) (name PD0) (type 3state))
(pin (num 3) (name PD1) (type 3state))
(pin (num 4) (name PA1/XTAL2) (type 3state))
(pin (num 5) (name PA0/XTAL1) (type 3state))
(pin (num 6) (name PD2) (type 3state))
(pin (num 7) (name PD3) (type 3state))
(pin (num 8) (name PD4) (type 3state))
(pin (num 9) (name PD5) (type 3state))
(pin (num 10) (name GND) (type power_in))
(pin (num 11) (name PD6) (type 3state))
(pin (num 12) (name PB0) (type 3state))
(pin (num 13) (name PB1) (type 3state))
(pin (num 14) (name PB2) (type 3state))
(pin (num 15) (name PB3) (type 3state))
(pin (num 16) (name PB4) (type 3state))
(pin (num 17) (name PB5) (type 3state))
(pin (num 18) (name PB6) (type 3state))
(pin (num 19) (name PB7) (type 3state))
(pin (num 20) (name VCC) (type power_in))))
(libpart (lib PCA9685-TSSOP) (part PCA9685-TSSOP)
(fields
(field (name Reference) U)
(field (name Value) PCA9685-TSSOP)
(field (name Footprint) MODULE)
(field (name Datasheet) DOCUMENTATION))
(pins
(pin (num 1) (name A0) (type input))
(pin (num 2) (name A1) (type input))
(pin (num 3) (name A2) (type input))
(pin (num 4) (name A3) (type input))
(pin (num 5) (name A4) (type input))
(pin (num 6) (name LED0) (type output))
(pin (num 7) (name LED1) (type output))
(pin (num 8) (name LED2) (type output))
(pin (num 9) (name LED3) (type output))
(pin (num 10) (name LED4) (type output))
(pin (num 11) (name LED5) (type output))
(pin (num 12) (name LED6) (type output))
(pin (num 13) (name LED7) (type output))
(pin (num 14) (name GND) (type input))
(pin (num 15) (name LED8) (type output))
(pin (num 16) (name LED9) (type output))
(pin (num 17) (name LED10) (type output))
(pin (num 18) (name LED11) (type output))
(pin (num 19) (name LED12) (type output))
(pin (num 20) (name LED13) (type output))
(pin (num 21) (name LED14) (type output))
(pin (num 22) (name LED15) (type output))
(pin (num 23) (name OE) (type input))
(pin (num 24) (name A5) (type input))
(pin (num 25) (name EXTCLK) (type input))
(pin (num 26) (name SCL) (type input))
(pin (num 27) (name SDA) (type BiDi))
(pin (num 28) (name VCC) (type input))))
(libpart (lib Switch) (part SW_Push)
(description "Push button switch, generic, two pins")
(fields
(field (name Reference) SW)
(field (name Value) SW_Push))
(pins
(pin (num 1) (name 1) (type passive))
(pin (num 2) (name 2) (type passive))))
(libpart (lib Transistor_FET) (part BUZ11)
(aliases
(alias IRF3205)
(alias IRF540N)
(alias IRF740)
(alias IRLB8721PBF)
(alias IRLZ34N)
(alias IRLZ44N))
(description "30A Id, 50V Vds, N-Channel Power MOSFET, TO-220")
(docs http://www.fairchildsemi.com/ds/BU/BUZ11.pdf)
(footprints
(fp TO?220*))
(fields
(field (name Reference) Q)
(field (name Value) BUZ11)
(field (name Footprint) Package_TO_SOT_THT:TO-220-3_Vertical))
(pins
(pin (num 1) (name G) (type input))
(pin (num 2) (name D) (type passive))
(pin (num 3) (name S) (type passive)))))
(libraries
(library (logical AMS1117-5.0)
(uri P:\Electronics\Stairs\kicad/libs/AMS1117-5.0.lib))
(library (logical Connector_Generic)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library/Connector_Generic.lib"))
(library (logical Device)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library/Device.lib"))
(library (logical MAX485)
(uri P:\Electronics\Stairs\kicad/libs/MAX485.lib))
(library (logical MCU_Microchip_ATtiny)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library/MCU_Microchip_ATtiny.lib"))
(library (logical PCA9685-TSSOP)
(uri P:\Electronics\Stairs\kicad/libs/PCA9685-TSSOP.lib))
(library (logical Switch)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library/Switch.lib"))
(library (logical Transistor_FET)
(uri "C:\\Program Files\\KiCad\\share\\kicad\\library/Transistor_FET.lib")))
(nets
(net (code 1) (name "Net-(PCA9685-Pad25)")
(node (ref PCA9685) (pin 25)))
(net (code 2) (name "Net-(PCA9685-Pad15)")
(node (ref PCA9685) (pin 15)))
(net (code 3) (name "Net-(PCA9685-Pad16)")
(node (ref PCA9685) (pin 16)))
(net (code 4) (name "Net-(PCA9685-Pad17)")
(node (ref PCA9685) (pin 17)))
(net (code 5) (name "Net-(PCA9685-Pad18)")
(node (ref PCA9685) (pin 18)))
(net (code 6) (name "Net-(PCA9685-Pad19)")
(node (ref PCA9685) (pin 19)))
(net (code 7) (name "Net-(PCA9685-Pad20)")
(node (ref PCA9685) (pin 20)))
(net (code 8) (name /PD)
(node (ref R4) (pin 1))
(node (ref PCA9685) (pin 5))
(node (ref PCA9685) (pin 4))
(node (ref PCA9685) (pin 23))
(node (ref PCA9685) (pin 24))
(node (ref PCA9685) (pin 3))
(node (ref PCA9685) (pin 2))
(node (ref PCA9685) (pin 1)))
(net (code 9) (name GND)
(node (ref J1) (pin 4))
(node (ref AMS1117) (pin 1))
(node (ref U1) (pin 10))
(node (ref P3) (pin 5))
(node (ref SW1) (pin 2))
(node (ref C4) (pin 1))
(node (ref C3) (pin 1))
(node (ref C2) (pin 2))
(node (ref C1) (pin 2))
(node (ref Q1) (pin 3))
(node (ref P7) (pin 4))
(node (ref U2) (pin 5))
(node (ref P6) (pin 1))
(node (ref P5) (pin 2))
(node (ref P3) (pin 2))
(node (ref PCA9685) (pin 14))
(node (ref R4) (pin 2))
(node (ref Q2) (pin 3)))
(net (code 10) (name "Net-(PCA9685-Pad21)")
(node (ref PCA9685) (pin 21)))
(net (code 11) (name "Net-(P4-Pad3)")
(node (ref P4) (pin 3))
(node (ref Q1) (pin 2)))
(net (code 12) (name +12V)
(node (ref AMS1117) (pin 3))
(node (ref P6) (pin 2))
(node (ref P4) (pin 4))
(node (ref P5) (pin 1))
(node (ref P4) (pin 2)))
(net (code 13) (name "Net-(P4-Pad1)")
(node (ref Q2) (pin 2))
(node (ref P4) (pin 1)))
(net (code 14) (name "Net-(PCA9685-Pad22)")
(node (ref PCA9685) (pin 22)))
(net (code 15) (name "Net-(PCA9685-Pad13)")
(node (ref PCA9685) (pin 13)))
(net (code 16) (name "Net-(PCA9685-Pad12)")
(node (ref PCA9685) (pin 12)))
(net (code 17) (name "Net-(PCA9685-Pad11)")
(node (ref PCA9685) (pin 11)))
(net (code 18) (name "Net-(PCA9685-Pad10)")
(node (ref PCA9685) (pin 10)))
(net (code 19) (name "Net-(PCA9685-Pad9)")
(node (ref PCA9685) (pin 9)))
(net (code 20) (name "Net-(PCA9685-Pad8)")
(node (ref PCA9685) (pin 8)))
(net (code 21) (name "Net-(PCA9685-Pad7)")
(node (ref R3) (pin 1))
(node (ref PCA9685) (pin 7)))
(net (code 22) (name "Net-(PCA9685-Pad6)")
(node (ref R2) (pin 1))
(node (ref PCA9685) (pin 6)))
(net (code 23) (name "Net-(Q2-Pad1)")
(node (ref Q2) (pin 1))
(node (ref R3) (pin 2)))
(net (code 24) (name +5V)
(node (ref P3) (pin 3))
(node (ref PCA9685) (pin 28))
(node (ref U2) (pin 8))
(node (ref P3) (pin 6))
(node (ref J1) (pin 6))
(node (ref P7) (pin 3))
(node (ref R5) (pin 2))
(node (ref R1) (pin 1))
(node (ref U1) (pin 20))
(node (ref AMS1117) (pin 2))
(node (ref C4) (pin 2))
(node (ref C3) (pin 2)))
(net (code 25) (name RST)
(node (ref J1) (pin 3))
(node (ref U1) (pin 1))
(node (ref R5) (pin 1)))
(net (code 26) (name MOSI)
(node (ref PCA9685) (pin 27))
(node (ref U1) (pin 17))
(node (ref R1) (pin 2))
(node (ref P7) (pin 1))
(node (ref J1) (pin 5)))
(net (code 27) (name SCK)
(node (ref P7) (pin 2))
(node (ref J1) (pin 2))
(node (ref U1) (pin 19))
(node (ref PCA9685) (pin 26)))
(net (code 28) (name MISO)
(node (ref U1) (pin 18))
(node (ref J1) (pin 1)))
(net (code 29) (name "Net-(Q1-Pad1)")
(node (ref R2) (pin 2))
(node (ref Q1) (pin 1)))
(net (code 30) (name "Net-(SW1-Pad1)")
(node (ref SW1) (pin 1))
(node (ref U1) (pin 12)))
(net (code 31) (name "Net-(P3-Pad1)")
(node (ref U1) (pin 7))
(node (ref P3) (pin 1)))
(net (code 32) (name "Net-(U1-Pad15)")
(node (ref U1) (pin 15)))
(net (code 33) (name "Net-(U1-Pad9)")
(node (ref U1) (pin 9)))
(net (code 34) (name "Net-(U1-Pad8)")
(node (ref U1) (pin 8)))
(net (code 35) (name "Net-(U1-Pad16)")
(node (ref U1) (pin 16)))
(net (code 36) (name "Net-(U1-Pad14)")
(node (ref U1) (pin 14)))
(net (code 37) (name "Net-(U1-Pad13)")
(node (ref U1) (pin 13)))
(net (code 38) (name "Net-(P3-Pad4)")
(node (ref P3) (pin 4))
(node (ref U1) (pin 6)))
(net (code 39) (name "Net-(P1-Pad1)")
(node (ref U2) (pin 7))
(node (ref P2) (pin 2))
(node (ref P1) (pin 1)))
(net (code 40) (name "Net-(U1-Pad11)")
(node (ref U1) (pin 11))
(node (ref U2) (pin 3))
(node (ref U2) (pin 2)))
(net (code 41) (name "Net-(U1-Pad2)")
(node (ref U2) (pin 1))
(node (ref U1) (pin 2)))
(net (code 42) (name "Net-(U1-Pad3)")
(node (ref U1) (pin 3))
(node (ref U2) (pin 4)))
(net (code 43) (name "Net-(C1-Pad1)")
(node (ref U1) (pin 4))
(node (ref XTAL1) (pin 2))
(node (ref C1) (pin 1)))
(net (code 44) (name "Net-(C2-Pad1)")
(node (ref XTAL1) (pin 1))
(node (ref U1) (pin 5))
(node (ref C2) (pin 1)))
(net (code 45) (name "Net-(P1-Pad2)")
(node (ref P2) (pin 1))
(node (ref U2) (pin 6))
(node (ref P1) (pin 2)))))

30
kicad/Stairs.pro Normal file
View File

@ -0,0 +1,30 @@
update=2-9-2018 10:38:10
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[general]
version=1
[eeschema]
version=1
LibDir=

992
kicad/Stairs.sch Normal file
View File

@ -0,0 +1,992 @@
EESchema Schematic File Version 4
LIBS:Stairs-cache
EELAYER 26 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "Stairs submodule"
Date "2018-09-02"
Rev "1"
Comp "Mark van Renswoude"
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L PCA9685-TSSOP:PCA9685-TSSOP PCA9685
U 1 1 5B8AD5C2
P 7950 2600
F 0 "PCA9685" H 7950 3615 50 0000 C CNN
F 1 "PCA9685-TSSOP" H 7950 3524 50 0000 C CNN
F 2 "Housings_SSOP:TSSOP-28_4.4x9.7mm_Pitch0.65mm" H 7950 2600 50 0001 C CNN
F 3 "DOCUMENTATION" H 7950 2600 50 0001 C CNN
1 7950 2600
1 0 0 -1
$EndComp
$Comp
L MAX485:MAX485 U2
U 1 1 5B8AD72A
P 6050 5050
F 0 "U2" H 6050 5517 50 0000 C CNN
F 1 "MAX485" H 6050 5426 50 0000 C CNN
F 2 "Housings_SOIC:SO-8_5.3x6.2mm_Pitch1.27mm" H 6050 5050 60 0001 C CNN
F 3 "Maxim Integrated" H 6050 5050 50 0001 L BNN
F 4 "None" H 6050 5050 50 0001 L BNN "Field4"
F 5 "Unavailable" H 6050 5050 50 0001 L BNN "Field5"
F 6 "None" H 6050 5050 50 0001 L BNN "Field6"
F 7 "MAX485" H 6050 5050 50 0001 L BNN "Field7"
F 8 "" H 6050 5050 50 0001 L BNN "Field8"
1 6050 5050
1 0 0 -1
$EndComp
$Comp
L Connector_Generic:Conn_01x02 P6
U 1 1 5B8AD8CA
P 4650 6700
F 0 "P6" H 4728 6741 50 0000 L CNN
F 1 "PWR_IN" H 4728 6650 50 0000 L CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm" H 4650 6700 50 0001 C CNN
F 3 "" H 4650 6700 50 0001 C CNN
1 4650 6700
1 0 0 1
$EndComp
$Comp
L Connector_Generic:Conn_01x02 P5
U 1 1 5B8ADA74
P 3400 6600
F 0 "P5" H 3700 6550 50 0000 C CNN
F 1 "PWR_OUT" H 3750 6650 50 0000 C CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm" H 3400 6600 50 0001 C CNN
F 3 "" H 3400 6600 50 0001 C CNN
1 3400 6600
-1 0 0 -1
$EndComp
$Comp
L Connector_Generic:Conn_01x06 P3
U 1 1 5B8AE6A5
P 5700 6050
F 0 "P3" H 5778 6091 50 0000 L CNN
F 1 "SENSOR" H 5778 6000 50 0000 L CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-6_P5.08mm" H 5700 6050 50 0001 C CNN
F 3 "" H 5700 6050 50 0001 C CNN
1 5700 6050
1 0 0 1
$EndComp
$Comp
L Connector_Generic:Conn_01x02 P1
U 1 1 5B8AE987
P 7250 4650
F 0 "P1" H 7328 4691 50 0000 L CNN
F 1 "DATA_IN" H 7328 4600 50 0000 L CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm" H 7250 4650 50 0001 C CNN
F 3 "" H 7250 4650 50 0001 C CNN
1 7250 4650
0 1 -1 0
$EndComp
$Comp
L Connector_Generic:Conn_01x02 P2
U 1 1 5B8AE9DD
P 7250 5350
F 0 "P2" H 7550 5300 50 0000 C CNN
F 1 "DATA_OUT" H 7600 5400 50 0000 C CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-2_P5.08mm" H 7250 5350 50 0001 C CNN
F 3 "" H 7250 5350 50 0001 C CNN
1 7250 5350
0 1 1 0
$EndComp
$Comp
L AMS1117-5.0:AMS1117-5.0 AMS1117
U 1 1 5B8AFB24
P 2450 2150
F 0 "AMS1117" H 2450 2517 50 0000 C CNN
F 1 "AMS1117-5" H 2450 2426 50 0000 C CNN
F 2 "AMS1117-5.0:SOT229P700X180-4N" H 2450 2150 50 0001 L BNN
F 3 "AMS1117-5.0" H 2450 2150 50 0001 L BNN
F 4 "None" H 2450 2150 50 0001 L BNN "Field4"
F 5 "Unavailable" H 2450 2150 50 0001 L BNN "Field5"
F 6 "Sot223/Pkg 1-Amp 3.3-Volt Low Drop Out Voltage Regulatator" H 2450 2150 50 0001 L BNN "Field6"
F 7 "Advanced Monolithic Systems" H 2450 2150 50 0001 L BNN "Field7"
F 8 "None" H 2450 2150 50 0001 L BNN "Field8"
1 2450 2150
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR05
U 1 1 5B8AFFEE
P 3200 2400
F 0 "#PWR05" H 3200 2150 50 0001 C CNN
F 1 "GND" H 3205 2227 50 0000 C CNN
F 2 "" H 3200 2400 50 0001 C CNN
F 3 "" H 3200 2400 50 0001 C CNN
1 3200 2400
1 0 0 -1
$EndComp
$Comp
L power:+12V #PWR02
U 1 1 5B8B02AC
P 1700 1900
F 0 "#PWR02" H 1700 1750 50 0001 C CNN
F 1 "+12V" H 1715 2073 50 0000 C CNN
F 2 "" H 1700 1900 50 0001 C CNN
F 3 "" H 1700 1900 50 0001 C CNN
1 1700 1900
1 0 0 -1
$EndComp
Wire Wire Line
1700 1900 1700 2050
Wire Wire Line
1700 2050 1850 2050
Wire Wire Line
3050 2050 3200 2050
Wire Wire Line
3200 2050 3200 1900
Wire Wire Line
3050 2250 3200 2250
Wire Wire Line
3200 2250 3200 2400
$Comp
L Device:C C3
U 1 1 5B8B090B
P 4450 3500
F 0 "C3" H 4565 3546 50 0000 L CNN
F 1 "10µF" H 4565 3455 50 0000 L CNN
F 2 "Capacitors_Tantalum_SMD:CP_Tantalum_Case-D_EIA-7343-31_Hand" H 4488 3350 50 0001 C CNN
F 3 "" H 4450 3500 50 0001 C CNN
1 4450 3500
1 0 0 -1
$EndComp
$Comp
L Device:C C4
U 1 1 5B8B1267
P 4950 3500
F 0 "C4" H 5065 3546 50 0000 L CNN
F 1 "100nF" H 5065 3455 50 0000 L CNN
F 2 "Capacitors_SMD:C_1206_HandSoldering" H 4988 3350 50 0001 C CNN
F 3 "" H 4950 3500 50 0001 C CNN
1 4950 3500
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR011
U 1 1 5B8B1C8E
P 4000 5850
F 0 "#PWR011" H 4000 5600 50 0001 C CNN
F 1 "GND" H 4005 5677 50 0000 C CNN
F 2 "" H 4000 5850 50 0001 C CNN
F 3 "" H 4000 5850 50 0001 C CNN
1 4000 5850
1 0 0 -1
$EndComp
Wire Wire Line
4000 5750 4000 5850
$Comp
L power:GND #PWR013
U 1 1 5B8B3466
P 6750 5150
F 0 "#PWR013" H 6750 4900 50 0001 C CNN
F 1 "GND" H 6755 4977 50 0000 C CNN
F 2 "" H 6750 5150 50 0001 C CNN
F 3 "" H 6750 5150 50 0001 C CNN
1 6750 5150
1 0 0 -1
$EndComp
Wire Wire Line
6650 4850 6750 4850
Wire Wire Line
6650 5150 6750 5150
$Comp
L power:GND #PWR010
U 1 1 5B8B3A20
P 7050 3250
F 0 "#PWR010" H 7050 3000 50 0001 C CNN
F 1 "GND" H 7055 3077 50 0000 C CNN
F 2 "" H 7050 3250 50 0001 C CNN
F 3 "" H 7050 3250 50 0001 C CNN
1 7050 3250
1 0 0 -1
$EndComp
Wire Wire Line
7050 3250 7200 3250
Wire Wire Line
8850 1950 8700 1950
$Comp
L power:+5V #PWR03
U 1 1 5B8B883E
P 3200 1900
F 0 "#PWR03" H 3200 1750 50 0001 C CNN
F 1 "+5V" H 3215 2073 50 0000 C CNN
F 2 "" H 3200 1900 50 0001 C CNN
F 3 "" H 3200 1900 50 0001 C CNN
1 3200 1900
1 0 0 -1
$EndComp
$Comp
L power:+5V #PWR06
U 1 1 5B8B8A0A
P 4000 3500
F 0 "#PWR06" H 4000 3350 50 0001 C CNN
F 1 "+5V" H 4015 3673 50 0000 C CNN
F 2 "" H 4000 3500 50 0001 C CNN
F 3 "" H 4000 3500 50 0001 C CNN
1 4000 3500
1 0 0 -1
$EndComp
$Comp
L power:+5V #PWR012
U 1 1 5B8B8BF6
P 6750 4850
F 0 "#PWR012" H 6750 4700 50 0001 C CNN
F 1 "+5V" H 6765 5023 50 0000 C CNN
F 2 "" H 6750 4850 50 0001 C CNN
F 3 "" H 6750 4850 50 0001 C CNN
1 6750 4850
1 0 0 -1
$EndComp
$Comp
L power:+5V #PWR07
U 1 1 5B8B8E5A
P 8850 1950
F 0 "#PWR07" H 8850 1800 50 0001 C CNN
F 1 "+5V" H 8865 2123 50 0000 C CNN
F 2 "" H 8850 1950 50 0001 C CNN
F 3 "" H 8850 1950 50 0001 C CNN
1 8850 1950
1 0 0 -1
$EndComp
$Comp
L MCU_Microchip_ATtiny:ATtiny2313A-SU U1
U 1 1 5B8AD3B8
P 4000 4750
F 0 "U1" H 4000 6400 50 0000 C CNN
F 1 "ATTINY2313A-SU" H 4000 6300 50 0000 C CNN
F 2 "Housings_SOIC:SOIC-20W_7.5x12.8mm_Pitch1.27mm" H 4000 4750 50 0001 C CIN
F 3 "" H 4000 4750 50 0001 C CNN
1 4000 4750
1 0 0 -1
$EndComp
$Comp
L Device:C C2
U 1 1 5B8B93C9
P 2350 4000
F 0 "C2" H 2465 4046 50 0000 L CNN
F 1 "33pF" H 2465 3955 50 0000 L CNN
F 2 "Capacitors_SMD:C_1206_HandSoldering" H 2388 3850 50 0001 C CNN
F 3 "" H 2350 4000 50 0001 C CNN
1 2350 4000
0 1 1 0
$EndComp
$Comp
L Device:C C1
U 1 1 5B8B9824
P 2350 4500
F 0 "C1" H 2465 4546 50 0000 L CNN
F 1 "33pF" H 2465 4455 50 0000 L CNN
F 2 "Capacitors_SMD:C_1206_HandSoldering" H 2388 4350 50 0001 C CNN
F 3 "" H 2350 4500 50 0001 C CNN
1 2350 4500
0 1 1 0
$EndComp
$Comp
L Device:Crystal_Small XTAL1
U 1 1 5B8B9A62
P 2600 4250
F 0 "XTAL1" V 2554 4338 50 0000 L CNN
F 1 "8 Mhz" V 2645 4338 50 0000 L CNN
F 2 "Crystals:Crystal_HC49-U_Vertical" H 2600 4250 50 0001 C CNN
F 3 "" H 2600 4250 50 0001 C CNN
1 2600 4250
0 1 1 0
$EndComp
Wire Wire Line
3400 4350 2600 4350
Wire Wire Line
2600 4000 2500 4000
Wire Wire Line
2600 4350 2600 4500
Wire Wire Line
2600 4500 2500 4500
Wire Wire Line
3400 4150 2600 4150
Wire Wire Line
2600 4150 2600 4000
$Comp
L power:GND #PWR09
U 1 1 5B8B9DAC
P 2100 4500
F 0 "#PWR09" H 2100 4250 50 0001 C CNN
F 1 "GND" H 2105 4327 50 0000 C CNN
F 2 "" H 2100 4500 50 0001 C CNN
F 3 "" H 2100 4500 50 0001 C CNN
1 2100 4500
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR08
U 1 1 5B8B9E4D
P 2100 4000
F 0 "#PWR08" H 2100 3750 50 0001 C CNN
F 1 "GND" H 2105 3827 50 0000 C CNN
F 2 "" H 2100 4000 50 0001 C CNN
F 3 "" H 2100 4000 50 0001 C CNN
1 2100 4000
1 0 0 -1
$EndComp
Wire Wire Line
2200 4000 2100 4000
Wire Wire Line
2200 4500 2100 4500
Wire Wire Line
6650 5050 7250 5050
Wire Wire Line
7250 5000 7250 5050
Wire Wire Line
6650 4950 7050 4950
Wire Wire Line
7250 4950 7250 4850
Wire Wire Line
7150 4850 7150 5000
Wire Wire Line
7150 5000 7250 5000
Connection ~ 7250 5050
Wire Wire Line
7150 5150 7050 5150
Wire Wire Line
7050 5150 7050 4950
Connection ~ 7050 4950
Wire Wire Line
5450 4950 5300 4950
Wire Wire Line
5300 4950 5300 5050
Wire Wire Line
5300 5050 5450 5050
$Comp
L Device:R R1
U 1 1 5B8C2380
P 4900 4150
F 0 "R1" H 4970 4196 50 0000 L CNN
F 1 "10K" H 4970 4105 50 0000 L CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 4830 4150 50 0001 C CNN
F 3 "" H 4900 4150 50 0001 C CNN
1 4900 4150
1 0 0 -1
$EndComp
$Comp
L power:+5V #PWR014
U 1 1 5B8C2462
P 4900 3950
F 0 "#PWR014" H 4900 3800 50 0001 C CNN
F 1 "+5V" H 4915 4123 50 0000 C CNN
F 2 "" H 4900 3950 50 0001 C CNN
F 3 "" H 4900 3950 50 0001 C CNN
1 4900 3950
1 0 0 -1
$EndComp
Wire Wire Line
4900 3950 4900 4000
Wire Wire Line
4600 4450 4900 4450
Wire Wire Line
4900 4450 4900 4300
$Comp
L Connector_Generic:Conn_01x04 P7
U 1 1 5B8C32B0
P 9800 2150
F 0 "P7" H 9877 2191 50 0000 L CNN
F 1 "SSD1306" H 9877 2100 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9800 2150 50 0001 C CNN
F 3 "" H 9800 2150 50 0001 C CNN
1 9800 2150
1 0 0 -1
$EndComp
Text Notes 10350 2400 0 60 ~ 0
1 = SDA\n2 = SCL\n3 = VCC\n4 = GND
$Comp
L power:+5V #PWR016
U 1 1 5B8C452D
P 9350 2250
F 0 "#PWR016" H 9350 2100 50 0001 C CNN
F 1 "+5V" H 9365 2423 50 0000 C CNN
F 2 "" H 9350 2250 50 0001 C CNN
F 3 "" H 9350 2250 50 0001 C CNN
1 9350 2250
-1 0 0 1
$EndComp
$Comp
L power:GND #PWR018
U 1 1 5B8C457C
P 9500 2350
F 0 "#PWR018" H 9500 2100 50 0001 C CNN
F 1 "GND" H 9505 2177 50 0000 C CNN
F 2 "" H 9500 2350 50 0001 C CNN
F 3 "" H 9500 2350 50 0001 C CNN
1 9500 2350
1 0 0 -1
$EndComp
Wire Wire Line
9600 2350 9500 2350
Wire Wire Line
9600 2250 9350 2250
Wire Wire Line
8700 2050 8950 2050
Wire Wire Line
8700 2150 9150 2150
Connection ~ 9150 2150
Connection ~ 8950 2050
Connection ~ 4900 4450
Wire Wire Line
5150 5150 5450 5150
$Comp
L Transistor_FET:IRLB8721PBF Q1
U 1 1 5B8C8EA8
P 6050 2250
F 0 "Q1" V 6378 2250 50 0000 C CNN
F 1 "IRLB8721PBF" V 6287 2250 50 0000 C CNN
F 2 "TO_SOT_Packages_THT:TO-220-3_Horizontal" H 6300 2175 50 0001 L CIN
F 3 "" H 6050 2250 50 0001 L CNN
1 6050 2250
0 -1 -1 0
$EndComp
Wire Wire Line
5450 4850 4600 4850
Wire Wire Line
4600 4950 5150 4950
Wire Wire Line
5150 4950 5150 5150
Wire Wire Line
4600 4650 4700 4650
Wire Wire Line
5450 4650 5450 3950
Wire Wire Line
5450 3950 9150 3950
Wire Wire Line
9150 3950 9150 2150
Wire Wire Line
8950 2050 8950 3750
Wire Wire Line
8950 3750 5250 3750
Wire Wire Line
5250 3750 5250 4450
$Comp
L Device:R R2
U 1 1 5B8CAD1E
P 6700 2450
F 0 "R2" V 6493 2450 50 0000 C CNN
F 1 "150" V 6584 2450 50 0000 C CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 6630 2450 50 0001 C CNN
F 3 "" H 6700 2450 50 0001 C CNN
1 6700 2450
0 1 1 0
$EndComp
$Comp
L Device:R R3
U 1 1 5B8CAE68
P 6700 2550
F 0 "R3" V 6900 2550 50 0000 C CNN
F 1 "150" V 6800 2550 50 0000 C CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 6630 2550 50 0001 C CNN
F 3 "" H 6700 2550 50 0001 C CNN
1 6700 2550
0 1 1 0
$EndComp
$Comp
L Transistor_FET:IRLB8721PBF Q2
U 1 1 5B8CB00E
P 6050 2750
F 0 "Q2" V 6286 2750 50 0000 C CNN
F 1 "IRLB8721PBF" V 6377 2750 50 0000 C CNN
F 2 "TO_SOT_Packages_THT:TO-220-3_Horizontal" H 6300 2675 50 0001 L CIN
F 3 "" H 6050 2750 50 0001 L CNN
1 6050 2750
0 -1 1 0
$EndComp
$Comp
L power:GND #PWR015
U 1 1 5B8CB569
P 6300 2150
F 0 "#PWR015" H 6300 1900 50 0001 C CNN
F 1 "GND" H 6305 1977 50 0000 C CNN
F 2 "" H 6300 2150 50 0001 C CNN
F 3 "" H 6300 2150 50 0001 C CNN
1 6300 2150
0 -1 -1 0
$EndComp
$Comp
L power:GND #PWR020
U 1 1 5B8CB5C8
P 6300 2850
F 0 "#PWR020" H 6300 2600 50 0001 C CNN
F 1 "GND" H 6305 2677 50 0000 C CNN
F 2 "" H 6300 2850 50 0001 C CNN
F 3 "" H 6300 2850 50 0001 C CNN
1 6300 2850
0 -1 -1 0
$EndComp
$Comp
L Connector_Generic:Conn_01x04 P4
U 1 1 5B8CBF27
P 5050 2550
F 0 "P4" H 5128 2591 50 0000 L CNN
F 1 "LED" H 5128 2500 50 0000 L CNN
F 2 "Terminal_Blocks:TerminalBlock_bornier-4_P5.08mm" H 5050 2550 50 0001 C CNN
F 3 "" H 5050 2550 50 0001 C CNN
1 5050 2550
-1 0 0 1
$EndComp
Text Notes 4000 2700 0 60 ~ 0
1 = LED1 +12V\n2 = LED1 GND\n3 = LED2 +12V\n4 = LED2 GND
Wire Wire Line
6250 2150 6300 2150
Wire Wire Line
6250 2850 6300 2850
$Comp
L power:+12V #PWR017
U 1 1 5B8CDFC1
P 5400 2350
F 0 "#PWR017" H 5400 2200 50 0001 C CNN
F 1 "+12V" H 5415 2523 50 0000 C CNN
F 2 "" H 5400 2350 50 0001 C CNN
F 3 "" H 5400 2350 50 0001 C CNN
1 5400 2350
0 1 1 0
$EndComp
$Comp
L power:+12V #PWR019
U 1 1 5B8CE24A
P 5400 2550
F 0 "#PWR019" H 5400 2400 50 0001 C CNN
F 1 "+12V" H 5415 2723 50 0000 C CNN
F 2 "" H 5400 2550 50 0001 C CNN
F 3 "" H 5400 2550 50 0001 C CNN
1 5400 2550
0 1 1 0
$EndComp
Wire Wire Line
5250 2350 5400 2350
Wire Wire Line
5250 2550 5400 2550
Wire Wire Line
5250 2450 5750 2450
Wire Wire Line
5750 2450 5750 2150
Wire Wire Line
5750 2150 5850 2150
Wire Wire Line
5250 2650 5750 2650
Wire Wire Line
5750 2650 5750 2850
Wire Wire Line
5750 2850 5850 2850
Wire Wire Line
6550 2550 6050 2550
Wire Wire Line
6850 2450 7200 2450
Wire Wire Line
7200 2550 6850 2550
Wire Wire Line
4000 3650 4450 3650
Connection ~ 4450 3650
Wire Wire Line
4000 3650 4000 3500
$Comp
L power:GND #PWR022
U 1 1 5B8D17BD
P 4700 3250
F 0 "#PWR022" H 4700 3000 50 0001 C CNN
F 1 "GND" H 4705 3077 50 0000 C CNN
F 2 "" H 4700 3250 50 0001 C CNN
F 3 "" H 4700 3250 50 0001 C CNN
1 4700 3250
-1 0 0 1
$EndComp
Wire Wire Line
4450 3350 4450 3250
Wire Wire Line
4450 3250 4700 3250
Wire Wire Line
4950 3250 4950 3350
Connection ~ 4700 3250
NoConn ~ 7200 2650
NoConn ~ 7200 2750
NoConn ~ 7200 2850
NoConn ~ 7200 2950
NoConn ~ 7200 3050
NoConn ~ 7200 3150
NoConn ~ 8700 2550
NoConn ~ 8700 2650
NoConn ~ 8700 2750
NoConn ~ 8700 2850
NoConn ~ 8700 2950
NoConn ~ 8700 3050
NoConn ~ 8700 3150
NoConn ~ 8700 3250
NoConn ~ 8700 2250
Wire Wire Line
7050 4950 7250 4950
Wire Wire Line
9150 2150 9600 2150
Wire Wire Line
8950 2050 9600 2050
Wire Wire Line
4900 4450 5250 4450
Wire Wire Line
4450 3650 4950 3650
Wire Wire Line
4700 3250 4950 3250
Wire Wire Line
7200 2350 7100 2350
Wire Wire Line
7100 2350 7100 2250
Wire Wire Line
7200 1950 7100 1950
Connection ~ 7100 1950
Wire Wire Line
7100 1950 7100 1850
Wire Wire Line
7200 2050 7100 2050
Connection ~ 7100 2050
Wire Wire Line
7100 2050 7100 1950
Wire Wire Line
7200 2150 7100 2150
Connection ~ 7100 2150
Wire Wire Line
7100 2150 7100 2050
Wire Wire Line
7200 2250 7100 2250
Connection ~ 7100 2250
Wire Wire Line
7100 2250 7100 2150
$Comp
L Device:R R4
U 1 1 5B8C6BF9
P 7100 1700
F 0 "R4" V 6893 1700 50 0000 C CNN
F 1 "10K" V 6984 1700 50 0000 C CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 7030 1700 50 0001 C CNN
F 3 "" H 7100 1700 50 0001 C CNN
1 7100 1700
-1 0 0 1
$EndComp
$Comp
L power:GND #PWR021
U 1 1 5B8C6F7E
P 7100 1500
F 0 "#PWR021" H 7100 1250 50 0001 C CNN
F 1 "GND" H 7105 1327 50 0000 C CNN
F 2 "" H 7100 1500 50 0001 C CNN
F 3 "" H 7100 1500 50 0001 C CNN
1 7100 1500
-1 0 0 1
$EndComp
Wire Wire Line
7100 1500 7100 1550
Wire Wire Line
7000 1950 7100 1950
Text Label 7000 1950 2 50 ~ 0
PD
Wire Wire Line
8800 2350 8750 2350
Text Label 8800 2350 0 50 ~ 0
PD
Wire Wire Line
8700 2450 8750 2450
Wire Wire Line
8750 2450 8750 2350
Connection ~ 8750 2350
Wire Wire Line
8750 2350 8700 2350
Text Notes 5150 6750 0 60 ~ 0
1 = +12V\n2 = GND
Wire Wire Line
4450 6700 4000 6700
$Comp
L power:GND #PWR024
U 1 1 5B8E6FA0
P 4000 6850
F 0 "#PWR024" H 4000 6600 50 0001 C CNN
F 1 "GND" H 4005 6677 50 0000 C CNN
F 2 "" H 4000 6850 50 0001 C CNN
F 3 "" H 4000 6850 50 0001 C CNN
1 4000 6850
1 0 0 -1
$EndComp
$Comp
L power:+12V #PWR023
U 1 1 5B8E7817
P 4000 6500
F 0 "#PWR023" H 4000 6350 50 0001 C CNN
F 1 "+12V" H 4015 6673 50 0000 C CNN
F 2 "" H 4000 6500 50 0001 C CNN
F 3 "" H 4000 6500 50 0001 C CNN
1 4000 6500
1 0 0 -1
$EndComp
Wire Wire Line
4000 6500 4000 6600
Connection ~ 4000 6600
Wire Wire Line
4000 6600 4450 6600
Wire Wire Line
4000 6850 4000 6700
Connection ~ 4000 6700
$Comp
L power:+12V #PWR0101
U 1 1 5B8ED6A9
P 1200 1900
F 0 "#PWR0101" H 1200 1750 50 0001 C CNN
F 1 "+12V" H 1215 2073 50 0000 C CNN
F 2 "" H 1200 1900 50 0001 C CNN
F 3 "" H 1200 1900 50 0001 C CNN
1 1200 1900
1 0 0 -1
$EndComp
$Comp
L power:PWR_FLAG #FLG0101
U 1 1 5B8ED6E0
P 1200 1900
F 0 "#FLG0101" H 1200 1975 50 0001 C CNN
F 1 "PWR_FLAG" H 1200 2073 50 0000 C CNN
F 2 "" H 1200 1900 50 0001 C CNN
F 3 "" H 1200 1900 50 0001 C CNN
1 1200 1900
-1 0 0 1
$EndComp
NoConn ~ 4600 4050
NoConn ~ 4600 4150
NoConn ~ 4600 4250
NoConn ~ 4600 4350
NoConn ~ 4600 5250
NoConn ~ 4600 5350
$Comp
L Device:R R5
U 1 1 5B925FBE
P 3250 3800
F 0 "R5" V 3043 3800 50 0000 C CNN
F 1 "10K" V 3134 3800 50 0000 C CNN
F 2 "Resistors_SMD:R_0603_HandSoldering" V 3180 3800 50 0001 C CNN
F 3 "" H 3250 3800 50 0001 C CNN
1 3250 3800
-1 0 0 1
$EndComp
$Comp
L power:+5V #PWR0102
U 1 1 5B92641E
P 3250 3550
F 0 "#PWR0102" H 3250 3400 50 0001 C CNN
F 1 "+5V" H 3265 3723 50 0000 C CNN
F 2 "" H 3250 3550 50 0001 C CNN
F 3 "" H 3250 3550 50 0001 C CNN
1 3250 3550
1 0 0 -1
$EndComp
Wire Wire Line
3250 3550 3250 3650
Wire Wire Line
3250 3950 3400 3950
$Comp
L power:GND #PWR0103
U 1 1 5B92CB1E
P 1200 2500
F 0 "#PWR0103" H 1200 2250 50 0001 C CNN
F 1 "GND" H 1205 2327 50 0000 C CNN
F 2 "" H 1200 2500 50 0001 C CNN
F 3 "" H 1200 2500 50 0001 C CNN
1 1200 2500
1 0 0 -1
$EndComp
$Comp
L power:PWR_FLAG #FLG0102
U 1 1 5B92CB57
P 1200 2500
F 0 "#FLG0102" H 1200 2575 50 0001 C CNN
F 1 "PWR_FLAG" H 1200 2673 50 0000 C CNN
F 2 "" H 1200 2500 50 0001 C CNN
F 3 "" H 1200 2500 50 0001 C CNN
1 1200 2500
1 0 0 -1
$EndComp
Connection ~ 2600 4150
Connection ~ 2600 4350
Connection ~ 4000 3650
Text Notes 6100 6300 0 60 ~ 0
1 = Sensor 1 +5V\n2 = Sensor 1 GND\n3 = Sensor 1 DATA\n4 = Sensor 2 +5V\n5 = Sensor 2 GND\n6 = Sensor 2 DATA\n
$Comp
L power:+5V #PWR0104
U 1 1 5B93F20D
P 5350 5750
F 0 "#PWR0104" H 5350 5600 50 0001 C CNN
F 1 "+5V" H 5350 6050 50 0000 C CNN
F 2 "" H 5350 5750 50 0001 C CNN
F 3 "" H 5350 5750 50 0001 C CNN
1 5350 5750
0 -1 -1 0
$EndComp
$Comp
L power:+5V #PWR0105
U 1 1 5B93F49C
P 5350 6050
F 0 "#PWR0105" H 5350 5900 50 0001 C CNN
F 1 "+5V" H 5350 6350 50 0000 C CNN
F 2 "" H 5350 6050 50 0001 C CNN
F 3 "" H 5350 6050 50 0001 C CNN
1 5350 6050
0 -1 -1 0
$EndComp
$Comp
L power:GND #PWR0106
U 1 1 5B93F503
P 5350 5850
F 0 "#PWR0106" H 5350 5600 50 0001 C CNN
F 1 "GND" H 5355 5677 50 0000 C CNN
F 2 "" H 5350 5850 50 0001 C CNN
F 3 "" H 5350 5850 50 0001 C CNN
1 5350 5850
0 1 1 0
$EndComp
$Comp
L power:GND #PWR0107
U 1 1 5B93F5DD
P 5350 6150
F 0 "#PWR0107" H 5350 5900 50 0001 C CNN
F 1 "GND" H 5355 5977 50 0000 C CNN
F 2 "" H 5350 6150 50 0001 C CNN
F 3 "" H 5350 6150 50 0001 C CNN
1 5350 6150
0 1 1 0
$EndComp
Wire Wire Line
5350 5750 5500 5750
Wire Wire Line
5350 5850 5500 5850
Wire Wire Line
5350 6050 5500 6050
Wire Wire Line
5350 6150 5500 6150
Wire Wire Line
4600 5050 4850 5050
Wire Wire Line
4850 5050 4850 5950
Wire Wire Line
4850 5950 5500 5950
Wire Wire Line
4600 5150 4750 5150
Wire Wire Line
4750 5150 4750 6250
Wire Wire Line
4750 6250 5500 6250
Text Notes 7450 5050 0 60 ~ 0
1 = RS485 A\n2 = RS485 B
Connection ~ 4000 5850
Wire Wire Line
7250 5050 7250 5150
Wire Wire Line
3600 6600 4000 6600
Wire Wire Line
3600 6700 4000 6700
Wire Wire Line
6050 2450 6550 2450
$Comp
L Connector_Generic:Conn_02x03_Counter_Clockwise J1
U 1 1 5BEBD38C
P 9850 5900
F 0 "J1" H 9900 6217 50 0000 C CNN
F 1 "PROG" H 9900 6126 50 0000 C CNN
F 2 "Pin_Headers:Pin_Header_Straight_2x03_Pitch2.54mm" H 9850 5900 50 0001 C CNN
F 3 "~" H 9850 5900 50 0001 C CNN
1 9850 5900
1 0 0 -1
$EndComp
Text GLabel 9650 5800 0 50 Input ~ 0
MISO
Text GLabel 9650 5900 0 50 Input ~ 0
SCK
Text GLabel 9650 6000 0 50 Input ~ 0
RST
Text GLabel 10150 5900 2 50 Input ~ 0
MOSI
$Comp
L power:+5V #PWR0108
U 1 1 5BEBE75C
P 10250 5800
F 0 "#PWR0108" H 10250 5650 50 0001 C CNN
F 1 "+5V" H 10265 5973 50 0000 C CNN
F 2 "" H 10250 5800 50 0001 C CNN
F 3 "" H 10250 5800 50 0001 C CNN
1 10250 5800
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR0109
U 1 1 5BEBE86F
P 10250 6000
F 0 "#PWR0109" H 10250 5750 50 0001 C CNN
F 1 "GND" H 10255 5827 50 0000 C CNN
F 2 "" H 10250 6000 50 0001 C CNN
F 3 "" H 10250 6000 50 0001 C CNN
1 10250 6000
1 0 0 -1
$EndComp
Wire Wire Line
10150 5800 10250 5800
Wire Wire Line
10150 6000 10250 6000
Text GLabel 3100 3950 0 50 Input ~ 0
RST
Wire Wire Line
3100 3950 3250 3950
Connection ~ 3250 3950
Text GLabel 4600 4550 2 50 Input ~ 0
MISO
Text GLabel 4850 4750 2 50 Input ~ 0
SCK
Text GLabel 5050 4550 2 50 Input ~ 0
MOSI
Wire Wire Line
4700 4650 4700 4750
Wire Wire Line
4700 4750 4850 4750
Connection ~ 4700 4650
Wire Wire Line
4700 4650 5450 4650
Wire Wire Line
4900 4450 4900 4550
Wire Wire Line
4900 4550 5050 4550
Wire Wire Line
5300 5050 5300 5450
Wire Wire Line
5300 5450 4600 5450
Connection ~ 5300 5050
$Comp
L Switch:SW_Push SW1
U 1 1 5BF329CF
P 5700 3500
F 0 "SW1" H 5700 3785 50 0000 C CNN
F 1 "Button" H 5700 3694 50 0000 C CNN
F 2 "SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_:SW4-SMD-5.2X5.2X1.5MM" H 5700 3700 50 0001 C CNN
F 3 "" H 5700 3700 50 0001 C CNN
1 5700 3500
1 0 0 -1
$EndComp
Wire Wire Line
4600 3950 4800 3950
Wire Wire Line
4800 3950 4800 3700
Wire Wire Line
4800 3700 5500 3700
Wire Wire Line
5500 3700 5500 3500
$Comp
L power:GND #PWR01
U 1 1 5BF4430D
P 5900 3500
F 0 "#PWR01" H 5900 3250 50 0001 C CNN
F 1 "GND" H 5905 3327 50 0000 C CNN
F 2 "" H 5900 3500 50 0001 C CNN
F 3 "" H 5900 3500 50 0001 C CNN
1 5900 3500
1 0 0 -1
$EndComp
$EndSCHEMATC

5
kicad/fp-lib-table Normal file
View File

@ -0,0 +1,5 @@
(fp_lib_table
(lib (name AMS1117-5.0)(type Legacy)(uri ${KIPRJMOD}/libs/AMS1117-5.0.mod)(options "")(descr ""))
(lib (name MAX485)(type Legacy)(uri ${KIPRJMOD}/libs/MAX485.mod)(options "")(descr ""))
(lib (name SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_)(type Legacy)(uri ${KIPRJMOD}/libs/SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_.mod)(options "")(descr ""))
)

View File

@ -0,0 +1,29 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#(c) SnapEDA 2016 (snapeda.com)
#This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA) with Design Exception 1.0
#
# AMS1117-5.0
#
DEF AMS1117-5.0 U 0 40 Y Y 1 L N
F0 "U" -400 220 50 H V L BNN
F1 "AMS1117-5.0" -401 -321 50 H V L BNN
F2 "SOT229P700X180-4N" 0 0 50 H I L BNN
F3 "Sot223/Pkg 1-Amp 5-Volt Low Drop Out Voltage Regulatator" 0 0 50 H I L BNN
F4 "Unavailable" 0 0 50 H I L BNN
F5 "Advanced Monolithic Systems" 0 0 50 H I L BNN
F6 "None" 0 0 50 H I L BNN
F7 "None" 0 0 50 H I L BNN
F8 "AMS1117-5.0" 0 0 50 H I L BNN
DRAW
P 2 0 0 10 -400 200 400 200 N
P 2 0 0 10 400 200 400 -200 N
P 2 0 0 10 400 -200 -400 -200 N
P 2 0 0 10 -400 -200 -400 200 N
X VIN 3 -600 100 200 R 40 40 0 0 I
X VOUT 2 600 100 200 L 40 40 0 0 O
X ADJ/GND 1 600 -100 200 L 40 40 0 0 W
ENDDRAW
ENDDEF
#
# End Library

View File

@ -0,0 +1,3 @@
EESchema-DOCLIB Version 2.0
#
#End Doc Library

View File

@ -0,0 +1,24 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# AMS1117-5.0
#
DEF AMS1117-5.0 U 0 40 Y Y 1 L N
F0 "U" -400 220 50 H V L BNN
F1 "AMS1117-5.0" -401 -321 50 H V L BNN
F2 "SOT229P700X180-4N" 0 0 50 H I L BNN
F3 "Sot223/Pkg 1-Amp 5-Volt Low Drop Out Voltage Regulatator" 0 0 50 H I L BNN
F4 "Unavailable" 0 0 50 H I L BNN
F5 "Advanced Monolithic Systems" 0 0 50 H I L BNN
F6 "None" 0 0 50 H I L BNN
F7 "None" 0 0 50 H I L BNN
F8 "AMS1117-5.0" 0 0 50 H I L BNN
DRAW
S -400 200 400 -200 0 1 0 f
X ADJ/GND 1 600 -100 200 L 40 40 0 0 W
X VOUT 2 600 100 200 L 40 40 0 0 O
X VIN 3 -600 100 200 R 40 40 0 0 I
ENDDRAW
ENDDEF
#
#End Library

View File

@ -0,0 +1,73 @@
PCBNEW-LibModule-V1
# encoding utf-8
Units mm
$INDEX
SOT229P700X180-4N
$EndINDEX
$MODULE SOT229P700X180-4N
Po 0 0 0 15 00000000 00000000 ~~
Li SOT229P700X180-4N
Cd
Sc 00000000
At SMD
Op 0 0 0
.SolderMask 0
.SolderPaste 0
T0 -1.15242 -5.14581 1.00211 1.00211 0 0.05 N V 21 "SOT229P700X180-4N"
T1 -0.516467 5.54073 1.00285 1.00285 0 0.05 N V 21 "VAL**"
DS -3.36 1.86 -3.36 -1.86 0.127 24
DS -3.36 -1.86 3.36 -1.86 0.127 24
DS 3.36 -1.86 3.36 1.86 0.127 24
DS 3.36 1.86 -3.36 1.86 0.127 24
DS -3.36 1.86 -3.36 -1.86 0.127 21
DS 3.36 1.86 3.36 -1.86 0.127 21
DS -3.36 1.86 -3.1 1.86 0.127 21
DS 3.11 1.86 3.36 1.86 0.127 21
DS 3.36 -1.86 1.87 -1.86 0.127 21
DS -1.76 -1.86 -3.36 -1.86 0.127 21
DC -2.29 4.373 -2.19 4.373 0.2 21
DS -3.61 -2.11 -3.61 2.11 0.05 26
DS -3.61 2.11 -3.01 2.11 0.05 26
DS -3.01 2.11 -3.01 4.25 0.05 26
DS -3.01 4.25 3.01 4.25 0.05 26
DS 3.01 4.25 3.01 2.11 0.05 26
DS 3.01 2.11 3.61 2.11 0.05 26
DS 3.61 2.11 3.61 -2.11 0.05 26
DS 3.61 -2.11 1.87 -2.11 0.05 26
DS 1.87 -2.11 1.87 -4.25 0.05 26
DS 1.87 -4.25 -1.87 -4.25 0.05 26
DS -1.87 -4.25 -1.87 -2.11 0.05 26
DS -1.87 -2.11 -3.61 -2.11 0.05 26
$PAD
Sh "1" R 0.93 1.31 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -2.29 3.345
$EndPAD
$PAD
Sh "2" R 0.93 1.31 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 0 3.345
$EndPAD
$PAD
Sh "3" R 0.93 1.31 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 2.29 3.345
$EndPAD
$PAD
Sh "4" R 3.24 1.31 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 0 -3.345
$EndPAD
$EndMODULE SOT229P700X180-4N

3
kicad/libs/MAX485.bck Normal file
View File

@ -0,0 +1,3 @@
EESchema-DOCLIB Version 2.0
#
#End Doc Library

3
kicad/libs/MAX485.dcm Normal file
View File

@ -0,0 +1,3 @@
EESchema-DOCLIB Version 2.0
#
#End Doc Library

32
kicad/libs/MAX485.lib Normal file
View File

@ -0,0 +1,32 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# MAX485
#
DEF MAX485 U 0 40 Y Y 1 L N
F0 "U" -401 301 50 H V L BNN
F1 "MAX485" -401 -301 50 H V L BNN
F2 "" 0 0 50 H I C CNN
F3 "Maxim Integrated" 0 0 50 H I L BNN
F4 "None" 0 0 50 H I L BNN
F5 "Unavailable" 0 0 50 H I L BNN
F6 "None" 0 0 50 H I L BNN
F7 "MAX485" 0 0 50 H I L BNN
$FPLIST
DIL08
SO08
$ENDFPLIST
DRAW
S -400 300 400 -200 0 1 0 f
X RO 1 -600 200 200 R 40 40 0 0 B
X RE 2 -600 100 200 R 40 40 0 0 B I
X DE 3 -600 0 200 R 40 40 0 0 B
X DI 4 -600 -100 200 R 40 40 0 0 B
X GND 5 600 -100 200 L 40 40 0 0 W
X A 6 600 0 200 L 40 40 0 0 B
X B 7 600 100 200 L 40 40 0 0 B
X VCC 8 600 200 200 L 40 40 0 0 W
ENDDRAW
ENDDEF
#
#End Library

214
kicad/libs/MAX485.mod Normal file
View File

@ -0,0 +1,214 @@
PCBNEW-LibModule-V1
# encoding utf-8
Units mm
$INDEX
DIL08
SO08
$EndINDEX
$MODULE DIL08
Po 0 0 0 15 00000000 00000000 ~~
Li DIL08
Cd <b>Dual In Line</b>
Sc 00000000
At STD
Op 0 0 0
.SolderMask 0
.SolderPaste 0
T0 -6.35758 1.27152 1.00119 1.00119 900 0.05 N V 21 "DIL08"
T1 5.00698e-06 -2.00279e-06 1.00244 1.00244 0 0.05 N V 21 "VAL**"
DS 5.08 -5.08 -5.08 -5.08 0.1524 21
DS -5.08 5.08 5.08 5.08 0.1524 21
DS 5.08 -5.08 5.08 -2.54 0.1524 21
DS -5.08 -5.08 -5.08 -2.54 0.1524 21
DS -5.08 5.08 -5.08 2.54 0.1524 21
DA -5.08 0 -5.08 -1.016 1800 0.1524 21
DS -5.08 -2.54 5.08 -2.54 0.1524 21
DS -5.08 -2.54 -5.08 -1.016 0.2032 21
DS 5.08 -2.54 5.08 2.54 0.1524 21
DS -5.08 2.54 5.08 2.54 0.1524 21
DS -5.08 2.54 -5.08 1.016 0.1524 21
DS 5.08 2.54 5.08 5.08 0.1524 21
$PAD
Sh "1" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po -3.81 3.81
$EndPAD
$PAD
Sh "2" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po -1.27 3.81
$EndPAD
$PAD
Sh "3" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po 1.27 3.81
$EndPAD
$PAD
Sh "4" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po 3.81 3.81
$EndPAD
$PAD
Sh "5" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po 3.81 -3.81
$EndPAD
$PAD
Sh "6" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po 1.27 -3.81
$EndPAD
$PAD
Sh "7" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po -1.27 -3.81
$EndPAD
$PAD
Sh "8" C 1.6002 1.6002 0 0 0
Dr 0.8128 0 0
At STD N 00C0FFFF
.SolderMask 0
Ne 0 ""
Po -3.81 -3.81
$EndPAD
$EndMODULE DIL08
$MODULE SO08
Po 0 0 0 15 00000000 00000000 ~~
Li SO08
Cd <b>Small Outline Package</b> Fits JEDEC packages (narrow SOIC-8)
Sc 00000000
At SMD
Op 0 0 0
.SolderMask 0
.SolderPaste 0
T0 -0.45744 -0.203305 0.320166 0.320166 0 0.05 N V 21 "SO08"
T1 -0.254561 0.432759 0.32071 0.32071 0 0.05 N V 21 "VAL**"
DS -2.362 1.803 2.362 1.803 0.1524 24
DS 2.362 -1.803 -2.362 -1.803 0.1524 24
DC -1.8034 0.9906 -1.6598 0.9906 0.2032 21
DP 0 0 0 0 4 0 24
Dl -2.08797 1.8542
Dl -1.7272 1.8542
Dl -1.7272 2.87731
Dl -2.08797 2.87731
DP 0 0 0 0 4 0 24
Dl -0.813844 1.8542
Dl -0.4572 1.8542
Dl -0.4572 2.87389
Dl -0.813844 2.87389
DP 0 0 0 0 4 0 24
Dl 0.458097 1.8542
Dl 0.8128 1.8542
Dl 0.8128 2.87584
Dl 0.458097 2.87584
DP 0 0 0 0 4 0 24
Dl 1.72892 1.8542
Dl 2.0828 1.8542
Dl 2.0828 2.87306
Dl 1.72892 2.87306
DP 0 0 0 0 4 0 24
Dl -2.08675 -2.8702
Dl -1.7272 -2.8702
Dl -1.7272 -1.85772
Dl -2.08675 -1.85772
DP 0 0 0 0 4 0 24
Dl -0.813701 -2.8702
Dl -0.4572 -2.8702
Dl -0.4572 -1.85626
Dl -0.813701 -1.85626
DP 0 0 0 0 4 0 24
Dl 0.458322 -2.8702
Dl 0.8128 -2.8702
Dl 0.8128 -1.85875
Dl 0.458322 -1.85875
DP 0 0 0 0 4 0 24
Dl 1.73057 -2.8702
Dl 2.0828 -2.8702
Dl 2.0828 -1.85782
Dl 1.73057 -1.85782
$PAD
Sh "1" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -1.905 2.6162
$EndPAD
$PAD
Sh "2" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -0.635 2.6162
$EndPAD
$PAD
Sh "3" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 0.635 2.6162
$EndPAD
$PAD
Sh "4" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 1.905 2.6162
$EndPAD
$PAD
Sh "5" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 1.905 -2.6162
$EndPAD
$PAD
Sh "6" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 0.635 -2.6162
$EndPAD
$PAD
Sh "7" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -0.635 -2.6162
$EndPAD
$PAD
Sh "8" R 0.6096 2.2098 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -1.905 -2.6162
$EndPAD
$EndMODULE SO08

View File

@ -0,0 +1,43 @@
EESchema-LIBRARY Version 2.2 Date: 04/05/2014-04:12:59
#
# PCA9685-TSSOP
#
DEF PCA9685-TSSOP U 0 40 Y Y 1 0 N
F0 "U" 0 -100 50 H V C C
F1 "PCA9685-TSSOP" 0 100 50 H V C C
F2 "MODULE" 0 0 50 H I C C
F3 "DOCUMENTATION" 0 0 50 H I C C
DRAW
S -450 -850 450 850 1 0 0 N
X A0 1 -750 650 300 R 50 50 1 1 I
X A1 2 -750 550 300 R 50 50 1 1 I
X A2 3 -750 450 300 R 50 50 1 1 I
X A3 4 -750 350 300 R 50 50 1 1 I
X A4 5 -750 250 300 R 50 50 1 1 I
X LED0 6 -750 150 300 R 50 50 1 1 O
X LED1 7 -750 50 300 R 50 50 1 1 O
X LED2 8 -750 -50 300 R 50 50 1 1 O
X LED3 9 -750 -150 300 R 50 50 1 1 O
X LED4 10 -750 -250 300 R 50 50 1 1 O
X LED5 11 -750 -350 300 R 50 50 1 1 O
X LED6 12 -750 -450 300 R 50 50 1 1 O
X LED7 13 -750 -550 300 R 50 50 1 1 O
X GND 14 -750 -650 300 R 50 50 1 1 I
X LED8 15 750 -650 300 L 50 50 1 1 O
X LED9 16 750 -550 300 L 50 50 1 1 O
X LED10 17 750 -450 300 L 50 50 1 1 O
X LED11 18 750 -350 300 L 50 50 1 1 O
X LED12 19 750 -250 300 L 50 50 1 1 O
X LED13 20 750 -150 300 L 50 50 1 1 O
X LED14 21 750 -50 300 L 50 50 1 1 O
X LED15 22 750 50 300 L 50 50 1 1 O
X OE 23 750 150 300 L 50 50 1 1 I
X A5 24 750 250 300 L 50 50 1 1 I
X EXTCLK 25 750 350 300 L 50 50 1 1 I
X SCL 26 750 450 300 L 50 50 1 1 I
X SDA 27 750 550 300 L 50 50 1 1 B
X VCC 28 750 650 300 L 50 50 1 1 I
ENDDRAW
ENDDEF
#
#End Library

View File

@ -0,0 +1,3 @@
EESchema-DOCLIB Version 2.0
#
#End Doc Library

View File

@ -0,0 +1,44 @@
EESchema-LIBRARY Version 2.4
#encoding utf-8
#
# PCA9685-TSSOP
#
DEF PCA9685-TSSOP U 0 40 Y Y 1 F N
F0 "U" 0 -100 50 H V C CNN
F1 "PCA9685-TSSOP" 0 100 50 H V C CNN
F2 "MODULE" 0 0 50 H I C CNN
F3 "DOCUMENTATION" 0 0 50 H I C CNN
DRAW
S -450 -850 450 850 1 0 0 f
X A0 1 -750 650 300 R 50 50 1 1 I
X LED4 10 -750 -250 300 R 50 50 1 1 O
X LED5 11 -750 -350 300 R 50 50 1 1 O
X LED6 12 -750 -450 300 R 50 50 1 1 O
X LED7 13 -750 -550 300 R 50 50 1 1 O
X GND 14 -750 -650 300 R 50 50 1 1 I
X LED8 15 750 -650 300 L 50 50 1 1 O
X LED9 16 750 -550 300 L 50 50 1 1 O
X LED10 17 750 -450 300 L 50 50 1 1 O
X LED11 18 750 -350 300 L 50 50 1 1 O
X LED12 19 750 -250 300 L 50 50 1 1 O
X A1 2 -750 550 300 R 50 50 1 1 I
X LED13 20 750 -150 300 L 50 50 1 1 O
X LED14 21 750 -50 300 L 50 50 1 1 O
X LED15 22 750 50 300 L 50 50 1 1 O
X OE 23 750 150 300 L 50 50 1 1 I
X A5 24 750 250 300 L 50 50 1 1 I
X EXTCLK 25 750 350 300 L 50 50 1 1 I
X SCL 26 750 450 300 L 50 50 1 1 I
X SDA 27 750 550 300 L 50 50 1 1 B
X VCC 28 750 650 300 L 50 50 1 1 I
X A2 3 -750 450 300 R 50 50 1 1 I
X A3 4 -750 350 300 R 50 50 1 1 I
X A4 5 -750 250 300 R 50 50 1 1 I
X LED0 6 -750 150 300 R 50 50 1 1 O
X LED1 7 -750 50 300 R 50 50 1 1 O
X LED2 8 -750 -50 300 R 50 50 1 1 O
X LED3 9 -750 -150 300 R 50 50 1 1 O
ENDDRAW
ENDDEF
#
#End Library

View File

@ -0,0 +1,47 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#(c) SnapEDA 2016 (snapeda.com)
#This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA) with Design Exception 1.0
#
# SMD-BUTTON(4P-5.2X5.2X1.5MM-SKQGAKE010)
#
DEF SMD-BUTTON(4P-5.2X5.2X1.5MM-SKQGAKE010) SW 0 40 Y Y 1 L N
F0 "SW" -201 201 50 H V L BNN
F1 "SMD-BUTTON(4P-5.2X5.2X1.5MM-SKQGAKE010)" -200 -250 50 H V L BNN
F2 "SW4-SMD-5.2X5.2X1.5MM" 0 0 50 H I L BNN
F3 "None" 0 0 50 H I L BNN
F4 "SKQGAKE010" 0 0 50 H I L BNN
F5 "None" 0 0 50 H I L BNN
F6 "Unavailable" 0 0 50 H I L BNN
F7 "ALPS" 0 0 50 H I L BNN
F8 "Switch Tactile N.O. SPST Button Gull Wing 0.05A 12VDC 3.43N SMD T/R" 0 0 50 H I L BNN
DRAW
P 2 0 0 10 -200 200 200 200 N
P 2 0 0 10 200 200 200 100 N
P 2 0 0 10 200 100 200 -100 N
P 2 0 0 10 200 -100 200 -200 N
P 2 0 0 10 200 -200 -200 -200 N
P 2 0 0 10 -200 -200 -200 -100 N
P 2 0 0 10 -200 -100 -200 100 N
P 2 0 0 10 -200 100 -200 200 N
P 2 0 0 6 -200 100 0 100 N
P 2 0 0 6 0 100 200 100 N
P 2 0 0 6 0 100 0 50 N
P 2 0 0 6 0 50 -50 -30 N
P 2 0 0 6 0 -50 0 -100 N
P 2 0 0 6 0 -100 200 -100 N
P 2 0 0 6 0 -100 -200 -100 N
P 2 0 0 6 -250 100 -200 100 N
P 2 0 0 6 -250 -100 -200 -100 N
P 2 0 0 6 250 -100 200 -100 N
P 2 0 0 6 250 100 200 100 N
C -50 -30 6 0 0 0 N
C 0 -50 6 0 0 0 N
X A0 1 -350 100 100 R 40 40 0 0 B
X A1 2 350 100 100 L 40 40 0 0 B
X B0 3 -350 -100 100 R 40 40 0 0 B
X B1 4 350 -100 100 L 40 40 0 0 B
ENDDRAW
ENDDEF
#
# End Library

View File

@ -0,0 +1,67 @@
PCBNEW-LibModule-V1
# encoding utf-8
Units mm
$INDEX
SW4-SMD-5.2X5.2X1.5MM
$EndINDEX
$MODULE SW4-SMD-5.2X5.2X1.5MM
Po 0 0 0 15 00000000 00000000 ~~
Li SW4-SMD-5.2X5.2X1.5MM
Cd
Sc 00000000
At SMD
Op 0 0 0
.SolderMask 0
.SolderPaste 0
T0 -0.523383 -3.25313 0.701862 0.701862 0 0.05 N V 21 "SW4-SMD-5.2X5.2X1.5MM"
T1 -0.112861 -0.218191 0.501589 0.501589 0 0.05 N V 21 "VAL**"
DS 2.6 1.46863 1.46863 2.6 0.127 24
DS 1.5 2.6 -1.1 2.6 0.127 21
DS -1.1 2.6 -1.45982 2.6 0.127 21
DS -1.45982 2.6 -2.6 1.45982 0.127 24
DS -2.6 -1.39584 -1.39584 -2.6 0.127 24
DS -1.4 -2.6 1.5 -2.6 0.127 21
DS 1.43381 -2.6 2.6 -1.43381 0.127 24
DP 0 0 0 0 4 0 26
Dl -2.50464 -2.6
Dl 2.6 -2.6
Dl 2.6 2.60484
Dl -2.50464 2.60484
DS -1.4 -2.6 -2.4 -1.6 0.127 21
DS 1.5 -2.6 2.4 -1.7 0.127 21
DS 1.5 2.6 2.4 1.7 0.127 21
DS -1.45982 2.6 -1.5 2.6 0.127 21
DS -1.5 2.6 -2.4 1.7 0.127 21
$PAD
Sh "1" R 1 0.7 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -3 -1.85
$EndPAD
$PAD
Sh "2" R 1 0.7 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 3 -1.85
$EndPAD
$PAD
Sh "3" R 1 0.7 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po -3 1.85
$EndPAD
$PAD
Sh "4" R 1 0.7 0 0 0
At SMD N 00888000
.SolderMask 0
.SolderPaste 0
Ne 0 ""
Po 3 1.85
$EndPAD
$EndMODULE SW4-SMD-5.2X5.2X1.5MM

6
kicad/sym-lib-table Normal file
View File

@ -0,0 +1,6 @@
(sym_lib_table
(lib (name PCA9685-TSSOP)(type Legacy)(uri ${KIPRJMOD}/libs/PCA9685-TSSOP.lib)(options "")(descr ""))
(lib (name MAX485)(type Legacy)(uri ${KIPRJMOD}/libs/MAX485.lib)(options "")(descr ""))
(lib (name AMS1117-5.0)(type Legacy)(uri ${KIPRJMOD}/libs/AMS1117-5.0.lib)(options "")(descr ""))
(lib (name SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_)(type Legacy)(uri ${KIPRJMOD}/libs/SMD-BUTTON_4P-5.2X5.2X1.5MM-SKQGAKE010_.lib)(options "")(descr ""))
)

1
module/build.bat Normal file
View File

@ -0,0 +1 @@
@pio run

3
module/fuses.bat Normal file
View File

@ -0,0 +1,3 @@
REM Internal 8 Mhz oscillator, no clock division
REM http://www.engbedded.com/fusecalc/
@avrdude -c usbtiny -p t2313 -e -U lfuse:w:0xe4:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

19
module/platformio.ini Normal file
View File

@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[platformio]
env_default = board
[env:board]
platform = atmelavr
board = attiny4313
board_build.f_cpu = 8000000L
upload_speed = 115200
upload_protocol = usbtiny

126
module/src/display.c Normal file
View File

@ -0,0 +1,126 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#include "display.h"
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "lib/VeryTinySSD1306.h"
#include "lib/VeryTinyBigChars.h"
#include "lib/TinyMillis.h"
#include "global.h"
#define CharSpacing 4
#define CharOuterWidth (SSD1306_CharWidth_32px + CharSpacing)
#define SingleCharCenteredX ((SSD1306_DisplayWidth - SSD1306_CharWidth_32px) / 2)
#define WaitAnimationInterval 250
#define WaitAnimationMaxStep 3
const uint16_t WaitAnimation [] PROGMEM = {
0b0000000000000100, // Left
0b0000000010000000, // Middle
0b0001000000000000, // Right
0b0000000010000000 // Middle
};
/*
#define WaitAnimationMaxStep 7
const uint16_t WaitAnimation [] PROGMEM = {
0b0000000001000000, // Top
0b0000100000000000, // Top-right
0b0001000000000000, // Right
0b0010000000000000, // Bottom-right
0b0000000100000000, // Bottom
0b0000000000001000, // Bottom-left
0b0000000000000100, // Left
0b0000000000000010 // Top-left
};
*/
bool isWait = false;
uint16_t lastWait = 0;
uint8_t waitAnimationStep = 0;
inline void display_drawNumber(uint8_t* x, uint8_t value)
{
if (value > 9)
{
ssd1306_drawdigit_32px(*x, value / 10);
*x += CharOuterWidth;
ssd1306_drawdigit_32px(*x, value % 10);
}
else
ssd1306_drawdigit_32px(*x, value);
*x += CharOuterWidth;
}
void display_init(void)
{
ssd1306_begin_default();
ssd1306_clear();
ssd1306_on();
ssd1306_switchRenderFrame();
}
void display_drawIndex(void)
{
ssd1306_clear();
uint8_t moduleIndex = global_getModuleIndex();
if (moduleIndex == ModuleIndexUndefined)
{
ssd1306_drawminus_32px(SingleCharCenteredX);
}
else
{
uint8_t firstStep = (moduleIndex * 2) + 1;
uint8_t totalWidth = 3 * CharOuterWidth;
if (firstStep == 9)
totalWidth += CharOuterWidth;
else if (firstStep > 9)
totalWidth += 2 * CharOuterWidth;
uint8_t currentX = (SSD1306_DisplayWidth - totalWidth) / 2;
display_drawNumber(&currentX, firstStep);
ssd1306_drawminus_32px(currentX);
currentX += CharOuterWidth;
display_drawNumber(&currentX, firstStep + 1);
}
ssd1306_switchFrame();
}
void display_drawWait(void)
{
uint16_t currentTime = millis();
if (isWait && currentTime - lastWait < WaitAnimationInterval)
return;
ssd1306_clear();
ssd1306_drawchar_32px(SingleCharCenteredX, pgm_read_word(&WaitAnimation[waitAnimationStep]));
ssd1306_switchFrame();
waitAnimationStep++;
if (waitAnimationStep > WaitAnimationMaxStep)
waitAnimationStep = 0;
isWait = true;
lastWait = currentTime;
}

14
module/src/display.h Normal file
View File

@ -0,0 +1,14 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#ifndef __display
#define __display
void display_init(void);
void display_drawIndex(void);
void display_drawWait(void);
#endif

59
module/src/global.c Normal file
View File

@ -0,0 +1,59 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#include "global.h"
#include <avr/eeprom.h>
// EEPROM
// First byte is 0xAA to recognize uninitialised EEPROM
#define EEPROMHeader 0xAA
// Second byte is a version indicator
#define EEPROMCurrentVersion 1
// Version 1 fields
// index: 2
uint8_t moduleIndex = ModuleIndexUndefined;
void global_init(void)
{
uint8_t address = 0;
if (eeprom_read_byte(&address) != EEPROMHeader)
{
eeprom_write_byte(&address, EEPROMHeader); address++;
eeprom_write_byte(&address, EEPROMCurrentVersion); address++;
eeprom_write_byte(&address, moduleIndex); address++;
}
else
{
address++;
uint8_t version = eeprom_read_byte(&address); address++;
if (version >= 1)
{
moduleIndex = eeprom_read_byte(&address); address++;
}
}
}
uint8_t global_getModuleIndex(void)
{
return moduleIndex;
}
void global_setModuleIndex(uint8_t index)
{
if (index == moduleIndex)
return;
moduleIndex = index;
uint8_t address = 2;
eeprom_write_byte(&address, moduleIndex);
}

19
module/src/global.h Normal file
View File

@ -0,0 +1,19 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#ifndef __global
#define __global
#include <stdint.h>
#define ModuleIndexUndefined 0xff
void global_init(void);
uint8_t global_getModuleIndex(void);
void global_setModuleIndex(uint8_t index);
#endif

View File

@ -0,0 +1,46 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#include "TinyMillis.h"
#include <avr/io.h>
#include <util/atomic.h>
#include <avr/interrupt.h>
volatile uint16_t tickCount;
ISR(TIMER1_COMPA_vect)
{
tickCount++;
}
void millis_init(void)
{
uint32_t overflow;
overflow = ((F_CPU / 1000) / 8);
TCCR1B |= (1 << WGM12) | (1 << CS11);
OCR1AH = (overflow >> 8);
OCR1AL = overflow;
TIMSK |= (1 << OCIE1A);
}
uint16_t millis(void)
{
uint16_t value;
ATOMIC_BLOCK(ATOMIC_FORCEON)
{
value = tickCount;
}
return value;
}

View File

@ -0,0 +1,21 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Counts the elapsed milliseconds similar to Arduino's millis(void).
* Accuracy is not assumed to be important, and assumes no long-running
* checks are done so it can get away with 16 bits (65 seconds max).
*/
#ifndef __TinyMillis
#define __TinyMillis
#include <stdint.h>
// call sei(void) afterwards
void millis_init(void);
uint16_t millis(void);
#endif

262
module/src/lib/TinyRS485.c Normal file
View File

@ -0,0 +1,262 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Straight up port of Nick Gammon's non-blocking
* RS485 library to C and removing the Arduino
* framework dependency.
*
* Source:
* https://www.gammon.com.au/forum/?id=11428
* Devised and written by Nick Gammon.
* Date: 4 December 2012
* Version: 1.0
*/
#include "TinyRS485.h"
#include "TinyMillis.h"
#include <stdlib.h>
ReadCallback doRead;
AvailableCallback doAvailable;
WriteCallback doWrite;
// where we save incoming stuff
uint8_t* data;
// how much data is in the buffer
uint8_t bufferSize;
// this is true once we have valid data in buf
bool available;
// an STX (start of text) signals a packet start
bool haveSTX;
// count of errors
uint16_t errorCount;
// variables below are set when we get an STX
bool haveETX;
uint8_t inputPos;
uint8_t currentByte;
bool firstNibble;
uint16_t startTime;
// helper private functions
uint8_t crc8 (uint8_t* addr, uint8_t len)
{
uint8_t crc = 0;
while (len--)
{
uint8_t inbyte = *addr++;
for (uint8_t i = 8; i; i--)
{
uint8_t mix = (crc ^ inbyte) & 0x01;
crc >>= 1;
if (mix)
crc ^= 0x8C;
inbyte >>= 1;
}
}
return crc;
}
// send a byte complemented, repeated
// only values sent would be (in hex):
// 0F, 1E, 2D, 3C, 4B, 5A, 69, 78, 87, 96, A5, B4, C3, D2, E1, F0
void sendComplemented(uint8_t what)
{
uint8_t c;
// first nibble
c = what >> 4;
doWrite((c << 4) | (c ^ 0x0F));
// second nibble
c = what & 0x0F;
doWrite((c << 4) | (c ^ 0x0F));
}
void rs485_begin(ReadCallback readCallback,
AvailableCallback availableCallback,
WriteCallback writeCallback,
uint8_t bufferSize)
{
doRead = readCallback;
doAvailable = availableCallback;
doWrite = writeCallback;
data = (uint8_t*)malloc(bufferSize);
rs485_reset();
errorCount = 0;
}
void rs485_stop(void)
{
rs485_reset();
free(data);
data = NULL;
}
void rs485_reset(void)
{
haveSTX = false;
available = false;
inputPos = 0;
startTime = 0;
}
// send a message of "length" bytes (max 255) to other end
// put STX at start, ETX at end, and add CRC
void rs485_sendMsg(uint8_t* data, uint8_t length)
{
doWrite(STX); // STX
for (uint8_t i = 0; i < length; i++)
sendComplemented(data[i]);
doWrite(ETX); // ETX
sendComplemented(crc8(data, length));
}
bool rs485_available(void)
{
return available;
}
uint8_t* rs485_getData(void)
{
return data;
}
uint8_t rs485_getLength(void)
{
return inputPos;
}
uint16_t rs485_getErrorCount(void)
{
return errorCount;
}
uint16_t rs485_getPacketStartTime(void)
{
return startTime;
}
bool rs485_isPacketStarted(void)
{
return haveSTX;
}
// called periodically from main loop to process data and
// assemble the finished packet in 'data_'
// returns true if packet received.
// You could implement a timeout by seeing if isPacketStarted() returns
// true, and if too much time has passed since getPacketStartTime() time.
bool rs485_update(void)
{
// no data? can't go ahead (eg. begin() not called)
if (data == NULL)
return false;
// no callbacks? Can't read
if (doAvailable == NULL || doRead == NULL)
return false;
while (doAvailable() > 0)
{
uint8_t inByte = doRead();
switch (inByte)
{
case STX: // start of text
haveSTX = true;
haveETX = false;
inputPos = 0;
firstNibble = true;
startTime = millis();
break;
case ETX: // end of text (now expect the CRC check)
haveETX = true;
break;
default:
// wait until packet officially starts
if (!haveSTX)
break;
// check byte is in valid form (4 bits followed by 4 bits complemented)
if ((inByte >> 4) != ((inByte & 0x0F) ^ 0x0F))
{
rs485_reset();
errorCount++;
break; // bad character
}
// convert back
inByte >>= 4;
// high-order nibble?
if (firstNibble)
{
currentByte = inByte;
firstNibble = false;
break;
}
// low-order nibble
currentByte <<= 4;
currentByte |= inByte;
firstNibble = true;
// if we have the ETX this must be the CRC
if (haveETX)
{
if (crc8(data, inputPos) != currentByte)
{
rs485_reset();
errorCount++;
break; // bad crc
}
available = true;
return true; // show data ready
}
// keep adding if not full
if (inputPos < bufferSize)
data[inputPos++] = currentByte;
else
{
rs485_reset(); // overflow, start again
errorCount++;
}
break;
}
}
return false; // not ready yet
}

View File

@ -0,0 +1,69 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Straight up port of Nick Gammon's non-blocking
* RS485 library to C and removing the Arduino
* framework dependency.
*
* Source:
* https://www.gammon.com.au/forum/?id=11428
* Devised and written by Nick Gammon.
* Date: 4 December 2012
* Version: 1.0
*/
#ifndef __TinyRS485
#define __TinyRS485
#include <stdint.h>
#include <stdbool.h>
typedef void (*WriteCallback) (uint8_t what); // send a byte to serial port
typedef uint8_t (*AvailableCallback) (void); // return number of bytes available
typedef uint8_t (*ReadCallback) (void); // read a byte from serial port
enum {
STX = '\2', // start of text
ETX = '\3' // end of text
}; // end of enum
// allocate the requested buffer size
void rs485_begin(ReadCallback readCallback,
AvailableCallback availableCallback,
WriteCallback writeCallback,
uint8_t bufferSize);
// get rid of the buffer
void rs485_stop(void);
// handle incoming data, return true if packet ready
bool rs485_update(void);
// reset to no incoming data (eg. after a timeout)
void rs485_reset(void);
// send data
void rs485_sendMsg(uint8_t* data, uint8_t length);
// returns true if packet available
bool rs485_available(void);
// once available, returns the address of the current message
uint8_t* rs485_getData(void);
uint8_t rs485_getLength(void);
// return how many errors we have had
uint16_t rs485_getErrorCount(void);
// return when last packet started
uint16_t rs485_getPacketStartTime(void);
// return true if a packet has started to be received
bool rs485_isPacketStarted(void);
#endif

161
module/src/lib/TinyUART.c Normal file
View File

@ -0,0 +1,161 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Source:
* https://github.com/akafugu/helloworld/blob/master/attiny2313/uart.c
*/
#include "TinyUART.h"
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
volatile static uint8_t rx_buffer[BUFFER_SIZE] = "xxxxxxxxxxxxxxxx";
volatile static uint8_t tx_buffer[BUFFER_SIZE] = "xxxxxxxxxxxxxxxx";
volatile static uint8_t rx_head = 0;
volatile static uint8_t rx_tail = 0;
volatile static uint8_t tx_head = 0;
volatile static uint8_t tx_tail = 0;
void uart_init(void)
{
// set baud rate
UBRRH = (uint8_t)(MYUBBR >> 8);
UBRRL = (uint8_t)(MYUBBR);
// enable receive and transmit
UCSRB = (1 << RXEN) | (1 << TXEN) | (1 << RXCIE);
// set frame format
UCSRC = (1 << USBS) | (3 << UCSZ0); // asynchron 8n1
}
void uart_send(uint8_t c)
{
// wait for empty data register
while (!(UCSRA & (1<<UDRE)));
// set data into data register
UDR = c;
}
uint8_t uart_available(void)
{
return rx_head - rx_tail;
}
uint8_t uart_receive(void)
{
while (!(UCSRA & (1<<RXC)))
;
return UDR;
}
uint16_t uart_getc(void)
{
uint8_t c = 0;
uint8_t tmp_tail = 0;
if (rx_head == rx_tail)
return UART_NO_DATA;
tmp_tail = (rx_tail + 1) % BUFFER_SIZE;
c = rx_buffer[rx_tail];
rx_tail = tmp_tail;
return c;
}
uint8_t uart_getc_wait(void)
{
uint16_t c;
while ((c = uart_getc()) == UART_NO_DATA) {}
return c;
}
void uart_putc(uint8_t c)
{
uint8_t tmp_head = (tx_head + 1) % BUFFER_SIZE;
// wait for space in buffer
while (tmp_head == tx_tail)
;
tx_buffer[tx_head] = c;
tx_head = tmp_head;
// enable uart data interrupt (send data)
UCSRB |= (1<<UDRIE);
}
void uart_puts(const char *s)
{
while (*s)
{
uart_putc(*s);
s++;
}
}
void uart_puts_P(const char *s)
{
while (pgm_read_byte(s) != 0x00)
{
uart_putc(pgm_read_byte(s++));
}
}
/*
* ISR User Data Regiser Empty
* Send a char out of buffer via UART. If sending is complete, the
* interrupt gets disabled.
*/
ISR(USART_UDRE_vect)
{
uint8_t tmp_tail = 0;
if (tx_head != tx_tail)
{
tmp_tail = (tx_tail + 1) % BUFFER_SIZE;
UDR = tx_buffer[tx_tail];
tx_tail = tmp_tail;
}
else
{
// disable this interrupt if nothing more to send
UCSRB &= ~(1 << UDRIE);
}
}
/*
* ISR RX complete
* Receives a char from UART and stores it in ring buffer.
*/
ISR(USART_RX_vect)
{
uint8_t tmp_head = 0;
tmp_head = (rx_head + 1) % BUFFER_SIZE;
if (tmp_head == rx_tail)
{
// buffer overflow error!
}
else
{
rx_buffer[rx_head] = UDR;
rx_head = tmp_head;
}
}

86
module/src/lib/TinyUART.h Normal file
View File

@ -0,0 +1,86 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Source:
* https://github.com/akafugu/helloworld/blob/master/attiny2313/uart.c
*/
#ifndef __TinyUART
#define __TinyUART
#include <stdint.h>
#define UART_NO_DATA 0x0100
#define BAUD 38400
// 4.096MHz
// 4800: 52.3333333
// 9600: 25.6666667
// 14400: 16.7777778
// 19600: 12.06
// 28800: 7.8889
// 38400: 5.6667
#define MYUBBR ((F_CPU / (BAUD * 16L)) - 1)
#define BUFFER_SIZE 16
void uart_init(void);
/*
* uart_send
* Sends a single char to UART without ISR
*/
void uart_send(uint8_t c);
uint8_t uart_available(void);
/*
* uart_receive
* Receives a single char without ISR
*/
uint8_t uart_receive(void);
/*
* uart_getc
* Gets a single char from the receive buffer.
* return uint16_r the received char or UART_NO_DATA
*/
uint16_t uart_getc(void);
/*
* uart_getc_wait
* Blocking call to getc. Will not return until a char is received.
*/
uint8_t uart_getc_wait(void);
/*
* uart_putc
* Puts a single char. Will block until there is enough space in the
* send buffer.
*/
void uart_putc(uint8_t c);
/*
* uart_puts
* Sends a string.
*/
void uart_puts(const char *s);
/*
* uart_puts_P
* Sends a PROGMEM string.
*/
void uart_puts_P(const char *s);
#endif

View File

@ -0,0 +1,134 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#include "VeryTinyBigChars.h"
#include "VeryTinySSD1306.h"
#include <avr/pgmspace.h>
/*
* Each digit is composed of a 3x5 grid where each bit represents
* whether or not to draw that area. It is then stretched.
*
* Example:
*
* XXX
* X
* XXX
* X
* XXX
*
* The least significant bit is the top left corner, going down
* after that before wrapping to the middle column.
*/
const uint16_t ssd1306_digits_32px [] PROGMEM = {
0b0111111000111111, // 0
0b0100001111110010, // 1
0b0101111010111101, // 2
0b0111111010110101, // 3
0b0111110010000111, // 4
0b0111011010110111, // 5
0b0111011010111111, // 6
0b0111110000100001, // 7
0b0111111010111111, // 8
0b0111111010110111 // 9
};
void ssd1306_drawchar_32px(uint8_t x, uint16_t matrix)
{
uint8_t column[4];
// Vertical mode
ssd1306_setMemoryAddressingMode(0b01);
if (ssd1306_currentRenderFrame() == 1)
{
ssd1306_setPageStartAddress(4);
ssd1306_setPageAddress(4, 7);
}
else
{
ssd1306_setPageStartAddress(0);
ssd1306_setPageAddress(0, 3);
}
ssd1306_setCursor(x, 0);
ssd1306_startData();
// Three columns, each shifted 5 bits
for (uint8_t shift = 0; shift < 3; shift++)
{
uint16_t columnValue = matrix >> (shift * 5);
// It's a bit rough, but it works! First, third and fifth "row" are 6 bits, in between are 7 bits = 32 total
column[0] = 0;
column[1] = 0;
column[2] = 0;
column[3] = 0;
// 0 = 0b0111111000111111
if (columnValue & 0b1)
column[0] |= 0b00111111;
if (columnValue & 0b10) {
column[0] |= 0b11000000;
column[1] |= 0b00011111;
}
if (columnValue & 0b100) {
column[1] |= 0b11100000;
column[2] |= 0b00000111;
}
if (columnValue & 0b1000) {
column[2] |= 0b11111000;
column[3] |= 0b00000011;
}
if (columnValue & 0b10000)
column[3] |= 0b11111100;
// Each column is 6 pixels wide
for (uint8_t repeat = 0; repeat < SSD1306_CharColumnWidth_32px; repeat++)
{
ssd1306_sendData(column[0]);
ssd1306_sendData(column[1]);
ssd1306_sendData(column[2]);
ssd1306_sendData(column[3]);
}
}
ssd1306_endData();
// Default: horizontal mode
ssd1306_setMemoryAddressingMode(0b00);
ssd1306_setPageStartAddress(0);
ssd1306_setPageAddress(0, 7);
}
void ssd1306_drawdigit_32px(uint8_t x, uint8_t value)
{
if (value < 0 || value > 9)
return;
ssd1306_drawchar_32px(x, pgm_read_word(&ssd1306_digits_32px[value]));
}
void ssd1306_drawplus_32px(uint8_t x)
{
ssd1306_drawchar_32px(x, 0b0001000111000100);
}
void ssd1306_drawminus_32px(uint8_t x)
{
ssd1306_drawchar_32px(x, 0b0001000010000100);
}

View File

@ -0,0 +1,24 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#ifndef __VeryTinyBigChars
#define __VeryTinyBigChars
#include <stdint.h>
#define SSD1306_CharColumnWidth_32px 6
#define SSD1306_CharWidth_32px (3 * SSD1306_CharColumnWidth_32px)
void ssd1306_drawchar_32px(uint8_t x, uint16_t matrix);
// Draws a digit from 0 to 9, 32 pixels tall
void ssd1306_drawdigit_32px(uint8_t x, uint8_t value);
void ssd1306_drawplus_32px(uint8_t x);
void ssd1306_drawminus_32px(uint8_t x);
#endif

View File

@ -0,0 +1,153 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Minimalistic I2C library for the ATTiny2313's limited space.
* Based on David Johnson-Davies' TinyI2C:
* https://github.com/technoblogy/tiny-i2c
*/
#include "VeryTinyI2C.h"
// Constants
// Prepare register value to: Clear flags, and set USI to shift 8 bits i.e. count 16 clock edges.
const unsigned char USISR_8bit = 1<<USISIF | 1<<USIOIF | 1<<USIPF | 1<<USIDC | 0x0<<USICNT0;
// Prepare register value to: Clear flags, and set USI to shift 1 bit i.e. count 2 clock edges.
const unsigned char USISR_1bit = 1<<USISIF | 1<<USIOIF | 1<<USIPF | 1<<USIDC | 0xE<<USICNT0;
int32_t I2Ccount;
uint8_t i2c_transfer(uint8_t data)
{
USISR = data; // Set USISR according to data.
// Prepare clocking.
data = 0<<USISIE | 0<<USIOIE | // Interrupts disabled
1<<USIWM1 | 0<<USIWM0 | // Set USI in Two-wire mode.
1<<USICS1 | 0<<USICS0 | 1<<USICLK | // Software clock strobe as source.
1<<USITC; // Toggle Clock Port.
do {
DELAY_T2TWI;
USICR = data; // Generate positive SCL edge.
while (!(PIN_USI_CL & 1<<PIN_USI_SCL)); // Wait for SCL to go high.
DELAY_T4TWI;
USICR = data; // Generate negative SCL edge.
} while (!(USISR & 1<<USIOIF)); // Check for transfer complete.
DELAY_T2TWI;
data = USIDR; // Read out data.
USIDR = 0xFF; // Release SDA.
DDR_USI |= (1<<PIN_USI_SDA); // Enable SDA as output.
return data; // Return the data from the USIDR
}
void i2c_init(void)
{
PORT_USI |= 1<<PIN_USI_SDA; // Enable pullup on SDA.
PORT_USI_CL |= 1<<PIN_USI_SCL; // Enable pullup on SCL.
DDR_USI_CL |= 1<<PIN_USI_SCL; // Enable SCL as output.
DDR_USI |= 1<<PIN_USI_SDA; // Enable SDA as output.
USIDR = 0xFF; // Preload data register with "released level" data.
USICR = 0<<USISIE | 0<<USIOIE | // Disable Interrupts.
1<<USIWM1 | 0<<USIWM0 | // Set USI in Two-wire mode.
1<<USICS1 | 0<<USICS0 | 1<<USICLK | // Software stobe as counter clock source
0<<USITC;
USISR = 1<<USISIF | 1<<USIOIF | 1<<USIPF | 1<<USIDC | // Clear flags,
0x0<<USICNT0; // and reset counter.
}
uint8_t i2c_read(void)
{
if ((I2Ccount != 0) && (I2Ccount != -1)) I2Ccount--;
/* Read a byte */
DDR_USI &= ~1<<PIN_USI_SDA; // Enable SDA as input.
uint8_t data = i2c_transfer(USISR_8bit);
/* Prepare to generate ACK (or NACK in case of End Of Transmission) */
if (I2Ccount == 0) USIDR = 0xFF; else USIDR = 0x00;
i2c_transfer(USISR_1bit); // Generate ACK/NACK.
return data; // Read successfully completed
}
uint8_t i2c_readLast(void)
{
I2Ccount = 0;
return i2c_read();
}
bool i2c_write(uint8_t data)
{
/* Write a byte */
PORT_USI_CL &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.
USIDR = data; // Setup data.
i2c_transfer(USISR_8bit); // Send 8 bits on bus.
/* Clock and verify (N)ACK from slave */
DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.
if (i2c_transfer(USISR_1bit) & 1<<TWI_NACK_BIT) return false;
return true; // Write successfully completed
}
bool i2c_start(uint8_t address, int readcount)
{
if (readcount != 0) { I2Ccount = readcount; readcount = 1; }
uint8_t addressRW = address<<1 | readcount;
/* Release SCL to ensure that (repeated) Start can be performed */
PORT_USI_CL |= 1<<PIN_USI_SCL; // Release SCL.
while (!(PIN_USI_CL & 1<<PIN_USI_SCL)); // Verify that SCL becomes high.
#ifdef TWI_FAST_MODE
DELAY_T4TWI;
#else
DELAY_T2TWI;
#endif
/* Generate Start Condition */
PORT_USI &= ~(1<<PIN_USI_SDA); // Force SDA LOW.
DELAY_T4TWI;
PORT_USI_CL &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.
PORT_USI |= 1<<PIN_USI_SDA; // Release SDA.
if (!(USISR & 1<<USISIF)) return false;
/*Write address */
PORT_USI_CL &= ~(1<<PIN_USI_SCL); // Pull SCL LOW.
USIDR = addressRW; // Setup data.
i2c_transfer(USISR_8bit); // Send 8 bits on bus.
/* Clock and verify (N)ACK from slave */
DDR_USI &= ~(1<<PIN_USI_SDA); // Enable SDA as input.
if (i2c_transfer(USISR_1bit) & 1<<TWI_NACK_BIT) return false; // No ACK
return true; // Start successfully completed
}
bool i2c_restart(uint8_t address, int readcount)
{
return i2c_start(address, readcount);
}
void i2c_stop(void)
{
PORT_USI &= ~(1<<PIN_USI_SDA); // Pull SDA low.
PORT_USI_CL |= 1<<PIN_USI_SCL; // Release SCL.
while (!(PIN_USI_CL & 1<<PIN_USI_SCL)); // Wait for SCL to go high.
DELAY_T4TWI;
PORT_USI |= 1<<PIN_USI_SDA; // Release SDA.
DELAY_T2TWI;
}

View File

@ -0,0 +1,54 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Straight up port of David Johnson-Davies' TinyI2C to C
* and without the Arduino framework dependency.
* https://github.com/technoblogy/tiny-i2c
*/
#ifndef __VeryTinyI2C
#define __VeryTinyI2C
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
// Defines
//#define TWI_FAST_MODE
#ifdef TWI_FAST_MODE // TWI FAST mode timing limits. SCL = 100-400kHz
#define DELAY_T2TWI (_delay_us(2)) // >1.3us
#define DELAY_T4TWI (_delay_us(1)) // >0.6us
#else // TWI STANDARD mode timing limits. SCL <= 100kHz
#define DELAY_T2TWI (_delay_us(5)) // >4.7us
#define DELAY_T4TWI (_delay_us(4)) // >4.0us
#endif
#define TWI_NACK_BIT 0 // Bit position for (N)ACK bit.
// These are valid for the ATTiny2313
#define DDR_USI DDRB
#define DDR_USI_CL DDR_USI
#define PORT_USI PORTB
#define PORT_USI_CL PORT_USI
#define PIN_USI PINB
#define PIN_USI_CL PIN_USI
#define PORT_USI_SDA PB5
#define PORT_USI_SCL PB7
#define PIN_USI_SDA PINB5
#define PIN_USI_SCL PINB7
void i2c_init(void);
uint8_t i2c_read(void);
uint8_t i2c_readLast(void);
bool i2c_write(uint8_t data);
bool i2c_start(uint8_t address, int readcount);
bool i2c_restart(uint8_t address, int readcount);
void i2c_stop(void);
#endif

View File

@ -0,0 +1,517 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Port of Stephen Denne's Tiny4kOLED to C
* and without the Arduino framework dependency.
* https://github.com/technoblogy/tiny-i2c
*/
#include "VeryTinySSD1306.h"
#include <avr/pgmspace.h>
#include "VeryTinyI2C.h"
#define SSD1306_PAGES 4
#define SSD1306_COMMAND 0x00
#define SSD1306_DATA 0x40
// ----------------------------------------------------------------------------
// Some code based on "IIC_without_ACK" by http://www.14blog.com/archives/1358
const uint8_t ssd1306_init_sequence [] PROGMEM = { // Initialization Sequence
// 0xAE, // Display OFF (sleep mode)
// 0x20, 0b10, // Set Memory Addressing Mode
// 00=Horizontal Addressing Mode; 01=Vertical Addressing Mode;
// 10=Page Addressing Mode (RESET); 11=Invalid
// 0xB0, // Set Page Start Address for Page Addressing Mode, 0-7
0xC8, // Set COM Output Scan Direction
// 0x00, // ---set low column address
// 0x10, // ---set high column address
// 0x40, // --set start line address
// 0x81, 0x7F, // Set contrast control register
0xA1, // Set Segment Re-map. A0=address mapped; A1=address 127 mapped.
// 0xA6, // Set display mode. A6=Normal; A7=Inverse
0xA8, 0x1F, // Set multiplex ratio(1 to 64)
// 0xA4, // Output RAM to Display
// 0xA4=Output follows RAM content; 0xA5,Output ignores RAM content
// 0xD3, 0x00, // Set display offset. 00 = no offset
// 0xD5, 0x80, // --set display clock divide ratio/oscillator frequency
// 0xD9, 0x22, // Set pre-charge period
0xDA, 0x02, // Set com pins hardware configuration
// 0xDB, 0x20, // --set vcomh 0x20 = 0.77xVcc
0x8D, 0x14 // Set DC-DC enable
};
const DCfont *oledFont = 0;
uint8_t oledX = 0, oledY = 0;
uint8_t renderingFrame = 0xB0, drawingFrame = 0x40;
void ssd1306_send_command_start(void)
{
i2c_start(SSD1306, 0);
i2c_write(SSD1306_COMMAND);
}
void ssd1306_send_data_start(void)
{
i2c_start(SSD1306, 0);
i2c_write(SSD1306_DATA);
}
void ssd1306_send_command_byte(uint8_t byte)
{
if (i2c_write(byte) == 0)
{
i2c_stop();
ssd1306_send_command_start();
i2c_write(byte);
}
}
void ssd1306_send_data_byte(uint8_t byte)
{
if (i2c_write(byte) == 0)
{
i2c_stop();
ssd1306_send_data_start();
i2c_write(byte);
}
}
void ssd1306_send_command(uint8_t command)
{
ssd1306_send_command_start();
i2c_write(command);
i2c_stop();
}
void ssd1306_send_command2(uint8_t command1, uint8_t command2)
{
ssd1306_send_command_start();
i2c_write(command1);
i2c_write(command2);
i2c_stop();
}
void ssd1306_send_command3(uint8_t command1, uint8_t command2, uint8_t command3)
{
ssd1306_send_command_start();
i2c_write(command1);
i2c_write(command2);
i2c_write(command3);
i2c_stop();
}
void ssd1306_send_command6(uint8_t command1, uint8_t command2, uint8_t command3, uint8_t command4, uint8_t command5, uint8_t command6)
{
ssd1306_send_command_start();
i2c_write(command1);
i2c_write(command2);
i2c_write(command3);
i2c_write(command4);
i2c_write(command5);
i2c_write(command6);
i2c_stop();
}
void ssd1306_send_command7(uint8_t command1, uint8_t command2, uint8_t command3, uint8_t command4, uint8_t command5, uint8_t command6, uint8_t command7)
{
ssd1306_send_command_start();
i2c_write(command1);
i2c_write(command2);
i2c_write(command3);
i2c_write(command4);
i2c_write(command5);
i2c_write(command6);
i2c_write(command7);
i2c_stop();
}
void ssd1306_begin_default(void)
{
ssd1306_begin(sizeof(ssd1306_init_sequence), ssd1306_init_sequence);
}
void ssd1306_begin(uint8_t init_sequence_length, const uint8_t init_sequence [])
{
i2c_init();
ssd1306_send_command_start();
for (uint8_t i = 0; i < init_sequence_length; i++)
{
ssd1306_send_command_byte(pgm_read_byte(&init_sequence[i]));
}
i2c_stop();
}
void ssd1306_setFont(const DCfont *font)
{
oledFont = font;
}
void ssd1306_setCursor(uint8_t x, uint8_t y)
{
ssd1306_send_command3(renderingFrame | (y & 0x07), 0x10 | ((x & 0xf0) >> 4), x & 0x0f);
oledX = x;
oledY = y;
}
void ssd1306_clear(void)
{
ssd1306_fill(0x00);
}
void ssd1306_fill(uint8_t fill)
{
for (uint8_t m = 0; m < SSD1306_PAGES; m++)
{
ssd1306_setCursor(0, m);
ssd1306_fillToEOL(fill);
}
ssd1306_setCursor(0, 0);
}
void ssd1306_newLine_height(uint8_t fontHeight)
{
oledY+=fontHeight;
if (oledY > SSD1306_PAGES - fontHeight)
{
oledY = SSD1306_PAGES - fontHeight;
}
ssd1306_setCursor(0, oledY);
}
void ssd1306_newLine(void)
{
ssd1306_newLine_height(oledFont->height);
}
uint8_t ssd1306_write(uint8_t c)
{
if (!oledFont)
return 1;
if (c == '\r')
return 1;
uint8_t h = oledFont->height;
if (c == '\n')
{
ssd1306_newLine_height(h);
return 1;
}
uint8_t w = oledFont->width;
if (oledX > ((uint8_t)128 - w))
{
ssd1306_newLine_height(h);
}
uint16_t offset = ((uint16_t)c - oledFont->first) * w * h;
uint8_t line = h;
do
{
ssd1306_send_data_start();
for (uint8_t i = 0; i < w; i++)
{
ssd1306_send_data_byte(pgm_read_byte(&(oledFont->bitmap[offset++])));
}
i2c_stop();
if (h == 1)
{
oledX+=w;
}
else
{
if (line > 1)
{
ssd1306_setCursor(oledX, oledY + 1);
}
else
{
ssd1306_setCursor(oledX + w, oledY - (h - 1));
}
}
}
while (--line);
return 1;
}
void ssd1306_bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t bitmap[])
{
uint16_t j = 0;
for (uint8_t y = y0; y < y1; y++)
{
ssd1306_setCursor(x0,y);
ssd1306_send_data_start();
for (uint8_t x = x0; x < x1; x++)
{
ssd1306_send_data_byte(pgm_read_byte(&bitmap[j++]));
}
i2c_stop();
}
ssd1306_setCursor(0, 0);
}
void ssd1306_clearToEOL(void)
{
ssd1306_fillToEOL(0x00);
}
void ssd1306_fillToEOL(uint8_t fill)
{
ssd1306_fillLength(fill, 128 - oledX);
}
void ssd1306_fillLength(uint8_t fill, uint8_t length)
{
oledX += length;
ssd1306_send_data_start();
do
{
ssd1306_send_data_byte(fill);
}
while (--length);
i2c_stop();
}
void ssd1306_startData(void)
{
ssd1306_send_data_start();
}
void ssd1306_sendData(const uint8_t data)
{
ssd1306_send_data_byte(data);
}
void ssd1306_endData(void)
{
i2c_stop();
}
// Double Buffering Commands
void ssd1306_switchRenderFrame(void)
{
renderingFrame ^= 0x04;
}
void ssd1306_switchDisplayFrame(void)
{
drawingFrame ^= 0x20;
ssd1306_send_command(drawingFrame);
}
void ssd1306_switchFrame(void)
{
ssd1306_switchDisplayFrame();
ssd1306_switchRenderFrame();
}
uint8_t ssd1306_currentRenderFrame(void)
{
return (renderingFrame >> 2) & 0x01;
}
uint8_t ssd1306_currentDisplayFrame(void)
{
return (drawingFrame >> 5) & 0x01;
}
// 1. Fundamental Command Table
void ssd1306_setContrast(uint8_t contrast)
{
ssd1306_send_command2(0x81,contrast);
}
void ssd1306_setEntireDisplayOn(bool enable)
{
if (enable)
ssd1306_send_command(0xA5);
else
ssd1306_send_command(0xA4);
}
void ssd1306_setInverse(bool enable)
{
if (enable)
ssd1306_send_command(0xA7);
else
ssd1306_send_command(0xA6);
}
void ssd1306_off(void)
{
ssd1306_send_command(0xAE);
}
void ssd1306_on(void)
{
ssd1306_send_command(0xAF);
}
// 2. Scrolling Command Table
void ssd1306_scrollRight(uint8_t startPage, uint8_t interval, uint8_t endPage)
{
ssd1306_send_command7(0x26, 0x00, startPage, interval, endPage, 0x00, 0xFF);
}
void ssd1306_scrollLeft(uint8_t startPage, uint8_t interval, uint8_t endPage)
{
ssd1306_send_command7(0x27, 0x00, startPage, interval, endPage, 0x00, 0xFF);
}
void ssd1306_scrollRightOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset)
{
ssd1306_send_command6(0x29, 0x00, startPage, interval, endPage, offset);
}
void ssd1306_scrollLeftOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset)
{
ssd1306_send_command6(0x2A, 0x00, startPage, interval, endPage, offset);
}
void ssd1306_deactivateScroll(void)
{
ssd1306_send_command(0x2E);
}
void ssd1306_activateScroll(void)
{
ssd1306_send_command(0x2F);
}
void ssd1306_setVerticalScrollArea(uint8_t top, uint8_t rows)
{
ssd1306_send_command3(0xA3, top, rows);
}
// 3. Addressing Setting Command Table
void ssd1306_setColumnStartAddress(uint8_t startAddress)
{
ssd1306_send_command2(startAddress & 0x0F, startAddress >> 4);
}
void ssd1306_setMemoryAddressingMode(uint8_t mode)
{
ssd1306_send_command2(0x20, mode & 0x03);
}
void ssd1306_setColumnAddress(uint8_t startAddress, uint8_t endAddress)
{
ssd1306_send_command3(0x21, startAddress & 0x7F, endAddress & 0x7F);
}
void ssd1306_setPageAddress(uint8_t startPage, uint8_t endPage)
{
ssd1306_send_command3(0x22, startPage & 0x07, endPage & 0x07);
}
void ssd1306_setPageStartAddress(uint8_t startPage)
{
ssd1306_send_command(0xB0 | (startPage & 0x07));
}
// 4. Hardware Configuration (Panel resolution and layout related) Command Table
void ssd1306_setDisplayStartLine(uint8_t startLine)
{
ssd1306_send_command(0x40 | (startLine & 0x3F));
}
void ssd1306_setSegmentRemap(uint8_t remap)
{
ssd1306_send_command(0xA0 | (remap & 0x01));
}
void ssd1306_setMultiplexRatio(uint8_t mux)
{
ssd1306_send_command2(0xA8, (mux - 1) & 0x3F);
}
void ssd1306_setComOutputDirection(uint8_t direction)
{
ssd1306_send_command(0xC0 | ((direction & 0x01)<<3));
}
void ssd1306_setDisplayOffset(uint8_t offset)
{
ssd1306_send_command2(0xD3, offset & 0x3F);
}
void ssd1306_setComPinsHardwareConfiguration(uint8_t alternative, uint8_t enableLeftRightRemap)
{
ssd1306_send_command2(0xDA, ((enableLeftRightRemap & 0x01) << 5) | ((alternative & 0x01) << 4) | 0x02 );
}
// 5. Timing and Driving Scheme Setting Command table
void ssd1306_setDisplayClock(uint8_t divideRatio, uint8_t oscillatorFrequency)
{
ssd1306_send_command2(0xD5, ((oscillatorFrequency & 0x0F) << 4) | ((divideRatio -1) & 0x0F));
}
void ssd1306_setPrechargePeriod(uint8_t phaseOnePeriod, uint8_t phaseTwoPeriod)
{
ssd1306_send_command2(0xD9, ((phaseTwoPeriod & 0x0F) << 4) | (phaseOnePeriod & 0x0F));
}
void ssd1306_setVcomhDeselectLevel(uint8_t level)
{
ssd1306_send_command2(0xDB, (level & 0x07) << 4);
}
void ssd1306_nop(void)
{
ssd1306_send_command(0xE3);
}
// 6. Advance Graphic Command table
void ssd1306_fadeOut(uint8_t interval)
{
ssd1306_send_command2(0x23, (0x20 | (interval & 0x0F)));
}
void ssd1306_blink(uint8_t interval)
{
ssd1306_send_command2(0x23, (0x30 | (interval & 0x0F)));
}
void ssd1306_disableFadeOutAndBlinking(void)
{
ssd1306_send_command2(0x23, 0x00);
}
void ssd1306_enableZoomIn(void)
{
ssd1306_send_command2(0xD6, 0x01);
}
void ssd1306_disableZoomIn(void)
{
ssd1306_send_command2(0xD6, 0x00);
}
// Charge Pump Settings
void ssd1306_enableChargePump(void)
{
ssd1306_send_command2(0x8D, 0x14);
}
void ssd1306_disableChargePump(void)
{
ssd1306_send_command2(0x8D, 0x10);
}

View File

@ -0,0 +1,113 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*
* Port of Stephen Denne's Tiny4kOLED to C,
* without the Arduino framework dependency but with
* a hardcoded dependency on VeryTinyI2C.
*
* Original:
* https://github.com/technoblogy/tiny-i2c
*/
#ifndef __VeryTinySSD1306
#define __VeryTinySSD1306
#include <stdint.h>
#include <stdbool.h>
typedef struct {
uint8_t *bitmap; // character bitmaps data
uint8_t width; // character width in pixels
uint8_t height; // character height in pages (8 pixels)
uint8_t first, last; // ASCII extents
} DCfont;
#define SSD1306_DisplayWidth 128
#define SSD1306_DisplayHeight 32
#ifndef SSD1306
#define SSD1306 0x3C // Slave address
#endif
void ssd1306_begin_default(void);
void ssd1306_begin(uint8_t init_sequence_length, const uint8_t init_sequence []);
void ssd1306_switchRenderFrame(void);
void ssd1306_switchDisplayFrame(void);
void ssd1306_switchFrame(void);
uint8_t ssd1306_currentRenderFrame(void);
uint8_t ssd1306_currentDisplayFrame(void);
void ssd1306_setFont(const DCfont *font);
void ssd1306_setCursor(uint8_t x, uint8_t y);
void ssd1306_newLine();
void ssd1306_fill(uint8_t fill);
void ssd1306_fillToEOL(uint8_t fill);
void ssd1306_fillLength(uint8_t fill, uint8_t length);
void ssd1306_clear(void);
void ssd1306_clearToEOL(void);
void ssd1306_bitmap(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, const uint8_t bitmap[]);
void ssd1306_startData(void);
void ssd1306_sendData(const uint8_t data);
void ssd1306_endData(void);
// 1. Fundamental Command Table
void ssd1306_setContrast(uint8_t contrast);
void ssd1306_setEntireDisplayOn(bool enable);
void ssd1306_setInverse(bool enable);
void ssd1306_off(void);
void ssd1306_on(void);
// 2. Scrolling Command Table
void ssd1306_scrollRight(uint8_t startPage, uint8_t interval, uint8_t endPage);
void ssd1306_scrollLeft(uint8_t startPage, uint8_t interval, uint8_t endPage);
void ssd1306_scrollRightOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset);
void ssd1306_scrollLeftOffset(uint8_t startPage, uint8_t interval, uint8_t endPage, uint8_t offset);
void ssd1306_deactivateScroll(void);
void ssd1306_activateScroll(void);
void ssd1306_setVerticalScrollArea(uint8_t top, uint8_t rows);
// 3. Addressing Setting Command Table
void ssd1306_setColumnStartAddress(uint8_t startAddress);
void ssd1306_setMemoryAddressingMode(uint8_t mode);
void ssd1306_setColumnAddress(uint8_t startAddress, uint8_t endAddress);
void ssd1306_setPageAddress(uint8_t startPage, uint8_t endPage);
void ssd1306_setPageStartAddress(uint8_t startPage);
// 4. Hardware Configuration (Panel resolution and layout related) Command Table
void ssd1306_setDisplayStartLine(uint8_t startLine);
void ssd1306_setSegmentRemap(uint8_t remap);
void ssd1306_setMultiplexRatio(uint8_t mux);
void ssd1306_setComOutputDirection(uint8_t direction);
void ssd1306_setDisplayOffset(uint8_t offset);
void ssd1306_setComPinsHardwareConfiguration(uint8_t alternative, uint8_t enableLeftRightRemap);
// 5. Timing and Driving Scheme Setting Command table
void ssd1306_setDisplayClock(uint8_t divideRatio, uint8_t oscillatorFrequency);
void ssd1306_setPrechargePeriod(uint8_t phaseOnePeriod, uint8_t phaseTwoPeriod);
void ssd1306_setVcomhDeselectLevel(uint8_t level);
void ssd1306_nop(void);
// 6. Advance Graphic Command table
void ssd1306_fadeOut(uint8_t interval);
void ssd1306_blink(uint8_t interval);
void ssd1306_disableFadeOutAndBlinking(void);
void ssd1306_enableZoomIn(void);
void ssd1306_disableZoomIn(void);
// Charge Pump Settings
void ssd1306_enableChargePump(void);
void ssd1306_disableChargePump(void);
uint8_t ssd1306_write(uint8_t c);
#endif

83
module/src/main.c Normal file
View File

@ -0,0 +1,83 @@
/*
* Stairs lighting
* Copyright 2017 (c) Mark van Renswoude
*
* https://git.x2software.net/pub/Stairs
*/
#include <stdint.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "lib/TinyMillis.h"
#include "lib/TinyUART.h"
#include "lib/TinyRS485.h"
#include "global.h"
#include "display.h"
#define STEPS_DELAY_SHORT 200
#define STEPS_DELAY 800
#define STEPS_DELAY_LONG 2000
uint8_t uartRead(void)
{
return uart_getc();
}
uint8_t uartAvailable(void)
{
return uart_available();
}
void uartWrite(uint8_t what)
{
uart_putc(what);
}
typedef enum
{
WaitingForComm,
Connected
} State;
State currentState = WaitingForComm;
int main(void)
{
// Allow peripherals to start up before sending messages
_delay_ms(40);
global_init();
millis_init();
sei();
uart_init();
rs485_begin(uartRead, uartAvailable, uartWrite, 20);
display_init();
for (;;)
{
if (rs485_update())
{
// TODO get data
currentState = Connected;
}
switch (currentState)
{
case WaitingForComm:
display_drawWait();
break;
case Connected:
display_drawIndex();
break;
}
}
return 0;
}

1
module/upload.bat Normal file
View File

@ -0,0 +1 @@
@pio run -t program