Cov txheej txheem:

Ultrasonic Pi Piano Nrog Piav Qhia Kev Tswj!: 10 Kauj Ruam (nrog Duab)
Ultrasonic Pi Piano Nrog Piav Qhia Kev Tswj!: 10 Kauj Ruam (nrog Duab)

Video: Ultrasonic Pi Piano Nrog Piav Qhia Kev Tswj!: 10 Kauj Ruam (nrog Duab)

Video: Ultrasonic Pi Piano Nrog Piav Qhia Kev Tswj!: 10 Kauj Ruam (nrog Duab)
Video: Только стакан этого сока ... Обратное забивание артерий и снижение высокого кровяного давления 2024, Hlis ntuj nqeg
Anonim
Image
Image
Ultrasonic Pi Piano Nrog Kev Taw Taw!
Ultrasonic Pi Piano Nrog Kev Taw Taw!

Txoj haujlwm no siv tus nqi pheej yig HC-SR04 ultrasonic sensors ua cov tswv yim thiab tsim cov ntawv MIDI uas tuaj yeem ua si los ntawm kev sib xyaw ntawm Raspberry Pi rau lub suab zoo.

Txoj haujlwm no tseem siv lub hauv paus tswj kev piav tes piav taw, qhov twg tuaj yeem hloov kho lub suab paj nruas los ntawm kev tuav koj ob txhais tes hla ob lub ntsej muag sab nraud rau ob peb feeb. Lwm tus tes taw tuaj yeem siv los kaw Raspberry Pi thaum koj ua tiav.

Cov vis dis aus saum toj no qhia txog cov khoom tiav hauv qhov yooj yim laser-cut enclosure. Muaj cov yeeb yaj kiab ntxaws ntxiv tom qab hauv cov lus qhia no uas piav qhia tias txoj haujlwm ua haujlwm li cas.

Kuv tsim txoj haujlwm no nrog Gizmo Dojo (kuv tus neeg tsim khoom hauv nroog hauv Broomfield, CO) los ua qee qhov kev sib tham tim ntsej tim muag uas peb tuaj yeem coj mus rau STEM/STEAM cov xwm txheej hauv zej zog thiab Maker Faires.

Thov tseem txheeb xyuas cov ntaub ntawv tshiab thiab qhia paub ntawm https://theotherandygrove.com/octasonic/ uas tam sim no suav nrog cov ntaub ntawv ntawm Python version ntawm txoj haujlwm no (cov lus qhia no tau sau rau Rust version).

Kauj ruam 1: Cov khoom xyaw

Rau qhov kev qhia no, koj yuav xav tau cov khoom xyaw hauv qab no:

  • Raspberry Pi (2 lossis 3) nrog daim npav SD
  • 8 HC-SR04 ultrasonic sensors
  • Octasonic Breakout Board
  • Bi-Directional Logic Level Converter
  • 32 x 12 "Poj Niam-Poj Niam Jumper Cov Hluav Taws Xob rau txuas lub ntsuas hluav taws xob ultrasonic
  • 13 x 6 "Poj Niam-Poj Niam Jumper Cov Hluav Taws Xob rau txuas Raspberry Pi, Octasonic, thiab Logic Level Converter
  • Lub hwj chim tsim nyog rau Raspberry Pi
  • Hais lus PC lossis zoo sib xws

Kuv yuav pom zoo siv Raspberry Pi 3 yog tias ua tau vim nws muaj lub zog suav ntau dua, ua rau muaj lub suab ntau dua thiab txaus siab. Nws tuaj yeem ua haujlwm tau zoo nrog Raspberry Pi 2 nrog kho me ntsis tab sis kuv yuav tsis sim siv tus thawj Raspberry Pi rau txoj haujlwm no.

HC -SR04 ultrasonic sensors muaj 4 qhov sib txuas - 5V, GND, Trigger, thiab Echo. Feem ntau, Trigger thiab Echo txuas nrog cais cov pins ntawm lub microcontroller lossis Raspberry Pi tab sis qhov ntawd txhais tau tias koj yuav tsum tau siv 16 tus pin txuas rau 8 tus ntsuas, thiab qhov no tsis yog qhov ua tau. Nov yog qhov uas Octasonic breakout board los rau hauv. Pawg thawj coj no txuas rau txhua yam ntawm lub ntsuas cua thiab muaj lub siab tswj hwm microcontroller uas saib xyuas lub ntsuas hluav taws xob thiab tom qab ntawd sib txuas lus nrog Raspberry Pi hla SPI.

HC-SR04 xav tau 5V thiab Raspberry Pi tsuas yog 3.3V, yog li qhov no yog vim li cas peb tseem xav tau cov qib kev hloov pauv uas yuav txuas Raspberry Pi mus rau Octasonic breakout board.

Kauj Ruam 2: Txuas lub Ultrasonic Sensors mus rau Octasonic Board

Txuas lub Ultrasonic Sensors rau Octasonic Board
Txuas lub Ultrasonic Sensors rau Octasonic Board
Txuas lub Ultrasonic Sensors rau Octasonic Board
Txuas lub Ultrasonic Sensors rau Octasonic Board

Siv 4 tus poj niam-poj niam jumper xov hlau los txuas txhua lub ntsuas hluav taws xob ultrasonic mus rau lub rooj tsavxwm, ua tib zoo saib xyuas lawv kom raug. Lub Rooj Tswjhwm Saib tau tsim los kom cov pins nyob rau tib qhov kev txiav txim raws li cov pins ntawm lub ultrasonic sensor. Los ntawm sab laug mus rau sab xis ntawm lub rooj tsavxwm, tus pin yog GND, Ua rau, Echo, 5V.

Kauj Ruam 3: Txuas Lub Logic Level Converter mus rau Octasonic Board

Txuas lub Logic Level Converter mus rau Octasonic Board
Txuas lub Logic Level Converter mus rau Octasonic Board

Raspberry Pi thiab Octasonic Board sib tham nrog SPI. SPI siv 4 xov hlau:

  • Master in, Qhev Tawm (MISO)
  • Tswv Qhia, Qhua Hauv (MOSI)
  • Serial Moos (SCK)
  • Qhev Xaiv (SS)

Ib qho ntxiv, peb yuav tsum txuas lub zog (5V thiab GND).

Lub logic qib hloov pauv muaj ob sab - qhov hluav taws xob qis (LV) thiab qhov siab (HV). Raspberry yuav txuas rau LV sab txij li nws yog 3.3V. Lub Octasonic yuav txuas rau HV sab vim nws yog 5V.

Cov kauj ruam no yog txhawm rau txuas Octasonic mus rau HV sab ntawm lub logic qib hloov pauv

Saib daim duab txuas mus rau theem no qhia seb tus pin twg yuav tsum txuas nrog lub logic qib hloov pauv.

Cov kev sib txuas los ntawm Octasonic mus rau Logic Level converter yuav tsum yog raws li hauv qab no:

  • 5V to HUV
  • SC4 to HUV
  • MISO to HUV
  • MOSI to HUV
  • SS1 to HUV
  • GND to CSY

Kauj Ruam 4: Txuas Lub Logic Level Converter rau Raspberry Pi

Txuas lub Logic Level Converter mus rau Raspberry Pi
Txuas lub Logic Level Converter mus rau Raspberry Pi

Raspberry Pi thiab Octasonic Board sib tham nrog SPI. SPI siv 4 xov hlau:

  • Master in, Qhev Tawm (MISO)
  • Tswv Qhia, Qhua Hauv (MOSI)
  • Serial Moos (SCK)
  • Qhev Xaiv (SS)

Ib qho ntxiv, peb yuav tsum txuas lub zog (3.3V thiab GND). Lub logic qib hloov pauv muaj ob sab - qhov hluav taws xob qis (LV) thiab qhov siab (HV). Raspberry yuav txuas rau LV sab txij li nws yog 3.3V. Lub Octasonic yuav txuas rau HV sab vim nws yog 5V.

Cov kauj ruam no yog txhawm rau txuas Raspberry Pi mus rau LV sab ntawm lub logic qib hloov pauv

Kev sib txuas los ntawm Raspbery Pi mus rau Logic Level converter yuav tsum muaj raws li hauv qab no:

  • 3.3V to LWV
  • GPIO11 (SPI_SCLK) rau LV4
  • GPIO09 (SPI_MISO) rau LV3
  • GPIO10 (SPI_MOSI) rau LV2
  • GPIO08 (SPI_CE0_N) SS rau LV1
  • GND to CSY

Siv daim duab txuas mus rau cov kauj ruam no txhawm rau nrhiav tus pin raug ntawm Raspberry Pi!

Kauj Ruam 5: Txuas Raspberry Pi 5V rau Octasonic 5V

Txuas Raspberry Pi 5V rau Octasonic 5V
Txuas Raspberry Pi 5V rau Octasonic 5V
Txuas Raspberry Pi 5V rau Octasonic 5V
Txuas Raspberry Pi 5V rau Octasonic 5V

Muaj ib txoj xov hlau zaum kawg ntxiv. Peb yuav tsum tau ua lub hwj chim rau Octasonic board nrog 5V, yog li peb ua qhov ntawd los ntawm kev txuas ib qho ntawm Raspberry Pi 5V tus pin rau 5V tus pin ntawm Octasonic AVR header. Nov yog tus pin sab laug hauv qab ntawm AVR header block (qhov no yog 2 x 3 thaiv nyob rau sab xis ntawm lub rooj tsavxwm). Saib daim duab txuas nrog uas qhia tias AVR block nyob qhov twg.

Saib lwm daim duab txuas ntxiv kom pom 5V tus pin ntawm Raspberry Pi.

Kauj ruam 6: Nruab Software

Nruab Raspian

Pib nrog kev teeb tsa huv ntawm Raspbian Jessie, tom qab ntawd hloov kho nws mus rau qhov hloov tshiab kawg:

sudo apt-tau hloov tshiab

sudo apt-tau hloov tshiab

Pab kom SPI

Koj yuav tsum pab kom SPI ntawm Raspberry Pi rau txoj haujlwm no kom ua haujlwm! Siv Raspberry Pi Configuration utility los ua qhov no.

Nws tseem yog qhov tseem ceeb kom rov pib Pi tom qab ua kom SPI rau nws kom siv tau

Nruab FluidSynth

Fluidsynth yog qhov zoo tshaj plaws software dawb MIDI synth. Koj tuaj yeem nruab nws los ntawm kab hais kom ua nrog cov lus txib no:

sudo apt-tau nruab fluidsynth

Nruab Rust Programming Language

Ultrasonic Pi Piano tau ua tiav hauv Rust Programming Language los ntawm Mozilla (nws zoo li C ++ tab sis tsis muaj qhov phem). Nws yog dab tsi txhua tus menyuam txias siv niaj hnub no.

Ua raws cov lus qhia ntawm https://rustup.rs/ txhawm rau nruab Rust. Txhawm rau txuag koj lub sijhawm, cov lus qhia yog kom ua cov lus txib no. Koj tuaj yeem lees txais cov lus teb rau cov lus nug thaum lub sijhawm teeb tsa.

NCO TSEG: Txij li tshaj tawm cov lus qhia no, muaj qee qhov teeb meem nrog kev txhim kho Rust ntawm Raspberry Pi. Lub sijhawm tsis zoo:-/ tab sis kuv tau hloov kho cov lus txib hauv qab no los daws qhov teeb meem. Vam tias lawv yuav kho qhov no sai. Kuv tab tom ua haujlwm tsim cov duab uas tib neeg tuaj yeem rub tawm thiab hlawv mus rau SD daim npav. Yog tias koj xav tau, thov hu rau kuv.

export RUSTUP_USE_HYPER = 1curl https://sh.rustup.rs -sSf | sh ua

Rub tawm Ultrasonic Pi Piano qhov chaws

Cov peev txheej rau Ultrasonic Pi Piano qhov chaws tau teeb tsa ntawm github. Muaj ob txoj hauv kev kom tau txais txoj cai. Yog tias koj paub nrog git thiab github, koj tuaj yeem clone repo:

git clone [email protected]: TheGizmoDojo/UltrasonicPiPiano.git

Xwb, koj tuaj yeem rub tawm cov ntawv zip ntawm tus lej tshiab kawg.

Sau qhov chaws

cd UltrasonicPiPiano

thauj khoom -tso tawm

Kuaj cov cai

Ua ntej peb txav mus rau kev ua nkauj hauv cov kauj ruam tom ntej, cia peb paub tseeb tias software ua haujlwm thiab peb tuaj yeem nyeem cov ntaub ntawv siv tau los ntawm cov ntsuas.

Siv cov lus txib hauv qab no los khiav daim ntawv thov. Qhov no yuav nyeem cov ntaub ntawv los ntawm cov ntsuas thiab txhais lawv rau hauv MIDI cov ntawv uas tom qab ntawd luam tawm ntawm lub console. Thaum koj txav koj txhais tes hla lub ntsuas cua, koj yuav tsum pom cov ntaub ntawv raug tsim. Yog tias tsis yog, hla mus rau ntu kev daws teeb meem ntawm qhov kawg ntawm cov lus qhia no.

thauj khoom -tso tawm

Yog tias koj xav paub, tus chij "-thov" qhia Rust los sau cov cai kom muaj txiaj ntsig zoo li qhov ua tau, raws li qhov tsis ua raws "--debug" teeb tsa.

Kauj Ruam 7: Ua Cov Nkauj

Xyuas kom tseeb tias koj tseem nyob hauv phau ntawv teev npe uas koj rub tawm qhov chaws thiab khiav cov lus txib hauv qab no.

Tsab ntawv "run.sh" no ua kom ntseeg tau tias cov cai tau muab tso ua ke thiab tom qab ntawd sau cov cai, xa cov khoom xa mus rau hauv cov kua dej.

./run.sh

Nco ntsoov tias koj tau hais lus nrov txuas nrog lub hli 3.5 lub suab ntawm Raspberry Pi thiab koj yuav tsum hnov suab paj nruag thaum koj txav koj txhais tes hla lub ntsuas cua.

Yog tias koj tsis hnov suab paj nruag thiab koj muaj lub HDMI saib txuas nrog, tom qab ntawd lub suab tso tawm tej zaum yuav mus rau qhov ntawd. Txhawm rau kho qhov no, tsuas yog ua cov lus txib no thiab rov pib Pi Piano:

sudo amixer cset tus lej = 31

Hloov qhov ntim

Qhov ntim (lossis "nce") tau hais nrog "-g" qhov ntsuas rau cov kua dej. Koj tuaj yeem hloov kho tsab ntawv run.sh thiab hloov tus nqi no. Thov nco ntsoov tias kev hloov pauv me me hauv qhov ntsuas no ua rau muaj kev hloov pauv loj hauv ntim, yog li sim ua kom nws me me (zoo li 0.1 lossis 0.2).

Kauj Ruam 8: Kev Piav Qhia

Saib cov vis dis aus txuas nrog cov kauj ruam no rau kev ua kom pom tseeb ntawm txoj haujlwm, suav nrog kev tswj lub ntsej muag ua haujlwm li cas.

Lub tswvyim yog yooj yim heev. Lub software khaws cov cim uas tau npog (hauv 10cm) thiab uas tsis yog. Qhov no txhais ua 8 tus lej binary (1 lossis 0). Qhov no yooj yim heev, txij li ib ntu ntawm 8 tus lej binary ua tus "byte" uas tuaj yeem sawv cev tus lej nruab nrab ntawm 0 thiab 255. Yog tias koj tsis tau paub txog cov lej binary ces kuv pom zoo kom tshawb nrhiav kev qhia. Cov lej binary yog qhov txuj ci tseem ceeb los kawm yog tias koj xav kawm paub ntau ntxiv txog kev ua haujlwm.

Lub software qhia txog lub xeev tam sim no ntawm cov ntsuas hluav taws xob mus rau ib qho byte uas sawv cev rau tus cwj pwm tam sim no. Yog tias tus lej ntawd nyob tib yam rau ntau tus lej, tom qab ntawd software ua rau ntawm tes.

Vim tias cov ntsuas hluav taws xob ultrasonic tsis muaj kev ntseeg siab thiab tuaj yeem cuam tshuam ntawm cov ntsuas, koj yuav tsum tau siv qee qhov ua siab ntev thaum siv tes taw. Sim ua qhov sib txawv ntawm qhov uas koj tuav koj txhais tes los ntawm cov ntsuas ntsuas nrog rau lub kaum sab xis uas koj tuav koj txhais tes. Koj txias tseem sim tuav ib yam dab tsi tiaj thiab khov dua cov ntsuas kom pom zoo lub suab.

Kauj Ruam 9: Ua Qhov Ruaj Ntseg

Yog tias koj xav ua qhov khoom pov thawj tas mus li thiab tuaj yeem nthuav tawm rau tib neeg, koj yuav zaum xav ua qee yam ntawm cov ntaub thaiv. Qhov no tuaj yeem ua los ntawm ntoo, duab los qhia, lossis ntau yam khoom siv. Nov yog daim vis dis aus qhia txog chav thaiv peb tab tom ua haujlwm rau txoj haujlwm no. Qhov no yog tsim los ntawm ntoo, nrog lub qhov drilled tawm los tuav lub ultrasonic sensors nyob rau hauv qhov chaw.

Kauj Ruam 10: Teeb meem thiab cov kauj ruam tom ntej

Teeb meem

Yog tias txoj haujlwm tsis ua haujlwm, nws feem ntau yog mus rau qhov yuam kev thaiv. Siv koj lub sijhawm los txheeb xyuas txhua qhov kev sib txuas.

Lwm qhov teeb meem tshwm sim yog ua tsis tau los pab SPI thiab rov pib dua pi.

Thov mus ntsib https://theotherandygrove.com/octasonic/ rau tag nrho cov ntaub ntawv suav nrog cov lus qhia daws teeb meem, nrog Rust thiab Python cov ntawv tshwj xeeb, thiab tseem muaj ntaub ntawv yuav ua li cas thiaj tau txais kev txhawb nqa.

Cov kauj ruam tom ntej

Thaum koj muaj txoj haujlwm ua haujlwm, Kuv pom zoo sim nrog cov cai thiab sim ua cov twj paj nruag sib txawv. MIDI ntsuas cov lej nyob nruab nrab ntawm 1 txog 127 thiab tau sau tseg ntawm no.

Koj puas xav tau cov cuab yeej siv suab paj nruag ib leeg nrog txhua lub tshuab ua si sib txawv octave? Tej zaum koj yuav xav kom txhua lub ntsuas hluav taws xob los ua cov cuab yeej cais? Qhov muaj peev xwm yuav luag tsis muaj qhov txwv!

Kuv vam tias koj nyiam qhov kev qhia no. Thov nyiam nws yog tias koj tau ua, thiab nco ntsoov sau npe rau kuv ntawm no thiab rau kuv YouTube channel kom pom cov phiaj xwm yav tom ntej.

Pom zoo: