Cov txheej txheem:

Kev ntsuas kub kom raug ntawm Raspberry Pi 4: 3 Cov Kauj Ruam
Kev ntsuas kub kom raug ntawm Raspberry Pi 4: 3 Cov Kauj Ruam

Video: Kev ntsuas kub kom raug ntawm Raspberry Pi 4: 3 Cov Kauj Ruam

Video: Kev ntsuas kub kom raug ntawm Raspberry Pi 4: 3 Cov Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Kev ntsuas kub kom raug ntawm Raspberry Pi 4
Kev ntsuas kub kom raug ntawm Raspberry Pi 4

Pimoroni Fan Shim yog cov tshuaj zoo rau txo qhov kub ntawm koj Pi thaum nws kub. Cov neeg tsim khoom tseem muab software uas ua rau kiv cua thaum CPU kub nce siab tshaj qhov pib (piv txwv li 65 degrees). Qhov ntsuas kub sai sai hauv qab qhov pib qis dua thiab tua lub kiv cua. Qhov no yog qhov zoo tab sis ua rau qhov kub nce thiab poob qis hauv qhov hnyav thiab tsim cov suab nrov nrov ntxuam. Cov lus qhia no yuav txo qis lub suab nrov ntawm tus kiv cua thaum kho CPU kub rau tus nqi tshwj xeeb uas siv qee yam hu ua PID maub los. Qhov pib siab dua (piv txwv li 65 degrees) yuav ua rau muaj kiv cua nyob ntsiag to thaum qis dua (piv txwv li 50 degrees) yuav ua rau kiv cua nrov tab sis tswj tau qhov kub zoo dua.

Qhov piv txwv saum toj no qhia kuv cov txiaj ntsig los ntawm kev khiav PID tus tswj hwm thiab hloov pauv lub hom phiaj kev ua haujlwm txhua txhua 500 vib nas this. Qhov tseeb yog +/- 1 degree nrog qee qhov kev tshaj tawm ntawm kev hloov pauv sai hauv lub sijhawm ua haujlwm.

Qhov tseem ceeb, qhov kev xeem no tau tshwm sim nyob rau tib lub sijhawm rau tag nrho lub sijhawm sim (saib BBC iPlayer).

Khoom siv

  • Raspberry Pi 4
  • Pimoroni Fan Shim

Kauj Ruam 1: Teeb Koj Tus Kheej

Teeb Koj Tus Kheej
Teeb Koj Tus Kheej

Thawj kauj ruam yog teeb tsa koj tus kiv cua. Pimorini qhia tau zoo heev!

Tom qab ntawd qhib lub davhlau ya nyob twg ntawm koj Pi (ctrl alt t)

Thiab teeb tsa cov cai muab los ntawm Pimoroni

git clone https://github.com/pimoroni/fanshim-pythoncd fanshim-python sudo./install.sh

Kauj Ruam 2: Tsim PI (D) Tus Tswj

Tsim tus PI (D) Tus Tswj
Tsim tus PI (D) Tus Tswj

Tus Txheej Txheem Sib Piv Derivative (PID) tus tswj hwm yog lub kaw lus siv los tswj tus nqi ntawm qee yam txheej txheem (CPU kub) los ntawm kev siv qee yam khoom siv lub cev (kiv cua nrawm). Peb tuaj yeem siv lub 'nrawm' thiab lub suab nrov ntawm lub kiv cua los ntawm kev qhib nws thiab tawm ib ntus (Pulse Wave Modulation). Lub sijhawm nws nyob rau hauv ib lub sijhawm twg (piv txwv li 1 thib ob) txiav txim siab nrawm npaum li cas thiab lub suab nrov nrov li cas (900ms = nrov thiab nrawm, 100ms = nyob ntsiag to thiab qeeb). Peb yuav siv PID los tswj kev nrawm ntawm tus kiv cua thiab yog li tswj qhov ntsuas kub.

Peb tuaj yeem faib kev siv PID rau hauv cov lej.

  1. Txiav txim siab tus nqi ntawm cov txheej txheem sib txawv koj xav kom ua tiav (piv txwv li CPU kub = 55). Qhov no hu ua koj qhov teeb tsa.
  2. Xam PID yuam kev. Yog tias koj qhov teeb tsa yog 55 degrees thiab qhov kub tiag tiag yog 60 degrees koj qhov yuam kev yog 5 degrees (Kub - teeb tsa)
  3. Hloov lub sijhawm ntawm tus kiv cua hauv kev faib ua feem rau qhov ua yuam kev (Qhov ua yuam kev loj ua rau muaj kev hloov pauv loj hauv cov kiv cua nrawm, qhov ua yuam kev me me ua rau hloov pauv me me hauv kiv cua nrawm).
  4. Kho tus kiv cua hauv kev ua tswv cuab rau qhov txiaj ntsig yav dhau los (Ib qho/tag nrho ntawm txhua qhov ua yuam kev yav dhau los)
  5. Optionally koj hloov kho tus kiv cua nrawm raws li qhov hloov pauv ntawm qhov ua yuam kev (derivative) tab sis peb yuav tsis ua qhov no

Tam sim no koj muaj txoj kev xav khiav cov cai hauv qab no hauv Thonny IDE (lossis qee qhov nab npawb nab nab IDE). Hloov tus nqi ntawm 'phiaj' hauv cov cai hauv qab no txhawm rau hloov pauv thaj av uas koj xav kom tswj hwm koj li Pi ntawm. Kuv tau teeb tsa 'P' thiab 'Kuv' cov ntsiab lus ntawm qhov kev xav me ntsis. Xav tias dawb los kho cov no yog tias lawv tsis ua haujlwm rau koj. ua 'P' loj dua txhais tau tias tus tswj hwm yuav teb sai rau qhov yuam kev tshiab (tab sis yuav tsis ruaj khov). Hloov 'Kuv' yuav ua rau tus tswj kom hnyav nws cov lus teb ntau rau yav dhau los qhov tseem ceeb. Kuv yuav tsis sim ua cov ntsiab lus no loj li sai chaning tus kiv cua nrawm yuav tsis hloov pauv sai sai. Tsis tas li, yog tias koj tab tom ua haujlwm hnyav heev ntawm koj Pi koj yuav tsis ua tiav koj lub sijhawm xav tau (qhov txwv ntawm tus kiv cua tseem siv tau).

los ntawm fanshim ntshuam FanShim

los ntawm lub sijhawm ntshuam pw tsaug zog, lub sijhawm ntshuam os xa cov lej # Rov qab CPU kub raws li tus lej cim def def getCPUtemperature (): res = os.popen ('vcgencmd measure_temp'). readline () rov qab (res.replace ("temp =", " ").replace (" 'C / n "," ")) fanshim = FanShim () lub hom phiaj = 55 # yam xav tau kub (ua si nrog qhov no thiab pom dab tsi tshwm sim) lub sijhawm = 1 # PWM lub sijhawm ntawm =.1 # initialise rau 0 % lub voj voog ua haujlwm tawm = lub sijhawm-rau # pib rau 0% lub voj voog ua haujlwm P =.01 # qhov sib npaug nce lub sijhawm (ua si nrog qhov no thiab pom dab tsi tshwm sim) thiab pom dab tsi tshwm sim) thaum Tseeb: # tau txais kev npau taws temp = int (ntab (getCPUtemperature ())) # suav yuam kev thiab ua yuam kev du = temp-phiaj # suav suav nrog lerror thiab txwv nws intErr = intErr+yuam kev yog intErr> 10: intErr = 10 if intErr = period: on = period off = 0 else: on = on off = period-on # teeb tsa lub luag haujlwm yam tsawg kawg yog yog ntawm <.09: on =.09 else: on = on # PWM ntawm tus kiv cua pin ntawm == lub sijhawm: fanshim.set_fan (Tseeb) tsaug zog (ntawm) lwm tus: fanshim.set_fan (Tseeb) s leep (on) fanshim.set_fan (Cuav) pw (tawm)

Kauj Ruam 3: Khiav Tswj Tsab Ntawv ntawm Kev Pib

Khiav Control Script ntawm Startup
Khiav Control Script ntawm Startup

Koj tuaj yeem khiav tsab ntawv no txhua lub sijhawm koj pib koj tus pi lossis koj tuaj yeem muaj nws ua kom tsis siv neeg rov pib dua. Qhov no yooj yim heev ua nrog crontab.

  1. qhib lub davhlau ya nyob twg
  2. ntaus crontab-e rau hauv lub davhlau ya nyob twg
  3. ntxiv cov kab hauv qab ntawm cov cai rau cov ntawv '@reboot python /home/pi/bootScripts/fanControl.py &'
  4. tawm thiab reboot

Kuv muab tsab ntawv (fanControl.py) tso rau hauv floder hu ua bootScripts tab sis koj tuaj yeem tso nws nyob txhua qhov chaw tsuas yog xyuas kom tseeb tias koj qhia meej txoj hauv kev hauv crontab.

Txhua yam ua tiav! Tam sim no koj tus kiv cua yuav tswj qhov ntsuas kub ntawm koj CPU rau tus nqi tshwj xeeb, thaum txo qis cov suab nrov uas nws tsim tawm.

Pom zoo: