Cov txheej txheem:

RGB Tus Ntsuas Kub Siv PICO: 6 Kauj Ruam
RGB Tus Ntsuas Kub Siv PICO: 6 Kauj Ruam

Video: RGB Tus Ntsuas Kub Siv PICO: 6 Kauj Ruam

Video: RGB Tus Ntsuas Kub Siv PICO: 6 Kauj Ruam
Video: Txawj Pes Vaj: Cia Vajtswv Siv 2024, Hlis ntuj nqeg
Anonim
Image
Image

Qhov ntawd yog qhov txiaj ntsig kawg ntawm peb kev mob siab rau hnub no. Nws yog tus pas ntsuas kub uas yuav qhia rau koj paub tias sov li cas hauv koj chav, los ntawm kev siv RGB LED sawb tso rau hauv lub thawv acrylic, uas txuas nrog lub ntsuas kub kom nyeem tau qhov kub. Thiab peb yuav siv PICO kom ua txoj haujlwm no rau lub neej.

Kauj Ruam 1: Cheeb Tsam

Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
  • PICO, muaj nyob ntawm mellbell.cc ($ 17)
  • 1 meter RGB LED sawb
  • 3 TIP122 Darlington transistor, ib pob ntawm 10 ntawm ebay ($ 3.31)
  • 1 PCA9685 16-channel 12-ntsis PWM tsav tsheb, muaj nyob ntawm ebay ($ 2.12)
  • 12v fais fab tuag
  • 3 1k ohm resistors, ib pob ntawm 100 ntawm ebay ($ 0.99)
  • Lub khob cij, muaj nyob ntawm ebay ($ 2.30)
  • Txiv neej - poj niam jumper xov hlau, pob ntawm 40 ntawm ebay ($ 0.95)

Kauj Ruam 2: Hwj chim rau RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source

Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source
Fais fab RGB Sawb Nrog Transistors thiab Lub Hwj Chim Source

Cov kab hluav taws xob LED yog cov kab hluav taws xob hloov pauv tau yooj yim uas muaj cov LEDs. Lawv tau siv ntau txoj hauv kev, zoo li koj tuaj yeem siv lawv hauv koj lub tsev, koj lub tsheb, lossis tsheb kauj vab. Koj tseem tuaj yeem tsim qhov txias txias RGB coj los siv lawv.

Yog li, lawv ua haujlwm li cas? Nws yog qhov yooj yim zoo nkauj. Txhua qhov ntawm LEDs hauv kab txaij LED tau txuas nrog ua ke, thiab lawv ua zoo li ib qho loj loj RGB LED. Thiab kom ua nws, koj tsuas yog xav tau txuas lub sawb rau 12v lub zog tam sim no.

Txhawm rau tswj cov kab hluav taws xob LED nrog lub microcontroller, koj yuav tsum cais cov khoom siv hluav taws xob los ntawm qhov chaw tswj hwm. Vim tias cov kab hluav taws xob LED xav tau 12v, thiab peb lub microcontroller tsis tuaj yeem muab qhov hluav taws xob ntau npaum li cas, thiab yog vim li cas peb txuas rau sab nraud 12v siab zog tam sim no, thaum xa cov cim tswj los ntawm peb PICO.

Tsis tas li, qhov kos tam sim no ntawm txhua lub xov tooj ntawm tes RGB siab, raws li txhua tus tib LED hauv nws - liab, ntsuab, thiab xiav LEDs - xav tau 20mA los ua haujlwm, uas txhais tau tias peb xav tau 60mA los teeb lub teeb ib leeg ntawm RGB. Thiab qhov ntawd yog teeb meem heev, vim tias peb GPIO tus pin tsuas tuaj yeem muab qhov siab tshaj ntawm 40mA rau tus pin, thiab txuas RGB sawb rau PICO ncaj qha yuav hlawv nws, yog li thov tsis txhob ua nws.

Tab sis, muaj qhov kev daws teeb meem, thiab nws hu ua Darlington Transistor uas yog ib khub ntawm cov transistors uas tau nce siab heev tam sim no, uas yuav pab peb txhawb peb tam sim no kom ua tiav peb cov kev xav tau.

Cia peb kawm paub ntau ntxiv txog kev nce tam sim no ua ntej. Kev nce tam sim no yog cov cuab yeej ntawm transistors uas txhais tau tias tam sim no dhau los ntawm transistor yuav muab sib npaug los ntawm nws, thiab nws cov kab zauv zoo li qhov no:

thauj khoom tam sim no = tawm tam sim no * transistor nce.

Qhov no tseem muaj zog dua hauv Darlington transistor, vim tias nws yog ib khub ntawm transistors tsis yog ib leeg, thiab lawv cov txiaj ntsig tau sib txuam ua ke, ua rau peb tau txais txiaj ntsig tam sim no.

Tam sim no peb yuav txuas cov kab hluav taws xob LED rau peb lub zog sab nraud, lub transistor, thiab tau kawg peb PICO.

  • Base (transistor) → D3 (PICO)
  • Collector (transistor), B (LED sawb)
  • Emitter (transistor) thiab GND
  • +12 (LED sawb) → +12 (lub zog siv)

Tsis txhob hnov qab txuas PICO's GND mus rau lub zog siv hauv av

Kauj Ruam 3: Tswj Cov Xim ntawm RGB LED Sawb

Tswj cov xim ntawm RGB LED Sawb
Tswj cov xim ntawm RGB LED Sawb
Tswj cov xim ntawm RGB LED Sawb
Tswj cov xim ntawm RGB LED Sawb
Tswj cov xim ntawm RGB LED Sawb
Tswj cov xim ntawm RGB LED Sawb

Peb paub tias peb PICO muaj ib tus PWM tus pin (D3) uas txhais tau tias nws tsis tuaj yeem ib txwm tswj hwm peb 16 LEDs. Qhov no yog vim li cas peb tab tom qhia PCA9685 16-channel 12-ntsis PWM I2C module, uas cia peb nthuav PICO's PWM pins.

Ua ntej tshaj plaws, I2C yog dab tsi?

I2C yog txheej txheem kev sib txuas lus uas cuam tshuam nrog tsuas yog 2 lub xov tooj sib txuas lus nrog ib lossis ntau lub cuab yeej los ntawm kev hais lub ntaus ntawv qhov chaw nyob thiab cov ntaub ntawv twg yuav xa.

Muaj ob hom khoom siv: thawj tus yog tus tswv cuab, uas yog lub luag haujlwm xa cov ntaub ntawv, thiab lwm qhov yog cov cuab yeej qhev, uas tau txais cov ntaub ntawv. Nov yog tus pin tawm ntawm PCA9685 module:

  • VCC: Qhov no yog lub zog rau pawg tswj hwm nws tus kheej. 3-5v max.
  • GND → Qhov no yog tus pin tsis zoo, thiab nws yuav tsum txuas nrog GND kom ua tiav qhov Circuit Court.
  • V+ → Qhov no yog lub hwj chim xaiv tau uas yuav muab lub zog rau servos yog tias koj muaj ib qho ntawm lawv txuas nrog koj tus qauv. Koj tuaj yeem tso nws tawm yog tias koj tsis siv ib qho kev pabcuam.
  • SCL clock Tus lej xov tooj txuas, thiab peb txuas nws mus rau SCL ntawm PICO.
  • SDA → Serial Data pin, thiab peb txuas nws mus rau SDA ntawm PICO.
  • OE → tso zis tus pin, tus pin no tau ua haujlwm LOW, thaum tus pin LOW tag nrho cov txiaj ntsig tau qhib, thaum nws HIGH tag nrho cov txiaj ntsig tau xiam. Thiab qhov kev xaiv tus pin no tau siv los pab sai lossis cuam tshuam tus qauv tus pin.

Muaj 16 qhov chaw nres nkoj, txhua qhov chaw nres nkoj muaj V+, GND, PWM. Txhua tus pin PWM tau ua tiav ntawm nws tus kheej, thiab lawv tau teeb tsa rau servos tab sis koj tuaj yeem siv lawv rau LEDs yooj yim. Txhua PWM tuaj yeem tuav 25mA ntawm tam sim no yog li ceev faj.

Tam sim no peb paub dab tsi peb tus lej tus pin thiab nws ua dab tsi, cia siv nws txhawm rau nce tus lej PICO's PWM pins, yog li peb tuaj yeem tswj peb RGB LED sawb.

Peb yuav siv cov qauv no nrog rau TIP122 transistors, thiab qhov no yog li cas koj yuav tsum txuas lawv rau koj PICO:

  • VCC (PCA9685) thiab VCC (PICO).
  • GND (PCA9685) thiab GND.
  • SDA (PCA9685) → D2 (PICO).
  • SCL (PCA9685) → D3 (PICO).
  • PWM 0 (PCA9685) ASE BASE (thawj TIP122).
  • PWM 1 (PCA9685) → BASE (thib ob TIP122).
  • PWM 2 (PCA9685) ASE BASE (thib peb TIP122).

Tsis txhob hnov qab txuas PICO's GND nrog lub zog hluav taws xob GND. Thiab nco ntsoov TSIS txuas PCA9685 VCC tus pin nrog lub hwj chim muab +12 volts lossis nws yuav puas

Kauj Ruam 4: Tswj RGB LED Sawb Xim Nyob ntawm Sensor Nyeem Ntawv

Tswj lub RGB LED Sawb Xim Nyob ntawm Sensor Nyeem Ntawv
Tswj lub RGB LED Sawb Xim Nyob ntawm Sensor Nyeem Ntawv
Tswj RGB LED Sawb Xim Nyob ntawm Sensor Nyeem Ntawv
Tswj RGB LED Sawb Xim Nyob ntawm Sensor Nyeem Ntawv

Nov yog theem kawg hauv txoj haujlwm no, thiab nrog nws peb txoj haujlwm yuav hloov pauv los ntawm "ua neeg ruam" mus rau qhov ntse thiab muaj peev xwm coj tus yam ntxwv nyob ntawm nws ib puag ncig. Txhawm rau ua qhov ntawd peb yuav txuas peb PICO nrog LM35DZ qhov ntsuas kub.

Qhov ntsuas no muaj qhov ntsuas hluav taws xob analog uas nyob ntawm qhov kub nyob ib puag ncig nws. Nws pib ntawm 0v sib xws nrog 0 Celsius, thiab qhov hluav taws xob nce ntxiv 10mV rau txhua qib siab dua 0c. Cov khoom siv no yooj yim heev thiab tsuas yog muaj 3 ceg, thiab lawv tau txuas nrog raws li hauv qab no:

  • VCC (LM35DZ) thiab VCC (PICO)
  • GND (LM35DZ) → GND (PICO)
  • Cov Zis (LM35DZ) → A0 (PICO)

Kauj Ruam 5: Txoj Cai Kawg

Txoj Cai Kawg
Txoj Cai Kawg
Txoj Cai Kawg
Txoj Cai Kawg

Tam sim no peb muaj txhua yam txuas nrog peb PICO, cia pib ua haujlwm nws kom cov LEDs hloov xim nyob ntawm qhov kub thiab txias.

Rau qhov no, peb xav tau cov hauv qab no:

Ib const. sib txawv hu ua "tempSensor" nrog tus nqi A0 uas tau txais nws nyeem los ntawm qhov ntsuas kub

Ib qho lej sib txawv uas muaj npe "sensorReading" nrog tus nqi pib 0. Qhov no yog qhov sib txawv uas yuav txuag tau qhov nyeem ntawv nyoos nyoos

Ib ntus hloov pauv lub npe "volts" nrog thawj tus nqi 0. Qhov no yog qhov sib txawv uas yuav txuag tau qhov hloov pauv hloov pauv cov khoom nyoos nyeem rau volts

Cov ntab sib txawv hu ua "temp" nrog tus nqi pib 0. Qhov no yog qhov sib txawv uas yuav txuag tau qhov hloov pauv hloov pauv qhov ntsuas hluav taws xob nyeem thiab hloov nws mus rau qhov kub thiab txias

Ib qho kev hloov pauv uas muaj npe hu ua "mapped" nrog tus nqi pib 0. Qhov no yuav txuag tau PWM tus nqi uas peb daim ntawv qhia lub sijhawm hloov pauv mus rau, thiab qhov sib txawv no tswj hwm LED kab xim

Siv tus lej no, PICO yuav nyeem cov ntsuas kub cov ntaub ntawv, hloov nws mus rau hauv volts, tom qab ntawd mus rau Celsius, thiab thaum kawg nws qhia txog qib Celsius mus rau PWM tus nqi uas tuaj yeem nyeem los ntawm peb cov kab LED, thiab qhov ntawd yog qhov peb xav tau.

Kauj Ruam 6: Koj Ua tiav

Image
Image

Peb kuj tau ua cov thawv acrylic rau cov hlua LED kom nws sawv ntsug zoo. Koj tuaj yeem pom cov ntaub ntawv CAD ntawm no yog tias koj xav rub tawm lawv.

Tam sim no koj muaj lub ntsej muag ntsuas kub zoo txaus uas qhia koj qhov ntsuas sov thaum koj saib nws, uas yog qhov yooj yim zoo los hais tsawg kawg: P

Tawm lus tawm yog tias koj muaj lus pom lossis tawm tswv yim, thiab tsis txhob hnov qab ua raws peb hauv facebook lossis mus ntsib peb ntawm mellbell.cc kom tau txais cov ntsiab lus txaus.

Pom zoo: