Cov txheej txheem:

Plotting Live Cov Ntaub Ntawv ntawm Qhov Kub Kub Sensor (TMP006) Siv MSP432 LaunchPad thiab Python: 9 Kauj Ruam
Plotting Live Cov Ntaub Ntawv ntawm Qhov Kub Kub Sensor (TMP006) Siv MSP432 LaunchPad thiab Python: 9 Kauj Ruam

Video: Plotting Live Cov Ntaub Ntawv ntawm Qhov Kub Kub Sensor (TMP006) Siv MSP432 LaunchPad thiab Python: 9 Kauj Ruam

Video: Plotting Live Cov Ntaub Ntawv ntawm Qhov Kub Kub Sensor (TMP006) Siv MSP432 LaunchPad thiab Python: 9 Kauj Ruam
Video: Tik Tok || Tseem Nco Koj Thiab Kuv P15 2024, Kaum ib hlis
Anonim
Image
Image
Software - Energia IDE, PyCharm
Software - Energia IDE, PyCharm

TMP006 yog qhov ntsuas kub uas ntsuas qhov kub ntawm ib yam khoom yam tsis tas yuav ua kom muaj kev sib cuag nrog cov khoom. Hauv qhov kev qhia no peb yuav npaj cov ntaub ntawv ntsuas kub nyob ntawm BoosterPack (TI BOOSTXL-EDUMKII) siv Python.

Kauj Ruam 1: Software - Energia IDE, PyCharm

Energia IDE:

Kauj Ruam 2: Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII

Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII
Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII
Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII
Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII
Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII
Kho vajtse - MSP432 LaunchPad, Kev Kawm BoosterPack MKII

Kauj Ruam 3: Energia IDE

Energia IDE
Energia IDE

Txuas MSP432 LaunchPad + Kev Kawm BoosterPack rau ib qho ntawm koj lub computer USB chaw nres nkoj thiab qhib Energia IDE.

Kauj Ruam 4: Xaiv Qhov Tsim Nyog COM Port thiab Board

Xaiv qhov tsim nyog COM Port thiab Board
Xaiv qhov tsim nyog COM Port thiab Board

Kauj Ruam 5: Energia Los Ua Ntej Ua Ntej Nrog Tus Qauv Piv Txwv rau TMP006

Energia Los Ua Ntej Ua Ntej Nrog Tus Qauv Piv Txwv rau TMP006
Energia Los Ua Ntej Ua Ntej Nrog Tus Qauv Piv Txwv rau TMP006

Tus qauv piv txwv tuaj yeem qhib raws li qhia hauv daim duab.

Kauj Ruam 6: Tshaj Tawm Cov Kev Pab Hauv Qab no mus rau LaunchPad los ntawm Nyem rau ntawm Upload khawm

Rub qhov program hauv qab no mus rau LaunchPad los ntawm Nyem rau ntawm Upload khawm
Rub qhov program hauv qab no mus rau LaunchPad los ntawm Nyem rau ntawm Upload khawm

#include #include "Adafruit_TMP006.h" #define USE_USCI_B1 Adafruit_TMP006 tmp006; void printFloat (tus nqi ntab, qhov chaw nyob); tsis muaj teeb tsa () {Serial.begin (115200); // Initalizes TMP006 rau kev ua haujlwm thiab rau I2C kev sib txuas lus yog (! Tmp006.begin (TMP006_CFG_8SAMPLE)) {Serial.println ("Tsis pom lub sensor"); thaum (1); }} void loop () {float objt = tmp006.readObjTempC (); ntab noj zaub mov = tmp006.readDieTempC (); Serial.print (objt); // Lub Hom Phiaj Kub Serial.print (" -"); Serial.println (kev noj haus); // Tuag Kub ncua (1000); }

Kauj ruam 7: PyCharm

PyCharm
PyCharm

Ua ntej khiav qhov haujlwm hauv qab no, xyuas kom tseeb tias cov pob khoom, pySerial thiab Matplotlib tau teeb tsa. PySerial yog Python lub tsev qiv ntawv uas muab kev txhawb nqa rau kev sib txuas txuas nrog ntau yam khoom siv sib txawv. Matplotlib yog lub tsev qiv ntawv npaj rau Python. To nruab ib lub pob hauv PyCharm, ua raws cov theem hauv qab no: 1. Cov Ntaub Ntawv -> Chaw. 2. Hauv Txoj Haujlwm, xaiv Txoj Haujlwm Txhais Lus thiab nyem rau ntawm lub cim "+" 3. Hauv kab ntawv tshawb nrhiav, ntaus pob koj xav nruab thiab nyem rau ntawm Install Package.

Kauj Ruam 8: Txoj Haujlwm Python

ntshuam ntshuam ntshuam ntshuam matplotlib.pyplot li pltplt.style.use ("seaborn") Hom kev sib tham kuj tseem tuaj yeem qhib ntawm matplotlib.pyplot.ion (), thiab kaw ntawm matplotlib.pyplot.ioff (). '' 'plt.ion () msp432 = serial. Serial (' COM4 ', 115200) #(tus lej chaw nres nkoj, baudrate) - tsim cov khoom sib txuas i = 0 x0 = y1 = y2 = thaum Muaj tseeb: msp432Serial = msp432.readline () tempArray = msp432Serial.split (b '-') objTemp = ntab (tempArray [0]) dieTemp = float (tempArray [1]) x0.append (i) y1.append (objTemp) y2.append (dieTemp) i += 1 plt.xlim (sab laug = max (0, i-20), txoj cai = i +10) #teeb tsa x-txwv ntawm cov kab tam sim no plt.ylim (20, 40) #set y-txwv ntawm cov kab tam sim no plt.ylabel ('Kub (C)', fontname = 'Comic Sans MS', xim = 'xiav', fontsize = 14) #teeb daim ntawv lo rau y-axis plt.grid (Muaj tseeb) #turn daim phiaj ntawm plt.title ('TMP006 Cov Ntaub Ntawv Nyob', fontname = 'Comic Sans MS', xim = 'liab', fontsize = 16) #teeb lub npe p1, = plt.plot (x0, y1, color = 'r', linewidth = 2) #plot x0 versus y1 - red line p2, = plt.plot (x0, y2, color = 'g', linewidth = 2) #plot x0 versus y2 - kab ntsuab plt.legend ([p1, p2], ['Object Temperature', 'Die Temperature'], loc = 'upper right', frameon = True) #tso cov lus dab neeg nyob rau sab xis saum toj ntawm e daim duab plt.show () #display daim duab plt.pause (.000001) #ncua rau ntu thib ob

Kauj ruam 9: Daim phiaj kawg

Daim phiaj kawg!
Daim phiaj kawg!

Lub Hom Phiaj Kub: Nws yog qhov kub ntawm cov nti ib puag ncig. Qhov Kub: Nws yog qhov kub ntawm cov nti nws tus kheej. -Scale Pob: https://www.ti.com/ww/eu/sensampbook/tmp006.pdfMatplotlib: https://matplotlib.org/pySerial: https://pyserial.readthedocs.io/en/latest/shortintro. html

Pom zoo: