- Главная
- Культурология
- Light Shade Controls Arduino Functional Design
Содержание
- 2. Arduino Mega 2560 Light and Shade Controls Assumptions: Arduino Mega or clone used – Shade and
- 3. Arduino Mega 2560 Light and Shade Controls Future Development: Arduino web interface consolidation on Raspy Configuration
- 4. lightOffTimer Light Controls Light Status On Light Status Off OutPin High OutPin Low InPin High InPin
- 5. Light Controls Startup/Setup check for all timer values in EEPROM – if there use those if
- 6. Light Controls Main Loop Check if first start – if ArdID is not default then not
- 7. Light Controls Program Loop Check status of all InPin[x] If status is high – Check lightStatus[y]
- 8. Light Controls fnTurnOnLight(x) Debounce Timer – settable but currently 200ms Count number of times pressed in
- 9. Timer Shade Controls Shade Opening On Shade Stopped Off OutPinShadeUp High OutPinShadeUp Low InPin High InPin
- 10. Timer Shade Controls Shade Opening On Shade Stopped Off OutPinShadeDown High OutPinShadeDown Low InPin High Timer
- 11. Light Controls Startup/Setup check for all timer values in EEPROM – if there use those if
- 12. Light Controls Main Loop Check if first start – if ArdID is not default then not
- 13. Light Controls Program Loop Check status of all InPin[x] If status is high – Check lightStatus[y]
- 15. Скачать презентацию
Arduino Mega 2560 Light and Shade Controls
Assumptions:
Arduino Mega or clone used
Arduino Mega 2560 Light and Shade Controls
Assumptions:
Arduino Mega or clone used
Shade and Light control program on separate Megas – not combined on one
Try to maximize number of out pins and in pins on each version – lights and shades
Requirements Shades:
shadeUpTimer and shadeDownTimer implementation: critical to make sure up and down relays are never on at the same time
Configurable timer and switch to shade mapping via serial interface and web –
Configuration conserved across reset
Configurable to send shade and switch status via serial and/or web interface
NTP client
Webserver
HTTP
Heartbeat monitoring from Raspy – with configurable timeout – initially 30 minutes
UDP – used for initiation registration of arduino with Raspy
Broadcast
Multicast
Arduino Mega 2560 Light and Shade Controls
Future Development:
Arduino web interface consolidation
Arduino Mega 2560 Light and Shade Controls
Future Development:
Arduino web interface consolidation
Configuration storage in db on Raspy
ArdID storage on Raspy
Authentication controlled by Raspy through web interface
Tunneling out to cloud from Raspy
Registration Procedure
Secure communication – potentially implementation of chacha encryption if possible
Thoughts about this – maybe a second Arduino is needed just for the comms?
Physical interfaces
Input I/O protection against overload and EMF etc.
Output I/O protection against overcurrent
Transistors?
Optical isolation?
lightOffTimer
Light Controls
Light Status
On
Light Status
Off
OutPin
High
OutPin
Low
InPin
High
InPin
Low
ligntOffTimer
Start
Running
lightOffTimer
Stopped
lightOffTimer
Expire
Push
LightSwitch
Release
LightSwitch
debounce
lightOffTimer not yet implemented –
Timer to be
lightOffTimer
Light Controls
Light Status
On
Light Status
Off
OutPin
High
OutPin
Low
InPin
High
InPin
Low
ligntOffTimer
Start
Running
lightOffTimer
Stopped
lightOffTimer
Expire
Push
LightSwitch
Release
LightSwitch
debounce
lightOffTimer not yet implemented –
Timer to be
Light Status and Timer to be written to EEPROM to conserve the value through restart
lightTimerSet
After 1.5sec timeout
Count number of pushes and set lightOff Timer
Light Controls
Startup/Setup
check for all timer values in EEPROM – if there
Light Controls
Startup/Setup
check for all timer values in EEPROM – if there
lightTimer[numOfLights]
Light timer to be configurable during runtime – by webserver or serial interface or via switch as below
If light switch is pressed quickly [y] number of times then light timer is set to y*15minutes
check for Light Status for each light in EEPROM and set appropriate outPin – cycling through all pins and initializing – put a delay between each so that you don’t generate too much current at the same time
Intitialize all needed global variables
Initialize all inPins and outPins
Check for device ID in EEPROM – if none then starting first time – make firstTimeStart variable True
Check for Mac Address in EEPROM – if default then make defMac variable True
Setup Mapping of inPin[x] -> outPin[x] – many to one (I haven’t done this yet – not sure how)
This should be configurable – so not constants but changeable during runtime
Read timeOfDayOn[] timeOfDayOff[] for each light – default is always on – to be made configurable by the web server or serial interface
Light Controls
Main Loop
Check if first start – if ArdID is not
Light Controls
Main Loop
Check if first start – if ArdID is not
If NOT first time
Go to Program Loop
If first start init NTP, Webserver
Look for Raspy by sending out multicast or broadcast
Check for message from Raspy initiating registration
Raspy answers with raspyID and ArdID
Set ardRegWithRaspy = True
Raspy ID is written to EEPROM
ArdID is written to EEPROM
Maybe below is better in the Startup/Setup phase
Light Controls
Program Loop
Check status of all InPin[x]
If status is high –
Light Controls
Program Loop
Check status of all InPin[x]
If status is high –
Check lightStatus[y] where y is the light that is manipulated by this particular inPin[x] based on the mapping
If lightStatus is On
go into routine to turn off light
If lightStatus is Off
go into routine to turn on light
Check NTP and update clock
Check inbound ethernet interface and HTTP
Check connectivity to Raspy if exists and if registered – if ardRegWithRaspy = True
Check for request for configuration page on HTTP
Go to function to process inbout webpage
Go to function to process response
Back to start of Program Loop
Light Controls
fnTurnOnLight(x)
Debounce Timer – settable but currently 200ms
Count number of times
Light Controls
fnTurnOnLight(x)
Debounce Timer – settable but currently 200ms
Count number of times
If only once then use lightTimer[x] value as gotten when initialized
If more than once-
Start light timer based on above z*x where x = integer(minutes) or equivalent millis()
Set outPin[x] to value to turn on light – may be high or low depending on config
Set lightStatus[a] per config mapping
fnTurnOffLight(x)
Debounce Timer – settable but currently 200ms
Stop light timer
Set outPin[x] to value to turn off light depending on config
Set lightStatus[a] per config mapping
Timer
Shade Controls
Shade Opening
On
Shade Stopped
Off
OutPinShadeUp
High
OutPinShadeUp
Low
InPin
High
InPin
Low
Timer
Start
Running
Timer
Stopped
Timer
Expire
Push
LightSwitch
Release
LightSwitch
debounce
Timer required to calculate if shade full open
Timer
Shade Controls
Shade Opening
On
Shade Stopped
Off
OutPinShadeUp
High
OutPinShadeUp
Low
InPin
High
InPin
Low
Timer
Start
Running
Timer
Stopped
Timer
Expire
Push
LightSwitch
Release
LightSwitch
debounce
Timer required to calculate if shade full open
Total time for closing and opening and incremental positions by 10% independently so timer for closing is different than for opening as shade changes speed as it rolls up and down
Shade UP
shadeStatus
If Shade Opening/Closing
If Shade Not/Opening/Closing
inPinShadeUP
OutPinShadeDown
Low
Must be careful never to have both up and down relays active at the same time
OutPinShadeUP
Low
Timer
Shade Controls
Shade Opening
On
Shade Stopped
Off
OutPinShadeDown
High
OutPinShadeDown
Low
InPin
High
Timer
Start
Running
Timer
Stopped
Timer
Expire
Push
LightSwitch
debounce
Timer required to calculate if shade full open
Timer
Shade Controls
Shade Opening
On
Shade Stopped
Off
OutPinShadeDown
High
OutPinShadeDown
Low
InPin
High
Timer
Start
Running
Timer
Stopped
Timer
Expire
Push
LightSwitch
debounce
Timer required to calculate if shade full open
Total time for closing and opening and incremental positions by 10% independently so timer for closing is different than for opening as shade changes speed as it rolls up and down
Shade Down
shadeStatus
If Shade Opening/Closing
If Shade Not/Opening/Closing
inPinShadeDown
OutPinShadeUP
Low
Must be careful never to have both up and down relays active at the same time
OutPinShadeUP
Low
InPin
Low
Release
LightSwitch
Light Controls
Startup/Setup
check for all timer values in EEPROM – if there
Light Controls
Startup/Setup
check for all timer values in EEPROM – if there
shadeTimerUP[numOfShades]
shadeTimerDown[]
shadeStatus[numOfShades]
shade timers to be configurable during runtime –
By web interface or via serial interface
check for Shade Status for each Shade in EEPROM and set appropriate outPin – cycling through all pins and initializing – put a delay between each so that you don’t generate too much current at the same time
Intitialize all needed global variables
Initialize all inPins and outPins
Check for device ID in EEPROM – if none then starting first time – make firstTimeStart variable True
Check for Mac Address in EEPROM – if default then make defMac variable True
Setup Mapping of inPin[x] -> outPin[x] – many to one (I haven’t done this yet – not sure how)
This should be configurable – so not constants but changeable during runtime
Read timeOfDayStatus[] for each shade– default is always half open – to be made configurable by the web server or serial interface
Light Controls
Main Loop
Check if first start – if ArdID is not
Light Controls
Main Loop
Check if first start – if ArdID is not
If NOT first time
Go to Program Loop
If first start init NTP, Webserver
Look for Raspy by sending out multicast or broadcast
Check for message from Raspy initiating registration
Raspy answers with raspyID and ArdID
Set ardRegWithRaspy = True
Raspy ID is written to EEPROM
ArdID is written to EEPROM
Maybe below is better in the Startup/Setup phase
Light Controls
Program Loop
Check status of all InPin[x]
If status is high –
Light Controls
Program Loop
Check status of all InPin[x]
If status is high –
Check lightStatus[y] where y is the light that is manipulated by this particular inPin[x] based on the mapping
If lightStatus is On
go into routine to turn off light
If lightStatus is Off
go into routine to turn on light
Check NTP and update clock
Check inbound ethernet interface and HTTP
Check connectivity to Raspy if exists and if registered – if ardRegWithRaspy = True
Check for request for configuration page on HTTP
Go to function to process inbout webpage
Go to function to process response
Back to start of Program Loop