Cov txheej txheem:

LifeGuard 2.0: 7 Cov Kauj Ruam (nrog Duab)
LifeGuard 2.0: 7 Cov Kauj Ruam (nrog Duab)

Video: LifeGuard 2.0: 7 Cov Kauj Ruam (nrog Duab)

Video: LifeGuard 2.0: 7 Cov Kauj Ruam (nrog Duab)
Video: Ka Yeng Vue speaking @ UW-Stevens Point for Earthweek 2017 2024, Kaum ib hlis
Anonim
LifeGuard hwm 2.0
LifeGuard hwm 2.0

Koj puas tau xav ua qhov kev ua lej, ntsuas lub ntsuas sensor, saib xyuas cov analog thiab digital inputs, thiab tswj cov analog thiab digital outputs uas tsis muaj kev paub txog hluav taws xob yav dhau los? Yog tias yog, txoj haujlwm no tsuas yog rau koj! Peb yuav siv lub microcontroller thiab MATLAB los tsim cov cuab yeej uas tuaj yeem siv los tshuaj xyuas thiab txhim kho EF Express SMART RAIL system. Nrog lub microcontroller, muaj peev xwm nkag tau thiab tso tawm (teeb liab/cov ntaub ntawv nkag mus rau hauv lub rooj tsavxwm thiab teeb liab tawm ntawm lub rooj tsavxwm) tsis muaj qhov kawg. Peb yuav siv lub flex sensor thiab potentiometer raws li peb cov tswv yim. Lawv cov txiaj ntsig yuav yog cov lus ntawm LCD screen thiab LED teeb nrog rau lub suab nrov, feem. Kev txhim kho peb vam tias yuav siv rau hauv SMART RAIL system yog txheeb ze rau kev txhim kho kev nyab xeeb ntawm lub system. Lob koj lub laptop thiab microcontroller, thiab cia peb pib!

Kauj Ruam 1: Software thiab Cov Ntaub Ntawv

Software thiab Khoom
Software thiab Khoom
Software thiab Khoom
Software thiab Khoom
Software thiab Khoom
Software thiab Khoom
Software thiab Khoom
Software thiab Khoom

Software xav tau

1.) MATLAB

- Koj yuav tsum rub tawm MATLAB version hauv koj lub computer. Mus rau mathworks.com thiab teeb tsa MATHWORKS tus account, rub tawm cov ntawv, thiab qhib koj daim ntawv tso cai.

-Koj yuav tsum rub tawm thiab teeb tsa TXHUA cov cuab yeej siv rau qhov tshaj tawm tshiab (R2016a lossis R2016b).

-Mac cov neeg siv: koj yuav tsum muaj OSX 10.9.5 lossis tom qab ntawd los khiav R2015b, nws yog qhov zoo los khiav MATLAB ua ntej.

2.) Pob Khoom Txhawb Arduino:

-Txhua pob Arduino Kho Vajtse Txhawb Pob. Qhib MATLAB. Ntawm MATLAB Tsev tab, hauv Cov Ntawv Qhia Ib puag ncig, xaiv Ntxiv-Tau Txais Cov Khoom Pab Txhawb Cov Khoom Xaiv "MATLAB Txhawb Pob rau Arduino Kho Vajtse". Koj yuav tsum nkag mus rau koj tus lej MATHWORKS

-Yog koj kev teeb tsa raug cuam tshuam thiab koj tau ua tiav qhov kev sim ua tsis tiav/yuam kev thaum txhim kho pob khoom kho vajtse - nrhiav thiab rho tawm daim nplaub tshev Arduino rub tawm ntawm koj lub hard drive thiab pib txij thaum pib.

Cov ntaub ntawv xav tau

1.) Lub laptop lossis lub khoos phis tawj desktop

2.) SparkFun Arduino Board

3.) Flex Sensor

4.) Potentiometer

5.) LCD npo

6.) LED teeb

7.) SparkFun Inventor's Kit (Nrhiav hauv online)

8.) USB cable thiab mini USB

9.) Jumper xov hlau

10.) Piezo buzzer

Kauj ruam 2: Txuas rau Koj Arduino thiab Txiav Txim COM Port

(Koj qhov chaw nres nkoj COM tuaj yeem hloov pauv txhua lub sijhawm koj txuas) Txuas Arduino USB cable rau koj lub khoos phis tawj thiab lub mini USB rau koj li Arduino board. Tej zaum koj yuav tsum tau tos ob peb feeb rau cov tsav tsheb kom rub tawm.

Txhawm rau txiav txim siab qhov chaw nres nkoj COM:

Hauv PC

Txoj Kev 1: Hauv MATLAB siv qhov hais kom ua - fopen (serial ('nada'))

-los txiav txim siab koj qhov chaw nres nkoj com. Koj tuaj yeem tau txais qhov yuam kev zoo li no: Yuam kev siv cov lej/fopen (kab 72) Qhib tsis tau: Chaw nres nkoj: NADA tsis muaj. Chaw nres nkoj muaj: COM3. Qhov yuam kev no qhia tias koj qhov chaw nres nkoj yog 3.

-Yog Txoj Kev 1 tsis ua haujlwm ntawm koj lub PC, qhib koj Tus Thawj Tswj Ntaus Ntawv thiab nthuav cov Chaw Nres Nkoj (COM thiab LPT). Nco tseg tus lej ntawm USB Serial Port. xws li 'USB Serial Port (COM *)' Tus lej chaw nres nkoj yog * ntawm no.

-Yog tsis muaj chaw nres nkoj pom, kaw MATLAB thiab rov pib kho koj lub computer. Qhib MATLAB thiab sim fopen (serial ('nada')) dua.

-Yog qhov ua tsis tiav, koj yuav xav rub SparkFun tus tsav tsheb los ntawm cov ntaub ntawv CDM_v2.12.00_WHQL_Certified.exe, qhib thiab khiav CDM_v2.12.00_WHQL_Certified.exe ntawv, thiab xaiv Extract. (Tej zaum koj yuav xav qhib cov ntaub ntawv los ntawm tus kws tshawb fawb, nyem rau nws, thiab 'Khiav raws li Tus Thawj Coj').

-MatLAB hais kom ua qhov rai tsim ib qho khoom Arduino - a = arduino ('comx', 'uno'); % x yog koj tus lej chaw nres nkoj los saum toj no rau PCs (tsis muaj xoom ua ntej!)

Hauv Mac

Txoj Kev 1: Los ntawm kab lus MATLAB lossis hauv Mac Terminal thiab ntaus: 'ls /dev/tty.*' Nco tseg tus naj npawb chaw nres nkoj teev rau dev/tty.usbmodem*lossis dev/tty.usbserial*. Tus naj npawb chaw nres nkoj yog * ntawm no.

-Yog Txoj Kev 1 tsis ua haujlwm ntawm koj MAC, koj yuav xav tau

-Exit MATLAB

-Kaw cov software Arduino thiab tshem lub Arduino USB cable

-nruab Java 6 Runtime

-teeb tsa USB tsav tsheb txuas ntxiv

-Pib dua koj lub computer

-Reconnect Arduino USB cable

-Run los ntawm MATLAB kab hais kom ua lossis Mac Terminal: ls /dev/tty.*

-Thov sau tus lej chaw nres nkoj teev rau dev/tty.usbmodem* lossis dev/tty.usbserial*. Tus naj npawb chaw nres nkoj yog * ntawm no.

-MatLAB hais kom ua qhov rai tsim ib qho khoom Arduino - a = arduino ('/dev/tty.usbserial*', 'uno'); % * yog koj tus lej chaw nres nkoj los saum toj no rau MACs, lossis '/dev/tty.usbmodem*'

Kauj Ruam 3: Matlab Code

Matlab Code
Matlab Code
Matlab Code
Matlab Code

Cov tswv yim:

1.) Flex Sensor

2.) Potentiometer

Cov Zis:

1.) LCD npo nrog cov lus uas nyeem "Tsheb ciav hlau los"

2.) LED teeb

3.) Piezo buzzer

Hauv theem no, peb yuav tsim cov cai uas yuav tshuaj xyuas cov tswv yim los ntawm Arduino pawg thawj coj thiab muab cov txiaj ntsig raws li cov txiaj ntsig ntawm MATLAB qhov kev tshuaj xyuas. Cov cai hauv qab no yuav tso cai rau koj ua ntau txoj haujlwm: thaum lub zog ntsuas hluav taws xob tau pib, lub piezo buzzer yuav tso tawm ntau zaus hloov pauv thiab LED liab yuav nyem. Thaum lub tsheb ciav hlau tsis pom, lub ntsuab LED yuav ci. Thaum Flex Sensor tau ua rau, kev siab hlob LED yuav tua, LED liab yuav ci, thiab lub LCD yuav tso tawm cov lus uas nyeem "Tsheb ciav hlau los".

MATLAB Code:

%remery1, shornsb1, wmurrin

Lub Hom Phiaj: Kev Ceeb Toom Qhia

%IInput: potentiometer, flex sensor

%tso tawm: lcd, suab, lub teeb

%Yog tias pawg thawj coj tsis tau pib ua ntej lossis muaj teeb meem kev sib txuas, ua raws li

%hauv qab cov lus txib hauv cov lus. Lawv tsis tas yuav tsum ua txhua lub sijhawm

%ntshiab txhua

%kaw tag nrho

%kws

%a = arduino ('/dev/tty.usbserial-DN01DXOM', 'uno');

%lcd = addon (a, 'Piv txwvLCD/LCDAddon', {'D7', 'D6', 'D5', 'D4', 'D3', 'D2'});

%Kho lub rooj tsavxwm thaum nws txuas nrog

configurePin (a, 'D8', 'pullup');%teeb tsa D8

configurePin (a, 'D9', 'PWM');%configure D9

sijhawm = 50; %teem sijhawm rau 50

clearLCD (lcd) %pib ua LCD

%Pib Loop

thaum lub sijhawm> 0

%Flex sensor voltage txiav txim siab seb lub teeb ntsuab, lossis yog lub teeb

%yog liab thiab LCD qhia "tsheb ciav hlau los"

flex_status = readVoltage (a, 'A0'); %nyeem voltage ntawm flex sensor

yog flex_status> 4 %yog qhov hluav taws xob ntau dua 4, ua rau lub voj

writeDigitalPin (a, 'D12', 0) %tua ntsuab

writeDigitalPin (a, 'D11', 1) %tig liab

printLCD (lcd, 'Tsheb ciav hlau los') %tso saib "tsheb ciav hlau los" ntawm LCD

ncua (5) %Tos 5 vib nas this

clearLCD (lcd) %Ntshiab cov lus los ntawm LCD

writeDigitalPin (a, 'D11', 0) %Tua Liab LED

lwm tus

kawg

pe_status = readVoltage (a, 'A2'); %Nyeem potentiometer voltage

yog pe_status> 2 %yog qhov hluav taws xob ntau dua 2, ua kom lub voj

writeDigitalPin (a, 'D13', 1);%tig rau LED liab

playTone (a, 'D9', 400,.25);% Ua Si 400Hz ntawm Piezo buzzer,.25 sec

writeDigitalPin (a, 'D13', 0)%tua LED liab

ncua (.25)%tos.25 vib nas this

writeDigitalPin (a, 'D13', 1) %Rov hais dua saum toj no, nrog lub suab nrov ntawm 200Hz

playTone (a, 'D9', 200,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1);%Rov ua dua

playTone (a, 'D9', 400,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1)

playTone (a, 'D9', 200,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1) %Rov ua dua

playTone (a, 'D9', 400,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1)

playTone (a, 'D9', 200,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1) %Rov ua dua

playTone (a, 'D9', 400,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

writeDigitalPin (a, 'D13', 1)

playTone (a, 'D9', 200,.25);

writeDigitalPin (a, 'D13', 0)

ncua (.25)

lwm tus

writeDigitalPin (a, 'D12', 1)%yog qhov hluav taws xob tsawg dua 2, tig ntsuab LED

writeDigitalPin (a, 'D13', 0)%tig ntawm Liab LED

kawg

kawg

Kauj Ruam 4: Txuas lub Flex Sensor

Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor
Txuas lub Flex Sensor

Cov ntaub ntawv xav tau

1.) 1 Flex Sensor

2.) 1 10K Ohm Resistor

3.) 8 Jumper Wires

*Xa mus rau cov duab, feem.

Hauv qhov kev sib tham no, peb yuav ntsuas kev ywj pheej. Lub ntsuas hluav taws xob siv cov pa roj carbon rau ntawm cov yas los ua zoo li qhov sib txawv tiv taus, tab sis hloov pauv qhov tsis kam los ntawm tig lub pob qhov rooj, koj hloov los ntawm kev hloov pauv cov khoom. Ib qho hluav taws xob faib hluav taws xob txhawm rau txheeb xyuas kev hloov pauv. Hauv peb qhov xwm txheej, yuav siv lub ntsuas hluav taws xob txhawm rau txhawm rau pom lub tsheb ciav hlau hla mus hais kom lub vijtsam LCD (saib daim duab) kom nyeem cov lus hais tias "Tsheb ciav hlau los".

*Hauv cov duab uas qhia cov lus qhia rau xaim Flex Sensor, tsuas yog xa mus rau cov xov hlau uas txheeb ze rau txuas lub Flex Sensor. Tsis saib xyuas qhov thaiv rau Servo.

Hlau pins raws li hauv qab no:

Kauj Ruam 1: Ntawm Arduino pawg thawj coj hauv ntu POWER, ntsaws 1 xaim rau hauv 5V thiab 1 xaim rau nkag GND (hauv av). Txuas lwm qhov kawg ntawm 5V xaim rau hauv qhov zoo (+) cov tswv yim ntawm lub rooj tsav xwm hauv Circuit Court. Txuas lwm qhov kawg ntawm GND xaim rau hauv qhov tsis zoo (-) cov tswv yim ntawm lub rooj tsav xwm hauv Circuit Court.

Kauj Ruam 2: Ntawm Arduino pawg thawj coj hauv ANALOG IN ntu, ntsaws 1 hauv A0 cov tswv yim. Txuas qhov kawg ntawm cov xaim ntawd mus rau hauv j20 cov tswv yim ntawm lub rooj tsav xwm hauv Circuit.

Kauj Ruam 3: Ntawm Arduino pawg thawj coj hauv DIGITAL I / O ntu, ntsaws 1 xaim rau hauv kev nkag 9. Txuas lwm qhov kawg rau hauv kev nkag a3.

Kauj Ruam 4: Ntawm lub rooj tsav xwm hluav taws xob, Txuas 1 xaim rau hauv qhov zoo (+) cov tswv yim. Txuas lwm qhov kawg rau hauv kev nkag h24.

Kauj Ruam 5: Ntawm lub rooj tsav xwm hauv Circuit Court, Plug 1 xaim rau qhov tsis zoo (+) cov tswv yim. Txuas lwm qhov kawg rau hauv kev nkag a2.

Kauj Ruam 6: Ntawm lub rooj tsav xwm hluav taws xob, Txuas 1 xaim rau hauv qhov tsis zoo (-) cov tswv yim. Txuas lwm qhov kawg rau hauv kev nkag mus b1.

Kauj Ruam 7: Ntawm lub rooj tsav xwm hauv Circuit Court, Plug 1 xaim rau qhov tsis zoo (-) cov tswv yim. Txuas lwm qhov kawg rau hauv cov tswv yim i19.

Kauj Ruam 8: Ntawm lub rooj tsav xwm hauv Circuit Court, tso lub resistor hauv i20 thiab i24 cov tswv yim.

*Daim duab kawg hais txog kev thov ntiaj teb tiag.

Kauj Ruam 5: Txuas Arduino rau LCD

Txuas Arduino rau LCD
Txuas Arduino rau LCD
Txuas Arduino rau LCD
Txuas Arduino rau LCD
Txuas Arduino rau LCD
Txuas Arduino rau LCD

*Ua raws qhov txuas no (https://ef.engr.utk.edu/ef230-2017-08/projects/ard…) thiab tom qab ntawv xa mus rau cov kauj ruam uas kuv tau muab hauv qab no txhawm rau txuas LCD rau Arduino:

Kauj ruam 1: Qhib zip file

Kauj ruam 2: qhib cov ntawv ReadMe thiab ua raws cov lus qhia

Cov ntaub ntawv xav tau

1.) 16x2 LCD zoo ib yam li cov cuab yeej no los ntawm SparkFun -

2.) Jumper xov hlau

*Xa mus rau cov duab, feem.

Cov kauj ruam no yuav qhia tias yuav tsim lub tsev qiv ntawv LCD ntxiv rau lub tsev qiv ntawv li cas thiab tso tawm "Tsheb nqaj hlau los" ntawm LCD.

Hlau pins raws li hauv qab no:

LCD Pin -> Arduino Pin

1 (VSS) -> Hauv av

2 (VDD) -> 5V

3 (V0) -> Nruab nrab tus pin ntawm Flex Sensor

4 (RS) -> D7

5 (R/W) -> Hauv av

6 (E) -> d6

11 (DB4) - D5 (PWM)

12 (DB5) -> D4

13 (DB6) -> D3 (PWM)

14 (DB7) -> D2

15 (LED+) -> 5 V

16 (LED-) -> Hauv av

Kauj Ruam 6: Txuas Txuas Potentiometer

Txuas Cov Khoom Siv Hluav Taws Xob
Txuas Cov Khoom Siv Hluav Taws Xob
Txuas Cov Khoom Siv Hluav Taws Xob
Txuas Cov Khoom Siv Hluav Taws Xob
Txuas Cov Khoom Siv Hluav Taws Xob
Txuas Cov Khoom Siv Hluav Taws Xob

Cov ntaub ntawv xav tau

1.) 1 LED

2.) 1 Cov Potentiometer Mos

3.) Jumper Wires

4.) 3 330 Ohm Resistor

5.) 10K Ohm Resistor

*Xa mus rau cov duab, feem.

Hauv qhov kev sib tham no, peb yuav siv lwm hom kev sib txawv ntawm qhov sib txawv, lub zog potentiometer. Nov yog daim nyias nyias thiab hloov pauv tau uas tuaj yeem txheeb xyuas qhov twg yog siv lub siab. Los ntawm kev nyem rau ntawm ntau qhov chaw ntawm kab txaij, koj tuaj yeem hloov qhov kev tiv thaiv ntawm 100 txog 10 K ohms. Koj tuaj yeem siv lub peev xwm no txhawm rau taug qab kev txav ntawm lub hwj chim lossis ua lub pob. Hauv qhov kev sib tham no, peb yuav tau txais lub hwj chim mos muag nce thiab khiav los tswj hwm RGB LED.

Kauj Ruam 1: Ntawm Arduino pawg thawj coj hauv DIGITAL I / O ntu, ntsaws 1 tus pin rau hauv cov tswv yim 10 thiab 1 tus pin rau hauv cov tswv yim 11. Raws li, ntsaws lwm qhov kawg ntawm cov pins rau hauv h6 thiab h7.

Kauj Ruam 2: Ntawm daim phiaj hluav taws xob, ntsaws cov LED rau hauv cov ntawv a4, a5, a6, thiab a7.

Kauj Ruam 3: Ntawm daim phiaj hluav taws xob, tso 3 330 ohm resistors hauv cov khoom siv e4-g4, e6-g6, thiab e7-g7.

Kauj Ruam 4: Ntawm lub rooj tsav xwm hluav taws xob, ntsaws 1 tus pin rau hauv cov ntawv e5. Txuas lwm qhov kawg ntawm tus pin ntawd rau hauv qhov tsis zoo (-) cov tswv yim.

Kauj Ruam 5: Ntawm lub rooj tsav xwm hauv Circuit Court, tso 10K ohm resistor rau hauv cov tswv yim i19-negative (-).

Kauj Ruam 6: Ntawm daim phiaj hluav taws xob, ntsaws 1 tus pin rau hauv j18. Txuas lwm qhov kawg ntawm tus pin ntawd mus rau qhov zoo (+) cov tswv yim.

Kauj Ruam 7: Ntawm lub rooj tsav xwm Circuit Court, ntsaws 1 tus pin rau hauv j20. Txuas lwm qhov kawg ntawm tus pin ntawd rau hauv qhov tsis zoo (-) cov tswv yim.

Kauj Ruam 7: Kuaj Koj Li Kev Txhim Kho ntawm Smart Rail System

Kuaj Koj Kev Txhim Kho ntawm Smart Rail System
Kuaj Koj Kev Txhim Kho ntawm Smart Rail System
Kuaj Koj Kev Txhim Kho ntawm Smart Rail System
Kuaj Koj Kev Txhim Kho ntawm Smart Rail System

Txog tam sim no, koj tus lej MATLAB yuav tsum muaj kev ua haujlwm thiab Arduino pawg thawj coj yuav tsum raug txuas nrog nrog txhua qhov ntxiv. Sim nws tawm ntawm daim ntawv pov thawj Smart Rail System thiab pom tias koj qhov kev txhim kho ua rau lub system muaj kev nyab xeeb dua.

Pom zoo: