Cov txheej txheem:

Wakeup Light: 7 Kauj Ruam (nrog Duab)
Wakeup Light: 7 Kauj Ruam (nrog Duab)

Video: Wakeup Light: 7 Kauj Ruam (nrog Duab)

Video: Wakeup Light: 7 Kauj Ruam (nrog Duab)
Video: Tswv Yexus lub neej thaum pib txug thaum xaus 2024, Kaum ib hlis
Anonim
Wakeup Teeb
Wakeup Teeb

Raws li kuv sau cov lus qhia no nws yog lub caij ntuj no nyob rau sab qaum teb hemisphere thiab qhov ntawd txhais tau tias yog hnub luv thiab hmo ntuj ntev. Kuv tau siv los sawv thaum 06:00 thiab thaum Lub Caij Ntuj Sov lub hnub yuav ci tuaj thaum ntawd. Nyob rau lub caij ntuj no tab sis, nws tau txais lub teeb ntawm 09:00 yog tias peb muaj hmoo tau muaj ib hnub uas nws tsis pos huab (uas yog … tsis ntau).

Qee lub sij hawm dhau los kuv tau nyeem txog "lub teeb sawv" ua los ntawm Philips uas tau siv hauv Norway los ua piv txwv thaum tshav ntuj. Kuv yeej tsis tau yuav ib qho, tab sis kuv tseem xav txog kev ua ib qho vim tias ua rau koj tus kheej muaj kev lom zem ntau dua li tsuas yog yuav nws.

Khoom siv:

Daim duab thav duab "Ribba" 50 x 40 cm los ntawm IKEA

perforated hardboard los ntawm khw kho vajtse

STM8S103 pawg thawj coj loj ntawm Ebay lossis lwm tus

DS1307 Lub Sijhawm Tiag (Mouser, Farnell, Conrad, thiab lwm yam)

32768 Hz saib siv lead ua (Mouser, Farnell, Conrad, thiab lwm yam)

3V lithium coincell + coincell yas dhos

BUZ11 lossis IRLZ34N N-channel MOSFETs (3x)

BC549 (lossis lwm yam NPN transistor)

muaj ntau yam dawb, liab, xiav, ntsuab, thiab lwm yam coj raws li koj xav tau

ib co resistors thiab capacitors (saib schematic)

Powerbrick, 12V txog 20V, 3A lossis ntau dua (piv txwv li lub laptop qub lub zog tsim khoom)

Kauj Ruam 1: Ua Nws (Me Me) Yooj Yim Kom Sawv Daws

Ua Nws (Me Me) Yooj Yim Kom Sawv Daws
Ua Nws (Me Me) Yooj Yim Kom Sawv Daws

Lub tswv yim yog tias nws nyuaj rau sawv tawm thaum sawv ntxov thaum nws tseem tsaus ntuj. Thiab yog tias koj nyob ze lossis txawm nyob saum lub vojvoog Arctic nws yuav tsaus ntuj heev. Hauv cov chaw xws li Tromsö hauv Norway nws yuav tsis tau txais lub teeb pom kev zoo li nyob ntawd lub hnub poob ib nrab Kaum Ib Hlis tsuas yog rov tshwm sim ib nrab ntawm Januari.

Yog li dab tsi Philips tau ua yog sim ua kom lub hnub nce tuaj.

Philips maj mam nce qhov ci ntawm lub teeb, uas yog tej zaum ua nrog ntau lub leds tab sis zais tom qab ib qho diffuser. Lawv lub sijhawm los ntawm kev tawm mus rau qhov ci tag nrho yuav siv 30 feeb.

Lub teeb ci ntawm Philips tsis kim li tab sis nws tsuas muaj xim ib leeg thiab nws zoo li me ntsis. Kuv xav tias kuv tuaj yeem ua tau zoo dua.

Kauj Ruam 2: Xim Ntau

Ntau Xim
Ntau Xim

Kuv lub teeb pom kev siv plaub xim, dawb, liab, xiav thiab ntsuab. Ua ntej tshaj plaws cov leds dawb, tom qab ntawd tuaj liab, thiab kav ob peb xim xiav thiab ntsuab. Kuv lub tswv yim yog tias kuv tuaj yeem sim tsis tsuas yog nce qhov ci ci tab sis tseem hloov pauv ntawm lub teeb thaum sawv ntxov, los ntawm pib nrog me ntsis dawb, ntxiv liab me ntsis tom qab thiab sib xyaw hauv xiav thiab ntsuab thaum kawg. Kuv tsis paub tseeb tias nws zoo ib yam li lub teeb thaum sawv ntxov, tab sis kuv nyiam cov xim zoo li nws yog tam sim no.

Kuv kuj tseem nrawm dua li Philips lub teeb tsa lub teeb, hloov 30 feeb ntawm Philips lub teeb, kuv mus los ntawm 0% txog 100% ci ntsa iab hauv tsawg dua 5 feeb. Yog li kuv lub hnub nce ceev dua.

NCO TSEG:

Nws nyuaj heev kom ua duab ntawm kuv lub teeb pom kev, Kuv sim nrog ob peb lub koob yees duab thiab cov xov tooj tab sis txhua daim duab kuv tau ua tsis ua qhov ncaj ncees tiag.

Kauj Ruam 3: Sigmoid Curve, Flickering thiab "daws teeb meem"

Sigmoid nkhaus, Flickering thiab
Sigmoid nkhaus, Flickering thiab

Tau kawg kuv xav ua kom lub ntsej muag ci zoo li ua tau. Tib neeg lub qhov muag yog logarithmic hauv kev nkag siab, txhais tau tias hauv qhov tsaus ntuj tag nrho lawv nkag siab ntau dua li lawv nyob hauv nruab hnub nrig. Qhov nce me me ntawm qhov ci ci thaum qib qis "hnov" zoo ib yam li cov kauj ruam loj dua thaum lub teeb nyob ntawm 40% ci. Txhawm rau ua tiav qhov no kuv siv txoj kab nkhaus tshwj xeeb hu ua Sigmoid (lossis S-nkhaus) txoj kab nkhaus no pib ua qhov nkhaus nthuav dav uas ib nrab theem tawm ib nrab. Kuv pom tias nws yog ib txoj hauv kev zoo heev ntawm kev nce (thiab txo qis) qhov kev siv.

Lub moos zaus ntawm lub microcontroller (thiab cov timers) yog 16 MHz thiab kuv siv qhov kev daws teeb meem siab tshaj plaws ntawm TIMER2 (65536) los tsim peb lub mem tes dav dav (PWM). Yog li pulses tuaj 16000000 /65536 = 244 zaug hauv ib pliag. Ntawd yog qhov deb tshaj qhov txwv ntawm lub qhov muag kom pom ib qho flickering.

Yog li cov leds tau pub nrog PWM teeb liab uas tau ua nrog qhov 16 bittimer ntawm STM8S103 microcontroller. Yam tsawg kawg no PWM lub cim tuaj yeem yog ON yog 1 lub plawv dhia ntev thiab qhov seem 65535 lub plawv dhia ntev.

Yog li cov leds txuas nrog rau PM teeb liab ntawd yuav yog ON 1/65536-th ntawm lub sijhawm: 0.0015%

Qhov siab tshaj plaws lawv yog ON 65536/65536-th ntawm lub sijhawm: 100%.

Kauj ruam 4: Electronics

Electronics
Electronics
Electronics
Electronics
Electronics
Electronics
Electronics
Electronics

Microcontroller

Lub paj hlwb ntawm lub teeb tsa sawv yog STM8S103 microcontroller los ntawm STMicroelectronics. Kuv nyiam siv cov ntu uas tsuas muaj peev xwm txaus rau txoj haujlwm. Rau txoj haujlwm yooj yim raws li qhov no nws tsis yog qhov yuav tsum tau siv STM32 microcontrollers (kuv lwm qhov nyiam) tab sis Arduino UNO tsis txaus raws li kuv xav tau peb PWM cov cim nrog 16 kev daws teeb meem thiab tsis muaj lub sijhawm nrog peb qhov tso tawm ntawm UNO.

Lub Sijhawm Tiag

Lub sijhawm nyeem los ntawm DS1307 lub sijhawm tiag tiag uas ua haujlwm nrog 32768 Hz siv lead ua thiab muaj lub roj teeb 3V thaub qab.

Kev teeb tsa lub sijhawm tam sim no, hnub thiab lub sijhawm sawv los ua tiav nrog ob lub nyees khawm thiab pom ntawm 16 x 2 LCD cov cim cim. Txhawm rau kom kuv chav pw tsaus ntuj heev thaum hmo ntuj, lub teeb pom kev ntawm lub LCD tau hloov pauv tsuas yog thaum lub teeb ci dua li lub teeb ci thiab thaum koj teeb tsa lub sijhawm, nruab hnub thiab sawv ntxov.

