Cov txheej txheem:

5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing: 7 Cov Kauj Ruam
5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing: 7 Cov Kauj Ruam

Video: 5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing: 7 Cov Kauj Ruam

Video: 5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing: 7 Cov Kauj Ruam
Video: Светильник складной, 1 LED, 1 Вт, 8,5x4,8см, 3хAA, 3 режима, пластик (225-003) 2024, Hlis ntuj nqeg
Anonim
5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing
5x4 LED Zaub Matrix Siv Lub Stamp 2 (bs2) thiab Charlieplexing

Muaj Cov Ntawv Stamp 2 thiab qee qhov LED ntxiv zaum ib puag ncig? Vim li cas ho tsis ua si ib puag ncig nrog lub tswv yim ntawm charlieplexing thiab tsim cov khoom siv tsuas yog 5 tus pin.

Txog qhov kev qhia no kuv yuav siv BS2e tab sis ib tus tswv cuab ntawm tsev neeg BS2 yuav tsum ua haujlwm.

Kauj Ruam 1: Charlieplexing: Dab Tsi, Vim Li Cas, Thiab Li Cas

Wb tau txais yog vim li cas tawm ntawm txoj kev ua ntej. Vim li cas thiaj siv charlieplexing nrog Lub Stamp 2 yooj yim? --- Ntawv pov thawj ntawm lub tswvyim: Kawm paub ua haujlwm zoo li cas thiab kawm qee yam txog BS2. Qhov no yuav muaj txiaj ntsig rau kuv tom qab siv cov 8-pin nrawm dua (tsuas yog 5 ntawm lawv yuav yog i/o).--- Qhov laj thawj zoo: Yeej tsis muaj. BS2 qeeb dhau los tso tawm yam tsis pom qhov muag pom. Dab tsi yog charlieplexing? --- Charlieplexing yog ib txoj hauv kev tsav tsheb ntau tus LEDs nrog tsawg tus microprocessor i/o pins. Kuv tau kawm txog charlieplexing los ntawm www.instructables.com thiab koj tuaj yeem ib yam: Charlieplexing LEDs- Txoj kev xav Yuav ua li cas tsav ntau lub LEDs los ntawm ob peb lub microcontroller pins. Tsis tas li ntawm wikipedia: Charlieplexing Kuv tuaj yeem tsav 20 leds nrog 5 i/o pins li cas? --- Thov nyeem los ntawm peb qhov txuas hauv qab "charlieplexing yog dab tsi?". Qhov ntawd piav qhia nws zoo dua li kuv tuaj yeem ua tau. Charlieplexing sib txawv los ntawm kev sib txuam sib txawv uas xav tau ib tus pin i/o rau txhua kab thiab txhua kab (uas yuav yog tag nrho 9 i/o pins rau 5/4 zaub).

Kauj ruam 2: Kho vajtse thiab Schematic

Kho vajtse thiab Schematic
Kho vajtse thiab Schematic

