Cov txheej txheem:

Txuas Ob OOBoards Ua Ke Siv I2C: 4 Cov Kauj Ruam
Txuas Ob OOBoards Ua Ke Siv I2C: 4 Cov Kauj Ruam

Video: Txuas Ob OOBoards Ua Ke Siv I2C: 4 Cov Kauj Ruam

Video: Txuas Ob OOBoards Ua Ke Siv I2C: 4 Cov Kauj Ruam
Video: Sib Hawm Dhau (Time Passed) Music Video by: Deeda/Dib Xwb 2024, Kaum ib hlis
Anonim
Txuas Ob OOBoards Ua Ke Siv I2C
Txuas Ob OOBoards Ua Ke Siv I2C

Cov lus qhia no qhia txog yuav ua li cas txuas ob OOBoards siv I2C.

Kauj Ruam 1: Txuas mus rau I2C Network Bus

Txuas mus rau I2C Network Bus
Txuas mus rau I2C Network Bus
Txuas mus rau I2C Network Bus
Txuas mus rau I2C Network Bus

Muaj ob lub tsheb npav I2C ntawm OOBoards, tsheb npav hauv nroog, thiab tsheb npav sib txuas.

OOPIC code yog qhov tseem ceeb txhais lus, piv txwv li "tus lej" tau khaws cia hauv EEPROM, thiab nyeem/txhais los ntawm microprocessor hauv lub sijhawm. EEPROM siv LOCAL I2C tsheb npav los sib txuas lus nrog lub microcontroller. Yog tias koj tau saib lub npav no hauv zos ntawm oscilloscope, koj yuav pom kev sib tham tas li. Ntawm OOBoards cov laug cam, lub tsheb npav hauv zos yog qhov txuas nrog I2C txuas, qhov no tsis tas yuav yog yam peb xav tau. Lub npav NETWORK feem ntau yog lub npav uas siv los sib txuas lus nrog lwm cov khoom siv/oopics, ntawm OOBoards lub npav no tsis muaj tus txuas. Txhawm rau nkag mus rau lub npav no, koj yuav tsum tau siv cov xaim xaim txuas rau tus pin 42 thiab 37 ntawm lub microcontroller (cim N_SDA, N_SCL ntawm cov txheej txheem feem).

Kauj Ruam 2: Ntxiv Pullup Resistors

Thaum SDA thiab SCL kev sib txuas ua tiav ntawm txhua tus txheej txheem, ob lub rooj tsavxwm tuaj yeem ua tau

sib txuas ua ke los ntawm kev txuas SDA rau SDA, SCL rau SCL, thiab txuas ib qho xov hlau hauv av ntawm cov laug cam. Koj tseem yuav xav tau rub tawm tus neeg tawm tsam ntawm txhua kab (kuv siv 12k, tab sis qhov ntawd tsuas yog qhov kuv tau dag ib ncig). Nco ntsoov tias koj tsuas xav tau ib tus rub tawm cov kab tawm ntawm ib kab rau tag nrho ntawm ob tus neeg tawm tsam (tsis yog 4).

Kauj Ruam 3: Program Tus Qhev

Tam sim no hais tias kev sib txuas ntawm lub cev nyob ntawd, koj yuav tsum tau teeb tsa tus qhev microcontroller. Kuv ntxiv qee cov cai hauv qab no uas yuav tsum tau koj pib.

Dim SLAVE Raws Li Tshiab oDDELinkDim LED Raws Li Tshiab oDIO1Sub Main () & tshem tawm peb qhov chaw nyob I2C rau 2 (nco ntsoov, qhov no yuav tsum phim cov chaw taws teeb & aposaddress peb teeb tsa hauv tus lej tswv) ooPIC. Node = 2 & apossetup ib qho LED. IOLine = 5 LED. Direction = cvOutput & aposnow, txuas qhov tso tawm ntawm peb DDELink cov khoom rau & aposthe LED, thiab tig nws… tam sim no automagically, cov LED yuav ntsais SLAVE. Output. Link (LED) SLAVE. Operate = cvTrueEnd Sub

Kauj Ruam 4: Program Master

Thaum kawg, teeb tsa tus tswv microcontroller. Ua tib zoo mloog cov kab uas teeb tsa DDELink's. Location property: Tshwj tsis yog qhov no tau teeb tsa kom raug, qhov no yuav tsis ua haujlwm!

Dim Tswv Raws Li Tshiab oDDELinkDim hlau Raws Li Tshiab oWireDim hz1 Raws li Tshiab oBitSub Main () & aposlink lub sijhawm thib ob thib ob rau qhov me ntsis peb tuaj yeem nkag mus & aposthis me ntsis yuav tam sim no toggle ib zaug thib ob xaim. Txuas (hz1) wire. Operat = cvTrue & aposthis teeb tsa I2C chaw nyob ntawm peb lub microcontroller hauv zos & tus thwjtim I2C interface tsis ua haujlwm kom txog thaum qhov chaw nyob tau teeb tsa ooPIC. Node = 1 & aposnow peb teeb tsa peb DDELink cov khoom, peb cov tswv yim yog me ntsis hz1 & aposnote tias khoom kuj muaj. Output cuab yeej siv & aposwhen thaum peb tau txais hom Master. Input. Link (hz1) & aposthis yog I2C chaw nyob ntawm cov chaw taws teeb microcontroller, nco ntsoov tias & aposin tus qhev txoj cai, peb qhia nws kom muaj chaw nyob ntawm 2 Master. Node = 2 & aposugh… qhov no yog qhov tsis zoo, qhov no yog “chaw nyob” ntawm DDELink & aposobject hauv tus qhev & qhov chaw nco nco. Txhawm rau txiav txim siab tus lej no, & aposwe xav tau qhib thiab suav sau tus lej qhev, tom qab ntawd mus rau View-> Compiled Code. & aposlook rau qee yam xws li: & aposL *. Construct. Begin; Dim li tshiab oDDELink & aposwhere * yog tus lej, thiab yog lub npe ntawm koj li DDELink cov khoom & aposin koj tus lej qhev. Kab ntawv tam sim hauv qab no nws yuav tsum nyeem qee yam xws li: & aposC0020: 041; Qhov no.. Tus lej & tus lej thwjtim rau sab xis ntawm & apos: & apos yog qhov chaw nyob ntawm tus qhev DDELink lub hom phiaj Master. Location = 41 & aposthis qhia cov khoom uas peb yuav xa mus cov ntaub ntawv (piv txwv li, theej cov ntaub ntawv los ntawm peb. Input cuab yeej & Aposto cov qhev. tawm cov cuab yeej (nco ntsoov, yog tias koj teeb tsa qhov no kom tau txais, nws yog qhov rov qab) = cvTrue Ua & aposcheck kom pom tias tam sim no peb tab tom xa cov ntaub ntawv Yog Master. Transmitting = cvFalse Tom qab ntawd & suav cov nqi no rau 1 yuav ua rau tus tswv xa tus nqi rau tus qhev & aposnote, qhov no tau rov pib dua rau 0 thaum ua tiav ntawm Master. Sync = 1 End Yog LoopEnd Sub

Pom zoo: