Cov txheej txheem:

Stepper Speed Control Menu Qhia rau Arduino: 6 Cov Kauj Ruam
Stepper Speed Control Menu Qhia rau Arduino: 6 Cov Kauj Ruam

Video: Stepper Speed Control Menu Qhia rau Arduino: 6 Cov Kauj Ruam

Video: Stepper Speed Control Menu Qhia rau Arduino: 6 Cov Kauj Ruam
Video: Watch how safety features such as ABS & Traction control can save your life! Continental Automotive 2024, Hlis ntuj nqeg
Anonim
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino
Stepper Ceev Tswj Cov Ntawv Qhia Tsav rau Arduino

Lub tsev qiv ntawv SpeedStepper no yog rov sau dua ntawm AccelStepper lub tsev qiv ntawv kom tso cai tswj ceev ntawm lub tshuab tsav. Lub tsev qiv ntawv SpeedStepper tso cai rau koj hloov pauv teeb tsa lub cev muaj zog thiab tom qab ntawd ua kom nrawm/qeeb mus rau qhov teeb tsa tshiab siv tib lub txheej txheem ib yam li AccelStepper lub tsev qiv ntawv. Lub tsev qiv ntawv SpeedStepper tseem tso cai rau koj teeb tsa ntxiv thiab rho tawm txwv thiab txoj haujlwm 'hauv tsev'. Muaj goHome hais kom rov mus rau txoj haujlwm hauv tsev.

Cov kev txwv: Lub tsev qiv ntawv SpeedStepper tsuas yog tsav cov kev taw qhia thiab cov kauj ruam tso tawm thiab yog li xav tau txuas nrog tus tsav tsheb, xws li Tsav Tsheb Yooj Yim, txhawm rau tsav lub stepper lub cev muaj zog. Lub tsev qiv ntawv AccelStepper muab ntau txoj kev xaiv tsav tsheb uas tuaj yeem theej rau hauv lub tsev qiv ntawv no yog xav tau.

Peb muab cov duab piv txwv piv txwv, txhua tus tuaj yeem ua haujlwm yam tsis muaj lub cav lossis tsav tsheb. speedStepperPlot kos duab teeb meem piv txwv cov lus txib nrawm thiab goHome hais kom ua thiab tsim cov phiaj xwm ntawm qhov ua tiav nrawm thiab txoj haujlwm. Cov duab nrawm speedSetpperSetup muab cov ntawv qhia zaub mov uas tau teeb tsa los teeb tsa lub cev muaj zog lub tsev thiab txwv thiab tom qab ntawd khiav lub cav thiab kho qhov nrawm nce thiab nqis thiab mus hauv Tsev kom tiav. SpeedStepperProfile kos duab qhia ua piv txwv ntawm kev teeb tsa thiab ua tiav qhov nrawm.

Thaum lub tsev qiv ntawv AccelStepper muab txoj haujlwm tswj tau zoo, xav tau kev tswj ceev rau Prototype Ice-Melting Probe rau Kev Txheeb Xyuas Cov Piv Txwv ntawm Europa. Nov yog cov vis dis aus ntawm cov ntawv ua ntej ntawm tsab ntawv, uas siv qhov hnyav hloov chaw tsis siv lub cav. Kev kho dua 1.1 ntxiv cov ntaub ntawv nrawm tom qab tus neeg siv thov lub ntsiab lus rau kev tswj hwm qhov nrawm ntawm lub twj tso kua mis.

Lub tsev qiv ntawv no ua haujlwm ntawm Arduino Uno thiab Mega2560, tab sis rau qhov qauv ua lub cim xeeb loj / nrawm dua SparkFun Redboard Turbo tau siv.

Cov lus qhia no tseem muaj nyob online ntawm Stepper Speed Control Library rau Arduino

Khoom siv

Txhawm rau ua piv txwv piv txwv tsuas yog Arduino UNO lossis Mega2560 thiab cov tsev qiv ntawv software xav tau

Rau lub rooj zaum ntsuas ntawm lub tsev qiv ntawv SparkFun Redboard Turbo tau siv nrog Tus Tsav Tsheb Yooj Yim, 200 kauj ruam/rov ua haujlwm, 12V 350mA stepper motor thiab 12 DC muab 2A lossis loj dua, piv txwv li. https://www.sparkfun.com/products/14934. USB A rau Micro cableUSB rau TTL Serial CableArduino IDE V1.8.9 thiab lub khoos phis tawj los khiav nws. SpeedStepper librarypfodParser library rau nonBlockingInput thiab pfodBufferedStream chav kawm millisDelay tsev qiv ntawv rau qhov tsis thaiv kev ncua

Kauj Ruam 1: Lub Tsev Qiv Ntawv Ua Haujlwm

Lub tsev qiv ntawv SpeedStepper khiav lub stepper lub cev muaj zog txwv los ntawm ciam teb teeb los ntawm lub tsev qiv ntawv. Saib SpeedStepper.h cov ntaub ntawv rau ntau txoj hauv kev qiv ntawv muaj. Nov yog tus txheej txheem ntawm cov laj thawj tom qab lawv.

Txoj hauj lwm ntawm tus stepper yog taug qab los ntawm suav cov naj npawb ntawm cov kauj ruam (pulses). Lub tsev qiv ntawv txwv txoj haujlwm kom nyob nruab nrab ntawm setPlusLimit (int32_t) thiab setMinusLimit (int32_t) txoj haujlwm. Qhov txwv ntxiv yog ib txwm> = 0 thiab qhov rho tawm ib txwm yog <= 0. Thaum pib lub tshuab qhov chaw yog 0 (tsev) thiab cov kev txwv tau teeb tsa loj heev +/- lej (txog +/- 1e9 cov kauj ruam). setAcceleration (ntab) teeb tsa nrawm npaum li cas lub cav yuav hloov pauv nrawm li nce lossis nqis. Raws li lub cav txav mus rau qhov ntxiv lossis rho tawm nws yuav ua rau qeeb ntawm tus nqi no kom txog thaum nres ntawm qhov txwv. Thaum pib nce qhov nrawm tau teeb tsa rau 1.0 cov kauj ruam/sec/sec. Kev teeb tsa nrawm yog ib txwm muaj tus lej +ve. Qhov kos npe ntawm setSpeed (ntab) teeb tsa cov lus qhia uas lub tshuab yuav txav mus.

setSpeed (ntab) teeb tsa qhov nrawm los ua kom nrawm / qeeb lub cav mus rau, los ntawm nws qhov nrawm tam sim no. Qhov nrawm uas tuaj yeem teeb tsa ntawm setSpeed (ntab) raug txwv, nyob rau qhov muaj txiaj ntsig, los ntawm kev teeb tsa, setMaxSpeed (ntab), lub neej ntawd 1000 kauj ruam/sec thiab setMinSpeed (ntab), tsis yog 0.003 cov kauj ruam/sec. Cov kev ua tsis tiav no tseem yog qhov nyuaj ua kom nrawm nrawm txwv lub tsev qiv ntawv yuav lees txais rau setMaxSpeed () thiab setMinSpeed (). Yog tias koj xav teeb tsa qhov nrawm tshaj> 1000 cov kauj ruam/feeb koj yuav tsum tau kho thawj kab hauv SpeedStepper.cpp cov ntaub ntawv txhawm rau hloov maxMaxSpeed (1000) rau qhov nrawm uas koj xav tau. Hauv kev xyaum ceev tshaj plaws tseem raug txwv los ntawm lub sijhawm ntawm kev hu mus rau lub tsev qiv ntawv txoj haujlwm () txoj haujlwm. Rau 1000 cov kauj ruam / sec txoj kev khiav () txoj hauv kev yuav tsum raug hu tsawg kawg txhua txhua 1mS. Saib ntu Latency hauv qab no.

Sim ua kom nrawm dua qhov nrawm dua yuav ua rau lub cav nres. Txhua tus ntawm cov teeb tsa no muaj tus lej sib xws, saib cov ntawv SpeedStepper.h. Txhawm rau nrawm, getSetSpeed () rov qab nrawm koj teeb tsa ntawm setSpeed (), thaum getSpeed () rov qab lub cev muaj zog tam sim no uas txawv raws li nws ua kom nrawm/qeeb rau koj teeb tsa ceev. Yog tias lub cav tsis mus rau hauv qhov kev taw qhia koj xav txog a +ve koj tuaj yeem hu rau invertDirectionLogic () los pauv qhov kev taw qhia lub cav txav mus rau +ve nrawm.

getCurrentPosition () rov qab ua haujlwm lub cev tam sim no piv rau 'tsev' (0). Koj tuaj yeem hla qhov tam sim no lub cev muaj zog txoj haujlwm setCurrentPosition (int32_t). Txoj haujlwm tshiab raug txwv kom tsis pub dhau qhov teeb tsa ntxiv/rho tawm txwv.

Thaum pib lub cav tau nres ntawm txoj haujlwm 0. Hu rau setSpeed (50.0) yuav ua rau nws pib nrawm hauv +ve kev taw qhia kom nrawm tshaj plaws ntawm 50 kauj ruam/min. Hu rau hardStop () yuav nres lub cav tam sim ntawd. Ntawm qhov tod tes hu qhov nres () txoj hauv kev yuav teeb tsa qhov nrawm mus rau xoom thiab ua kom lub cav qis dua. Hu rau stopAndSetHome () yuav nres lub cav tam sim thiab teeb tsa nws txoj haujlwm rau 0. Qhov ntxiv/rho tawm qhov txwv tsis tau hloov pauv tab sis tam sim no raug xa mus rau txoj haujlwm 0 (tsev) tshiab no. Hu mus goHome () yuav xa tus stepper mus rau 0 (tsev) txoj haujlwm no thiab nres. Hu rau setSpeed () yuav thim rov qab mus tsev.

Lub tsev qiv ntawv SpeedStepper kuj tseem muaj kev tswj hwm qhov nrawm ntawm cov txheej txheem setProfile (SpeedProfileStruct* profileArray, size_t arrayLen), startProfile (), stopProfile (), txhawm rau cuam tshuam ib qho profile, thiab isProfileRunning (). Saib speedStepperProfile piv txwv kos duab.

Kauj Ruam 2: Khiav SpeedStepperPlot Piv Txwv Tsis Muaj Lub Cev

Khiav SpeedStepperPlot Piv Txwv Tsis Muaj Lub Cev
Khiav SpeedStepperPlot Piv Txwv Tsis Muaj Lub Cev

Nruab Arduino IDE V1.8.9Download thiab nruab SpeedStepper lub tsev qiv ntawv Txuag SpeedStepper.zip thiab tom qab ntawd siv Arduino IDE ntawv qhia zaub mov yam khoom Sketch → suav nrog Tsev qiv ntawv → Ntxiv. ZIP tsev qiv ntawv rau ntshuam lub tsev qiv ntawv rub tawm thiab nruab lub tsev qiv ntawv millisDelay ib yam

Qhib Cov Piv Txwv → SpeedStepper → speedStepperPlot piv txwv kos duab (Rov pib dua IDE yog tias tsim nyog). Cov duab no tau teeb tsa los ua haujlwm nrog Serial, xws li UNO thiab Mega thiab lwm yam Rau kev khiav ntawm SparkFun Redboard Turbo pom hauv qab no.

Tsis muaj tus tsav tsheb lossis tus tsav tsheb yuav tsum tau ua qhov piv txwv no. Cov piv txwv no siv D6 thiab D7 ua cov txiaj ntsig. Koj tuaj yeem hloov pauv tus pin mus rau txhua qhov kev tso tawm digital los ntawm kev hloov STEP_PIN thiab DIR_PIN teeb tsa ze rau saum daim duab kos.

Tshaj tawm cov duab kos rau lub rooj tsavxwm thiab tom qab ntawd qhib Cov Cuab Yeej → Cov Plotter ntawm 115200 baud los qhia cov phiaj xwm ntawm qhov nrawm (RED) thiab txoj haujlwm (XEEB) Qhov txwv ntxiv tau teeb tsa rau 360 uas ua rau kom nrawm mus rau xoom los ntawm kwv yees li 100 taw tes ntawm x-axis. Qhov rho tawm txwv yog -510. Txoj haujlwm nres ntawm ~ -390 vim tias qhov nrawm tau thov rau 0.0. Qhov ntawm 380 taw tes ntawm x-axis, goHome cmd tau tshaj tawm uas rov qab tus stepper mus rau qhov chaw xoom.

Qhov nrawm noStepperPlot kos duab siv millisDelays mus rau lub sijhawm hloov pauv ntawm ntau yam nrawm thiab nrawm. Muaj ntau zaus siv SpeedStepperProfile, zoo li hauv qhov piv txwv tom ntej, yooj yim dua.

Kauj Ruam 3: Khiav SpeedStepperProfile Piv Txwv Tsis Muaj Lub Cev

Khiav SpeedStepperProfile Piv Txwv Tsis Muaj Tsav Tsheb
Khiav SpeedStepperProfile Piv Txwv Tsis Muaj Tsav Tsheb

Qhib Cov Piv Txwv → SpeedStepper → speedStepperPlot piv txwv kos duab, cov duab kos no tsim cov phiaj xwm saum toj no siv Arduino Serial Plotter thiab yog ib qho piv txwv ntawm kev khiav cov ntaub ntawv qhia ceev piv txwv yog tias khiav lub twj tso kua mis.

Stepper Speed Profiles tau ua los ntawm ib pawg ntawm SpeedProfileStruct, uas tau hais tseg hauv SpeedStepper.h cov ntaub ntawv.

struct SpeedProfileStruct {

ntab ceev; // lub hom phiaj nrawm tom kawg ntawm cov kauj ruam no tsis kos npe ntev deltaTms; // lub sijhawm kom nrawm los ntawm kev nrawm tam sim no (thaum pib ntawm cov kauj ruam no) mus rau lub hom phiaj nrawm};

Txheeb xyuas ntau yam ntawm SpeedProfileStruct uas muaj lub hom phiaj nrawm rau txhua kauj ruam thiab sijhawm, deltaTms, hauv mS, kom mus txog lub hom phiaj nrawm los ntawm lub hom phiaj yav dhau los. Yog tias deltaTms yog xoom lossis tsawg heev, tom qab ntawd qhov nrawm yuav dhia tam sim rau lub hom phiaj tshiab nrawm. Txwv tsis pub, qhov xav tau nrawm yuav raug suav setAcceleration () yuav raug hu ua raws los ntawm kev hu mus rau setSpeed () rau lub hom phiaj tshiab nrawm. Hauv txhua qhov xwm txheej cov ntaub ntawv yuav raug txwv los ntawm qhov tam sim no ntxiv thiab rho tawm txoj haujlwm txwv thiab max/min ceev teeb tsa. Yog tias koj xav tuav ceev, tsuas yog rov ua qhov nrawm dhau los nrog lub sijhawm koj xav kom nws tuav. Txij li lub hom phiaj tshiab nrawm yog tib yam li qhov nrawm tam sim no, kev suav nrawm yuav yog xoom thiab, tsis muaj kev hloov pauv yog nrawm dua.

Qhov SpeedProfileStruct array tau tsim cov phiaj xwm saum toj no

const SpeedProfileStruct profile = {{0, 0}, // nres tam sim yog tias tsis tau tso tseg {0, 1000}, // tuav xoom rau 1sec {-50, 0}, // dhia mus -50 {-200, 2000}, // nce mus rau -200 {-200, 6000}, // tuav ntawm -200 rau 6sec {-50, 2000}, // nce mus rau -50 {0, 0}, // // nres tsis tau sai {0, 1500}, // tuav xoom rau 1.5sec {50, 0}, // dhia mus rau 50 {200, 2000}, // nce mus txog 200 {200, 6000}, // tuav 200 rau 6 vib nas this {50, 2000}, // nce mus rau 50 {0, 0}, // // nres tsis tau sai {0, 1000} // tuav xoom // rau cov phiaj xwm tso tawm}; const size_t PROFILE_LEN = sizeof (profile) / sizeof (SpeedProfileStruct); // xam qhov loj ntawm qhov profile array

Cov ntaub ntawv raug teeb tsa los ntawm kev hu rau setProfile (SpeedProfileStruct* profileArray, size_t arrayLen) xws li stepper.setProfile (profile, PROFILE_LEN);

Thaum cov ntaub ntawv tau teeb tsa, hu rau startProfile () kom pib khiav nws los ntawm lub cev muaj zog tam sim no (feem ntau koj yuav pib los ntawm nres). Thaum kawg ntawm qhov profile, lub cav yuav cia li txuas ntxiv ntawm lub hom phiaj kawg. IsProfileRunning () txoj hauv kev tuaj yeem raug hu kom pom tias cov ntaub ntawv tseem tab tom ua haujlwm. Yog tias koj xav nres qhov profile thaum ntxov koj tuaj yeem hu rau stopProfile () uas yuav tso tseg qhov profile thiab nres lub cav.

Kauj Ruam 4: Khiav SpeedStepperSetup Piv Txwv Tsis Muaj Lub Cev

Cov duab piv txwv tau tsim los rau lub hauv paus rau koj tus kheej daim ntawv thov lub cev muaj zog. Nws muab cov ntawv qhia zaub mov uas cuam tshuam nrog kev tso cai rau koj txav mus rau lub cev muaj zog mus rau nws txoj haujlwm hauv tsev, yog tias tsis tau muaj thiab tom qab ntawd xaiv qhov pib dua qhov ntxiv thiab rho tawm txwv thiab tom qab ntawd khiav lub cav hauv qhov ntawd. Cov ntawv qhia zaub mov 'khiav' tso cai rau koj nce thiab txo qis, khov ntawm qhov nrawm tam sim no, nres thiab tseem rov qab mus tsev.

Cov duab kos no qhia txog tus lej ntawm cov software uas ua rau lub voj () teb kom koj tuaj yeem ntxiv koj tus kheej lub tswv yim nkag los tswj tus stepper. Nws yuav siv qhov mob kom tsis txhob qeeb uas yuav cuam tshuam nrog kev tswj ceev. (Saib qeeb yog qhov phem)

Nruab ib lub tsev qiv ntawv siv rau khiav SpeedStepperPlot, saum toj no, thiab tom qab ntawd tseem nruab pfodParser lub tsev qiv ntawv. Lub tsev qiv ntawv pfodParser muab cov NonBlockingInput thiab pfodBufferedStream cov chav kawm uas tau siv los tswj cov neeg siv cov tswv yim thiab cov ntawv qhia zaub mov tso tawm nrog thaiv lub voj () los ntawm kev khiav.

Qhib Cov Piv txwv → SpeedStepper → speedSpeedSetup piv txwv. Cov duab no tau teeb tsa los ua haujlwm nrog Serial, xws li UNO thiab Mega thiab lwm yam Rau kev khiav ntawm SparkFun Redboard Turbo pom hauv qab no.

Tsis muaj tus tsav tsheb lossis tus tsav tsheb yuav tsum tau ua qhov piv txwv no. Cov piv txwv no siv D6 thiab D7 ua cov txiaj ntsig. Koj tuaj yeem hloov pauv tus pin mus rau txhua qhov kev tso tawm digital los ntawm kev hloov STEP_PIN thiab DIR_PIN teeb tsa ze rau saum daim duab kos. Tshaj tawm cov duab kos rau lub rooj tsavxwm thiab tom qab ntawd qhib Cov Cuab Yeej → Serial Monitor ntawm 115200 kom pom SETUP cov ntawv qhia zaub mov.

SETUP pos: 0 sp: 0.00 +Lim: 500000 -Lim: -500 LATENCY: stepper: 492uS voj: 0uS p -teeb Tsev l -teeb txwv h -goHome r -khiav>

Thaum cov duab kos ua haujlwm tam sim no ntawm tus stepper raug coj raws li nws 'tsev' (0) txoj haujlwm. Yog tias koj xav tau rov ua haujlwm tus stepper rau nws qhov tseeb 'tsev' txoj haujlwm, nkag mus rau p hais kom ua kom pom SET HOME menu

SET HOME pos: 0 sp: 0.00 + Lim: 1073741808 -Lim: -1073741808 LATENCY: stepper: 752uS loop: 3852uS x -setHome ntawm no thiab tawm mus - -Mus rau tom ntej - -Rov qab s -pauv mus rau tom ntej/Rov qab -hardStop >

Raws li koj tuaj yeem pom cov kev txwv coded hauv daim duab kos tau raug tshem tawm yog li koj tuaj yeem rov muab txoj haujlwm stepper nyob qhov twg. Koj yuav tsum tau saib xyuas koj tsis txhob tsav nws hla lub cev txwv lossis koj tuaj yeem tsoo qee yam.

Siv tus + cmd los pib txav tus stepper rau pem hauv ntej, yog tias koj pom nws txav mus rau qhov tsis ncaj ncees lawm nkag mus rau qhov tsis-hais kom ua lossis tsuas yog kab khoob kom nres nws thiab tom qab ntawd siv lub scommand los pauv cov lus qhia ntawm Forward. Koj yuav tsum hloov kho cov duab kos kom suav nrog hu mus rau invertDirectionLogic () hauv kev teeb tsa txhawm rau txhim kho qhov no rau kev ua haujlwm tom ntej.

Siv tus + / - cmds los tso tus stepper rau txoj haujlwm xoom raug. Lub cav pib qeeb thiab tom qab ntawd ua kom nrawm dua thaum nws mus, tsuas yog siv thiab khoob kab kom nres nws. Qhov siab tshaj plaws rau qhov no thiab txwv cov ntawv qhia zaub mov tau teeb tsa los ntawm MAX_SETUP_SPEED nyob rau sab saud ntawm setupMenus.cpp.

Thaum lub cav tau teeb tsa ntawm nws lub tsev 'txoj haujlwm, siv x cmd los teeb tsa txoj haujlwm tam sim no li 0 thiab rov qab mus rau SETUP cov ntawv qhia zaub mov.

Yog tias koj xav tau teeb tsa qhov txwv, feem ntau tsuas yog ntawm qhov pib teeb tsa, siv l cmd nkag mus rau SET LIMITS cov ntawv qhia zaub mov

SET LIMITS pos: 0 sp: 0.00 + Lim: 1073741808 -Lim: -1073741808 LATENCY: stepper: 944uS loop: 5796uS l -setLimit here + -Forward - -Rov qab h -goHome x -tawm -hardStop>

Siv tus + cmd mus rau tom ntej rau qhov txwv ntxiv thiab tom qab ntawd siv l cmd los teeb nws ua qhov txwv ntxiv. Cov lus txib h tuaj yeem siv rov qab mus rau 0 thiab - cmd siv txav mus yog tias tswm seeb rau txoj hauj lwm lub cev muaj zog ntawm qhov rho tawm txwv. Ib zaug ntxiv siv l cmd los teeb qhov rho tawm txwv. Nco tseg txoj haujlwm ntawm qhov ntxiv thiab rho tawm txwv thiab hloov kho teeb tsa () txoj kev setPlusLimit thiab setMinusLimit cov nqe lus nrog cov txiaj ntsig no.

Thaum cov kev txwv tau teeb tsa siv x cmd kom rov qab mus rau SETUP cov ntawv qhia zaub mov thiab tom qab ntawd koj tuaj yeem siv r cmd los qhib RUN menu

RUN MENU pos: 0 sp: 3.31 + Lim: 500000 -Lim: -500 LATENCY: stepper: 944uS voj: 5796uS + -Ua kom nrawm - -Ua kom h -goHome. -hardStop-khov ceev> +pos: 4 sp: 9.49 +Lim: 500000 -Lim: -500 LATENCY: stepper: 792uS loop: 5664uS pos: 42 sp: 29.15 +Lim: 500000 -Lim: -500 LATENCY: stepper: 792uS loops: 5664uS pos: 120 sp: 49.09 +Lim: 500000 -Lim: -500 LATENCY: stepper: 792uS loop: 5664uS pos: 238 sp: 69.06 +Lim: 500000 -Lim: -500 LATENCY: stepper: 792uS voj: 5664 ua

Cov + cmd pib nrawm dua rau hauv kev qhia ua ntej thiab luam tawm txoj haujlwm thiab nrawm txhua 2 vib nas this. Thaum lub cav nce mus txog qhov nrawm koj xav tau koj tuaj yeem nres qhov nrawm nrog lwm qhov tseem ceeb (lossis cov khoom siv khoob). Koj tuaj yeem txo qhov nrawm siv - cmd nqis kom nres. Yog tias nres qhov - cmd yuav nrawm dua rov qab.

Cov ntawv qhia zaub mov RUN no muab kev tswj hwm ntawm koj qhov haujlwm. Txog kev tswj hwm tus kheej koj yuav xav tau ntxiv qee qhov ntsuas.

Kauj ruam 5: Latency

Stepper lub cev muaj zog tswj nyob ntawm qhov software txib txhua kauj ruam. Txhawm rau tswj qhov teeb tsa nrawm, koj daim duab xav tau hu rau stepper.run () txoj kev feem ntau txaus los tua cov kauj ruam tom ntej ntawm lub sijhawm rau qhov nrawm tam sim no. Txog kev tswj hwm ntawm cov ntsuas koj yuav tsum muaj peev xwm ua cov txheej txheem ntsuas tshiab tam sim. Txoj hauj lwm/nrawm luam tawm suav nrog ob qho kev ntsuas LATENCY kom koj txheeb xyuas koj daim duab kos tau nrawm txaus.

Stepper Latency (pfodBufferedStream)

Tus stepper latency ntsuas qhov ncua ntev tshaj plaws ntawm kev hu xov tooj mus rau stepper.run () txoj kev. Txhawm rau kom khiav lub tshuab hluav taws xob stepper ntawm 1000 cov kauj ruam ib ntus, stepper latency xav tau tsawg dua 1000uS (1mS). Thawj qhov qauv ntawm daim duab no tau muaj qhov tsis txaus ntseeg ntawm ntau milliseconds. Txhawm rau kov yeej qhov kev hu ntxiv no mus rau runStepper () txoj kev (uas hu stepper.run ()) qhov twg ntxiv los ntawm cov cai. Qhov no tsis tau daws qhov teeb meem kiag li vim tias cov ntawv qhia zaub mov thiab cov ntawv luam tawm tau thaiv qhov kos thaum lub Serial Tx me me tsis puv. Txhawm rau zam qhov kev thaiv no, pfodBufferedStream los ntawm lub tsev qiv ntawv pfodParser tau siv los ntxiv 360 byte tso tawm cov ntawv tsis pub luam ntawv uas cov ntawv tshaj tawm tuaj yeem sau sai. Tom qab ntawd pfodBufferedStream tso tawm cov bytes ntawm tus nqi baud teev 115200 hauv qhov no. pfodBufferedStream yuav tsum muaj kev xaiv los thaiv thaum qhov tsis puv lossis tsuas yog tso cov ntawv hla. Ntawm no nws tau teeb tsa kom tso ib qho cim tshwj xeeb ntxiv thaum qhov tsis nyob puv kom cov duab kos tsis raug thaiv tos rau Serial xa cov ntawv.

Loop Latency (NonBlockingInput)

Lub voj latency ntsuas qhov ncua ntev tshaj plaws ntawm kev hu ua txuas mus rau lub voj () txoj kev. Qhov no teeb tsa nrawm npaum li cas koj tuaj yeem ua cov ntsuas ntsuas tshiab thiab kho lub cav teeb tsa nrawm. Yuav nrawm npaum li cas yuav tsum yog nyob ntawm qhov koj tab tom sim tswj hwm.

Qhov qeeb vim yog cov ntawv luam tawm tau raug tshem tawm los ntawm kev siv pfodBufferedStream saum toj no, tab sis txhawm rau ua cov txheej txheem tus neeg siv khoom koj yuav tsum tau siv thawj zaug nkaus xwb ntawm kev nkag thiab tsis quav ntsej cov kab ntxiv. Cov NonBlockingInput chav kawm hauv pfodParer lub tsev qiv ntawv tau siv los rov qab tus lej uas tsis yog xoom thaum muaj kev nkag, siv readInput (), thiab tshem tawm thiab muab pov tseg cov cim hauv qab no, siv clearInput (), kom txog thaum tsis tau txais tus lej rau 10mS yam tsis thaiv lub voj ()

Tau kawg lub voj latency yuav nce ntxiv los ntawm cov lej ntxiv uas koj ntxiv los nyeem cov cim thiab suav qhov teeb tsa tshiab. Ntau lub tsev qiv ntawv sensor siv qhov kev txiav ntawm kev siv ncua (..) nruab nrab ntawm kev pib ntsuas thiab rov ua qhov tshwm sim. Koj yuav tsum tau rov sau cov tsev qiv ntawv no los siv millisDelay hloov, kom khaws qhov ntsuas tom qab qhov tsim nyog tsis txwv qhov ncua.

Kauj Ruam 6: Khiav SpeedStepperSetup Nrog Stepper Motor thiab SparkFun Redboard Turbo

Khiav SpeedStepperSetup Nrog Stepper Motor thiab SparkFun Redboard Turbo
Khiav SpeedStepperSetup Nrog Stepper Motor thiab SparkFun Redboard Turbo
Khiav SpeedStepperSetup Nrog Stepper Motor thiab SparkFun Redboard Turbo
Khiav SpeedStepperSetup Nrog Stepper Motor thiab SparkFun Redboard Turbo

Txhawm rau khiav SpeedStepperSetup kos duab rau tiag tiag koj yuav xav tau stepper lub cev muaj zog, tus tsav tsheb thiab lub zog siv thiab hauv qhov piv txwv no SparkFun Redboard Turbo.

Daim duab thaiv kab ntawv saum toj no (pdf version) qhia txog kev sib txuas. Hauv SpeedStepperSetup kos duab hloov pauv SERIAL txhais rau #define SERIAL Serial1

Stepper Motor, Lub Hwj Huam, Tsav Tsheb thiab Kev Tiv Thaiv

Muaj ntau hom thiab ntau thiab tsawg ntawm stepper motors. Nov yog ob lub kauj 12V 350mA stepper motor tau siv rau kev sim. Txhawm rau ua kom lub zog hluav taws xob no koj xav tau lub zog hluav taws xob ntawm 12V lossis ntau dua thiab ntau dua 350mA.

Lub tsev qiv ntawv no tsuas yog muab cov lus qhia thiab cov kauj ruam tso tawm yog li koj xav tau tus neeg tsav tsheb los cuam tshuam nrog lub cav tsav. Tus Tsav Tsheb Yooj Yim thiab Tus Tsav Tsheb Loj Loj tswj hwm tam sim no rau lub cav lub cev kom koj tuaj yeem siv lub zog hluav taws xob ntawm qhov hluav taws xob siab dua, piv txwv li siv 6V muab rau lub zog 3.3V. Tus Tsav Tsheb Yooj Yim tuaj yeem muab nruab nrab ntawm 150mA/kauj thiab 700mA/kauj. Rau qhov siab dua tam sim no, Tus Tsav Tsheb Loj Loj tuaj yeem muab txog 2A rau ib lub kauj. Nyeem cov FAQ nyob hauv qab ntawm nplooj ntawv Easy Drive.

Cov piv txwv no siv D6 thiab D7 raws li Cov Lus Qhia thiab Cov Lus Qhia. Koj tuaj yeem hloov pauv tus pin mus rau txhua qhov tso tawm digital los ntawm kev hloov STEP_PIN thiab DIR_PIN teeb tsa ze rau saum daim duab kos.

Kev ua haujlwm ntawm Sparkfun Redboard Turbo

Lub cajmeem Redboard Turbo yog teeb meem. Yog tias nws tsis ua haujlwm, thawj zaug nias lub pob pib dua ib zaug thiab rov xaiv qhov chaw nres nkoj COM hauv Arduino Cov cuab yeej ntawv qhia zaub mov thiab rov ua dua. Yog tias tsis ua haujlwm, ob npaug nias lub pob pib dua thiab sim dua.

Txuas tus tsav tsheb yooj yim

Ob lub kauj stepper motors muaj 4 xov hlau. Siv lub ntsuas ntsuas ntsuas txhawm rau nrhiav cov khub uas txuas rau txhua lub kauj thiab tom qab ntawd xaim ib lub xaim mus rau Tus Tsav Tsheb Yooj Yim A thiab lwm qhov txuas rau B davhlau ya nyob twg. Nws tsis muaj teeb meem txoj kev puag ncig koj xaim lawv vim tias koj tuaj yeem siv s cmd hauv cov ntawv qhia zaub mov teeb tsa los pauv qhov kev taw qhia ntawm kev txav mus los.

Lub zog siv hluav taws xob tau txuas mus rau M+ thiab GND teeb tsa qib kev xav ntawm pawg thawj coj nrog 3/5V txuas. Luv qhov txuas ua ke rau 3.3V microprocessor tso tawm, zoo li SparkFun Redboard Turbo (yog tias koj tso nws qhib nws yog qhov tsim nyog rau 5V cov cim, piv txwv li UNO, Mega) Txuas GND, STEP, DIR pins rau microprocessor GND thiab cov kauj ruam thiab dir tso pins. No lwm qhov kev sib txuas tsim nyog los tsav lub cav.

USB rau TTL Serial Cable

Thaum txav SpeedStepperSetup kos duab los ntawm Uno/Mega mus rau Redboard Turbo koj yuav tsis tuaj yeem hloov pauv #define SERIAL Serial nrog #define SerialUSB kom haum rau Redboard Turbo usb txuas txuas, txawm li cas los xij koj yuav pom tias qhov ua tiav stepper latency yog li 10mS. Ntawd yog 10x qeeb dua rau UNO. Qhov no vim li cas Redboard cpu ua haujlwm USB txuas. Txhawm rau dhau qhov no, txuas USB rau TTL Serial Cable rau D0/D1 thiab teeb#piav qhia Serial Serial1 kom siv kho vajtse txuas txuas los tswj lub tshuab tsav. Siv Serial1 muab LATENCY: stepper: 345uS loop: 2016uS uas yog 3 zaug sai dua UNO rau tus stepper thiab loop latency

Qhov Kev Pabcuam Terminal

Arduino Serial Monitor yog qhov nyuab me ntsis los siv los tswj lub tshuab hluav taws xob thaum koj yuav tsum nkag mus rau tus lej hauv kab cmd thiab tom qab ntawv nyem Enter kom xa nws. Kev teb sai dua txhais tau tias yog qhib lub qhov rai dav, TeraTerm rau PC (lossis CoolTerm Mac), txuas nrog USB rau TTL cable COM chaw nres nkoj. Tom qab ntawd hauv lub qhov rai nias tus yuam sij cmd xa nws tam sim ntawd. Nias Enter tsuas yog xa kab tsis raug.

Teem lub cav ceev ntau

Raws li txuas rau saum toj no, Cov Tsav Tsheb Yooj Yim tau teeb tsa rau 1/8 cov kauj ruam, yog li 1000 kauj ruam/feeb yuav tig lub cav ntawm 1000/8/200 kauj ruam/kev hloov pauv = 0.625 revs ib sec lossis 37.5 rpm siab kawg. Los ntawm kev hloov cov tswv yim rau MS1/MS2 koj tuaj yeem hloov ntawm 1/8, ¼, ½ thiab tag nrho cov kauj ruam. Rau tag nrho cov kauj ruam txuas ob MS1 thiab MS2 rau GND. Qhov no yuav tso cai kom nrawm txog 300 rpm. Xaiv qhov tsim nyog MS1/MS2 teeb tsa tso cai rau koj los kho qhov sib piv iav nruab nrab ntawm lub cev muaj zog thiab cov tsav.

Kev Tiv Thaiv Khoom Siv

Thaum lub tsev qiv ntawv SpeedStepper tso cai rau koj teeb tsa txoj haujlwm txwv ntawm kev txav lub cev, kev ua haujlwm ntawm txoj haujlwm yog ua los ntawm suav cov kauj ruam tso tawm los ntawm software. Yog hais tias lub tshuab nres, piv txwv li lub zog tsis txaus los tsav lub cav cov kauj ruam tom ntej ces txoj haujlwm software yuav tsis sib xws nrog txoj haujlwm lub cev. Tom qab ntawd thaum koj siv 'goHome' hais kom ua lub cav yuav hla txoj haujlwm hauv tsev. Txhawm rau tiv thaiv kev puas tsuaj rau kho vajtse koj yuav tsum ua kom haum cov hloov pauv ntawm qhov nyuaj txwv kom txiav tawm lub zog tsav lub zog

Teeb lub cav tam sim no txwv

Ua ntej tshaj, teeb nws mus rau qhov chaw qis tshaj ntawm lub hwj chim. xws li qhov hluav taws xob ntawm TP1 yog qhov tsawg kawg nkaus. Lub potentiometer yog qhov muag, yog li tsis txhob yuam lub potentiometer yav dhau los cov tshuab nres. Teem lub tshuab tsav ntawm lub nrawm nrawm nrawm nrawm, tom qab ntawd maj mam tig lub hwj chim kom txog thaum lub cav tsis hla lossis txav ntawm cov kauj ruam.

Xaus

Txoj haujlwm no qhia pom yuav siv SpeedStepper lub tsev qiv ntawv li cas hauv daim ntawv thov. Thaum lub tsev qiv ntawv AccelStepper muab txoj haujlwm tswj tau zoo, xav tau kev tswj ceev rau Prototype Ice-Melting Probe rau Kev Txheeb Xyuas Cov Qauv Piv Txwv ntawm Europa yog li AccelStepper lub tsev qiv ntawv tau rov sau dua los muab kev tswj nrawm nrog qhov kawg txwv thiab GoHome muaj nuj nqi.

Pom zoo: