Cov txheej txheem:

Raspberry Pi Impact Force Monitor !: 16 Cov Kauj Ruam (nrog Duab)
Raspberry Pi Impact Force Monitor !: 16 Cov Kauj Ruam (nrog Duab)

Video: Raspberry Pi Impact Force Monitor !: 16 Cov Kauj Ruam (nrog Duab)

Video: Raspberry Pi Impact Force Monitor !: 16 Cov Kauj Ruam (nrog Duab)
Video: doubling the drop every time the PC survives #shorts 2024, Kaum ib hlis
Anonim
Image
Image
Pom Kev Nyeem Ntawv
Pom Kev Nyeem Ntawv

Muaj kev cuam tshuam ntau npaum li cas tib neeg lub cev tuaj yeem ua tau? Txawm hais tias nws yog ncaws pob, nce pob zeb, lossis caij tsheb kauj vab, kev paub thaum twg yuav nrhiav kev kho mob tam sim tom qab kev sib tsoo yog qhov tseem ceeb heev, tshwj xeeb tshaj yog tias tsis muaj cov cim qhia pom ntawm kev raug mob. Phau ntawv qhia no yuav qhia koj li cas los tsim koj tus kheej lub zog saib xyuas lub zog!

Lub Sijhawm Nyeem Ntawv: ~ 15 feeb

Tsim Sijhawm: ~ 60-90 feeb

Qhov haujlwm qhib qhov no siv Raspberry Pi Zero W thiab LIS331 ntsuas lub ntsuas kom ntsuas thiab ceeb toom cov neeg siv ntawm G-rog uas muaj peev xwm txaus ntshai. Yog lawm, xav tias yuav hloov kho thiab hloov kho qhov system kom haum rau koj cov kev xav tau ntawm pej xeem ntau yam.

Nco tseg: Tsim cov khoom lom zem nrog Impact Force Monitor! Txawm li cas los xij, thov tsis txhob siv nws los hloov pauv rau kev qhia paub kho mob thiab kuaj mob. Yog tias koj xav tias koj tau poob qhov hnyav, thov mus ntsib tus kws tshaj lij thiab muaj ntawv tso cai rau kev kho kom raug.

Kauj Ruam 1: Pom Kev Nyeem Ntawv

Txhawm rau ua qhov kev qhia luv luv n 'qab zib (er, zoo, ntau li ntau tau), Kuv xav tias koj tab tom pib ua haujlwm Pi Zero W. Xav tau kev pab? Tsis muaj teeb meem! Nov yog daim ntawv qhia teeb tsa tag nrho.

Peb tseem yuav txuas nrog Pi nyob deb (aka wirelessly). Yog xav paub ntau ntxiv txog cov txheej txheem no txheeb xyuas qhov kev qhia no.

** Nkees lossis xav kawm ntxiv? Nov yog qee cov peev txheej siv tau: **

1. Qhia tau zoo "Pib Pib" rau Pi.

2. Daim ntawv qhia kev sib txuas tag nrho rau LIS331 lub ntsuas hluav taws xob tawm suab.

3. Ntau ntxiv txog kev ntsuas nrawm!

4. Txheej txheem cej luam ntawm Raspberry Pi GPIO pins.

5. Siv tsheb npav SPI thiab I2C Serial ntawm Pi.

6. LIS331 Cov Ntaub Ntawv

Kauj ruam 2: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv
  • Raspberry Pi Zero W Basic Kit

    • Cov khoom siv no suav nrog cov hauv qab no: SD Card w/ NOOBS Operating System; USB OTG cable (microUSB rau USB poj niam); Mini HDMI rau HDMI; MicroUSB fais fab mov (~ 5V)
    • Kuj pom zoo: USB hub
  • Raspberry Pi 3 Header Pins
  • LIS331 Accelerometer Breakout Board
  • Roj teeb pob w/ MicroUSB txuas
  • 5mm Liab LED
  • 1 k Resistor
  • 6 "Cov cua sov ntsws los yog kab xev hluav taws xob
  • Header pins rau accelerometer (4 - 8) thiab LED (2)
  • Poj niam-rau-poj niam jumper xov hlau (6)

Cov cuab yeej

  • Soldering Hlau & accessories
  • Epoxy (lossis lwm yam ruaj khov, tsis ua kua nplaum)
  • Tej zaum tseem txiab txiab:)

Kauj ruam 3: Tab sis Tos! Impact Force yog dab tsi?

Hmoov zoo, lo lus "cuam tshuam lub zog" yog qhov yooj yim zoo nkauj: qhov muaj zog hauv qhov cuam tshuam. Zoo li ntau yam txawm hais tias, ntsuas nws xav tau lub ntsiab lus tseeb dua. Qhov sib npaug rau kev cuam tshuam lub zog yog:

F = KE/d

qhov twg F yog lub zog cuam tshuam, KE yog lub zog hluav taws xob (lub zog ntawm kev txav mus los), thiab d yog qhov cuam tshuam nrug, lossis ntau npaum li cas cov khoom tawg. Muaj ob qhov tseem ceeb coj los ntawm qhov sib npaug no:

1. Lub zog cuam tshuam ncaj qha rau lub zog hluav taws xob, txhais tau tias lub zog cuam tshuam nce yog tias lub zog hluav taws xob nce ntxiv.

2. Qhov cuam tshuam quab yuam yog qhov rov qab sib piv rau qhov cuam tshuam nrug, txhais tau tias qhov kev cuam tshuam qis dua yog tias qhov cuam tshuam nrug nce (Qhov no yog vim li cas peb thiaj li muaj lub hnab cua: txhawm rau txhawm rau txhawm rau cuam tshuam peb.)

Kev quab yuam feem ntau ntsuas hauv Newtons (N), tab sis kev cuam tshuam lub zog tuaj yeem tham txog qhov "G-Force", tus lej qhia raws li ntau ntawm g, lossis lub ntiaj teb lub ntiajteb txawj nqus nrawm (9.8 m/s^2). Thaum peb siv chav G-quab yuam, peb tab tom ntsuas cov khoom nrawm uas txheeb ze kom tsis txhob poob rau lub ntiaj teb.

Kev hais lus zoo, g yog kev nrawm, tsis yog lub zog, tab sis nws muaj txiaj ntsig thaum tham txog kev sib tsoo vim tias kev nrawm* yog dab tsi ua rau tib neeg lub cev puas tsuaj.

Txog qhov haujlwm no, peb yuav siv G-quab yuam los txiav txim seb puas muaj kev phom sij txaus ntshai thiab tsim nyog tau txais kev kho mob. Kev tshawb fawb tau pom tias g-rog siab dua 9G tuaj yeem ua rau neeg tuag coob (tsis muaj kev qhia tshwj xeeb), thiab 4-6G tuaj yeem ua rau muaj kev phom sij yog txhawb nqa ntau dua li ob peb feeb.

Paub txog qhov no, peb tuaj yeem teeb tsa peb lub zog saib xyuas kom ceeb toom rau peb yog tias peb lub ntsuas ntsuas ntsuas G-quab yuam siab dua ib qho ntawm cov pib no. Huag, science!

Yog xav paub ntxiv, nyeem txog kev cuam tshuam thiab g-quab yuam ntawm Wikipedia!

Kev nrawm yog kev hloov pauv nrawm thiab/lossis kev taw qhia

Kauj Ruam 4: teeb tsa Pi Zero W

Configure Pi Zero W
Configure Pi Zero W

Sau koj li Raspberry Pi Zero thiab cov khoom siv los teeb tsa Pi kom tsis muaj hau!

  • Txuas tus Pi mus rau tus saib thiab cuam tshuam cov khoom siv sib txuas (keyboard, nas), ntsaws rau hauv lub hwj chim, thiab nkag mus.
  • Hloov kho software kom koj Pi nrawm & nyab xeeb. Qhib lub davhlau ya nyob twg qhov rai thiab ntaus cov lus txib no:

    Ntaus thiab nkag mus:

sudo apt-tau hloov tshiab

Ntaus thiab nkag mus:

sudo apt-tau hloov tshiab

Pib dua:

sudo kaw -r tam sim no

Kauj ruam 5: Pab kom WiFi & I2C

Pab kom WiFi & I2C
Pab kom WiFi & I2C
Pab kom WiFi & I2C
Pab kom WiFi & I2C
Pab kom WiFi & I2C
Pab kom WiFi & I2C
  • Nyem rau lub cim WiFi ntawm lub kaum sab xis saum toj ntawm lub desktop thiab txuas rau koj li WiFi network.
  • Hauv lub davhlau ya nyob twg hom lus txib no kom coj Pi's Software Configuration Tool:

sudo raspi-teeb tsa

  • Xaiv "Kev xaiv cuam tshuam", tom qab ntawd "SSH", thiab xaiv "Yog" hauv qab kom pab tau.
  • Rov qab mus rau "Kev xaiv cuam tshuam", tom qab ntawd "I2C", thiab xaiv "Yog" los pab.
  • Hauv lub davhlau ya nyob twg, teeb tsa cov software txuas rau lub desktop deb:

sudo apt-tau nruab xrdp

  • Ntaus 'Y' (yog) ntawm koj cov keyboard rau ob qho tib si.
  • Nrhiav Pi tus IP chaw nyob los ntawm kev hla lub WiFi txuas (koj kuj tseem xav sau nws).
  • Hloov Pi tus password nrog passwd hais kom ua.

Kauj Ruam 6: Pib dua Pi thiab Nkag Mus Hauv Qhov Chaw

Rov pib dua Pi thiab nkag mus rau hauv Chaw Nyob
Rov pib dua Pi thiab nkag mus rau hauv Chaw Nyob

Tam sim no peb tuaj yeem tso HDMI thiab cov khoom siv txuas ntxiv, woohoo!

  • Teeb lub chaw taws teeb duab sib txuas.

    • Ntawm lub PC, qhib Kev Txuas Hluav Taws Xob Desktop (lossis PuTTY yog tias koj xis nyob nrog qhov ntawd).
    • Rau Mac/Linux, koj tuaj yeem nruab qhov program no lossis siv VNC program.
  • Nkag mus rau IP rau Pi thiab nyem "Txuas" (Tsis quav ntsej cov lus ceeb toom txog cov cuab yeej tsis paub).
  • Nkag mus rau Pi siv koj daim ntawv pov thawj thiab tam sim ntawd peb mus!

Kauj Ruam 7: Tsim Nws: Electronics

Tsim Nws: Electronics!
Tsim Nws: Electronics!
Tsim Nws: Electronics!
Tsim Nws: Electronics!

Ob daim duab saum toj no qhia cov phiaj xwm hluav taws xob rau txoj haujlwm no thiab Pi Zero Pinout. Peb yuav xav tau ob qho los daws cov kev sib txuas ntawm cov khoom siv.

Nco tseg: LIS331 pawg thawj coj tawg hauv cov txheej txheem yog cov laus dua - siv tus lej cim rau kev taw qhia

Kauj Ruam 8: Txuas Accelerometer mus rau Pi's GPIO

Txuas Accelerometer mus rau Pi's GPIO
Txuas Accelerometer mus rau Pi's GPIO
Txuas Accelerometer mus rau Pi's GPIO
Txuas Accelerometer mus rau Pi's GPIO
Txuas Accelerometer mus rau Pi's GPIO
Txuas Accelerometer mus rau Pi's GPIO
  • Cov laug thiab ua tib zoo tshem tawm ib qho seem uas seem ntawm qhov nrawm thiab Pi GPIO tus header pins.
  • Tom qab ntawd txuas cov xov hlau txuas nruab nrab ntawm LIS331 cov pawg tawm tsam thiab Pi ntawm cov pins hauv qab no:

LIS331 Breakout Board Raspberry Pi GPIO Pin

GND GPIO 9 (GND)

VCC GPIO 1 (3.3V)

SDA GPIO 3 (SDA)

SCL GPIO 5 (SCL)

Txhawm rau ua kom yooj yim dua los txuas lub ntsuas hluav taws xob rau Pi Zero, ib qho kev hloov kho tau tsim los ntawm kev siv tus poj niam lub taub hau thiab cov xov hluav taws xob. Thaum tshav kub kub ntsws tau ntxiv tom qab kuaj cov kev sib txuas

Kauj Ruam 9: Ntxiv Alert LED

Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
Ntxiv Alert LED!
  • Siv lub zog tam sim no tiv thaiv tus tsis zoo ntawm LED ceg (ceg luv dua) thiab ntxiv cov qhwv qhwv (lossis kab xev hluav taws xob) rau rwb thaiv tsev.
  • Siv ob lub jumper cable lossis lub taub hau taub hau los txuas qhov zoo LED ceg rau GPIO26 thiab tus tiv thaiv rau GND (txoj haujlwm header 37 thiab 39, feem).
  • Txuas lub roj teeb pob mus rau Pi lub zog siv hluav taws xob kom ua tiav kev teeb tsa!

Kauj ruam 10: Program Nws

Program nws!
Program nws!

Python code rau txoj haujlwm no yog qhib-qhov! Nov yog qhov txuas rau GitHub chaw cia khoom.

Rau Folks Tshiab rau Programming:

Nyeem los ntawm txoj haujlwm program thiab cov lus pom. Tej yam uas hloov pauv tau yooj yim yog nyob hauv ntu "Tus Neeg Siv Khoom Siv" nyob rau saum toj

Rau Cov Neeg Nyuaj Siab Tshaj nrog w/ Technical 'Deets:

Qhov haujlwm no pib LIS331 ntsuas lub ntsuas nrog lub teeb tsa ua ntej, suav nrog lub zog qub thiab 50Hz cov ntaub ntawv tus nqi. Nyeem los ntawm daim ntawv LIS331 thiab hloov kho qhov pib ua ntej raws li xav tau

Txhua

  • Qhov ntsuas qhov nrawm tshaj plaws siv hauv txoj haujlwm no yog 24G, vim tias kev cuam tshuam lub zog tau nrawm tiag tiag!
  • Nws raug nquahu kom tawm tswv yim tawm cov lus tshaj tawm nrawm hauv lub luag haujlwm tseem ceeb thaum koj npaj txhij rau kev xa tawm tag nrho.

Ua ntej koj pib qhov program, xyuas ob zaug tias qhov chaw nyob nrawm yog 0x19. Qhib lub davhlau ya nyob twg qhov rai thiab teeb tsa qee cov cuab yeej pab tau nrog cov lus txib no:

sudo apt-tau nruab -y i2c-cuab yeej

Tom qab ntawd khiav qhov program i2cdetect:

i2cdetect -y 1

Koj yuav pom lub rooj ntawm I2C chaw nyob tso tawm raws li pom hauv daim duab saum toj no. Piv txwv tias qhov no tsuas yog siv I2C txuas nrog, tus lej koj pom (hauv qhov no: 19) yog qhov chaw nyob nrawm! Yog tias koj pom tus lej sib txawv, sau tseg thiab hloov pauv hauv txoj haujlwm (hloov pauv ntxiv).

Kauj Ruam 11: Txheej Txheem Txheej Txheem Ceev

Txheej txheem cej luam ntawm Txoj Haujlwm
Txheej txheem cej luam ntawm Txoj Haujlwm

Qhov kev zov me nyuam nyeem x, y, thiab z nrawm dua, suav lub zog g, thiab tom qab ntawd khaws cov ntaub ntawv hauv ob daim ntawv (hauv tib daim nplaub tshev raws li qhov program program) raws li qhov tsim nyog:

  • AllSensorData.txt-muab lub sijhawm cim tseg ua raws g-quab yuam hauv x, y, thiab z axes.
  • AlertData.txt - zoo ib yam li saum toj no tab sis tsuas yog rau kev nyeem ntawv uas siab dua peb qhov kev nyab xeeb (qhov pib ntawm 9G lossis 4G ntau dua 3 vib nas this).

G-rog saum peb qhov kev nyab xeeb tseem yuav qhib rau peb ceeb toom LED thiab khaws nws kom txog thaum peb rov pib qhov haujlwm. Nres qhov kev zov me nyuam los ntawm kev ntaus "CTRL+c" (keyboard cuam tshuam) hauv qhov hais kom ua davhlau ya nyob twg.

Daim duab saum toj no qhia ob qho ntaub ntawv cov ntaub ntawv tsim thaum sim.

Kauj Ruam 12: Xeem Qhov System

Kuaj Qhov System!
Kuaj Qhov System!
Kuaj Qhov System!
Kuaj Qhov System!

Qhib lub davhlau ya nyob twg qhov rai, mus rau daim nplaub tshev uas koj tau khaws cov program program siv cov lus txib cd.

cd txoj kev/rau/nplaub tshev

Khiav qhov program siv cov cai hauv paus:

sudo nab hab sej NameOfFile.py

Txheeb xyuas tias qhov ntsuas nrawm hauv x, y, thiab z-kev taw qhia tau luam tawm mus rau lub qhov rai qhov rai, tsim nyog, thiab qhib lub teeb LED yog tias g-quab yuam yog siab dua peb qhov pib.

  • Txhawm rau ntsuas, tig lub ntsuas qhov ntsuas kom txhua lub axis taw tes rau lub ntiaj teb thiab txheeb xyuas tias qhov ntsuas ntsuas yog 1 lossis -1 (sib npaug rau kev nrawm vim yog lub ntiajteb txawj nqus).
  • Co co lub ntsuas cua kom paub tseeb tias kev nyeem nce ntxiv (kos npe qhia qhov taw qhia ntawm txoj kab, peb nyiam tshaj plaws ntawm qhov nyeem tau).

Kauj Ruam 13: Kev Ruaj Ntseg Hluav Taws Xob Txuas & Nruab Nws

Ruaj Ntseg Hluav Taws Xob Cov Hluav Taws Xob & Nruab Nws!
Ruaj Ntseg Hluav Taws Xob Cov Hluav Taws Xob & Nruab Nws!

Thaum txhua yam ua haujlwm tau zoo, cia peb paub tseeb tias lub zog saib xyuas puas tuaj yeem tiv taus qhov cuam tshuam!

  • Siv lub raj cua sov thiab/lossis lub tsho tiv thaiv hluav taws xob txuas rau lub ntsuas cua thiab LED hauv epoxy.
  • Rau qhov ruaj khov, kev teeb tsa ruaj khov, txiav txim siab txheej tag nrho shebang hauv epoxy: Pi Zero, LED, thiab lub ntsuas cua (tab sis tsis yog Pi cable txuas lossis SD daim npav).

    Ceeb toom! Koj tseem tuaj yeem nkag mus rau Pi thiab ua txhua yam khoom siv hauv computer, tab sis lub tsho epoxy tag nrho yuav tiv thaiv kev siv GPIO pins rau cov phiaj xwm yav tom ntej. Xwb, koj tuaj yeem ua lossis yuav cov ntaub ntawv tshwj xeeb rau Pi Zero, txawm hais tias kuaj xyuas kom ruaj khov

Ruaj ntseg rau lub kaus mom hlau, koj tus neeg, lossis hom kev thauj mus los zoo li koj lub skateboard, tsheb kauj vab, lossis miv*!

Ua tiav qhov ntsuas tias Pi tau nrawm nrawm los yog GPIO tus pin yuav dhau los ua qhov kev pab cuam poob.

*Nco tseg: Kuv xub xav ntaus "tsheb", tab sis xam pom qhov cuam tshuam cuam tshuam rau tus miv kuj tseem yuav tsim qee cov ntaub ntawv nthuav tawm (nrog kitty kev tso cai, tau kawg)

Kauj Ruam 14: Khaws lub Circuit hauv lub kaus mom hlau

Khaws qhov Circuit hauv lub kaus mom hlau
Khaws qhov Circuit hauv lub kaus mom hlau
Khaws qhov Circuit hauv lub kaus mom hlau
Khaws qhov Circuit hauv lub kaus mom hlau
Khaws qhov Circuit hauv lub kaus mom hlau
Khaws qhov Circuit hauv lub kaus mom hlau

Muaj ob peb txoj hauv kev los teeb lub hauv paus rau hauv lub kaus mom hlau. Nov yog kuv txoj hauv kev rau kev txhim kho lub kaus mom hlau:

  • Yog tias koj tseem tsis tau muaj, txuas lub roj teeb rau Pi (nrog roj teeb tawm). Ruaj ntseg lub ntsuas hluav taws xob mus rau sab nraum qab ntawm Pi nrog cov rwb thaiv tsev tsis zoo nyob hauv nruab nrab (zoo li cov npuas qhwv lossis cov ntim ua npuas nyias).
  • Ntsuas qhov ntev ntawm Pi Zero, ntsuas lub zog, LED, thiab roj teeb txuas ua ke. Ntxiv 10% ntawm ob tog.
  • Kos qhov txiav tawm rau txoj haujlwm ntawm ib sab ntawm lub kaus mom hlau, nrog lub roj teeb txuas mus rau sab saum toj ntawm lub kaus mom hlau. Txiav tawm cov ntaub qhwv hauv lub kaus mom hlau tawm ob peb millimeters (~ 1/8 hauv.).
  • Muab lub sensor, Pi, thiab LED tso rau hauv qhov txiav tawm. Txiav tej daim ntawm lub kaus mom hlau ntau dhau los yog siv cov ntim ua npuas dej kom tiv thaiv, tiv thaiv, thiab tuav cov khoom siv hluav taws xob nyob hauv qhov chaw.
  • Ntsuas lub roj teeb qhov ntev, ntxiv 10%, thiab ua raws tib qho kev txiav tawm rau lub roj teeb. Ntxig lub roj teeb rau hauv hnab tshos.
  • Rov ua dua cov txheej txheem rwb thaiv tsev rau lub roj teeb nyob rau lwm sab ntawm lub kaus mom hlau.
  • Tuav lub kaus mom hlau rau hauv qhov chaw nrog daim kab xev (koj lub taub hau yuav ua rau lawv nyob hauv qhov chaw thaum koj hnav nws).

Kauj ruam 15: Tso tawm

Tso tawm!
Tso tawm!
Tso tawm!
Tso tawm!

Fais fab lub roj teeb pob!

Tam sim no koj tuaj yeem nkag mus rau hauv Pi los ntawm SSH lossis lub desktop nyob deb thiab khiav cov haujlwm ntawm lub davhlau ya nyob twg. Thaum txoj haujlwm tau pib, nws pib sau cov ntaub ntawv.

Thaum koj txiav tawm ntawm koj lub tsev WiFi, SSH kev sib txuas yuav tawg, tab sis txoj haujlwm yuav tsum tseem teev cov ntaub ntawv. Txiav txim siab txuas tus Pi mus rau koj lub xov tooj ntawm tes hotspot WiFi, lossis tsuas yog nkag rov qab thiab rub cov ntaub ntawv thaum koj mus txog tsev.

Txhawm rau nkag mus rau cov ntaub ntawv, nkag mus rau Pi nyob deb thiab nyeem cov ntawv sau. Txoj haujlwm tam sim no ib txwm ntxiv cov ntaub ntawv rau cov ntaub ntawv uas twb muaj lawm - yog tias koj xav rho tawm cov ntaub ntawv (zoo li los ntawm kev sim), rho tawm cov ntawv ntawv (ntawm lub desktop lossis siv rm hais kom ua hauv lub davhlau ya nyob twg) lossis tsim cov npe tshiab hauv cov haujlwm code (hauv Cov Neeg Siv Khoom Parameters).

Yog tias LED qhib, rov pib dua txoj haujlwm yuav tua nws.

Tam sim no tawm mus, muaj kev lom zem hauv lub neej, thiab tshawb xyuas cov ntaub ntawv txhua zaus yog tias koj tau tsoo rau qee yam. Vam tias, nws yog pob me me tab sis tsawg kawg koj yuav paub!

Kauj Ruam 16: Ntxiv Ntau Yam

Ntxiv Nta Ntxiv
Ntxiv Nta Ntxiv

Nrhiav kev txhim kho rau qhov cuam tshuam lub zog saib? Nws nyob sab nraum qhov kev qhia tab sis sim saib cov npe hauv qab no rau cov tswv yim!

Ua qee qhov kev tshuaj xyuas ntawm koj cov ntaub ntawv g-quab yuam hauv Python!

Pi Zero muaj peev xwm Bluetooth thiab WiFi - sau App kom xa cov ntaub ntawv ntsuas qhov ntsuas mus rau koj lub xov tooj! Txhawm rau kom koj pib, ntawm no yog kev qhia rau Pi Twitter Monitor.

Ntxiv rau lwm qhov ntsuas, xws li ntsuas kub lossis lub microphone*!

Zoo Siab Tsev

*Nco tseg: Kom hnov lub suab nrov nrov cuam tshuam nrog koj qhov nrawm!: D

Pom zoo: