Cov txheej txheem:
- Khoom siv
- Kauj Ruam 1: Txhim Kho YAKINDU Statechart Cov Cuab Yeej Ua Plugin rau Code Composer Studio
- Kauj Ruam 2: Pib Nrog Lub Xeev Machine hauv Code Composer Studio
- Kauj Ruam 3: Tsim Lub Tshuab Blinky State
- Kauj Ruam 4: Tsim Lub Xeev Tshuab C Code
- Kauj Ruam 5: Hu Lub Xeev Tshuab Los Ntawm Koj Li Cai
- Kauj Ruam 6: Khiav Txoj Haujlwm
Video: Finite State Machine ntawm MSP430: 6 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Kuv yuav qhia koj li cas rau phiaj xwm MSP430G2 Launchpad nrog Finite State Machine (FSM) siv YAKINDU Statechart Cuab Yeej ncaj qha hauv Texas Instruments Code Composer Studio.
Qhov kev qhia no muaj rau qib:
- Txhim kho YAKINDU Statechart Cov Cuab Yeej raws li txuas rau Code Composer Studio
- Pib nrog State Machine hauv Code Composer Studio
- Tsim Blinky State Machine
- Tsim lub Xeev Lub Tshuab C code
- Hu rau Lub Xeev Tshuab los ntawm koj tus lej
- Khiav qhov project!
Txoj haujlwm no tuaj yeem siv los ua phiaj xwm rau ib qho MPS430 lossis MSP432!
Khoom siv
Software:
- YAKINDU Statechart Cov Cuab Yeej
- Code Composer Studio (CCS) Kev Txhim Kho Ib Leeg Ib puag ncig (IDE)
Kho vajtse:
MSP430G2 LaunchPad Cov Khoom Siv Txhim Kho
Kauj Ruam 1: Txhim Kho YAKINDU Statechart Cov Cuab Yeej Ua Plugin rau Code Composer Studio
Ua ntej, koj yuav tsum teeb tsa TI's Code Composer Studio. Kuv tau ua tiav kev sim teeb tsa nrog CCS version 9.2 thiab laus dua ib zaug. Koj tuaj yeem pom qhov rub tawm txuas ntawm no:
Download CCS
Nyem rau rub tawm thiab xyuas kom koj muaj tsawg kawg tau xaiv MSP430 ultra-low-power MCUs thaum txhim kho. Lub caij no, koj tuaj yeem lob qhov hloov tshiab rau YAKINDU Statechart Cov Cuab Yeej. Mus rau:
Rub tawm YAKINDU Statechart Cov Cuab Yeej
Ntawm qhov chaw no, nyem rau Download Tam sim no thiab ua raws cov lus qhia. Raws li koj tuaj yeem pom hauv daim duab: Nws yog pub dawb rau kev siv tsis yog lag luam. Tom qab sau npe, koj yuav tau txais cov ntsiab lus ntawm cov kev xaiv rub tawm. Nyem rau STANDARD DOWNLOAD SITE thiab nyem rau ntawm INSTALL FROM UPDATE SITE. Muaj koj yuav tau txais qhov txuas hauv qab Kev Tso Tawm Ncaj Ncees. Lob qhov txuas no thiab khaws nws lossis muab tso rau hauv koj daim ntawv teev cia.
Txhim kho YAKINDU Statechart Cov Cuab Yeej rau hauv Code Composer Studio tuaj yeem ua qhov nyuaj me ntsis, nyob ntawm qhov version ntawm Code Composer Studio koj tab tom siv. Tej zaum cov kauj ruam no dhau sijhawm lawm - txawm li cas los xij: tsis txhob ua siab deb nug kuv hauv cov lus yog tias koj xav tau kev pab.
Nov yog kuv cov kauj ruam:
Tom qab ua tiav txhim kho CCS rau koj lub kaw lus, qhib Cov Pab Pawg tab thiab nyem rau Nruab Nruab Software Tshiab…
download.eclipse.org/releases/2018-09/
Tsis txhob ntxiv dab tsi, nws tsuas yog yuav tsum tau daws. Koj tuaj yeem pom nws hauv daim duab.
Tom qab qhov no, rov ua cov kauj ruam thiab nyem rau ntawm Add … khawm. Ntxig rau YAKINDU Statechart Cuab Yeej hloov chaw, uas koj tau cia siab tias tau txais kev cawmdim. Tom qab ntawv, xaiv YAKINDU Daim Ntawv Tso Cai Tswj Xyuas Kev Tswj Xyuas thiab nyem rau tom ntej. Ua raws li cov lus qhia. Koj li IDE yuav rov pib dua ib zaug.
Thaum kawg, koj tuaj yeem nruab YAKINDU Statechart cov cuab yeej. Rov ua cov kauj ruam kawg, tab sis lub sijhawm no xaiv YAKINDU Statechart Tools Standard Edition. Ib zaug ntxiv, ua raws cov lus qhia. Tom qab rov pib dua koj tau ua tiav teeb tsa YAKINDU Statechart Cov Cuab Yeej.
Kauj Ruam 2: Pib Nrog Lub Xeev Machine hauv Code Composer Studio
Txhawm rau siv lub xeev cov tshuab ua haujlwm raws li ib txwm muaj thiab tsim CCS Project tshiab. Qhib Cov Ntawv tab, qhib Tshiab thiab nyem rau ntawm CCS Project. Txhais lub npe lub phiaj xwm, xaiv koj lub microcontroller thiab tsim qhov haujlwm khoob, uas muaj cov ntaub ntawv tseem ceeb khoob. Kuv siv MSP430G2553.
Tam sim no koj tuaj yeem pib ua haujlwm nrog cov tshuab hauv xeev!
Right-click qhov project, qhib Tshiab thiab xaiv Statechart Model. Tus Wizard yuav qhib uas koj tuaj yeem xaiv koj txoj haujlwm thiab npe koj daim ntawv qhia xeev. Piv txwv li, hu nws blinkyStateMachine.sct.
Daim qauv Statechart yuav tshwm nyob rau hauv daim nplaub tshev qhov project tom qab txhaj rau Finish. Nyem rau Yes yog tias koj raug nug kom hloov qhov kev xav.
Kauj Ruam 3: Tsim Lub Tshuab Blinky State
Tam sim no koj tuaj yeem pib tsim daim ntawv qhia xeev!
Ntawm sab laug, koj yuav pom qhov hu ua Cov Lus Txhais. Muaj koj tuaj yeem ntxiv cov ntsiab lus ntawm tus qauv, piv txwv li, kev ua haujlwm, uas tuaj yeem raug hu hauv lub xeev tshuab.
Rho tawm txhua yam los ntawm nws thiab yooj yim ntxiv peb cov ntsiab lus ua haujlwm no:
sab hauv:
ua haujlwm pib () ua haujlwm redOn () ua haujlwm redOff ()
Tom qab ntawd, hloov mus rau tus qauv daim phiaj xwm txheej thiab ntxiv peb lub xeev:
- Kev pib ua
- liab LED rau
- liab LED tawm
Txuas cov xeev raws li qhia hauv daim duab thiab ntxiv cov kev hloov pauv thiab nkag mus. Koj tuaj yeem pom lawv ntawm daim duab suav nrog dua.
Kauj Ruam 4: Tsim Lub Xeev Tshuab C Code
Tam sim no nws yog lub sijhawm los tsim C-Code. Txhawm rau ua qhov no, yuav tsum tsim cov qauv hluav taws xob. Txoj cai-nyem qhov haujlwm ib zaug ntxiv thiab qhib Tshiab thiab nyem rau ntawm Code Generator Model. Xaiv lub npe rau sgen-file. Nws yog ib qho kev coj ua zoo nyob nrog lub xeev lub npe tshuab. Hu rau nws blinkyStateMachine.sgen thiab nyem rau Next. Xaiv lub Xeev Lub Tshuab uas xav tau los ntawm txhaj rau ntawm lub npov. Ua kom ntseeg tau tias koj tau xaiv YAKINDU SCT C Code Generator (raws li peb xav tsim C-Code) thiab nyem rau ntawm Finish.
Feem ntau, C-Code yuav raug txiav tawm ncaj qha, tab sis yog tias tsis yog, koj tuaj yeem nyem qhov sgen -file thiab nyem rau ntawm Generate Code Artifacts kom ua li ntawd. Cov ntawv src thiab src-gen yuav tsum tshwm hauv koj qhov haujlwm. Lawv suav nrog qhov tsim C-Code, uas yuav raug kho tshiab thaum koj hloov kho thiab txuag daim ntawv qhia xeev.
Vim tias daim ntawv qhia xeev no siv cov xwm txheej raws sijhawm, yuav tsum tau siv sijhawm ua haujlwm. Txhawm rau npaj qhov no, koj xav tau ob daim ntawv no: sc_timer_service.c thiab sc_timer_service.h Koj tuaj yeem tau txais lawv los ntawm GitHub lossis rub tawm lawv ntawm no. Koj yuav tsum ntxiv lawv mus rau src nplaub tshev.
Kauj Ruam 5: Hu Lub Xeev Tshuab Los Ntawm Koj Li Cai
Thaum kawg, lub xeev lub tshuab tuaj yeem siv rau hauv koj lub luag haujlwm tseem ceeb!
Ua ntej tshaj, koj yuav tsum suav nrog lub xeev lub tshuab thiab lub sijhawm ua haujlwm pabcuam. Tom qab ntawd lub xeev tshuab, lub sijhawm ua haujlwm thiab cov haujlwm xav tau rau lub sijhawm pabcuam yuav tsum tau tshaj tawm thiab txhais. Ib qho ntxiv, cov haujlwm uas tau hais tseg uas tau tig lub teeb liab coj los thiab tawm dua yuav tsum tau ua tiav.
#suav nrog
#include "src-gen/BlinkyStateMachine.h" #include "src/sc_timer_service.h" BlinkyStateMachine ntsais muag; #define MAX_TIMERS 4 zoo li qub sc_timer_t timers [MAX_TIMERS]; zoo li qub sc_timer_service_t timer_service; //! Kev hu rov qab rau kev teeb tsa lub sijhawm txheej xwm sab nrauv tsis muaj dab tsi blinkyStateMachine_setTimer (BlinkyStateMachine* tuav, const sc_eventid evid, const sc_integer time_ms, const sc_boolean periodic) {sc_timer_start (& timer_service, tuav, evid, time_ms, periodic) } // ib! kev hu rov qab rau kev tshem tawm cov xwm txheej sijhawm. extern void blinkyStateMachine_unsetTimer (BlinkyStateMachine* tuav, const sc_eventid evid) {sc_timer_cancel (& timer_service, evid); } // ib! txhais kev ua haujlwm sab nrauv tsis muaj dab tsi blinkyStateMachineInternal_init (const BlinkyStateMachine* tuav) {WDTCTL = WDT_MDLY_32; IE1 | = WDTIE; P1DIR | = BIT0; } extern void blinkyStateMachineInternal_redOn (const BlinkyStateMachine* tuav) {P1OUT | = BIT0; } extern void blinkyStateMachineInternal_redOff (const BlinkyStateMachine* tuav) {P1OUT & = ~ BIT0; }
Lub luag haujlwm tseem ceeb muaj ob ntu:
Kev pib ua ntej thiab nkag mus ua haujlwm ntawm lub xeev lub tshuab thiab pib ua lub sijhawm.
Qhov thib ob yog lub voj tsis muaj qhov kawg - lub sijhawm (1) lub voj. Tsis pub dhau lub voj no, kev ua haujlwm ntawm lub tshuab hauv lub xeev yog hu ua. Tom qab ntawd, MSP430 yuav raug teeb tsa rau hauv Lub Hwj Chim Qis 0 thiab Kev cuam tshuam dav dav Pab kom me ntsis tau teeb tsa. Tam sim no lub microcontroller tau tsaug zog thiab tos kom muaj kev cuam tshuam. Tom qab kev cuam tshuam ntawm WDT, lub sijhawm yuav pib. Qhov no txhais tau tias txhua lub sijhawm tau hloov kho tshiab thiab lub sijhawm dhau los tau nce ntxiv los ntawm 32 - lub sijhawm hauv milliseconds, uas tau ua tom qab txhua qhov cuam tshuam ntawm WDT.
void main (void) {WDTCTL = WDTPW | WDTHOLD; // Nres watchdog timer
// Init timer thiab lub xeev tshuab sc_timer_service_init (& timer_service, timers, MAX_TIMERS, (sc_raise_time_event_fp) & blinkyStateMachine_raiseTimeEvent); blinkyStateMachine_init (& blinky); blinkyStateMachine_enter (& blinky);
thaum (1)
{// hu rau lub xeev tshuab txhua 32 ms blinkyStateMachine_runCycle (& blinky); _bis_SR_register (LPM0_bits + GIE); sc_timer_service_proceed (& timer_service, 32); }}
// WDT ISR
#pragma vector = WDT_VECTOR _ cuam tshuam void watchdog_timer (tsis muaj dab tsi) {_bic_SR_register_on_exit (LPM0_bits + GIE); }
Kauj Ruam 6: Khiav Txoj Haujlwm
Nov yog nws - Tam sim no koj tuaj yeem tsim thiab xa cov program rau koj MSP430!
Vam tias, qhov kev qhia no tau pab koj kom ua tiav txoj haujlwm rau koj MSP430. Tam sim no nws yog lub sijhawm los siv koj li kev xav!
Txog kev tsim cov cai, YAKINDU Cov Ntawv Cuam Tshuam Hauv Xeev yog xav tau los ua Plugin hauv koj li Code Composer Studio.
Koj tuaj yeem tau txais qhov hloov tshiab ntawm no! <
Nws pib nrog 30 hnub sim version. Tom qab ntawd, koj tuaj yeem tau txais daim ntawv tso cai pub dawb rau kev siv tsis yog lag luam!
Pom zoo:
Plotting Real-time Graph ntawm Android Los Ntawm Arduino Los Ntawm HC-05: 3 Cov Kauj Ruam
Plotting Real-time Graph ntawm Android Los ntawm Arduino Los ntawm HC-05: Hav nyob ntawm no, ntawm no yog kev qhia qhia yuav ua li cas npaj cov phiaj xwm ntawm lub sijhawm tiag tiag ntawm qhov tseem ceeb los ntawm tus tswj hwm micro xws li Arduino rau lub app. Nws siv Bluetooth qauv xws li HC-05 los ua lub cuab yeej xa xov mus rau kis thiab tau txais cov ntaub ntawv ntawm Ar
Tsim thiab Ua tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels: 5 Cov Kauj Ruam
Tsim thiab Ua kom tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels: Tsim thiab Ua tiav ntawm Cov Txheej Txheem ntawm Kev Taw Qhia ntawm Photovoltaic Panels
Kev tswj hwm tus kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Li Tachometer: 5 Cov Kauj Ruam (nrog Duab)
Kev Tswj Tus Kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Lub Tachometer: Muaj ib txwm xav tau rau kev siv tshuab txheej txheem, ua nws yooj yim/tsis txaus ntseeg. cov txheej txheem rau dej/siv dej rau peb daim av me me.Qhov teeb meem ntawm tsis muaj kab khoom siv tam sim no
Zaub Cov Duab Tawm ntawm PSP/Lub Xov Tooj Ntawm Lub Xov Tooj Ntawm Digital Duab: 3 Kauj Ruam
Zaub Cov Duab Tawm PSP/Lub Xov Tooj Ntawm Lub Xov Tooj Ntawm Tus Duab: Zoo … lub npe hais tias txhua yam tiag tiag … Qhov no yog qhov qhia tau yooj yim heev thiab nws tsis xav tau kho vajtse lossis software ntau dua li koj yuav tsum muaj ! Cov Lus Nug Qhia Rau Kuv lossis Tawm Tswv Yim! Koj tsis tas yuav hloov kho kom ua
Cov lus qhia ntawm Kev Ua Kom Zoo Mock-Up ntawm Track Slide Tsim rau Nqa/Txo Hauv Pem Hauv Ntej-Mounted Footrests ntawm Lub Hwj Huam Log: 9 Kauj Ruam (nrog Duab)
Cov lus qhia ntawm Kev Ua Kom Tiav Mock-Up ntawm Track Slide Tsim rau Nqa/Sab Qaum Nruab Nrab-Mounted Footrests ntawm Lub Hwj Huam Lub Rooj Zaum: Lub hauv paus tau teeb tsa lub tog zaum kom nqa tau hauv qab lub rooj kom zoo, thiab qis dua kom siv tau. Ib lub tswv yim rau kev ua haujlwm ywj pheej ntawm kev tuav cov footrest thiab kev xa tawm tsis suav nrog lub rooj zaum fais fab lag luam, thiab PWC cov neeg siv tau qhia txog qhov xav tau