Fais fab

Lub hwj chim los ntawm lub khoos phis tawj qub lub hwj chim, kuv tsim 12V thiab tuaj yeem xa 3A. Thaum koj muaj lwm lub hwj chim nws yuav tsim nyog los kho cov resistors hauv koob nrog cov hlua coj. (Saib hauv qab)

Leds

Cov leds tau txuas nrog 12V khoom siv, tas li ntawm cov khoom siv hluav taws xob ntawm 5V ua nrog 7805 txoj cai tswj kab. Hauv cov txheej txheem nws hais tias kuv siv TO220 tus tswj hwm, uas tsis xav tau raws li tus tswj hwm microcontroller, tso saib thiab lub sijhawm tiag tiag siv tsuas yog ob peb milliamps. Kuv lub moos siv me me TO92 version ntawm 7805 muaj peev xwm muab 150mA.

Kev hloov pauv ntawm cov hlua coj tau ua tiav nrog N-channel MOSFETs. Ib zaug ntxiv, hauv cov txheej txheem nws qhia lwm yam khoom siv dua li kuv tau siv. Kuv tau tshwm sim kom muaj peb qhov qub heev BUZ11 MOSFETs hloov tshiab IRLZ34N MOSFETs tshiab. Lawv ua haujlwm zoo

Tau kawg koj tuaj yeem tso ntau lub leds raws li koj nyiam, tsuav yog MOSFETs thiab cov khoom siv muaj peev xwm tuaj yeem ua haujlwm tam sim no. Hauv qhov txheej txheem kuv tau kos ib txoj hlua ntawm cov xim twg, qhov tseeb muaj ob peb xim sib xws rau lwm txoj hlua ntawm cov xim ntawd.

Kauj Ruam 5: Resistors (rau Leds)

Resistors (rau Leds)
Resistors (rau Leds)

Txog cov resistors hauv cov hlua coj. Cov xim dawb thiab xiav feem ntau muaj qhov hluav taws xob ntawm 2.8V hla lawv thaum lawv nyob rau qhov ci tag nrho.

Leds liab muaj tsuas yog 1.8V, kuv cov ntsuab ntsuab muaj 2V hla lawv ntawm qhov ci tag nrho.

Lwm qhov yog tias lawv qhov ci ci tsis zoo ib yam. Yog li nws tau coj qee qhov kev sim ua kom lawv zoo sib xws (rau kuv ob lub qhov muag). Los ntawm kev ua cov teeb ci sib npaug ntawm qhov ci ntsa iab, lawv tseem yuav zoo ib yam zoo ib yam ntawm qib qis, lub teeb liab dav dav ib txwm hloov pauv lawv ntawm qhov ci ci tab sis nyob rau lub sijhawm ntev dua thiab luv dua, koj lub qhov muag saib xyuas qhov nruab nrab.

Pib nrog kev suav zoo li no. Lub hwj chim muab (hauv kuv qhov teeb meem) 12V.

Plaub lub leds dawb hauv koob xav tau 4 x 2.8V = 11.2V, qhov no tawm 0.8V rau tus tiv thaiv.

Kuv tau pom tias lawv ci txaus ntawm 30mA yog li tus tiv thaiv yuav tsum yog:

0.8 / 0.03 = 26.6 hli Hauv cov txheej txheem koj pom tias kuv tso rau hauv 22 ohm resistor, ua rau cov leds tsuas yog me ntsis ci dua.

Cov leds xiav tau ci heev ntawm 30mA, tab sis piv zoo rau cov leds dawb ntawm 15 mA, lawv kuj muaj txog 2.8V hla lawv ntawm 15mA yog li kev suav yog 4 x 2.8V = 11.2V rov tawm 0.8V

0.8 / 0.015 = 53.3 ohm yog li kuv xaiv 47 ohm resistor.

Kuv cov leds liab tseem xav tau qee qhov 15 mA te zoo ib yam li lwm tus, tab sis lawv tsuas muaj 1.8V hla lawv ntawm qhov tam sim no. Yog li kuv tuaj yeem tso ntau ntxiv thiab tseem muaj qee qhov "chav" rau tus tiv thaiv.

Rau cov leds liab muab rau kuv 6 x 1.8 = 10.8V, yog li dhau qhov tiv thaiv yog 12 - 10.8 = 1.2V

1.2 / 0.015 = 80 ohm, Kuv ua rau 68 ohm. Ib yam li lwm tus, me ntsis me ntsis ci dua.

Cov leds ntsuab kuv siv yog ci ib yam li lwm qhov ntawm kwv yees li 20mA. Kuv xav tau tsuas yog ob peb (ib yam li cov xim xiav) thiab kuv tau xaiv muab plaub qhov ua ke. Ntawm 20mA lawv muaj 2, 1V hla lawv, muab 3 x 2.1 = 8.4V

12 - 8.4 = 3.6V rau tus tiv thaiv. Thiab 3.6 / 0.02 = 180 ohm.

Yog tias koj tsim lub teeb tsa thaum sawv ntxov no nws tsis zoo li koj muaj lub zog zoo ib yam, koj yuav tsum hloov tus lej ntawm cov leds hauv koob thiab cov tiv thaiv xav tau.

Piv txwv me me. Hais tias koj muaj lub zog xa khoom uas muab 20V. Kuv yuav xaiv teeb 6 xiav (thiab dawb) coj hauv kab, 6 x 3V = 18V yog li 2V rau tus tiv thaiv. Thiab cia hais tias koj nyiam qhov ci ci ntawm 40mA. Tus resistor yuav tsum yog 2V / 0.04 = 50 ohm, 47 ohm resistor yuav zoo.

Kuv qhia kom tsis txhob mus siab dua 50mA nrog qhov zoo ib yam (5mm) leds. Qee tus tuaj yeem lis ntau dua, tab sis kuv nyiam nyob ntawm qhov nyab xeeb.

Kauj ruam 6: Software

Txhua tus lej tuaj yeem rub tawm los ntawm:

gitlab.com/WilkoL/wakeup_light_stm8s103

khaws qhov chaws qhib, nyob ib sab ntawm cov lus qhia no yog tias koj xav ua raws cov lus piav qhia.

Main.c

Main.c xub teeb tsa lub moos, timers thiab lwm yam khoom siv ntxiv. Feem ntau ntawm "tus tsav tsheb" Kuv tau sau siv Standard Library los ntawm STMicroelectronics thiab yog tias koj muaj lus nug txog lawv, sau nws hauv kab lus hauv qab cov lus qhia.

Eeprom

Kuv tawm ntawm "ntawv los tso saib" cov cai uas kuv siv los sau cov ntawv hauv eeprom ntawm STM8S103 raws li cov lus pom. Kuv tsis paub tseeb tias kuv muaj lub cim xeeb nyem txaus rau txhua qhov kuv tus lej yog li kuv tau sim muab ntau npaum li ua tau hauv eeprom kom muaj txhua qhov nyem rau qhov haujlwm. Thaum kawg qhov pov thawj tsis tsim nyog thiab kuv tau txav cov ntawv mus nyem. Tab sis kuv tso nws raws li tau hais tawm cov ntawv hauv cov ntawv main.c. Nws yog qhov zoo kom muaj nws, thaum kuv xav tau ua qee yam zoo sib xws tom qab (hauv lwm qhov haujlwm)

Lub eeprom tseem siv, tab sis tsuas yog khaws cia lub sijhawm sawv.

Ib zaug thib ob

Tom qab teeb tsa cov khoom siv sab nraud cov cai ntsuas yog tias ib thib ob dhau los (ua tiav nrog lub sijhawm).

Ntawv qhia zaub mov

Yog tias yog qhov xwm txheej nws kuaj xyuas yog tias lub pob nyem, yog li nws nkag mus rau hauv cov ntawv qhia zaub mov uas koj tuaj yeem teev sijhawm tam sim no, hnub ntawm lub lim tiam thiab lub sijhawm sawv. Nco ntsoov tias nws siv sijhawm li 5 feeb los ntawm kev tawm mus rau qhov ci tag nrho, yog li teeb tsa lub sijhawm sawv ntxov ua ntej me ntsis.

Lub sijhawm sawv los yog khaws cia hauv eeprom kom txawm tias tom qab lub hwj chim tsis txaus nws yuav "paub" thaum twg yuav tsa koj. Lub sijhawm tam sim no tau khaws cia hauv lub sijhawm tiag tiag ntawm chav kawm.