Cov ntaub ntawv teev npe: 1x - Stamp 220x - Lub teeb pom kev zoo diodes (LEDs) ntawm tib hom (xim thiab qhov hluav taws xob poob) 5x - resistors (saib hauv qab no hais txog tus nqi tiv thaiv) Pabcuam/Tsis Yeem: Txoj hauv kev ntawm koj li BS2Momentary laub khawm raws li rov pib dua 6v -9v Lub zog xa khoom nyob ntawm koj qhov kev hloov pauv ntawm BS2 (nyeem koj phau ntawv qhia) Cov Qauv: Cov txheej txheem no tau muab tso ua ke nrog cov txheej txheem teeb tsa hauv siab. Koj yuav pom kab sib chaws ntawm LED teeb tsa rau sab laug, qhov no yog kev taw qhia uas BS2 tus lej tau sau. Daim ntawv ceeb toom tias txhua khub ntawm LEDs muaj anode txuas nrog rau cathode ntawm lwm qhov. Tom qab ntawd lawv txuas nrog ib ntawm tsib tus i/o pins. Resistor Qhov Muaj Peev Xwm: Koj yuav tsum suav koj tus kheej qhov ntsuas qhov ntsuas. Txheeb cov ntaub ntawv rau koj li LEDs lossis siv teeb tsa LED ntawm koj lub digital multimeter kom pom qhov hluav taws xob poob ntawm koj cov LED. Los ua qee qhov kev suav: Muab Voltage - Voltage Drop / Desired Current = Resistor ValueThe BS2 muab 5v tswj lub zog, thiab tuaj yeem siv 20ma ntawm tam sim no. Kuv cov LEDs muaj 1.6v poob thiab ua haujlwm ntawm 20ma.5v - 1.6v /.02amps = 155ohms Txhawm rau tiv thaiv koj BS2 koj yuav tsum siv tus nqi txuas ntxiv tom ntej los ntawm qhov koj tau txais nrog kev suav, qhov no kuv ntseeg tias nws yuav yog 180ohms. Kuv siv 220ohms vim tias kuv lub rooj tsav xwm kev txhim kho muaj tus nqi ntawm resistor ua rau nws rau txhua tus i/o tus pin. NCO TSEG: Kuv ntseeg tias txij li muaj tus tiv thaiv ntawm txhua tus pin qhov no ua tau zoo ob npaug ntawm kev tiv thaiv ntawm txhua tus coj txij li ib tus pin yog V+ thiab lwm qhov yog Gnd. Yog tias qhov no yog qhov koj yuav tsum txo tus nqi tiv thaiv ib nrab. Qhov tsis zoo ntawm qhov siab dhau tus nqi tiv thaiv yog dimmer LED. Ib tus neeg tuaj yeem txheeb xyuas qhov no thiab tso kuv PM lossis tawm tswv yim yog li kuv tuaj yeem hloov kho cov ntaub ntawv no? Kuv kuj tseem siv cov nti no rau ntawm kuv cov laug cam-tsawg breadboard thiab tau suav nrog In Circuit Serial Programming (ICSP) header. Lub taub hau yog 5 tus pin, tus pin 2 txog 5 txuas rau tus pin 2-5 ntawm DB9 serial cable (Pin 1 tsis siv). Thov nco ntsoov tias txhawm rau siv ICSP lub taub hau pins 6 thiab 7 ntawm DB9 cable yuav tsum txuas nrog ib leeg. Pib dua: Ib lub sijhawm thawb pib khawm yog nyob ntawm yeem. Qhov no tsuas yog rub tus pin 22 rau hauv av thaum thawb.

Kauj ruam 3: Breadboarding

Breadboarding
Breadboarding
Breadboarding
Breadboarding

Tam sim no nws yog lub sijhawm los tsim cov lej ntawm daim ntawv qhia zaub mov. Kuv siv lub dav hlau dav hlau txuas txuas ib txhais ceg los ntawm txhua tus coj coj los ua ke thiab lub xaim xaim me me los txuas rau lwm tus ceg. Qhov no tau piav qhia ntxaws hauv daim duab ze thiab piav qhia qhov tob ntawm no: 1. Taw qhia koj lub khob cij kom phim cov duab loj dua 2. Tso LED 1 nrog Anode (+) rau koj thiab Cathode (-) deb ntawm koj. 3. Tso LED 2 nyob rau tib qho kev taw qhia nrog Anode (+) hauv kab txuas txuas ntawm LED 1 cathode.4. Siv lub jumper me me los txuas Anode ntawm LED 1 nrog Cathode ntawm LED 2.5. Rov ua dua kom txog thaum txhua khub ntawm LED tau ntxiv rau hauv pawg thawj coj saib. Kuv siv dab tsi uas ib txwm yog lub hwj chim npav npav ntawm lub rooj noj mov ua cov kab tsheb npav rau BS2 I/O pins. Vim tias tsuas muaj 4 txoj kab tsheb npav kuv siv lub dav hlau dav hlau rau P4 (qhov txuas I/O thib tsib). Qhov no tuaj yeem pom ntawm daim duab loj hauv qab no. 6. Txuas lub dav hlau dav hlau rau LED 1 cathode mus rau P0 lub npav npav. Rov ua dua rau txhua tus lej suav tus lej hloov pauv P* kom raug rau txhua khub (saib cov txheej txheem).7. Txuas lub dav hlau dav hlau rau LED 2 cathode mus rau P1 lub npav npav. Rov ua dua rau txhua tus lej suav tus lej hloov pauv P* kom raug rau txhua khub (saib cov txheej txheem).8. Txuas txhua lub npav npav mus rau tus pin I/O uas tsim nyog ntawm BS2 (P0-P4).9. Txheeb xyuas txhua qhov kev sib txuas kom ntseeg tau tias lawv phim cov txheej txheem. 10. NCO NTSOOV: Hauv qhov ze koj yuav pom tias nws tsis tshwm uas kuv tau ua raws li kauj ruam 7 raws li kev txuas mus rau tus lej I/O thib ob yog nyob ntawm Anode ntawm cov lej lej sib txawv. Nco ntsoov tias Cathode ntawm cov lej suav nrog tseem txuas nrog Anode ntawm cov lej suav tsis sib xws yog li kev sib txuas zoo ib yam nkaus. Yog tias daim ntawv no cuam tshuam koj, cia li tsis quav ntsej nws.

Kauj Ruam 4: Lub Hauv Paus Tseem Ceeb

Rau charlieplexing ua haujlwm koj qhib tsuas yog coj ib zaug. Txhawm rau kom ua haujlwm nrog peb BS2 peb xav tau ob kauj ruam yooj yim: 1. Teem hom tso zis rau tus pin los ntawm kev siv OUTS hais kom ua. 2. Qhia rau BS2 tus pin twg los siv raws li kev siv DIRS cov lus txib Qhov no ua haujlwm vim tias BS2 tuaj yeem hais qhia tus pin twg kom tsav siab thiab qis thiab yuav tos kom ua li ntawd kom txog thaum koj qhia meej tias cov pins raug tso tawm li cas. tsuas yog sim ntsais muag LED 1. Yog tias koj saib cov txheej txheem koj tuaj yeem pom tias P0 tau txuas rau Cathode (-) ntawm LED 1 thiab P1 tau txuas rau Anode ntawm tib lub LED. Qhov no txhais tau tias peb xav tsav P0 qis thiab P1 siab. Qhov no tuaj yeem ua tiav zoo li no: "OUTS = % 11110" uas ua rau P4-P1 siab thiab P0 qis.) BS2 khaws cov ntaub ntawv ntawd tab sis yuav tsis ua rau nws txog thaum peb tshaj tawm tias cov pins twg yog qhov tso tawm. Cov kauj ruam no yog qhov tseem ceeb raws li tsuas yog ob tus pin yuav tsum tau muab tso rau tib lub sijhawm. Tus so yuav tsum yog cov tswv yim, uas teev cov pins rau High Impedance hom yog li lawv yuav tsis tso dab tsi tam sim no. Peb yuav tsum tau tsav P0 thiab P1 yog li peb yuav teeb tsa cov ntawd rau cov lus tso tawm thiab qhov seem rau cov tswv yim zoo li: "DIRS = % 00011". (% Qhia txog tus lej binary yog ua raws. Tus lej qis qis qis tshaj plaws ib txwm nyob ntawm sab xis. 0 = INPUT, 1 = OUTPUT) Wb muab qhov ntawd ua ke rau qee qhov muaj txiaj ntsig zoo: '{$ STAMP BS2e}' {$ PBASIC 2.5} Ua OUTS = %11110 'Tsav P0 qis thiab P1-P4 siab DIRS = %00011' Teeb P0- P1 li Cov Lus Qhia thiab P2-P4 raws li Kev Nkag Mus PAUSE 250 'Ncua rau LED kom nyob twj ywm ntawm DIRS = 0' Teem tag nrho cov pins rau Tswv Yim. Qhov no yuav tua LED PAUSE 250 'Pause rau LED kom nyob twj ywm offLOOP

Kauj Ruam 5: Txoj Kev Loj Hlob

Tam sim no peb tau pom ib tus pin ua haujlwm lub sijhawm kom paub tseeb tias lawv txhua tus ua haujlwm.20led_Zig-Zag.bseQhov txuas nrog tus lej no yuav tsum teeb txhua ntawm 20 LEDS hauv zig-zag qauv. Koj yuav pom tias tom qab txhua tus pin tau tso rau hauv lub teeb Kuv siv "DIRS = 0" tig tag nrho tus pin rov qab rau hauv cov tswv yim. Yog tias koj hloov OUTS yam tsis tig lub pins tso tawm koj tuaj yeem tau txais qee qhov "ghosting" qhov twg coj uas yuav tsum tsis txhob taws yuav ntsais nruab nrab ntawm ib puag ncig. yuav tsuas yog 1 millisecond ncua ntawm txhua qhov LED ntsais. Qhov no yuav ua rau pom kev tsis pom kev (POV) uas ua rau nws zoo li txhua lub LEDs tau teeb. Qhov no muaj qhov cuam tshuam ntawm kev ua cov LED dimmer tab sis yog qhov tseem ceeb ntawm yuav ua li cas peb yuav tso tawm cov cim ntawm cov lej no.20led_Interpreter_Proto.bse LEDs rau hauv tus qauv siv tau. Cov ntaub ntawv no yog kuv thawj zaug sim. Koj yuav pom tias hauv qab ntawm cov ntawv cov cim tau khaws cia hauv plaub kab ntawm 5 tus lej binary. Txhua kab tau nyeem hauv, txheeb cais, thiab subroutine tau hu ua txhua lub sijhawm xav tau teeb tsa qhov chaws no ua haujlwm, caij tsheb kauj vab dhau tus lej 1-0. Yog tias koj sim ua kom nws pom tias nws tau plagued los ntawm qhov ua kom qeeb qeeb heev ua rau cov cim ua rau nyem yuav luag qeeb dhau los kom pom. Txoj cai no tsis zoo rau ntau yam. Ua ntej tshaj, tsib tus lej ntawm binary coj mus rau chav ntau nyob hauv EEPROM li 8 tus lej ntawm binary raws li txhua cov ntaub ntawv khaws tseg hauv pab pawg ntawm plaub qhov. Qhov thib ob, SELECT CASE siv los txiav txim siab tus pin twg yuav tsum tau teeb tsa kom xav tau 20 qhov xwm txheej. BS2 raug txwv rau 16 qhov xwm txheej rau kev xaiv SELECT. Qhov no txhais tau tias kuv yuav tsum tau hack ib puag ncig qhov kev txwv nrog IF-THEN-ELSE nqe lus. Qhov yuav tsum muaj txoj hauv kev zoo dua. Tom qab ob peb teev ntawm lub taub hau khawb kuv pom nws.

Kauj Ruam 6: Tus Neeg Txhais Lus Zoo

Txhua kab ntawm peb cov lej suav nrog 4 LEDs, txhua tus tuaj yeem qhib lossis tawm. BS2 khaws cov ntaub ntawv hauv nws EEPROM hauv plaub pawg me. Qhov kev sib txheeb ntawd yuav tsum ua kom yooj yim dua rau peb. Qhov no ua rau lossis xaiv CASE yooj yim dua. Ntawm no yog tus lej 7 raws li khaws cia hauv EEPROM: '7 %1111, %1001, %0010, %0100, %0100, Txhua kab muaj zauv sib npaug rau 0-15 yog li peb nyeem kab los ntawm kev nco thiab pub ncaj qha rau SELECT CASE muaj nuj nqi. Qhov no txhais tau tias tib neeg nyeem tau binary matrix siv los ua txhua tus cim (1 = coj mus, 0 = coj tawm) yog tus yuam sij rau tus neeg txhais lus. los teeb tsa DIRS thiab OUTS ua qhov sib txawv. Kuv xub nyeem hauv txhua ntawm tsib kab ntawm tus cwj pwm mus rau qhov sib txawv ROW1-ROW5. Txoj haujlwm tseem ceeb tom qab ntawd hu rau subroutine los ua tus cim. Cov kab ntawv luv no siv thawj kab thiab muab plaub qhov ua tau OUTS sib txuas ua ke kom hloov pauv tau outp1-outp4 thiab ob qhov ua tau DIRS ua ke rau direc1 & direc2. LEDs tau flashed, cov kab ntawm kab tau nce ntxiv, thiab cov txheej txheem zoo ib yam yog ua rau txhua ntawm plaub kab lus no. Nws nrawm dua li thawj txoj haujlwm txhais lus. Uas tau hais tias, tseem muaj qhov pom kev flicker. Ua tibzoo saib cov vis dis aus, lub koob yees duab ua rau lub ntsej muag zoo li tsis zoo tab sis koj tau txais lub tswv yim. Kev xa cov tswv yim no mus rau cov nti nrawm dua, zoo li picMicro lossis AVR nti yuav ua kom pom cov cim no yam tsis pom qhov muag pom.

Kauj Ruam 7: Mus Qhov Twg Ntawm No

Kuv tsis muaj lub tshuab cnc lossis cov khoom siv los ua cov laug cam yog li kuv yuav tsis txuas qhov haujlwm no. Yog tias koj muaj lub zeb thiab xav koom tes ua haujlwm kom txav mus tom ntej ntawm no, xa xov tuaj rau kuv. Kuv yuav zoo siab them rau cov ntaub ntawv thiab xa khoom txawm tias zoo siab los qhia qee yam ntawm cov khoom tiav rau txoj haujlwm no.

Lwm Yam Muaj Peev Xwm: 1. Hloov qhov no mus rau lwm lub nti. Qhov kev tsim qauv no tuaj yeem siv nrog ib qho nti uas muaj 5 i/o pins muaj uas yog lub xeev muaj peev xwm (pins uas tuaj yeem siab, qis, lossis nkag (siab impedance)). 2. Siv lub nti nrawm dua (tej zaum AVR lossis picMicro) koj tuaj yeem nce qhov ntsuas. Nrog 20pin nti koj tuaj yeem siv 14 tus pin rau charlieplex qhov 8x22 zaub thiab siv cov pins ntxiv kom tau txais cov lus txib los ntawm lub khoos phis tawj lossis lwm tus tswj. Siv peb ntau daim npav 20-tus lej thiab koj tuaj yeem muaj cov duab tso tawm uas yog 8x88 rau tag nrho ntawm 11 tus cim ib zaug (nyob ntawm qhov dav ntawm txhua tus cim ntawm chav kawm). Hmoov zoo, muaj kev lom zem!

Pom zoo: