Cov txheej txheem:

Ua Nkauj Nkauj Siv Stepper Motor !!: 11 Kauj Ruam (nrog Duab)
Ua Nkauj Nkauj Siv Stepper Motor !!: 11 Kauj Ruam (nrog Duab)

Video: Ua Nkauj Nkauj Siv Stepper Motor !!: 11 Kauj Ruam (nrog Duab)

Video: Ua Nkauj Nkauj Siv Stepper Motor !!: 11 Kauj Ruam (nrog Duab)
Video: Koj mus ua neej zoo li cas lawm 11/16/2018 2024, Hlis ntuj nqeg
Anonim
Ua Nkauj Nkauj Siv Stepper Motor !!
Ua Nkauj Nkauj Siv Stepper Motor !!

Txoj haujlwm no yog hais txog kev tsim qauv yooj yim sib cuam tshuam, uas yuav tso cai rau cuam tshuam nrog lub tshuab hluav taws xob stepper hauv ob txoj kev sib txawv.

Thawj qhov kev sib tham yuav tswj cov kev taw qhia thiab nrawm ntawm tus tsav tsheb los ntawm kev siv GUI yooj yim, uas muaj cov xub xub thiab sab xis rau kev taw qhia, thiab nce thiab nqis xub rau qhov nrawm.

Qhov cuam tshuam thib ob yuav yog suab paj nruas ntau dua uas yuav tso cai ua suab nkauj yooj yim siv lub suab tig ntawm lub cav tsav.

Kauj Ruam 1: Qhov Yuav Tsum Tau

  1. Arduino UNO (lossis pawg thawj coj saib tau)
  2. Nextion Txhim Kho NX4827K043 los ntawm iTead Studio.
  3. Nextion Expansion board rau Nextion Txhim kho cov zaub
  4. Micro SDHC Daim Npav
  5. SD Card Reader/Writer - hloov cov ntaub ntawv los ntawm lub computer mus rau SDHC card
  6. Cov qhob cij
  7. Stepper Tsav (42BYGHM809)
  8. 100 uF CapacitorDuinotech Stepper Tsav Tsheb (L298) - [JayCar ntu# XC4492].
  9. Lub Hwj Huam Sab Nraud - piv txwv li Kev Tswj Cov Khoom Siv Hluav Taws Xob

Kauj ruam 2: Tsim Kev Sib Txuas

Tsim Interface
Tsim Interface

Thawj kauj ruam yog tsim cov cuam tshuam hauv Nextion Editor ntawm koj lub PC.

Koj tuaj yeem rub tawm Nextion Editor ntawm no.

Thauj mus rau Nextion Editor thiab tsim txoj haujlwm tshiab. Thaum koj pib txoj haujlwm tshiab, koj yuav tsum paub tseeb tias koj xaiv qhov cuab yeej Nextion raug los ntawm cov kev xaiv muaj. Nov yog "Nextion Enhanced NX4827K043" cov cuab yeej siv.

  1. Xaiv Cov Ntaub Ntawv → Tshiab Xaiv lub npe rau txoj haujlwm thiab khaws nws mus rau qhov chaw tsim nyog ntawm lub hard drive.
  2. Xaiv qhov tsim nyog Nextion ntaus ntawv los ntawm cov kev xaiv muaj

    Kuv lub cuab yeej muaj lub vijtsam loj 480 x 272 pixels

Kauj Ruam 3: Cov Haujlwm Pabcuam

Cov peev txheej
Cov peev txheej
Cov peev txheej
Cov peev txheej
Cov peev txheej
Cov peev txheej

Koj yuav tsum tau ntshuam tag nrho cov peev txheej (piv txwv li duab thiab fonts) rau hauv koj qhov project, thiab tom qab ntawd tsim lub interface kom haum rau koj cov kev xav tau tshwj xeeb.

Fonts

Tsis muaj cov fonts tshwj xeeb tau siv, tab sis yog tias koj xav sau ib cov ntawv rau ntawm lub vijtsam, koj yuav tsum tsim cov ntawv hauv Nextion Editor.

A) Cov Cuab Yeej → Font Generator

  1. Xaiv qhov siab ntawm Font (piv txwv. 16).
  2. Xaiv hom Font code (piv txwv. Iso-8859-2)
  3. Xaiv yog tias koj xav kom nws nyob hauv Bold lossis tsis
  4. Xaiv Font koj xav siv (piv txwv li. Arial)
  5. Xaiv qhov nrug (piv txwv. 0)
  6. Thiab thaum kawg muab Font no lub npe tshwj xeeb (piv txwv li Arial_16)
  7. Thawb lub pob "Tsim Font" nyob hauv qab txoj cai ntawm lub qhov rais.

Thaum koj nias lub khawm Generate Font, nws yuav ua rau koj txuag cov font siv *.zi txuas ntxiv, thiab yuav cia li nug koj yog tias koj xav "Ntxiv cov font tsim?" mus rau qhov project. Yog tias koj zoo siab nrog cov ntawv, thiab xav siv daim ntawv no hauv koj qhov haujlwm, tom qab ntawv xaiv "Yog", txwv tsis pub xaiv "Tsis yog" thiab pib dua.

Koj tsis tuaj yeem ntxiv cov ntawv rau koj qhov haujlwm kom txog thaum koj tau nkag los lossis ntxiv tus font. Txhua yam ntawm koj qhov haujlwm fonts yuav tshwm rau hauv lub qhov rai fonts.

** Nco tseg: Txhua tus ntawv yuav raug suav ua tus lej, yog li koj tuaj yeem siv cov font pro grammatically yog xav tau. Qhov tseeb txhua qhov peev txheej uas koj ntxiv rau koj txoj haujlwm tau muab tus lej thiab nce ntxiv los ntawm ib qho rau txhua qhov peev txheej ntxiv. Txog qee qhov peev txheej, koj tuaj yeem pom tus lej no nyob rau sab laug ntawm cov khoom. Piv txwv li Hauv daim duab saum toj no, Courier Font muaj qhov ntsuas ntawm 0, qhov Arial font muaj qhov ntsuas ntawm 1. Yog tias koj rho tawm cov peev txheej, tus lej ntsuas yuav hloov pauv rau cov khoom ntawd.

Kauj ruam 4: Ntshuam Duab

Ntshuam duab
Ntshuam duab
Ntshuam duab
Ntshuam duab

Ntawm Nextion Enhanced NX4827K043 ntaus ntawv, txhua daim duab yuav tsum yog 480 x 272 pixels hauv qhov loj me.

Tam sim no peb yuav ntshuam cov duab hauv qab no rau hauv Nextion Editor kom peb tuaj yeem siv lawv hauv txoj haujlwm. Hauv qab sab laug tes kaum ntawm Nextion tus editor yog "Fonts and Picture" qhov rai peev txheej:

  1. Xaiv Daim Duab tab
  2. Tom qab ntawd xaiv lub cim "+"
  3. Qhov no yuav qhib lub thawv sib tham kom tso cai rau koj xaiv cov duab (duab) ntxiv rau hauv txoj haujlwm. Koj tuaj yeem xaiv ntau dua ib daim duab los ntshuam.

Rau Splash Screen koj tuaj yeem tsim cov duab raws li koj xaiv.

Thiab rau Stepper lub cev muaj zog thiab piano interface koj tuaj yeem rub tawm cov duab saum toj no.

Kauj ruam 5: Ua GUI

Ua GUI
Ua GUI

Txhua qhov peev txheej yuav tau txais tus ID raws li qhov kev txiav txim nws tau ntxiv, thiab txhua qhov peev txheej yuav tau txais lub npe.

Koj tuaj yeem hloov lub npe ntawm cov peev txheej lossis khoom siv, tab sis koj tsis tuaj yeem hloov kho tus ID.

Peb nplooj ntawv yuav raug tsim los kom tau raws li cov qauv tau piav qhia saum toj no.

Txhawm rau ntxiv nplooj ntawv, koj tsuas yog xaiv lub cim "Ntxiv" los ntawm "nplooj ntawv qhov rai". Thiab khaws cov nplooj ntawv ntxiv kom txog thaum koj muaj tag nrho 3 nplooj ntawv (nplooj 0, nplooj 1 thiab nplooj 2).

Kauj Ruam 6: Nplooj Ntawv 0-Splash Screen

Nplooj ntawv 0-Splash Screen
Nplooj ntawv 0-Splash Screen

Thaum Nextion tau teeb tsa, lub vijtsam txaws yuav tshwm rau 3 vib nas this ua ntej nws qhia pom Stepper Motor Controller screen. Kuv siv cov theem hauv qab no los tsim lub vijtsam txaws.

Ntxiv cov duab ntxig rau nplooj 0

  • Xaiv "nplooj ntawv 0" los ntawm Nplooj ntawv qhov rai
  • Xaiv "Duab" los ntawm lub qhov rais Toolbox
  • Ob npaug nias rau "pic" tus yam ntxwv los ntawm lub qhov rai Tus Cwj Pwm
  • Xaiv cov duab txaws ntawm daim ntawv
  • Nias lub pob OK

2. Ntxiv Timer rau nplooj 0

  • Xaiv Timer los ntawm Toolbox window
  • Hloov qhov "tim" tus cwj pwm los ntawm 400 txog 3000 hauv Tus Cwj Pwm Qhov rai
  • Nkag mus rau "nplooj ntawv page1" hauv Tus lej siv ntu ntawm Timer Event (0) Lub sijhawm teem sijhawm no yuav ua rau Nextion dhia mus rau page1 tom qab 3 vib nas this.

Qhov kev tshwm sim timer no yuav ua rau Nextion dhia mus rau nplooj 1 tom qab 3 vib nas this.

Kauj Ruam 7: Nplooj 1 - Stepper Motor Controller

Nplooj ntawv no yog tsim los tswj cov kev taw qhia thiab nrawm ntawm stepper lub cev muaj zog. Yuav muaj ob lub khawm rau kev taw qhia (Sab laug thiab Txoj Cai), thiab ob lub khawm rau qhov nrawm (nrawm dua thiab qeeb dua). Thiab ib lub pob ntxiv kom dhia mus rau nplooj ntawv tom ntej (piv txwv li Stepper Motor Piano page). Cov nyees khawm no tseem yuav raug teeb tsa mus rau Pawg Thawj Coj nthuav tawm. Cov nyees khawm yooj yim ntawm lub rooj nthuav dav nthuav dav yuav muab lwm txoj hauv kev los tswj lub cav.

Ntxiv daim duab Stepper Motor Controller rau nplooj 1

  • Xaiv "page1" los ntawm Nplooj ntawv qhov rai
  • Xaiv "Duab" los ntawm lub qhov rais Toolbox
  • Ob npaug nias rau "pic" tus yam ntxwv los ntawm lub qhov rai Tus Cwj Pwm
  • Xaiv "Stepper Motor Controller" duab los ntawm cov npe
  • Nias lub pob OK

2. Ntxiv Hotspots hla txhua lub pob ntawm Stepper Motor Controller duab

a) Xaiv "Hotspot" los ntawm Toolbox window

b) Luag thiab hloov qhov Hotspot kom nws npog lub pob "Sab laug"

  • Nov yog thaj chaw uas yuav teb rau "Left button" presses.
  • Nws yuav pob tshab thaum tso rau Pawg Thawj Coj

c) Xaiv lub "Touch Press Event" tab hauv qhov tshwm sim qhov rai

d) Un-Check the “Send Component ID” checkbox

e) Ntaus cov cai hauv qab no rau hauv “Tus Neeg Siv Txoj Cai” Tshooj ntawm Qhov Rooj Txheej Txheem:

luam tawm "L"

f) Hloov lub npe khoom ntawm lub hotspot mus rau "Sab laug" siv cov txheej txheem hauv qab no:

  • Xaiv ob lub npe los ntawm lub qhov rai tus cwj pwm thiab hloov cov ntawv los ntawm "m0" mus rau "Sab laug"
  • Nws tsis yog yuav tsum hloov pauv lub npe hotspot; txawm li cas los nws yuav pab tom qab.

g) Rov ua cov kauj ruam 2a-2f rau txhua tus ntawm lwm cov nyees khawm hauv qab no thiab raws li cov lus hauv qab no

  • Txoj cai
  • Sai
  • Qeeb dua
  • Tom ntej no

Cov lej lej ASCII rau tsab ntawv "L" yog 76, yog li thaum Nextion Enhanced zaub xa tsab ntawv L mus rau Arduino siv cov ntawv "L" hais kom ua, Arduino yuav tau txais tus lej 76. Thaum nias lub khawm raug, nws yuav tau txais tus lej 82, thiab ntxiv rau. Lub pob "Tom ntej" tsis xa ib yam dab tsi mus rau Arduino, nws tsuas yog muaj los dhia mus rau qhov txuas tom ntej ntawm Nextion Txhim kho cov zaub, yog li qhov laj thawj yog vim li cas tus lej siv sib txawv rau lub pob ntawd.

3. Map cov nyees khawm mus rau Lub Rooj Sib Tham nthuav dav

a) Xaiv "page0" thiab tom qab ntawd "page1" los ntawm Nplooj Ntawv Qhov rai

b) Xaiv qhov "Preinitialize Event" tab los ntawm Qhov Rooj Txheej Txheem

c) Nkag mus rau cov cai hauv qab no rau hauv "Tus Neeg Siv Txoj Cai" teb ntawm Preinitialize Event tab:

  • cfgpio 5, 1, Sab laug
  • cfgpio 2,1, yog
  • cfgpio 4, 1, sai dua
  • cfgpio 3,1, qeeb dua
  • cfgpio 1, 1, Tom ntej

*** Thov nco tseg: Muaj ib qho chaw nruab nrab ntawm cfgpio thiab tus lej nyob ib sab, tab sis tsis muaj lwm qhov chaw ntawm txhua kab. Yog tias koj qhia chaw ntxiv, nws yuav tsis suav sau. Txoj cai no qhia cov nyees khawm ntawm lub rooj nthuav dav nthuav dav mus rau cov khoom hotspot ntawm nplooj ntawv 1. Piv txwv li, thaum khawm sab laug (IO5) ntawm lub rooj nthuav dav nthuav dav, nws simulates qhov kev ua lossis cov xwm txheej cuam tshuam nrog hotspot m0/Sab laug. Hauv qhov no nws yuav xa tus nqi ntawm "L" (76) mus rau Arduino.

Tus lej IO tau cim rau hauv kab zauv ntawm lub rooj nthuav dav.

Kauj Ruam 8: Nplooj 2 - Stepper Tsav Piano

Nplooj ntawv 2 - Stepper Motor Piano
Nplooj ntawv 2 - Stepper Motor Piano
Nplooj ntawv 2 - Stepper Tsav Piano
Nplooj ntawv 2 - Stepper Tsav Piano

nws lub interface yuav raug tsim los kom zoo li lub piano, thiab yuav tso cai rau kuv los tswj lub stepper motor xws li nws tsim cov ntawv hauv tib tus yuam sij ib yam li kuv nias ntawm Nextion zaub. Stepper lub cev muaj zog yuav tsim cov ntawv los ntawm kev tig ntawm qhov tshwj xeeb.

1. Ntxiv Stepper Motor Piano duab rau nplooj 2.

  • Xaiv "page2" los ntawm Nplooj ntawv qhov rai
  • Xaiv "Duab" los ntawm lub qhov rais Toolbox
  • Ob npaug nias rau "pic" tus yam ntxwv los ntawm lub qhov rai Tus Cwj Pwm
  • Xaiv "Stepper Motor Piano" duab los ntawm cov npe
  • Nias lub pob OK

2. Ntxiv Hotspots hla txhua qhov tseem ceeb ntawm Stepper Motor Piano duab

a) Xaiv "Hotspot" los ntawm Toolbox window

b) Luag thiab hloov qhov Hotspot kom nws npog qhov "A" qhov no yog thaj chaw uas yuav teb rau "A-key" nias.

c) Xaiv lub "Touch Press Event" tab hauv qhov tshwm sim qhov rai.

d) Ntaus cov hauv qab no rau hauv “Tus Neeg Siv Txoj Cai” ntu

luam tawm 1

e) Rov ua cov kauj ruam 2a-2d rau txhua tus yuam sij raws li cov lus hauv qab no.

** Thaum tus yuam sij tshwj xeeb raug nias, Nextion Enhanced board yuav xa cov lej luam tawm, ua raws li peb 0x00 qhov tseem ceeb. Qhov txiav qhov tseem ceeb tuaj yeem tsis quav ntsej.

3. Qhov "Back" khawm yuav tso cai rau kuv kom rov qab mus rau qhov kev sib tham yav dhau los ntawm Nextion Enhanced board.

a) Tsim lub hotspot rau khawm rov qab siv cov txheej txheem hauv qab no:

  1. Xaiv Hotspot los ntawm Toolbox window
  2. Txav/Hloov qhov hotspot hla lub pob "Rov qab"

b) Xaiv qhov tshwm sim qhov rai.

c) Nco ntsoov tias "Touch press event" tab tau xaiv

d) Hom: nplooj ntawv page1 rau hauv Tus Neeg Siv Cov Cai

Kauj ruam 9: Debugging

Debugging
Debugging
Debugging
Debugging

Qhov zoo tshaj plaws ntawm Nextion Editor, yog tias koj tuaj yeem sim tawm lub interface ua haujlwm ua ntej rub nws mus rau pawg thawj coj.

  1. Txuag qhov haujlwm los ntawm nias lub pob txuag ntawm lub luag haujlwm
  2. Tom qab ntawd nias lub pob nyem
  3. Tom qab ntawd nias lub pob debug.

Lub qhov rais Nextion emulator yuav tshwm sim. Lub qhov rai no yuav tsum teb zoo ib yam li Nextion module tom qab cov ntawv Nextion tau muab tso rau hauv pawg thawj coj. Cov emulator no yog txoj hauv kev zoo los ntsuas koj lub interface thiab kom ntseeg tau tias nws zoo li thiab ua haujlwm raws li qhov xav tau. Thaum kuv zoo siab nrog lub interface (s), Kuv xa cov ntawv suav ua Nextion rau hauv daim npav SD:

  1. Nias lub pob sau
  2. Cov Ntaub Ntawv: Qhib Tsim Cov Ntawv
  3. Xaiv * *.tft cov ntaub ntawv nrog tib lub npe zoo li ntawm qhov haujlwm.
  4. Luam nws mus rau daim npav micro SDHC
  5. Ntxig daim npav SDHC rau hauv daim npav SD daim ntawm Nextion zaub
  6. Fais fab lub Nextion board

Tos rau cov ntawv kom nyem rau Nextion board, thiab koj yuav tsum pom cov lus uas zoo li no:

Cov kauj ruam tom ntej yog txhawm rau tshem tawm Pawg Thawj Coj Nextion, thiab tshem daim npav SDHC.

Kauj ruam 10: ARDUINO teeb tsa

Nextion Enhanced zaub tau npaj tiav, thiab tam sim no nws yog Arduino tig. Arduino tau teeb tsa kom tau txais cov lus xov xwm los ntawm Nextion Enhanced zaub thiab tswj lub tshuab hluav taws xob raws li cov ntawv lossis tus lej tau txais. Cov ntawv tshwj xeeb lossis tus lej raug xa tawm los ntawm Pawg Thawj Coj Nextion, tso cai rau Arduino nkag siab lub pob twg tau raug nias, thiab nws siv cov lej lossis ntawv los tswj kev ntws ntawm cov cai txhawm rau ua qhov tshwj xeeb stepper lub zog ua.

Lub tsev qiv ntawv SoftwareSerial tau siv los ua kom muaj kev sib txuas lus ntawm Arduino thiab Nextion Enhanced zaub. AccelStepper lub tsev qiv ntawv tau siv los ua kom yooj yim rau cov txheej txheem ntawm kev tswj lub cev muaj zog.

Teeb tsa qhov siab tshaj plaws thiab yam tsawg kawg nkaus rau lub cav, thiab qee cov yuam sij tau npaj ua ntej. Nws muaj peev xwm "qhib" lub cav siv thawj lub ntsej muag ntawm Nextion zaub. Koj tuaj yeem ua qhov no los ntawm kev ua kom lub cav tig nrawm dua lossis qeeb dua kom txog thaum koj mus txog qhov xav tau. Nov yog "Tuner T1 Free" app los ntawm iTunes app khw tau siv los txheeb xyuas thaum twg lub tshuab tau tsim cov ntawv sau hauv qhov tseem ceeb. Thaum lub cav tau tsim cov ntawv tshwj xeeb, kuv yuav sau cov stepper lub cev muaj zog nrawm uas tau luam tawm rau Serial monitor window. Txhua lub sijhawm lub cev muaj zog tau nce lossis qis dua, Arduino code luam tawm qhov nrawm mus rau lub qhov rooj saib xyuas. Tom qab ntawd kuv siv cov nrawm los hloov kho cov ntawv kab hauv Arduino code. Cov ntawv array tuav cov stepper lub cev muaj zog nrawm uas sib haum rau tus kheej cov ntawv ntawm piano. Nextion zaub tseem ceeb xa cov lej lej ntawm cov ntawv los ua si los ntawm cov ntawv sau tseg ntawm Arduino, yog li ua kom yooj yim cov cai yuav tsum tau tig lub cav ntawm 16 sib txawv nrawm.

Kauj ruam 11: Kawg+Schematics

Kawg+Schematics
Kawg+Schematics
Kawg+Schematics
Kawg+Schematics
Kawg+Schematics
Kawg+Schematics
Kawg+Schematics
Kawg+Schematics

Nrog txhua lub rooj tsav xwm tau tawm, cov kauj ruam tom ntej yog ua kom txhua qhov tsim nyog kho vajtse txuas mus rau Arduino. Muaj ob ntu loj los xav txog:

  • Stepper lub cev muaj zog tsav tsheb thiab lub cev muaj zog
  • Pawg Nextion Enhanced board.

Koj yuav tsum ua kom ntseeg tau tias koj siv lub zog sab nraud los ua lub zog rau ob lub cav stepper thiab Nextion Enhanced board. Stepper lub cev muaj zog tsav lub rooj tsavxwm nws tus kheej tau siv los ntawm Arduino yam tsis muaj teeb meem, tab sis qhov tseeb stepper lub cev muaj zog yuav xav tau lub zog hluav taws xob sab nraud. Pawg Thawj Coj Txhim Kho Ntxiv kuj xav tau lub zog siv hluav taws xob sab nraud vim tias nws xav tau tam sim no ntau dua li Arduino tuaj yeem muab kev nyab xeeb.

Nco tseg ntawm cov khoom siv hluav taws xob sab nraud siv. Kuv ua kom ntseeg tau tias kuv muaj lub zog loj txaus los tswj lub zog xav tau ntawm txoj haujlwm, thiab siv cov ntaub ntawv cuam tshuam los pab kuv txheeb xyuas cov kev xav tau no. Yog tias koj npaj yuav rov ua txoj haujlwm no, xyuas kom tseeb tias koj tau txiav txim siab tshwj xeeb lub zog xav tau ntawm koj lub cav, koj tus tsav tsheb thiab koj lub Nextion zaub. Arduino tuaj yeem tsuas yog muab 400mA ntawm tam sim no los ntawm 5V tus pin. Nrog txhua yam sib txuas, Kuv txhawb lub Nextion zaub, tom qab ntawd txhawb nqa Arduino. Stepper lub cev muaj zog pib tig tau txiav. Kuv siv thawj qhov kev sib hloov los hloov cov kev taw qhia thiab/lossis nrawm ntawm lub cev muaj zog. Thov nco ntsoov qhov siab tshaj plaws thiab yam tsawg kawg teeb tsa hauv Arduino code. Tom qab ntawd kuv siv lub khawm Tom ntej los dhia mus rau lub interface thib ob ntawm Nextion Enhanced zaub. Qhov thib ob interface zoo li piano. Thiab thaum kuv nias tus yuam sij ntawm lub tshuab ntaus piano, lub tshuab hloov pauv kom haum rau daim ntawv uas kuv nias.

Tam sim no koj ua tiav lawm.

Vam tias koj yuav nyiam nws

Pom zoo: