Cov txheej txheem:

MATLAB Tswj Microcontroller (Arduino MKR1000): 4 Cov Kauj Ruam
MATLAB Tswj Microcontroller (Arduino MKR1000): 4 Cov Kauj Ruam

Video: MATLAB Tswj Microcontroller (Arduino MKR1000): 4 Cov Kauj Ruam

Video: MATLAB Tswj Microcontroller (Arduino MKR1000): 4 Cov Kauj Ruam
Video: Healthy Drinks intake in Proteinuria | Protein in Urine Treatment | Protein Loss | Albumin in urine 2024, Kaum ib hlis
Anonim
MATLAB Tswj Microcontroller (Arduino MKR1000)
MATLAB Tswj Microcontroller (Arduino MKR1000)

Lub hom phiaj ntawm peb txoj haujlwm yog siv MATLAB nrog rau Arduino MKR1000 kom zoo tshaj qhov peb muaj peev xwm. Peb lub hom phiaj yog txhawm rau tsim tsab ntawv uas tso cai rau qee yam tshwj xeeb ntawm arduino kom ua tiav qhov tsim tawm raws li cov lus qhia tshwj xeeb. Peb tau siv ntau lub ntsiab lus thiab cov nqe lus hais tshwj xeeb hauv MATLAB uas ua rau qhov no ua tau. Peb kuj tseem siv MATLAB mobile los ntawm kev siv cov ntaub ntawv tau txais los ntawm lub xov tooj ntawm tes gyroscope los txhim kho txoj haujlwm kom ntau li ntau tau.

Kauj Ruam 1: Cov Khoom thiab Cov Khoom

Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom

MATLAB 2018 a

-Cov 2018 MATLAB yog qhov nyiam tshaj plaws, feem ntau vim nws ua haujlwm tau zoo tshaj plaws nrog cov cai uas txuas rau lub xov tooj ntawm tes. Txawm li cas los xij, feem ntau ntawm peb cov lej tuaj yeem txhais los ntawm feem ntau ntawm MATLAB cov qauv.

Arduino MKX 1000

-Qhov no yog cov cuab yeej tshwj xeeb uas tso cai rau peb xaim hluav taws xob txuas mus rau ob qho tib si digital thiab analog chaw nres nkoj. Nws yog ib qho tseem ceeb heev uas koj tseem muaj lub khob cij los nrog nws.

Accessories

-Thaum siv MKR1000, peb xav tau cov khoom siv ntxiv txhawm rau ua tiav cov haujlwm tsim nyog.

Qhov no suav nrog

  1. Servo
  2. Khawm (6)
  3. Hloov pauv RBG LED teeb
  4. Cov Xov Xwm Yooj Yim
  5. breadboard (s) cov
  6. mini fais fab hloov
  7. kub sensor
  8. 330 ohm tiv thaiv
  9. 10K ohm resistor
  10. USB-microUSB qaum
  11. Laptop/desktop
  12. Txawb ntaus ntawv

Nws tseem yuav tsum tau sau tseg tias muaj ntau, ntau yam khoom siv ntxiv uas tuaj yeem siv nrog MKR1000

Kauj Ruam 2: MATLAB Arduino Support Package

Txhawm rau kom siv Arduino MKR1000 kom raug los ntawm MATLAB, koj yuav tsum rub tawm MATLAB Cov Pob Txhawb rau Arduino Kho Vajtse. Qhov rub tawm no muab rau koj nkag mus rau qee qhov haujlwm thiab cov lus txib ncaj qha rau pawg thawj coj saib arduino.

Koj tuaj yeem rub tawm pob ntawm qhov txuas hauv qab no

www.mathworks.com/matlabcentral/fileexchange/47522-matlab-support-package-for-arduino-hardware

Kauj Ruam 3: Siv Cov Ntaub Ntawv Ruaj Ntseg Tau Txais Los Ntawm Txawb Xov Tooj

Siv Cov Ntaub Ntawv Ruaj Ntseg Tau Txais Los Ntawm Cov Khoom Siv Mobile
Siv Cov Ntaub Ntawv Ruaj Ntseg Tau Txais Los Ntawm Cov Khoom Siv Mobile

MATLAB Txawb app tso cai rau peb siv lub xov tooj ntawm tes kom ntws cov ntaub ntawv los ntawm kev siv nws lub gyroscope. Txhawm rau kom tau txais cov ntaub ntawv los ntawm MATLAB, peb tau txais cov ntaub ntawv los ntawm kev rov ua nws los ntawm kev taw qhia cov lej los ntawm MATLAB mobile. Peb ua qhov no los ntawm kev tsim qhov sib txawv rau txhua kab lus ntawm cov lej sib piv (Azimuth, Suab, thiab Roll), thiab ntsuas qhov ntsuas tas li ntawm cov txiaj ntsig los ntawm lub xov tooj ntawm tes mus rau lub khoos phis tawj. Qhov no tso cai rau peb los tsim cov lus hais raws li yuav npaj ua ntej tso tawm yog tias MATLAB khaws cov ntaub ntawv tshwj xeeb los ntawm lub xov tooj ntawm tes. Txhawm rau ua qhov no, koj yuav xav tau MATLAB txawb ntawm koj lub xov tooj ntawm tes, thiab pob khoom txhawb nqa MATLAB rau ntawm koj lub computer.

Koj tuaj yeem rub tawm cov ntawv ntawm qhov txuas hauv qab no

www.mathworks.com/matlabcentral/fileexchange/51235-matlab-support-package-for-apple-ios-sensors

Kauj Ruam 4: Cov Cai thiab Cov Chaw Txuas Hluav Taws Xob

Txoj cai pib nrog cov lus pib uas nug yog tias peb xav pib peb lub cuab yeej ruaj ntseg hauv tsev. Yog tias peb teb tias yog, thiab muab tus lej nkag nkag raug, cov ntawv tam sim dhia mus rau lub sijhawm luv. Los ntawm qhov ntawd, nws pib sau cov ntaub ntawv los ntawm lub xov tooj ntawm tes. Muaj cov xwm txheej uas nyeem cov ntaub ntawv no. Peb tuaj yeem qhib thiab kaw lub kaw lus los ntawm peb lub xov tooj ntawm tes, thiab cov cai yuav tig lub servo thiab ntsais lub teeb LED nyob ntawm qhov muab cov ntaub ntawv los ntawm lub xov tooj ntawm tes

pib = questdlg ('Koj puas xav qhib ecoTECH Smart Home Energy System?'); % Pib qhib ua ntu zus ntawm ecoTECHwaitfor (pib) yog tias pib == "Yog" % Yog tias "Yog" raug xaiv qhov ua kom ua ntu zus pib thiab nkag mus thaum lub voj ntawm lub zog kawg = "rau"; m1 = msgbox ('Pib li ecoTECH…'); ncua (2); rho tawm (m1); m1_wait = waitbar (0, 'Thov tos …'); cov kauj ruam = 25; rau kuv = 1: kauj ruam ncua (.1); waitbar (i/cov kauj ruam); % Hloov kho qhov tos tos kawg tshem tawm (m1_wait); PASSCODE = [0 0 0 0]; % Initializes passcode ii = 0; % Initializes ib qhov txawv txav siv los ua txhaum ntawm loops m2 = msgbox ('ecoTECH ua haujlwm tag nrho!'); ncua (2); rho tawm (m2); elseif pib == "Tsis yog" || pib == "Nthuav tawm" % Yog tias "Tsis yog" lossis "Nthuav tawm" raug xaiv ces qhov ua kom ua ntu zus tsis pib thiab tsis nkag mus rau lub sijhawm voj zog = "tawm"; m3 = msgbox ('Okay! Nyob zoo!'); ncua (2); rho tawm (m3); kawg

% ecoTECH hauv Nqe Nqis thaum muaj tseeb thaum lub zog == "ntawm" % Txawb Ntu Ntu thaum muaj tseeb % Sau cov ntaub ntawv hais txog Kev taw qhia Roll ntawm lub xov tooj ntawm tes KEY = m. Orientation (3); % Sau cov ntaub ntawv hais txog cov nyees khawm b2 = readDigitalPin (a, 'D2'); % Khawm 2 (Liab) b3 = readDigitalPin (a, 'D3'); % Khawm 3 (Dawb) yog KEY> = 35 % hauv qib m4 = msgbox ('Zoo Siab Txais Tos Tsev!')) writeDigitalPin (a, 'D8', 1); % Tig rau lub teeb ntsuab ncua (.5); sauPosition (s, 1); % Tig lub servo kom qhib lub qhov rooj ncua (2); writeDigitalPin (a, 'D8', 0); Qhib lub teeb ntsuab rho tawm (m4); elseif KEY <= -35 % hauv qib m5 = msgbox ('Qhov Rooj Xauv!'); writeDigitalPin (a, 'D7', 1); % Tig rau lub teeb liab ncua (.5); sauPosition (s, 0); % Tig lub servo kaw lub qhov rooj ncua (2); writeDigitalPin (a, 'D7', 0); % Tua lub teeb liab tshem tawm (m5); ii = 1; tawg % Tawm thaum lub voj uas muaj lub xov tooj ntawm tes yog lub qhov rooj raug kaw siv lub xov tooj ntawm tes elseif b2 == 0 && b3 == 0 % Tawm thaum lub voj uas muaj lub xov tooj ntawm tus yuam sij nkag mus rau ntu passcode ntu xaus kawg

Tom qab qhov no, nws tuaj yeem nkag mus rau lwm lub voj. Qhov no thaum lub voj tswj hwm cov txiaj ntsig raws li kev nkag los ntawm cov nyees khawm. Yog tias thawj lub voj yog qhov tsis tsim nyog, lossis yuav tsum tau kaw phau ntawv, nws yuav nkag mus rau lwm lub voj thaum twg xav tau tus password tshwj xeeb. Yog tias tus password tsis raug, nws yuav rov pib dua lub voj

thaum muaj tseeb yog tias ii == 1 % Tawm thaum lub voj uas muaj tus lej nkag yog lub qhov rooj tau qhib nrog lub cuab yeej txawb tawg kawg % Sau cov ntaub ntawv hais txog cov nyees khawm b5 = readDigitalPin (a, 'D5'); % Khawm 5 (Xiav) b1 = readDigitalPin (a, 'D1'); % Khawm 1 (Dub) b4 = readDigitalPin (a, 'D4'); % Button 4 (Dawb) yog b5 == 0 % Pib passcode nkag mus rau ntu rau b = 1: 5 m6 = msgbox ('Thov Nias Thiab Nias Ib Khawm'); ncua (2); rho tawm (m6); % Sau cov ntaub ntawv hais txog cov nyees khawm b1 = readDigitalPin (a, 'D1'); % Khawm 1 (Dub) b2 = readDigitalPin (a, 'D2'); % Khawm 2 (Liab) b3 = readDigitalPin (a, 'D3'); % Khawm 3 (Dawb) b4 = readDigitalPin (a, 'D4'); % Khawm 4 (Daj) b5 = readDigitalPin (a, 'D5'); % Khawm 5 (Xiav) % Hloov qhov tseem ceeb hauv thawj tus lej cim ib zaug yog b1 == 0 PASSCODE (0+b) = 1; elseif b2 == 0 PASSCODE (0+b) = 2; elseif b3 == 0 PASSCODE (0+b) = 3; elseif b4 == 0 PASSCODE (0+b) = 4; elseif b5 == 0 PASSCODE = sprintf ('%. 0f%.0f%.0f%.0f', PASSCODE (1), PASSCODE (2), PASSCODE (3), PASSCODE (4)); % Tig qhov sib lawv liag ntawm cov nyees khawm nias rau tus lej ces hloov nws mus rau txoj hlua kawg % Qhov kawg ntawm lub voj rau nkag mus rau tus lej rau tus lej cim yog tias PASSCODE == "2314" % Yog tias tus lej nkag nkag nkag sib xws ces lub qhov rooj qhib rau ob peb feeb ces xauv m7 = msgbox ('Zoo Siab Txais Tos Tsev!'); writeDigitalPin (a, 'D8', 1); % Tig rau lub teeb ntsuab ncua (.5); sauPosition (s, 1); % Tig lub servo los qhib lub qhov rooj ncua (5); writeDigitalPin (a, 'D8', 0); % Tua lub teeb ntsuab ncua (.1); writeDigitalPin (a, 'D7', 1); % Tig rau lub teeb liab ncua (.5); sauPosition (s, 0); % Tig lub servo kaw lub qhov rooj ncua (1); writeDigitalPin (a, 'D7', 0); % Tua lub teeb liab tshem tawm (m7); ii = 1; tawg % Tawm thaum lub voj uas muaj tus lej nkag mus tom qab nkag mus rau tus lej nkag mus raug lawm yog tias PASSCODE ~ = "2314" writeDigitalPin (a, 'D7', 1); % Tig lub teeb liab m8 = msgbox ('Passcode tsis raug! Sim dua!'); tos rau (m8) writeDigitalPin (a, 'D7', 0); % Tua lub teeb liab txuas ntxiv % Tso cai rau koj rov nkag tus lej nkag mus kawg lwm qhov yog tias b1 == 0 && b4 == 0 % Tawm thaum lub voj uas muaj ntu ntu passcode yog tias koj tsis xav nkag mus rau tus lej passcode ii = 1; tawg kawg kawg

Yog tias raug, nws yuav nkag mus tam sim tam sim lub voj uas tswj hwm qhov ntsuas kub. Yog tias qhov hloov pauv, lub voj yuav txuas ntxiv mus thiab npaj qhov ntsuas kub piv rau lub sijhawm phiaj xwm, tso cai rau ib tus los saib qhov sib txawv. Yog tias lub pob txuas nrog lub ntsuas kub tau ntsuas, nws tseem yuav xa email qhia koj tias qhov ntsuas kub nyob hauv koj "tsev" li cas. Yog tias qhov kev hloov pauv raug kaw, nws yuav xaus txoj cai tam sim ntawd

t = 0; % Lub sijhawm pib = 0 vib nas this ncua (5) % Muab sijhawm rau tus neeg siv qhib lub ntsuas kub hloov SWITCH = readDigitalPin (a, 'D11'); % Sau cov ntaub ntawv hais txog qhov hloov pauv hauv tus pin D11 thaum SWITCH == 0 SWITCH = readDigitalPin (a, 'D11'); % Sau cov ntaub ntawv hais txog kev hloov pauv tus pin D11 voltage = readVoltage (a, 'A1'); % Nyeem qhov hluav taws xob los ntawm qhov ntsuas qhov ntsuas kub temp_C = (voltage.*1000 - 500)./ 10; % Hloov qhov hluav taws xob mus rau qhov kub hauv ° C temp_F = (9/5).*Temp_C + 32; % Hloov los ntawm ° C mus rau ° F cov phiaj (t, temp_C, 'b.') Tuav ntawm lub npe ('Chav Kub'); xlabel ('Sijhawm hauv vib nas this'); ylabel ('Kub'); axis ([0, 180, 0, 100]); lub ntsiab lus (t, temp_F, 'r.') lus dab neeg ('Kub hauv ° C', 'Kub hauv ° F') ncua (1); t = t + 1; % Lub sijhawm suav hauv vib nas this % E-mail Tshooj b_temp = readDigitalPin (a, 'D0'); % Sau cov ntaub ntawv ntawm (xiav) qhov kub thiab txias hauv tus pin D0 yog tias b_temp == 0 setpref ('Internet', 'SMTP_Server', 'smtp.gmail.com'); setpref ('Internet', 'E_mail', '[email protected]'); % Sender setpref ('Internet', 'SMTP_Username', '[email protected]'); % Sender's username setpref ('Internet', 'SMTP_Password', 'Integral_ecoTECH'); % Sender's password props = java.lang. System.getProperties; props.setProperty ('mail.smtp.auth', 'tseeb'); props.setProperty ('mail.smtp.socketFactory.class', 'javax.net.ssl. SSLSocketFactory'); props.setProperty ('mail.smtp.socketFactory.port', '465'); xa ntawv ('[email protected] ',' ecoTECH Chav Kub ', sprintf (' Qhov kub ntawm chav tam sim no yog %.1f ° C lossis %.1f ° F ', tem_C, temp_F)); % Xa e-mail rau tus tau txais kev pabcuam muab cov ntaub ntawv ntawm chav sov tam sim no fprintf ('E-mail ua tiav xa! / N') kawg yog temp_F> = 75 % Yog tias chav sov nce mus rau 75 ° F … temp_AC = 65; % Hloov qhov ntsuas kub ntawm lub ntsuas cua mus rau 65 ° F lwm qhov yog temp_F <= 65 % Yog tias chav sov sov qis dua 60 ° F … temp_AC = 80; % Hloov qhov ntsuas kub ntawm lub ntsuas cua mus rau 80 ° F kawg kawg % Qhov kawg ntawm "SWITCH == 0" thaum lub voj yog tias lub zog == "tawm" || ii == 1 % Tawm "lub zog == rau" thaum lub voj tawg xaus kawg % Qhov kawg ntawm "lub zog == ntawm" thaum lub voj yog tias lub zog == "tawm" || ii == 1 % Tawm tag nrho thaum lub voj tawg xaus

Qhov no tsuas yog piav qhia luv luv ntawm cov cai thiab nws lub luag haujlwm. Peb tau txuas tag nrho cov cai ua pdf yog xav tau

Nov yog cov npe ntawm qhov chaw nres nkoj txhua lub cuab yeej txuas rau

1. RGB LED: Cov Pins Digital (7, 8, 9)

2. Servo: Digital Pin 6

3. Khawm: Digital Pins (1, 2, 3, 4, 5)

4. Xiav Khawm rau email: Digital Pin 0

5. Kub Sensor: Pin Pin 1

6. Hloov: Digital Pin 11

Pom zoo: