Cov txheej txheem:

Kawm Kev Taw Qhia Nrog Raspberry Pi thiab MXC6226XU Siv Python: 6 Kauj Ruam
Kawm Kev Taw Qhia Nrog Raspberry Pi thiab MXC6226XU Siv Python: 6 Kauj Ruam

Video: Kawm Kev Taw Qhia Nrog Raspberry Pi thiab MXC6226XU Siv Python: 6 Kauj Ruam

Video: Kawm Kev Taw Qhia Nrog Raspberry Pi thiab MXC6226XU Siv Python: 6 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Hlis ntuj nqeg
Anonim
Image
Image

Lub suab nrov tsuas yog ib feem ntawm kev ua haujlwm tsheb

Lub suab nrov ntawm lub tsheb loj heev kho lub tsheb yog lub suab zoo kawg. Cov log tsheb yws yws tawm tsam txoj kev, cua ntsawj thaum nws mus ncig tsom iav, cov khoom yas, thiab cov khoom hauv lub dashboard tsim suab me ntsis thaum lawv txhuam ua ke. Feem coob ntawm peb tsis pom cov ntawv tsis zoo no ua ntej ntev. Txawm li cas los xij, qee qhov kev sib tw tsis zoo li tsis muaj kev phom sij. Lub suab nrov txawv txawv tuaj yeem pom ua ntej los ntawm koj lub tsheb kom qhia rau koj paub tias qee yam tsis raug. Yuav ua li cas yog tias peb siv cov cuab yeej thiab cov txheej txheem txhawm rau txheeb xyuas Lub suab nrov, kev co, thiab hnyav (NVH) suav nrog kev sib tw nruj thiab ntsuas rattle, thiab lwm yam.

Kev tsim kho tshiab yog ib qho tseem ceeb ntawm lub zog yav tom ntej yam tsis muaj kev txwv; nws tau hloov pauv peb lub neej thiab tsim peb lub neej tom ntej ntawm cov txiaj ntsig zoo tshaj plaws, nrog cov txiaj ntsig tseem ceeb uas peb tsis tuaj yeem pib pom lossis tau txais. Raspberry Pi, lub micro, ib lub rooj tsavxwm Linux computer, muab tus nqi pheej yig thiab nruab nrab yooj yim rau kev lag luam kho vajtse. Raws li lub khoos phis tawj thiab khoom siv hluav taws xob, peb tau kawm ntau yam nrog Raspberry Pi thiab txiav txim siab los muab peb cov kev nyiam. Yog li dab tsi yog qhov tshwm sim tshwm sim uas peb tuaj yeem ua dab tsi ntawm qhov tsis muaj sijhawm uas peb muaj Raspberry Pi thiab 2-axis Accelerometer nyob ze? Hauv txoj haujlwm no, peb yuav tshuaj xyuas qhov nrawm ntawm 2 txoj kab sib dhos, X thiab Y, Raspberry Pi thiab MXC6226XU, 2-axis accelerometer. Yog li peb yuav tsum pom ntawm no, txhawm rau ua lub luag haujlwm txheeb xyuas qhov nrawm 2-seem.

Kauj Ruam 1: Cov Khoom Peb Xav Tau

Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau
Cov Khoom Peb Xav Tau

Cov teeb meem tau tsawg dua rau peb vim peb muaj qhov ntsuas loj heev ntawm cov khoom ib puag ncig los ua haujlwm los ntawm. Txawm li cas los xij, peb paub tias nws muaj teeb meem rau lwm tus li cas khaws cia qhov raug hauv lub sijhawm tsis muaj txiaj ntsig los ntawm qhov chaw txhawb nqa thiab uas tau tiv thaiv kev them nyiaj me me ceeb toom rau txhua npib. Yog li peb yuav pab koj. Ua raws cov ntawv txuas nrog kom tau txais cov npe ua tiav.

1. Raspberry Pi

Thawj kauj ruam tau txais Raspberry Pi board. Raspberry Pi yog ib leeg-board Linux raws PC. Lub PC me me no tau ntim rau hauv kev suav lub zog, siv los ua ib feem ntawm cov khoom siv ua haujlwm, thiab kev ua haujlwm yooj yim xws li daim ntawv nthuav qhia, kev npaj lo lus, kev tshuaj xyuas lub vev xaib thiab email, thiab kev ua si. Koj tuaj yeem yuav ib qho ntawm yuav luag txhua cov khoom siv hluav taws xob lossis khw hobbyist.

2. I2C Shield rau Raspberry Pi

Thawj qhov kev txhawj xeeb Raspberry Pi yog qhov tsis tuaj tiag yog I2C chaw nres nkoj. Yog li ntawd, TOUTPI2 I2C txuas ua rau koj nkag siab siv Raspberry Pi nrog ib qho ntawm I2C li. Nws muaj nyob ntawm DCUBE Store

3. 2-Axis accelerometer, MXC6226XU

MEMSIC MXC6226XU Digital Thermal Orientation Sensor (DTOS) yog (yog;) lub ntiaj teb thawj qhov kev ua haujlwm sib koom ua ke zoo ib yam. Peb tau txais qhov ntsuas no los ntawm DCUBE Store

4. Txuas Cable

Peb tau txais I2C Txuas txuas los ntawm DCUBE Store

5. Micro USB cable

Qhov tsis txaus ntseeg me me, tseem ceeb tshaj plaws rau qib kev xav tau yog Raspberry Pi! Txoj hauv kev yooj yim tshaj plaws rau kev teeb tsa yog los ntawm kev siv Micro USB cable. GPIO pins lossis USB chaw nres nkoj tuaj yeem siv tau los muab cov khoom siv hluav taws xob ntau.

6. Web Access yog Qhov Xav Tau

INTERNET menyuam tsis txhob pw

Tau txais koj li Raspberry Pi txuas nrog Ethernet (LAN) cable thiab cuam tshuam nws rau koj lub network network. Xaiv, luam theej duab rau WiFi txuas thiab siv ib qho ntawm USB chaw nres nkoj kom tau mus rau lub network deb. Nws yog qhov kev xaiv ntse, yooj yim, me me thiab yooj yim!

7. HDMI Cable/Kev Nkag Mus Rau Tej Chaw

Raspberry Pi muaj qhov chaw nres nkoj HDMI uas koj tuaj yeem cuam tshuam tshwj xeeb rau lub vijtsam lossis TV nrog HDMI cable. Kev xaiv, koj tuaj yeem siv SSH coj nrog koj li Raspberry Pi los ntawm Linux PC lossis Mac los ntawm lub davhlau ya nyob twg. Ntxiv mus, PuTTY, pub dawb thiab qhib-qhov davhlau ya nyob twg emulator suab zoo li qhov tsis zoo xaiv.

Kauj Ruam 2: Txuas Cov Khoom Kho Vajtse

Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse
Txuas Kev Kho Vajtse

Ua qhov Circuit Court raws li cov txheej txheem tshwm sim. Hauv daim duab, koj yuav pom ntau qhov sib txawv, ntu fais fab thiab I2C cov cim ntsuas tom qab I2C kev sib txuas lus raws tu qauv. Kev xav yog qhov tseem ceeb tshaj Kev Paub.

Kev sib txuas ntawm Raspberry Pi thiab I2C Shield

Qhov tseem ceeb tshaj plaws ntxiv, coj Raspberry Pi thiab pom I2C Shield rau nws. Nias lub Shield ua tib zoo hla GPIO pins ntawm Pi thiab peb tau ua tiav nrog cov kauj ruam no ncaj qha raws li ncuav qab zib (saib qhov snap).

Kev sib txuas ntawm Raspberry Pi thiab Sensor

Coj lub sensor thiab cuam tshuam nrog I2C cable nrog nws. Txog qhov tsim nyog ua haujlwm ntawm cov kab no, thov tshuaj xyuas I2C Cov Zais Tawm Ib txwm siv nrog I2C Kev Tawm Tswv Yim. Ib yam yuav tsum tau ua tom qab rau Raspberry Pi nrog I2C daim ntaub thaiv npog hla GPIO pins.

Peb txhawb nqa kev siv I2C cable raws li nws tsis lees paub qhov xav tau los txheeb xyuas tus pin sab, nyab xeeb, thiab kev tsis yooj yim ua tiav los ntawm txawm tias tus neeg siab tawv tshaj plaws. Nrog qhov txuas tseem ceeb no thiab ua si cable, koj tuaj yeem qhia, pauv tawm qhov tsis sib haum, lossis ntxiv cov cuab yeej ntxiv rau daim ntawv thov siv tau. Qhov no txhawb nqa qhov hnyav ua haujlwm mus txog qib loj.

Nco tseg: Cov xaim xim av yuav tsum ua raws li hauv av (GND) kev sib txuas ntawm cov khoom siv ntawm ib lub cuab yeej thiab cov tswv yim ntawm lwm lub cuab yeej

Web Network yog Qhov Tseem Ceeb

Txhawm rau kom peb qhov kev sim yeej, peb xav tau Web txuas rau peb Raspberry Pi. Txog qhov no, koj muaj kev xaiv zoo li cuam tshuam Ethernet (LAN) koom nrog hauv tsev network. Ntxiv mus, raws li kev xaiv, chav kawm txaus siab yog siv WiFi USB txuas. Feem ntau hais lus rau qhov no, koj xav tau tus tsav tsheb kom nws ua haujlwm. Yog li cia siab rau ib qho nrog Linux hauv kev piav qhia.

Hwj chim Mov

Txuas lub Micro USB cable rau hauv lub hwj chim nkaus ntawm Raspberry Pi. Xuas nrig thiab peb npaj txhij.

Kev Sib Txuas rau Screen

Peb tuaj yeem txuas HDMI cable txuas nrog lwm Tus Saib Xyuas. Qee zaum, koj yuav tsum tau mus rau Raspberry Pi yam tsis cuam tshuam nws mus rau lub vijtsam lossis koj yuav xav tau saib cov ntaub ntawv los ntawm nws los ntawm lwm qhov. Muaj peev xwm, muaj tswv yim thiab fiscally txoj hauv kev los daws nrog ua txhua yam uas tau txiav txim siab. Ib ntawm lawv yog siv - SSH (cov chaw taws teeb hais kom ua kab nkag). Koj kuj tseem tuaj yeem siv PuTTY software rau qhov ntawd.

Kauj Ruam 3: Python Coding rau Raspberry Pi

Python Coding rau Raspberry Pi
Python Coding rau Raspberry Pi

Python Code rau Raspberry Pi thiab MXC6226XU Sensor tuaj yeem nkag tau rau hauv peb Github Chaw Tso Khoom.

Ua ntej txuas mus rau txoj cai, xyuas kom koj nyeem cov cai tau muab hauv Readme cov ntawv khaws tseg thiab teeb tsa koj li Raspberry Pi raws li nws. Nws yuav cia li so rau ib pliag kom ua txhua yam xav tau.

Tus ntsuas hluav taws xob yog lub tshuab hluav taws xob siv hluav taws xob uas yuav ntsuas lub zog nrawm. Cov hwj huam no tej zaum yuav zoo li qub, zoo ib yam li lub zog nqus ntawm koj ob txhais taw, lossis lawv tuaj yeem hloov pauv tau - coj los ntawm kev txav lossis ua kom lub nrawm nrawm.

Cov ntawv txuas nrog yog tus nab npawb nab npawb thiab koj tuaj yeem clone thiab hloov pauv cov cai hauv txhua lub peev xwm uas koj tig mus rau.

# Faib nrog daim ntawv tso cai yuav dawb.# Siv nws txhua txoj hauv kev koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm. # MXC6226XU # Tus lej no yog tsim los ua haujlwm nrog MXC6226XU_I2CS I2C Mini Module muaj los ntawm dcubestore.com #

ntshuam smbus

lub sij hawm ntshuam

# Tau I2C npav

npav = smbus. SMBus (1)

# MXC6226XU chaw nyob, 0x16 (22)

# Xaiv kev txheeb xyuas npe, 0x04 (04) # 0x00 (00) Fais fab npav.write_byte_data (0x16, 0x04, 0x00)

sijhawm.s pw (0.5)

# MXC6226XU chaw nyob, 0x16 (22)

# Nyeem cov ntaub ntawv rov qab los ntawm 0x00 (00), 2 bytes # X-Axis, Y-Axis cov ntaub ntawv = bus.read_i2c_block_data (0x16, 0x00, 2)

# Hloov cov ntaub ntawv

xAccl = data [0] if xAccl> 127: xAccl -= 256 yAccl = data [1] yog yAccl> 127: yAccl -= 256

# Cov ntaub ntawv tso tawm rau lub vijtsam

luam "Ua kom nrawm hauv X-Axis: % d" % xAccl luam "Ua kom nrawm hauv Y-Axis: % d" % yAccl

Kauj Ruam 4: Kev Hloov Chaw ntawm Txoj Cai

Kev Txawj Ntse ntawm Txoj Cai
Kev Txawj Ntse ntawm Txoj Cai

Rub tawm (lossis git rub) cov cai los ntawm Github thiab qhib nws hauv Raspberry Pi.

Khiav cov lus txib kom sau thiab xa cov cai hauv lub davhlau ya nyob twg thiab pom cov txiaj ntsig ntawm Screen. Noj tom qab ob peb feeb, nws yuav qhia txhua tus ntawm qhov ntsuas. Tom qab ua kom ntseeg tau tias txhua yam ua haujlwm tau yooj yim, koj tuaj yeem siv qhov kev nqis peev no txhua hnub lossis ua qhov kev nqis peev no me ntsis ntawm txoj haujlwm loj dua. Xijpeem koj xav tau tam sim no koj muaj ib qho khoom siv ntxiv hauv koj cov khoom.

Kauj Ruam 5: Cov ntawv thov thiab Nta

Raug tsim los ntawm MEMSIC Digital Thermal Orientation Sensor (DTOS), MXC6226XU yog qhov ua tiav Kev Sib Ntsuas Kub Kub. MXC6226XU yog qhov tsim nyog rau Cov neeg siv khoom siv xws li Cov Xov Tooj Ntawm Tes, Cov Koob Yees Duab Digital (DSC), Cov Koob Yees Duab (DVC), TV LCD, Cov Khoom Ua Si, MP3 thiab MP4 Players. Nrog patented MEMS-thev naus laus zis thev naus laus zis, nws muaj txiaj ntsig zoo hauv kev thov kev nyab xeeb hauv tsev xws li Lub Tshuab Cua Txias, Lub Teeb Halogen, Hlau Txias thiab Kiv cua.

Kauj Ruam 6: Xaus

Ntawm qhov tsis muaj txiaj ntsig uas koj tau xav txog txhawm rau tshuaj xyuas lub ntiaj teb ntawm Raspberry Pi & I2C sensors, tom qab ntawd koj tuaj yeem ua rau koj xav tsis thoob los ntawm kev siv cov khoom siv hluav taws xob hauv paus, coding, phiaj xwm, khi thiab lwm yam. Hauv cov txheej txheem no, yuav muaj qee qhov haujlwm uas yuav yooj yim, thaum qee leej yuav sim koj, twv koj. Ua qhov zoo li nws tuaj yeem ua tau, koj tuaj yeem ua txoj hauv kev thiab ua kom dawb huv los ntawm kev hloov pauv thiab tsim kev tsim ntawm koj li.

Piv txwv li, Koj tuaj yeem pib nrog lub tswv yim tsim qauv los ntsuas Lub suab nrov thiab kev co (N & V) cov yam ntxwv ntawm tsheb, tshwj xeeb yog tsheb thiab tsheb thauj khoom siv MXC6226XU thiab Raspberry Pi nrog rau lub microphone thiab lub zog ntsuas. Hauv txoj haujlwm saum toj no, peb tau siv cov lej suav sau. Cov tswv yim yog txhawm rau saib lub suab nrov xws li lub suab nrov ntawm lub cav, lub suab nrov los yog cua nrov, ib txwm muaj. Cov kab ke resonant teb ntawm tus yam ntxwv nquag saib zoo li ntawm ib qho spectrum, lawv qhov dav sib txawv ntau yam. Peb tuaj yeem tshawb xyuas qhov ntawd rau qhov sib txawv sib txawv thiab tsim lub suab nrov rau qhov ntawd. Rau xws li x-axis tuaj yeem ua raws qhov sib luag ntawm lub cav nrawm thaum lub y-axis yog logarithmic. Fast Fourier hloov pauv thiab Txheeb Xyuas Kev Txheeb Xyuas Lub Zog (SEA) tuaj yeem ua rau kom tsim qauv. Yog li koj tuaj yeem siv lub ntsuas ntsuas no hauv ntau txoj hauv kev uas koj tuaj yeem xav txog. Peb yuav sim ua qhov kev ua haujlwm ntawm cov qauv no sai dua li tom qab, kev teeb tsa, cov cai, thiab cov qauv ua haujlwm rau cov qauv ua suab nrov thiab kev ntsuas kev co. Peb ntseeg tias koj txhua tus nyiam nws!

Txhawm rau kom koj xis nyob, peb muaj cov vis dis aus ntxim nyiam hauv YouTube uas tuaj yeem pab koj tshuaj xyuas. Ntseeg qhov kev mob siab rau txhawb ntxiv kev tshawb nrhiav Ntseeg qhov kev koom tes no txhawb kev tshawb nrhiav ntxiv. Pib qhov twg koj nyob. Siv qhov koj tau ua. Ua li koj ua tau.

Pom zoo: