Mundarija:

CMUCam2 ni OOPICga ulash: 5 qadam
CMUCam2 ni OOPICga ulash: 5 qadam

Video: CMUCam2 ni OOPICga ulash: 5 qadam

Video: CMUCam2 ni OOPICga ulash: 5 qadam
Video: NI@ RoboCup 2008 2024, Noyabr
Anonim

ArsinioFollow tomonidan Muallifning yana:

I2C yordamida ikkita OOBoardni bir -biriga ulash
I2C yordamida ikkita OOBoardni bir -biriga ulash
I2C yordamida ikkita OOBoardni bir -biriga ulash
I2C yordamida ikkita OOBoardni bir -biriga ulash

CMUCam2 va OOPIC -ga qanday ulanish haqida umumiy ma'lumot.

1 -qadam: Adapter kabelini yaratish

Adapter kabelini yaratish
Adapter kabelini yaratish

1. Radioshakka o'ting va shulardan ikkitasini sotib oling: Erkak DB-9 Solder Cup Connector2. lehim pimi 5 A konnektidagi B konnektidagi 5 pingacha (agar ulagichga diqqat bilan qarasangiz, ular belgilangan) 3. lehim pin 2 A konnektidagi B 3 ulagichiga (agar ulagichga diqqat bilan qarasangiz, ular belgilangan) 4. lehim pin 3 A konnektidagi B 2 ulagichiga (agar ulagichga diqqat bilan qarasangiz, ular belgilangan)

2 -qadam: CMUCam -da Baud tezligini o'zgartiring

CMUCam -da Baud tezligini o'zgartiring
CMUCam -da Baud tezligini o'zgartiring

CMUCamera -ning uzatish tezligini 9600 -ga o'zgartiring (0 -pozitsiyaga o'tish moslamasini qo'shing).

3 -qadam: Standart dasturlash kabelini ulang va kodni yuklang

Standart dasturlash kabelini va yuklash kodini ulang
Standart dasturlash kabelini va yuklash kodini ulang

Standart dasturiy kabelni ulang va kodingizni yuklang. Bu erda LF va FD buyruqlari yordamida harakatni kuzatib boradigan misol kodi. U IOLine 7 -ni (LEDga ulangan) o'zgartiradi va CMUCam -dagi kuzatuv holati LEDini aks ettiradi.

& apos ******** ketma -ket port bilan bog'liq ob'ektlar ******** Dim serPort yangi oSerialPortDim txBuff sifatida yangi oBuffer27 va 27 ni o'zgartiradi, buferni kattaroq/kichikroq qiladi Dim rxBuff yangi oBuffer10Dim serialActive_LED sifatida yangi oDIO1Dim toggleSerial_Button As Yangi oDIO1Dim toggleSerial_Event sifatida yangi oEventDim toggleSerial_Wire sifatida yangi oWireDim serialReceive_Event sifatida yangi oEventDim serialReceive_Wire sifatida yangi oWire & apos ******** disk raskadrovka bilan bog'liq ob'ektlar ******** Dim statLED sifatida yangi oDIO1 va apos ******** ********************************** va apos*Umumiy kichik dasturlar & apos ****** ************************************ Sub main & aposinitialize main_init & chiqish niqobini o'chirish faqat CMUCAM_setOutputMask (2, 3) massa markaziga amal qiling va CMUCAM_loadDiffFrame () boshlang'ich farq ramkamizni yuklang va farqni hisoblashni boshlang CMUCAM_startDiffCalc (10) SubSub main_init -ni tugating va LED statLED. IOLine = 7 serialvinali -serialini yuklang) Tugatish Su b va aposprocesses qabul qilingan paketlar Sub processPacket () Dim mx As Byte Dim My As Byte. Location = 2 mx = rxBuff. Value rxBuff. Location = 4 my = rxBuff. Value & aposthe LED kameradagi kuzatuvchi LED bilan bir vaqtda miltillashi kerak Agar (mx = "0") Va (mening = "0") statLED = 0 Boshqa statLED = 1 IfEnd Sub & apos tugasa **************************************** **** va apos*CMU Cam funktsiyalari*& apos ************************************* ******* & apossets berilgan LEDni yoqish, o'chirish, avtomatik va aposparamga olib o'tish) Yangi kompilyatorda Bayt va aposVString ishlamagani uchun … va eskisiga ishonch yo'q & apostxBuff. VString = "L0 0" & qo'lda buyruq satrini qo'lda o'rnatish txBuff. Location = 0 txBuff. Value = "L" txBuff. Location = 1 va aposthe s. tr $ funktsiyasi achchiq … shuning uchun hozir bu sodir bo'lmoqda = 13 & serial_SendBufferEnd Sub buyrug'ini uzatish & ramSub CMUCAM_loadDiffFrame () ning dastlabki farqini yuklash va qo'lda txBuff. Location = 0 txBuff. Value = "L" txBuff. Location = 1 txBuff. Value = "F" tx 2. Value = 13 & serial_SendBufferEnd Sub buyrug'ini bekor qilish va kadrlar farqi va aposparam chegarasi (0-9) Sub CMUCAM_startDiffCalc (th By As Thire) Dim o'n as Byte & apossetup buyruqlar qatorini qo'lda txBuff. Location = 0 txBuff. Value = "txBuff. Value =" 1 txBuff. Value = "D" txBuff. Location = 2 txBuff. Value = "" txBuff. Location = 3 tens = thresh/10 txBuff. Value = serial_toChar (o'nlab) txBuff. Location = 4 tens = thresh/10 txBuff. Value = serial_toChar (thres-tens) txBuff. Location = 5 txBuff. Value = 1 3 va serial_SendBufferEnd Sub buyrug'ini bekor qilish va chiqish niqobi va aposparam paketini niqoblash uchun paket turi (0, 1, 2 va boshqalar) 46-betga qarang va aposparam niqobining qiymati qo'llanilishi uchun (0-255) Sub CMUCAM_setOutputMask (packetType As Byte, mask as Byte) Dim yuzlab. As Byte Dim o'nlab As Byte & apossetup buyruq satrimiz qo'lda txBuff. Location = 0 txBuff. Value = "O" txBuff. Location = 1 txBuff. Value = "M" txBuff. Location = 2 txBuff. Value = "" va txBuff turi. Manzil = 3 txBuff. Value = serial_toChar (packetType) txBuff. Location = 4 txBuff. Value = "" va txBuff. Location = 5 yuz = niqob/100 txBuff. Value = serial_toChar (yuzlab) txBuff. Location = 6 tens = (mask-yuzlar)/10 txBuff. Value = serial_toChar (o'nlab) txBuff. Location = 7 txBuff. Value = serial_toChar (mask-yuzlab-o'nlab) & aposcarriage txBuff. Location = 8 txBuff. Value = 13 & serial_SendBufferE buyrug'ini bekor qilish*. ******************************************** Umumiy ketma -ket kichik dasturlar *va apo s ****************************************** va serialni aposinitsializatsiya qiladi portSub serial_init () va ketma -ket portni yoqish va o'chirish tugmachasini ochish (ishga tushirish uchun yoqish, dasturni o'chirish) toggleSerial_Button. IOLine = 5 toggleSerial_Button. Direction = cvInput toggleSerial_Wire. Input. Link (toggleSeral_Button. Havola (toggleSerial_Event. Operate) toggleSerial_Wire. Operate = cvTrue & aposinitialize bir voqea bizning ma'lumotlarni bufer bufererive_Wire. Input. Link (serialPort. Received) serialReceive_Wire. Output. Link (seriyali = 0 & serialPort. Baud = cv9600 & aposinitialize ketma -ket portimiz LED serialActive_LED. IOLine = 6 serialActive_LED. Direction = cvOutput & aposwit bu erda ketma -ket portimiz faollashguncha kutamiz serialPort. Operate = cvFalse bizni qabul qiladi va WendEnd yuboradi Paketni to'ldirishSub serialRe ceive_Event_Code () & apos.received 4 baytli tampon bo'sh bo'lganda bo'sh bo'ladi. Buferni rxBuff. Location = 0 boshiga qayta o'rnatish serialPort. Operate = cvFalse serialActive_LED = 0 If End End & Apos bir raqamli raqamni belgiga o'zgartiradi serial_toChar (inVal As Byte) Byte Dim retVal As Byte Case inVal Case 0 retVal = "0" Case 1 retVal = "1" Case 2 retVal = "2" Case 3 retVal = "3" Case 4 retVal = "4" Case 5 retVal = "5" Case 6 retVal = "6" Case 7 retVal = "7" Case 8 retVal = "8" Case 9 retVal = "9" oxiri serial_toChar = retValEnd funktsiyasini tanlang ds txBuff & apos -dagi ma'lumotlar Eslatma: buferning oxirida tashish qaytarilishi (13) borligiga ishonch hosil qiling !! serial_SendBuffer () va har bir baytni jo'natish orqali tugatish, txBuff. Location = 0 1 serialPort. Value = txBuff. Value ooPIC. Delay = 1 & aposm bu kerak emas, agar bu vagonning qaytishi bo'lsa txBuff. Value = 13 & aposbreak bizning tsikldan qaytish End & if aposgo keyingi belgiga txBuff. Location = txBuff. Location + 1 WendEnd Sub

4 -qadam: Dasturlash ulagichini uzing

Dasturlash ulagichini ajratib oling
Dasturlash ulagichini ajratib oling
Dasturlash ulagichini ajratib oling
Dasturlash ulagichini ajratib oling

Dasturlash ulagichi uzilganidan so'ng, yangi kabel moslamasini quyida ko'rsatilgan tarzda ulang. 1 -qadamda ishlab chiqarilgan adapter CMUCamni OOPICga to'g'ridan -to'g'ri ulash imkonini berishi kerak

5 -qadam: Serial aloqani boshlash uchun tugmani bosing

IOLine 5 tugmasi CMUCam va OOPIC o'rtasidagi ketma -ket aloqani boshlaydi. Ketma -ket port dasturlash uchun ham, CMUCam uchun ham ishlatilgani uchun, ehtimol, ikkalasini almashtirishning boshqariladigan usuli bo'lishi kerak.

Bu tugma bosilmaguncha dastur ishlamaydi. Agar siz yana tugmani bosgan bo'lsangiz, ketma -ket port ishlamay qoladi, bu sizga dasturlash imkonini beradi. IOLine 6 -dagi LED joriy ketma -ket port holatini ko'rsatadi (yoniq - faol, o'chirilgan - dasturlash uchun tayyor).

Tavsiya: