Cov txheej txheem:

TinyLiDAR ntawm tus Pi?: 9 Kauj Ruam (nrog Duab)
TinyLiDAR ntawm tus Pi?: 9 Kauj Ruam (nrog Duab)

Video: TinyLiDAR ntawm tus Pi?: 9 Kauj Ruam (nrog Duab)

Video: TinyLiDAR ntawm tus Pi?: 9 Kauj Ruam (nrog Duab)
Video: Nus Ham - Ntsuj Plig Tu Siab ❤️❤️(Nkauj Tawm Tshiab 2023)[Official MV] 2024, Kaum ib hlis
Anonim
TinyLiDAR ntawm Pi?
TinyLiDAR ntawm Pi?

Nyob zoo dua!

Zoo tam sim no koj tau siv qee lub sijhawm zoo nrog me meLiDAR thiab koj Arduino - koj Raspberry Pi tej zaum zoo li nyob ib leeg me ntsis;)

Tus pi muaj I2C chaw nres nkoj txoj cai? Yog li vim li cas ho tsis nqes nws thiab sim nws nyob ntawd?! Txoj phiaj xwm zoo, tab sis yog tias koj twb tau sim lawm - koj yuav tau pom cov ntaub ntawv zoo li coj txawv txawv me ntsis.

Yog lawm, tus pi tau tsim hauv 1.8K rub tawm ib zaug lawm yog li koj yuav tsum txiav I2C cov ntaub ntawm me meLiDAR kom tau txais 4.7K rub tawm ntawm Circuit-saib phau ntawv qhia kom ntxaws. Tab sis qhov no tsis yog vim li cas rau cov ntaub ntawv coj txawv txawv.

Nws yog vim tus pi lub tsheb npav I2C tsis tau raws qhov tshwj xeeb. Nws tau zoo li no txij li pi tau xub qhia ua ntej vim yog Broadcom nti teeb tsa. Los ntawm qhov pib lawv tsis tau txais kev txhawb nqa I2C qhov zoo hu ua "moos ncab".

Koj tuaj yeem nyeem ntxiv txog kab mob h/w no.

Kauj Ruam 1: Lub Sijhawm Ncab Yog Dab Tsi?

Clock Stretching yog dab tsi?
Clock Stretching yog dab tsi?

Raws li koj tuaj yeem paub, lub tsheb npav I2C muaj 3 kab. Cov no yog rau moos (SCL), cov ntaub ntawv (SDA) thiab thaj chaw ib puag ncig. Lub moos thiab cov kab ntawv yog qhib-hom/qhib-ntws hom uas txhais tau tias lawv xav tau rub tawm cov neeg tawm tsam txuas nrog txoj kev xa khoom zoo los muab lawv lub logic siab. Txhawm rau kom muaj logic qis, txhua lub cuab yeej ntawm lub npav tuaj yeem rub txoj kab mus rau hauv av.

Raws li tus txheej txheem I2C, Tus Xib Hwb ntaus ntawv yog tus muab lub moos teeb liab ntawm kab SCL tab sis yog tias tus nqi no nrawm dhau lawm Cov cuab yeej qhev raug tso cai kom qeeb nws los ntawm kev tuav lub moos kab kom txog thaum nws npaj tau los daws nrog cov ntaub ntawv. Qhov no yog qhov peb hu ua "clock stretching".

Kev ua haujlwm, lub sijhawm ncab tau teev tseg raws li qhov xav tau tshwj xeeb hauv I2C tus qauv tab sis nws yog qhov tshwj xeeb uas tsim nyog rau feem ntau "ntse" qhev uas xav tau qee lub sijhawm ntxiv los muab cov ntaub ntawv ntsuas thiab lwm yam.

Kauj Ruam 2: Kev Pab Me Me Los Ntawm Npua Uas Ya

Txhawm rau daws qhov I2C h/w kab no, peb pom lub tsev qiv ntawv zoo me me hu ua "pigpio". Nws yog lub tsev qiv ntawv nrov heev, nrawm thiab hnyav sau hauv C. Nws sau raws li keeb kwm yav dhau los rau Raspberry Pi thiab tso cai rau peb los tswj I2C ntxiv rau ib qho GPIO yooj yim los ntawm nab hab sej. Lub tsev qiv ntawv saib xyuas I2C cov chaw nres nkoj ntau dua li GPIO thiab yog li tau hla I2C moos ncab kab. Zoo li txhua qhov software ntawm pi, lub tsev qiv ntawv pigpio tsuas yog ib qho yooj yim "suav nrog" tseg yog li cia peb mus!

Kauj ruam 3: TL; DR Version

Teeb PiEnable SSH rau tus ID nkag mus nrog PuttyInstall pigpio library Tau txais me me LiDAR zip fileUnzip thiab khiav los ntawm Putty

Yeem:

Teeb SublimeText nrog WinSCP

Kauj Ruam 4: Kev Txhim Kho

Kev teeb tsa
Kev teeb tsa

Rau peb Raspberry Pi 3, peb siv tus qauv Tshiab Tawm Ntawm Lub Box Software (NOOBS Lite v2.4) kev ua haujlwm. Nws muaj qhov ua tsis tau zoo ntawm Python twb tau teeb tsa rau peb npaj rau code nrog. Koj tuaj yeem rub tawm OS los ntawm no.

Thaum nruab rau ntawm daim npav micro SD koj yuav tsum txuas cov keyboard thiab saib xyuas yog li koj tuaj yeem nkag mus rau pi thawj zaug:

Username: pi Lo lus zais: raspberry

Tom qab ntawd koj tuaj yeem pib lub server ruaj ntseg plhaub (SSH) nrog cov lus txib no:

sudo systemctl pab sshsudo systemctl pib ssh

Tom ntej no peb yuav xav tau tus IP chaw nyob ntawm tus pi ntawm koj lub network yog li peb tuaj yeem nkag mus nrog PuTTY. Txhawm rau kom tau qhov no, tsuas yog ntaus:

hostname -I

Thiab nrhiav qhov chaw nyob IPv4 (Rau peb teeb nws yog: 192.168.0.27)

Cov kauj ruam saum toj no yuav tso cai rau pi khiav "tsis muaj lub taub hau" uas txhais tau tias koj yuav tsis xav tau ntaus ntawm cov keyboard no ntxiv thiab tseem tsis xav tau lub vis dis aus saib ntxiv lawm. Peb yuav nkag mus hla lub network los ntawm kev ruaj ntseg SSH kev txuas mus rau tom ntej. Cov lus txib saum toj no ua rau SSH server qhib ncaj qha txhua lub sijhawm pi tau qhib. Qhov no yooj yim rau peb thaum peb tab tom ntsuas tab sis nws tuaj yeem yog kev nyab xeeb kev nyab xeeb tom qab (ua qhov tsis meej pem yog qhov zoo) yog li thaum koj npaj tau, koj tuaj yeem xiam qhov pib pib SSH no siv cov lus txib no:

sudo systemctl lov tes taw ssh

Cov lus txib no yuav tsum tau ntaus ntawm cov keyboard txuas nrog pi ntawm chav kawm.

PuTTY yog txoj haujlwm davhlau ya nyob twg uas yuav tsum tau tshaj tawm cov lus txib los ntawm PC mus rau pi yog li koj yuav tsum nqa daim ntawv theej tawm tshiab ntawm no.

Nruab thiab pib PuTTY. Koj yuav tsum tau ntaus tus IP chaw nyob los ntawm sab saud ntawm tus tswv lub npe nkag thiab siv lub hauv paus SSH teeb tsa. Muab lub rooj sib tham ib lub npe uas koj xav tau thiab ntaus tseg. Tom qab ntawd tsoo load thiab nyem Qhib kom pib sib tham.

Nws yuav tsum coj koj mus rau lub vijtsam nkag mus rau pi. Siv koj tus username thiab password tib yam uas koj siv ua ntej.

Kauj ruam 5: Nruab Pigpio

Tam sim no, tsuas yog qhov peb xav tau los nruab tom qab qhov no yuav yog lub tsev qiv ntawv pigpio thiab peb tuaj yeem ua qhov no los ntawm kev siv cov lus txib hauv qab no.

Tswv yim: Koj tuaj yeem yooj yim luam tawm [ctrl+c] thiab muab tshuaj txhuam [nas txoj cai nyem] cov no thiab lwm yam lus txib rau hauv PuTTY davhlau ya nyob twg

sudo apt-tau hloov tshiab

sudo apt-tau nruab pigpio sej-pigpio python3-pigpio

Kauj Ruam 6: Xaiv tau: Dev System teeb tsa

Yeem: Dev System Teeb
Yeem: Dev System Teeb

Yog li ntawm no yog cov lus qhia uas yuav pab txuag qee lub sijhawm hauv koj lub ntiaj teb kev txhim kho cov cai. Peb yeej ntxub unix raws li cov kws kho cov ntawv. Tus neeg siv interface yog ib txwm tsis meej pem thiab cov fonts nqus. GNU nano yuav luag yuav luag tab sis tsis muaj qhov ua tau zoo dua li SublimeText uas koj tuaj yeem rub tawm los ntawm no

Peb muaj lub qhov rais txhim kho ib puag ncig ib puag ncig thiab nyiam siv cov ntawv sau no thaum twg los xij. Yog li cov lus qhia ntawm no yog teeb tsa koj lub kaw lus kom tuaj yeem siv tus kws tshaj lij kho ntawv ib txwm nyob ntawm koj lub qhov rais desktop kom ncaj qha code ntawm koj lub taub hau pi.

Yuav ua li cas? Siv lub app dawb hu ua WinSCP uas koj tuaj yeem rub tawm los ntawm no

Kauj Ruam 7: Teeb WinSCP

Teeb tsa WinSCP
Teeb tsa WinSCP
Teeb tsa WinSCP
Teeb tsa WinSCP

WinSCP yog qhov hloov pauv cov ntaub ntawv ruaj ntseg uas muab cov duab sawv cev ntawm cov ntaub ntawv tam sim no ntawm koj rpi yam zoo li qhov koj pom hauv tus thawj tswj ntaub ntawv ntawm koj lub PC Windows.

Yog li mus tom ntej thiab teeb tsa ob txoj haujlwm saum toj no ib yam nkaus.

Tom ntej no koj yuav tau hloov kho ob peb yam kom lawv txhua tus ua haujlwm tau zoo.

Txog WinSCP, koj tuaj yeem nyem rau ntawm Qhov Chaw Tshiab. Peb yuav siv lub chaw SFTP lub neej ntawd thiab koj tsuas yog yuav tsum nkag tus IP chaw nyob (rau tus tswv lub npe) ntawm koj tus pi thiab tus ID nkag mus (rau Tus Neeg Siv Npe). Koj tuaj yeem xaiv tawm tus password tsis muaj dab tsi yog tias koj nyiam - nws yuav qhia koj tus password txhua zaus koj nkag mus.

Tom ntej no, nyem lub pob Advanced thiab tom qab ntawd nyem rau ntawm sab laug rau ib puag ncig Plhaub chaw. Ntawm sab xis hloov qhov "Default" rub nqis mus rau "sudo su -" kev xaiv. Qhov no yuav tso cai hloov pauv los sau rau koj tus pi yam tsis tau kev tso cai yuam kev thaum koj ntaus tseg los ntawm SublimeText.

Teem SublimeText los ua Tus Thawj Cuam Tshuam hauv WinSCP

Txhawm rau ua qhov no, nyem qhov cuab yeej khawm ntawm WinSCP ID nkag mus teeb tsa qhov screen uas koj tau pib koj qhov NewSite kev sib tham. Ob lub vijtsam txhaj tshuaj qhia pom tias qhov no tau teeb tsa li cas, tab sis qhov tseeb koj yuav nyem txhawm rau teeb tsa Tus Khoos phib tawj nyiam thiab ntxiv tus Editor uas yuav yog tus kws tshaj lij sab nrauv. Tom qab ntawv koj tuaj yeem tshawb xyuas cov ntaub ntawv.exe ntawm qhov uas tus kws kho mob no nyob hauv koj lub khoos phis tawj.

Kauj Ruam 8: (w) tau txais Txoj Cai

(w) tau txais Txoj Cai
(w) tau txais Txoj Cai

Thaum ua tiav, mus tom ntej thiab nkag mus nrog WinSCP thiab nrog PuTTY.

Tam sim no peb tau teeb tsa peb tuaj yeem pib peb qhov me meLiDAR code.

Ua cov npe hu ua tinyLiDAR nyob hauv koj lub tsev/pi phau ntawv teev npe.

Koj tuaj yeem ua qhov no los ntawm kev ua txoj nyem rau ntawm sab xis ntawm WinSCP npo thiab xaiv Tshiab / Cov Npe

Tam sim no ntawm PuTTY lub davhlau ya nyob twg koj tuaj yeem ntaus

cd twm

thiab nias tab kom cia nws ua tiav koj cov lus txib kom mus rau cov npe me meLiDAR.

Ib zaug ntawm no sau cov hauv qab no:

wget

kom tau txais cov ntaub ntawv ncaj qha los ntawm peb cov neeg rau zaub mov. Peb tuaj yeem tshem tawm lawv los ntawm kev ntaus ntawv

unzip ua r

thiab nias tab kom ua tiav lub npe dua

Txhawm rau khiav nws, tsuas yog ntaus

nab hab sej tlgui.py

Thiab koj qhov me meLiDAR yuav teb rau koj txhua lo lus txib ntawm pi:)

Kauj Ruam 9: Nco tseg rau sai-rau-ua Hackers

Mus tom ntej thiab saib hauv qab lub hood los ntawm ob npaug nyem rau ntawm ib qho ntawm cov ntaub ntawv cov cai los ntawm WinSCP. Lawv yog cov uas muaj.py txuas ntxiv mus Cov ntaub ntawv yuav tsum qhib hauv SublimeText ncaj qha rau ntawm koj lub PC. Hloov qhov koj nyiam thiab tom qab ntawd nyem txuag. Koj qhov kev hloov pauv yuav raug cawm ncaj qha rau koj tus pi.

Thaum npaj tau, koj rov ua dua los ntawm kev siv tus xub xub nce rau qhov kawg sau cov lus txib lossis tsuas yog ntaus nws dua thiab nias nkag mus:

nab hab sej tlgui.py

Tej zaum koj yuav tau ceeb toom txog Terminal GUI kev teeb tsa zoo li me ntsis zoo dua li Arduino version. Nws yog vim PuTTY txhawb cov cim unicode, yog li peb tuaj yeem siv qee tus cursor tswj tus cim ntxiv kom nws zoo dua.

Kuj tseem muaj cov lus txib ntxiv ntawm no (piv rau Arduino version) uas yog "dc" rau Kev Nyeem Nyeem Tsis Txaus. Sim nws thiab saib koj xav li cas.

Yog tag nrho!

Ua tsaug rau kev nyeem thiab txaus siab rau hack ntawm tus pi:)

Pom zoo: