Firmware for Arduino interconecting switch and shutter using relay board according to scheme
@startuml
class Arduino #pink
class Switch
class RelayBoard
Arduino *-- Switch
Arduino -- RelayBoard
RelayBoard *-- Shutter
@endul
The control logic is set by user defined state machine so it can be easily changed.
- install
arduino ide
usingSynaptic
- on directory
shutter_unit
processcompress to zip
, fileshutter_unit.zip
is created - run
arduino ide
- add
/library/shutter_unit
toarduino ide
Sketch -> Import Library -> Add Library
selectshutter_unit.zip
- open
/zaluzie_*np/zaluzie_*np.ino
- compile and upload to Arduino Uno
- for tests on PC use folder
zaluzie_pc
OPEN = UP direction CLOSE = DOWN direction
@startuml
(IDLE) --> (OPEN_MAN): UP_CLICK
(OPEN_MAN) --> (IDLE): UP_RELEASE
(OPEN_MAN) --> (PULL_UP): UP_PRESS
(PULL_UP) ..> IDLE: active_time > 60s
(PULL_UP) --> IDLE: DN_CLICK
(IDLE) --> (CLOSE_MAN): DN_CLICK
(CLOSE_MAN) --> (IDLE): DN_RELEASE
(CLOSE_MAN) --> (PULL_DN): DN_PRESS
(PULL_DN) ..> IDLE: active_time > 60s
(PULL_DN) --> IDLE: UP_CLICK
(PULL_DN) --> (PULL_DN_TO_OPEN): DN_CLICK
(PULL_DN_TO_OPEN) ..> (PULL_DN_OPEN): active_time > 60s
(PULL_DN_TO_OPEN) --> IDLE: UP_CLICK
(PULL_DN_OPEN) ..> (IDLE): active_time > 60.5s
@enduml
class ShutterUnit {
Setup()
Loop()
}
class Button {
Button::Event Loop(timeMs, isPushed)
}
class TwinButton {
EventId Loop(timeMs, IoState ioState)
}
class PlatformIf {
Setup()
IoState ReadSwitch()
WritePower(IoState state)
GetTimeMs()
}
class StateMachine {
OnTime(timeMs);
OnEvent(EventId eventId, timeMs);
StateId GetState();
}
class TranzitionMap {
SetEventTranzition(stateId, eventId, nextStateId)
SetDurationTranzition(stateId, nonIdleDurationMs, nextState)
StateId GetNextStateEvent(stateId, eventId)
StateId GetNextStateOnDuration(stateId, nonIdleDurationMs)
}
@startuml
ARDUINO.zaluzie_1NP *-- ShutterUnit
ARDUINO.zaluzie_2NP *-- ShutterUnit
PC.zaluzie_PC *-- ShutterUnit
ShutterUnit -- StateMachine
ShutterUnit -- TranzitionMap
StateMachine - TranzitionMap
ShutterUnit -- TwinButton
TwinButton *-- Button: 2
ShutterUnit -- PlatformIf
PlatformIf <-- PlatformArduino
PlatformIf <-- PlatformPc
PlatformPc -- InputSwitching
@enduml
Deployment examples - authors house.
- IN_OBYVAK(6) ... UP_LEFT, DOWN_LEFT, UP_RIGHT, DOWN_RIGHT, UP_TERAS, DOWN_TERAS
- OUT_OBYVAT(6)
- IN_PRAC(2) ... UP, DOWN
- OUT_PRAC(2)
- PATICE 0-7 (8) : IN_OBYV(6), IN_PRAC(2)
- PATICE 8-13 (6) piny 8-9 : OUT_PRAC(2)
- PATICE A0-A5 : OUT_OBYV(6)
- PATICE 0-7: 2,3,4,5,6,11,12,13
- PATICE 8-13: 14,15,16,17,18,19
- PATICE A0-A5: 23,24,25,26,27,28
- IN_POKOJ_VYCHOD(4) ... UP_VYCHOD, DOWN_VYCHOD, UP_JIH, DOWN_JIH
- OUT_POKOJ_VYCHOD(4)
- IN_POKOJ_ZAPAD(4) ... UP_JIH, DOWN_JIH, UP_ZAPAD, DOWN_ZAPAD
- OUT_POKOJ_ZAPAD
- IN_KOUPELNA(2) ... UP, DOWN
- OUT_KOUPELNA
- PATICE 0-7 (8) : IN_POKOJ_VYCHOD, IN_POKOJ_ZAPAD
- PATICE 8-13 (6) : piny 8-9: IN_KOUPELNA, piny 10-13: OUT_POKOJ_VYCHOD
- PATICE A0-A5(6) : piny 0-3: OUT_POKOJ_ZAPAD, piny 4-5: OUT_KOUPELNA