Sib piv tam sim no & sijhawm sawv

Thaum tsis muaj khawm tau nyem nws txheeb xyuas lub sijhawm tam sim no thiab muab piv rau lub sijhawm sawv thiab hnub ua haujlwm. Kuv tsis xav kom nws tsa kuv thaum hnub so:-)

Feem ntau tsis muaj dab tsi yuav tsum tau ua yog li nws teeb tsa qhov sib txawv "leds" rau OFF lwm tus rau ON. Qhov sib txawv no tau tshuaj xyuas ua ke nrog "hloov pauv _ qhov hnyav" teeb liab, uas tseem yog los ntawm lub sijhawm thiab ua haujlwm 244 zaug hauv ib pliag. Yog li thaum qhov "leds" sib txawv yog ON qhov siv tau nce 244 zaug hauv ib pliag thiab thaum nws OFF yog txo 244 zaug hauv ib pliag. Tab sis qhov nce mus rau ib qib uas qhov kev txo qis hauv cov kauj ruam ntawm 16 lub ntsiab lus tias thaum lub teeb tsa tsaug zog tau cia siab ua nws txoj haujlwm, nws tua 16 zaug sai dua tab sis tseem ua tau zoo.

Smoothness thiab OUT OF MEMORY

Qhov ua tau zoo los ntawm Sigmoid nkhaus suav. Kev suav yog yooj yim heev tab sis nws yuav tsum tau ua nyob rau hauv qhov taw tes ntab hloov pauv (ob npaug) vim tias qhov exp () muaj nuj nqi, saib cov ntawv sigmoid.c.

Hauv qhov xwm txheej txheej txheej, Cosmic compiler / linker tsis muaj kev txhawb nqa rau cov ntsiab lus ntab ntab. Hloov nws yog qhov yooj yim (ib zaug koj tau pom nws) tab sis yog los nrog kev nce qib loj. Qhov kev nce no tau ntau dhau los ua kom cov cai haum hauv flash nco thaum ua ke nrog kev ua haujlwm sprintf (). Thiab qhov haujlwm ntawd xav tau los hloov cov lej rau hauv cov ntawv rau cov zaub.

Nws ()

Txhawm rau daws qhov teeb meem no kuv tsim lub itoa () muaj nuj nqi. Qhov no yog Kev Sib Koom Rau Ascii ua haujlwm uas zoo ib yam, tab sis tsis suav nrog STMicroelectronics tus qauv tsev qiv ntawv, lossis nrog Cosmic cov tsev qiv ntawv.

Kauj Ruam 7: IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)

IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)
IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)
IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)
IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)
IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)
IKEA (Peb Yuav Ua Li Cas Yog Tsis Muaj Lawv)

Daim duab los ntawm yuav los ntawm IKEA. Nws yog Ribba thav duab ntawm 50 x 40cm. Cov thav duab no tuab heev thiab ua rau nws zoo rau zais cov khoom siv hluav taws xob tom qab nws. Hloov chaw ntawm daim ntawv loj loj lossis duab kuv muab tso rau hauv ib qho ntawm cov ntawv tawv tawv. Koj tuaj yeem yuav nws ntawm lub khw muag khoom kho vajtse qhov nws qee zaum hu ua "lub txaj txaj" Nws muaj qhov me me hauv nws uas ua rau nws zoo tagnrho rau kev tso hauv leds. Hmoov tsis zoo qhov nyob hauv kuv lub rooj tsavxwm loj dua 5 mm yog li kuv yuav tsum tau siv cov kua nplaum kub rau "teeb tsa" lub teeb.

Kuv tau ua lub qhov plaub fab nyob hauv nruab nrab ntawm lub rooj tsav tsheb nyuaj rau 16x2 zaub thiab nias nws hauv. PCB nrog txhua yam khoom siv hluav taws xob dai ntawm cov zaub no, nws tsis txuas rau lwm yam.

Cov tawv tawv tawv tawv tau pleev xim dub thiab tab sis nyob hauv qab daim lev. Kuv tau laum ob lub qhov nyob rau hauv tus ncej rau cov nyees khawm kom teem sijhawm thiab hnub tim, raws li lub thav duab yog tuab heev Kuv yuav tsum nthuav lub qhov nyob sab hauv ntawm tus ncej kom ua cov nyees khawm tawm kom txaus.

Pom zoo: