Mundarija:

MSP432 LaunchPad va Python yordamida harorat sensori (TMP006) ning jonli ma'lumotlarini chizish: 9 qadam
MSP432 LaunchPad va Python yordamida harorat sensori (TMP006) ning jonli ma'lumotlarini chizish: 9 qadam

Video: MSP432 LaunchPad va Python yordamida harorat sensori (TMP006) ning jonli ma'lumotlarini chizish: 9 qadam

Video: MSP432 LaunchPad va Python yordamida harorat sensori (TMP006) ning jonli ma'lumotlarini chizish: 9 qadam
Video: RGB LED Control on a MSP432 LaunchPad using Python (pySerial) 2024, Noyabr
Anonim
Image
Image
Dasturiy ta'minot - Energia IDE, PyCharm
Dasturiy ta'minot - Energia IDE, PyCharm

TMP006 - bu harorat sensori, u ob'ekt bilan aloqa qilmasdan, uning haroratini o'lchaydi. Ushbu qo'llanmada biz Python-dan foydalanib BoosterPack (TI BOOSTXL-EDUMKII) dan olingan harorat ma'lumotlarini tuzamiz.

1 -qadam: dasturiy ta'minot - Energia IDE, PyCharm

Energiya IDE: https://energia.nu/PyCharm:

2 -qadam: Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII

Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII
Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII
Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII
Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII
Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII
Uskuna - MSP432 LaunchPad, Educational BoosterPack MKII

3 -qadam: Energia IDE

Energiya IDE
Energiya IDE

MSP432 LaunchPad + Educational BoosterPack -ni kompyuteringizning USB portlaridan biriga ulang va Energia IDE -ni oching.

4 -qadam: Tegishli COM porti va kartasini tanlang

Tegishli COM porti va kartasini tanlang
Tegishli COM porti va kartasini tanlang

5 -qadam: Energia TMP006 uchun namuna kodi bilan oldindan yuklangan holda keladi

Energia TMP006 uchun namuna kodi bilan oldindan yuklangan holda keladi
Energia TMP006 uchun namuna kodi bilan oldindan yuklangan holda keladi

Misol kodini rasmda ko'rsatilgandek ochish mumkin.

6 -qadam: Yuklab olish tugmachasini bosish orqali pastdagi dasturni LaunchPad -ga yuklang

Yuklab olish tugmasini bosish orqali LaunchPad -ga quyidagi dasturni yuklang
Yuklab olish tugmasini bosish orqali LaunchPad -ga quyidagi dasturni yuklang

#include #include "Adafruit_TMP006.h" #USE_USCI_B1 ni aniqlang Adafruit_TMP006 tmp006; void printFloat (float qiymati, int joylari); void setup () {Serial.begin (115200); // TMP006 ni ishga tushirish va I2C aloqasi uchun, agar (! Tmp006.begin (TMP006_CFG_8SAMPLE)) {Serial.println ("Sensor topilmadi"); vaqt (1); }} void loop () {float objt = tmp006.readObjTempC (); float diet = tmp006.readDieTempC (); Serial.print (objt); // Ob'ekt harorati Serial.print (" -"); Serial.println (parhez); // Die Haroratni kechiktirish (1000); }

7 -qadam: PyCharm

PyCharm
PyCharm

Quyidagi dasturni ishga tushirishdan oldin, pySerial va Matplotlib paketlari o'rnatilganligiga ishonch hosil qiling. PySerial - bu turli xil qurilmalarda ketma -ket ulanishni qo'llab -quvvatlaydigan Python kutubxonasi. Matplotlib - Python uchun tuzilgan kutubxona, PyCharm -ga har qanday paketni o'rnatish uchun quyidagi amallarni bajaring: 1. 2. Fayl -> Sozlamalar. Loyiha ostida Project Interpreter -ni tanlang va "+" belgisini bosing. Qidiruv satriga siz o'rnatmoqchi bo'lgan paketni kiriting va "Paketni o'rnatish" ni bosing.

8 -qadam: Python dasturi

pltplt.style.use ("seaborn") sifatida ketma -ket import matplotlib.pyplot '' '' Interaktiv rejimda pyplot funktsiyalari avtomatik ravishda ekranga tortiladi. Interaktiv rejim matplotlib.pyplot.ion () orqali yoqilishi va matplotlib.pyplot.ioff () orqali o'chirilishi mumkin. '' 'plt.ion () msp432 = serial. Serial (' COM4 ', 115200) #(port raqami, uzatish tezligi) - ketma -ket ob'ekt yaratish i = 0 x0 = y1 = y2 = rost bo'lsa: msp432Serial = msp432.readline () tempArray = msp432Serial.split (b '-') objTemp = float (tempArray [0]) dieTemp = float (tempArray [1]) x0.append (i) y1.append (objTemp) y2.append (dieTemp) i += 1 plt.xlim (chap = max (0, i-20), o'ng = i +10) #joriy o'qning x chegaralarini o'rnatish plt.ylim (20, 40) #set plt.ylabel o'qining y-chegaralari ('Harorat (C)', shrift nomi = 'Comic Sans MS', rang = 'ko'k', fontsize = 14) #y o'qi plt.grid uchun yorliqni o'rnating (To'g'ri) #tarmoqni plt.title ('TMP006 Live Data', fontname = 'Comic Sans MS', color = 'red', fontsize = 16) color = 'r', linewidth = 2) #x1 y1 versus - qizil chiziq p2, = plt.plot (x0, y2, color = 'g', chiziq kengligi = 2) #x2 y2 ga qarshi - yashil chiziq plt.legend ([p1, p2], ['Ob'ektlar harorati', 'O'lish harorati'], loc = 'yuqori o'ng', frameon = To'g'ri) #afsonalarni th o'ng burchakda elektron jadval plt.show () #raqamini ko'rsatish plt.pause (.000001) #intervalli soniyalar uchun pauza

9 -qadam: Yakuniy reja

Yakuniy syujet!
Yakuniy syujet!

Ob'ektning harorati: Bu yon atrofdagi chipning harorati. O'lim harorati: Bu chipning harorati. Manbalar: Educational BoosterPack MKII: https://www.ti.com/tool/BOOSTXL-EDUMKII Chipdagi infraqizil termopil sensori -O'lchovli paket: https://www.ti.com/ww/eu/sensampbook/tmp006.pdfMatplotlib: https://matplotlib.org/pySerial: https://pyserial.readthedocs.io/en/latest/shortintro. html

Tavsiya: