Cov txheej txheem:

Ua haujlwm RC Tsheb Speedometer: 4 Cov Kauj Ruam (nrog Duab)
Ua haujlwm RC Tsheb Speedometer: 4 Cov Kauj Ruam (nrog Duab)

Video: Ua haujlwm RC Tsheb Speedometer: 4 Cov Kauj Ruam (nrog Duab)

Video: Ua haujlwm RC Tsheb Speedometer: 4 Cov Kauj Ruam (nrog Duab)
Video: Ua tau tsheb lawm nawb cov phooj ywg yog leej twg nyiam no nug tau nawb 2024, Kaum ib hlis
Anonim
Ua haujlwm RC Tsheb Speedometer
Ua haujlwm RC Tsheb Speedometer

Nov yog qhov haujlwm luv uas kuv tau tsim los ua ib feem ntawm qhov loj dua RC tsim ntawm Lightweight Land Rover. Kuv txiav txim siab tias kuv fancied muaj lub ntsuas cua ua haujlwm hauv lub dashboard, tab sis kuv paub tias tus servo yuav tsis txiav nws. Tsuas muaj ib qho kev xaiv tsim nyog: xa cov arduino!

Me ntsis keeb kwm yav dhau los pib nrog… Kuv tsis yog tus lej lossis cov khoom siv hluav taws xob. Kuv tseem xav txog hluav taws xob hais txog cov dej ntws thiab kuv paub me ntsis los ntawm cov neeg tawm tsam. Uas tau hais tias, yog tias txawm tias kuv muaj peev xwm ua txoj haujlwm no, ces koj yuav tsum muaj peev xwm ib yam!

PARTS LIST:

Microcontroller: Kuv siv ATTiny85 nti, uas raug nqi txog £ 1 txhua.

Microcontroller Programmer: Txhawm rau kom tau txais txoj cai mus rau hauv lub nti, koj xav tau txoj hauv kev los ua haujlwm rau nws. Nrog arduino tsis tu ncua qhov no tsuas yog USB cable, tab sis rau ATTiny nti, koj xav tau qee yam ntxiv. Koj tuaj yeem siv lwm tus arduino los ua qhov no lossis, zoo li kuv, koj tuaj yeem siv Tiny AVR programmer los ntawm Sparkfun.

learn.sparkfun.com/tutorials/tiny-avr-prog…

Kuv yuav pom zoo qhov no, raws li kuv tau sim ua haujlwm lawv nrog ntau txoj hauv kev thiab qhov no yog qhov yooj yim tshaj plaws. Pawg thawj coj tau kim me ntsis, tab sis kev nqis peev zoo yog tias koj ua ntau txoj haujlwm ATTiny.

8 Pin Chip Socket: Yog tias koj muab lub nti tso rau hauv lub qhov (socket) es tsis siv nws ncaj qha, koj tuaj yeem them koj tus kheej qee qhov yuam kev hauv kev sib dhos. Hais los ntawm kev paub - tsis muaj leej twg xav kom desolder chips rov ua dua lawv.

Capacitor: Ib lub decoupling capacitor ntawm 100nF (code 104) tau siv. Kuv tsis nkag siab vim li cas, tab sis kuv nyeem tias decoupling capacitors yog qhov tseem ceeb hauv is taws nem, yog li nws yuav tsum muaj tseeb …

Resistor: 10 kΩ resistor siv los rub txoj kab rau hauv arduino. Ib zaug ntxiv, tseem muaj lwm qhov paub tsis meej ntawm cov khoom siv hluav taws xob.

Perfboard/Stripboard: Qee lub hauv paus raws qhov uas sib sau ua ke koj lub Circuit Court.

Winding Wire: Cov xov hlau tsis tu ncua yog tuab heev rau cov laug rau ntawm lub cav. Kev siv cov xaim hluav taws xob zoo yuav txo qhov kev ntxhov siab ntawm lub tshuab hluav taws xob thiab ua rau koj lub neej yooj yim dua.

Servo Hlau: Peb txoj hlua xaim xaus rau hauv 3-tus pin JR poj niam ntsaws. Kuv tau txais kuv li los ntawm qhov hlawv tawm servo uas kuv tau 'hloov kho'.

Stepper Motor: Kuv siv 6mm bipolar Nidec stepper motor. Ib qho me me stepper yuav tsum ua haujlwm, txawm hais tias ua rau lawv me me, raws li tus stepper tau tsav ncaj qha los ntawm Arduino.

Header Pins: Tsis yog qhov tseem ceeb, tab sis yog tias koj xaim koj lub stepper rau 4 lub taub hau thiab muab lub qhov (socket) tso rau hauv koj lub Circuit Court, koj tuaj yeem yooj yim tshem koj lub dashboard kom yooj yim rau kev teeb tsa.

Khoos phis tawj: Txhawm rau teeb tsa koj lub rooj tsavxwm, koj yuav xav tau lub khoos phis tawj. Tej zaum nrog Arduino IDE. Thiab tej zaum USB cable. Yog tias nws muaj lub xov tooj hluav taws xob ib yam nkaus, tom qab ntawd txawm tias zoo dua.

Kauj ruam 1: Qhov System

Cov txheej txheem yooj yim ntawm cov kab ke kuv tau tsim yog ib txoj hauv kev uas Pulse Width Modulation (PWM) teeb liab los ntawm RC tus txais tau hloov pauv mus rau hauv lub tshuab hluav taws xob stepper ntawm ATTiny 85 microcontroller (uC).

Nov yog cov peev txheej ntawm PWM cov cim thiab RC, tab sis kom rov ua qhov no koj tsis tas yuav tsum nkag siab nws.

en.wikipedia.org/wiki/Servo_control

ATTiny yog qhov kuv nyiam tshaj plaws ntawm Arduino vim tias nws me me nrog tseem txaus I/O pins los ua tej yam yooj yim, yog li haum txig rau hauv cov qauv me me thiab RC cov haujlwm. Qhov tsis zoo ntawm ATTiny yog tias nws xav tau teeb tsa me ntsis txhawm rau txhawm rau ua haujlwm ib qho, tab sis thaum koj tau txais nws teeb tsa lawv pheej yig heev koj tuaj yeem yuav cov khoom sib lawv rau txhua hom phiaj xwm.

Qhov loj ntawm tus ntsuas lub ntsuas hluav taws xob me me dhau kom muaj lub zog tsav nrog cov lus tawm tswv yim, yog li txhawm rau kom muaj cov lus teb zoo ib tus neeg tsav tsheb yuav tsum tau siv. Stepper lub cev muaj zog yog lub cev muaj zog uas tau hloov pauv hauv qhov sib txawv (lossis cov kauj ruam …!) Tsuas yog qhov kev ceeb toom yog tias 'cov kauj ruam' yuav ua rau lub zog txav mus los tsis txav li qhov tsis sib haum. Yog tias koj tau txais tus stepper nrog cov kauj ruam txaus rau ib qho kev hloov pauv, uas tsis pom tau, tab sis nrog cov stepper uas kuv tau siv hauv txoj haujlwm no tsuas muaj 20 lossis yog li cov kauj ruam hauv kev sib hloov puv, lub kaum dhia yog qhov phem heev.

Lub kaw lus, ntawm lub zog-nce, yuav khiav tus stepper rov qab rau ob qhov kev tawm tsam, thiaj li yuav xoom koob. Tus ntsuas hluav taws xob xav tau tus pin nyob qhov twg koj xav kom lub cim cim yog, lossis lwm yam nws yuav tsuas yog tig mus tas li. Tom qab ntawd nws daim ntawv qhia rau pem hauv ntej thiab thim rov qab PWM cov cim rau teeb tsa tus lej ntawm cov kauj ruam ntawm lub cev muaj zog. Yooj yim, txoj cai …?

Kauj ruam 2: Software

Disclaimer: Kuv tsis yog programmer. Rau qhov haujlwm no kuv yog digital sib npaug ntawm Dr. Frankenstein, sib sau ua ib yam dab tsi ua haujlwm ntawm ntau yam pom cov khoom me me ntawm cov cai.

Yog li, kuv ua tsaug tshaj plaws mus rau Duane B, uas ua tus lej rau kev txhais lus RC cov cim:

rcarduino.blogspot.com/

Thiab rau Ardunaut, leej twg ua txoj cai rau kev ua haujlwm stepper raws li kev ntsuas sib piv:

arduining.com/2012/04/22/arduino-driving-a…

Thiab rau ob leeg, kuv thov txim siab tshaj plaws uas kuv tau ua rau koj tus lej.

Tam sim no uas tsis muaj txoj hauv kev, ntawm no yog yuav ua li cas upload rau ATTiny:

#define THROTTLE_SIGNAL_IN 0 // INTERRUPT 0 = DIGITAL PIN 2 - siv tus lej cuam tshuam hauv attachInterrupt #txhais THROTTLE_SIGNAL_IN_PIN 2 // INTERRUPT 0 = DIGITAL PIN 2 - siv tus lej PIN hauv digitalRead #define NEUTRAL_THRT ntawm qhov nruab nrab qhov txwv ntawm qhov hluav taws xob RC Tsheb #define UPPER_THROTTLE 2000 // qhov no yog lub sijhawm hauv microseconds ntawm qhov siab tshaj plaws ntawm qhov hluav taws xob RC Tsheb #define LOWER_THROTTLE 1000 // qhov no yog lub sijhawm nyob rau hauv microseconds ntawm qhov tsawg kawg nkaus ntawm qhov hluav taws xob RC Tsheb #define DEADZONE 50 // qhov no yog lub qhov rooj kaw qhov rooj. Tag nrho cov deadzone yog ob npaug rau qhov no. #suav nrog #define KAUJ RUAM 21 // cov kauj ruam ib puag ncig (txwv rau 315 °) Hloov qhov no txhawm rau kho qhov kev mus ncig ntau tshaj ntawm lub ntsuas cua. #define COIL1 3 // Coil Pins. ATTiny siv tus pin 0, 1, 3, 4 rau tus stepper. Tus Pin 2 yog tus pin nkaus xwb uas tuaj yeem ua haujlwm cuam tshuam yog li nws xav tau los ua cov tswv yim. #define COIL2 4 // Sim hloov cov no ib puag ncig yog tias lub cav tsav tsis ua haujlwm zoo. #define COIL3 0 #define COIL4 1 // tsim qhov piv txwv ntawm chav kawm stepper: Stepper stepper (STEPS, COIL1, COIL2, COIL3, COIL4); int pos = 0; // Txoj hauj lwm hauv cov kauj ruam (0-630) = (0 ° -315 °) int SPEED = 0; ntab ThrottleInAvg = 0; int MeasurementsToAverage = 60; ntab Resetcounter = 10; // lub sijhawm rov pib dua thaum tsis ua haujlwm lub zog pib dua = 0; tsis hloov pauv ThrottleIn = LOWER_THROTTLE; qhov hloov pauv tsis tau kos npe ntev StartPeriod = 0; // teeb tsa qhov cuam tshuam // peb tuaj yeem siv nThrottleIn = 0 hauv lub voj hloov ntawm qhov sib txawv sib txawv, tab sis siv bNewThrottleSignal los qhia tias peb muaj lub cim tshiab // yog pom tseeb rau qhov piv txwv no thawj zaug tsis muaj teeb tsa () {// qhia rau Arduino peb xav kom lub luag haujlwm calcInput raug hu thaum twg INT0 (tus lej digital 2) hloov pauv los ntawm HIGH rau LOW lossis LOW mus rau HIGH // ntes cov kev hloov pauv no yuav tso cai rau peb suav tau ntev npaum li cas cov tswv yim mem tes tau txuasInterrupt (THROTTLE_SIGNAL_IN, calcInput, CHANGE); stepper.setSpeed (50); // teeb tsa lub cav nrawm rau 30 RPM (360 PPS kwv yees.) stepper.step (KAUJ RUAM * 2); // Rov Pib Txoj Haujlwm (X cov kauj ruam rov qab-clockwise). } void loop () {Resetval = millis; rau (int i = 0; i (NEUTRAL_THROTTLE + DEADZONE) && ThrottleInAvg <UPPER_THROTTLE) {SPEED = map (ThrottleInAvg, (NEUTRAL_THROTTLE + DEADZONE), UPPER_THROTTLE, 0, 255); Rov pib dua = 0; } // Rov qab ua daim duab lwm yog (ThrottleInAvg LOWER_THROTTLE) {SPEED = daim ntawv qhia (ThrottleInAvg, LOWER_THROTTLE, (NEUTRAL_THROTTLE - DEADZONE), 255, 0); Rov pib dua = 0; } // Tawm ntawm thaj tsam sab saud yog (ThrottleInAvg> UPPER_THROTTLE) {SPEED = 255; Rov pib dua = 0; } // Tawm ntawm qhov qis dua lwm tus yog (ThrottleInAvg Resetcounter) {stepper.step (4); // Kuv sim qhia tus stepper kom rov pib dua nws tus kheej yog tias RC teeb liab nyob hauv qhov chaw tuag ntev. Tsis paub tseeb tias ib feem ntawm txoj cai ua haujlwm tiag. }} int val = SPEED; // tau txais tus nqi potentiometer (thaj tsam 0-1023) val = daim ntawv qhia (val, 0, 255, 0, STEPS * 0.75); // daim ntawv qhia lauj kaub ntau hauv cov stepper ntau. if (abs (val - pos)> 2) {// yog tias qhov sib txawv ntau dua 2 cov kauj ruam. yog ((val - pos)> 0) {stepper.step (-1); // txav ib kauj ruam mus rau sab laug. pos ++; } yog ((val - pos) <0) {stepper.step (1); // txav ib kauj ruam mus rau sab xis. pos-; }} // ncua (10); } void calcInput () {// yog tus pin siab, nws pib qhov cuam tshuam yog (digitalRead (THROTTLE_SIGNAL_IN_PIN) == HIGH) {// tau txais lub sijhawm siv micros - thaum peb cov cai tau tibneeg hu tauj coob qhov no yuav tsis raug, tab sis rau daim ntawv thov tam sim no nws // nkag siab yooj yim thiab ua haujlwm tau zoo heev StartPeriod = micros (); } lwm tus {// yog tus lej qis, nws poob qis ntawm cov mem tes yog li tam sim no peb tuaj yeem suav lub sijhawm ntawm lub plawv dhia los ntawm kev rho tawm // pib lub sijhawm ulStartPeriod los ntawm lub sijhawm tam sim no rov qab los ntawm micros () yog (StartPeriod) {ThrottleIn = (int) (micros () - StartPeriod); StartPeriod = 0; }}}

Xa mus rau qhov no kom paub ntau ntxiv txog kev ua haujlwm ATTiny85:

learn.sparkfun.com/tutorials/tiny-avr-prog…

Kauj ruam 3: Kho vajtse

Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse
Kho vajtse

Xa mus rau daim duab qhia chaw rau kev tsim lub Circuit Court. Yuav ua li cas koj sib sau ua ke nws nyob ntawm koj, tab sis kuv xav kom siv me ntsis ntawm kab txaij/kab ntawv siv rau kev tsim qauv Circuit Court board, thiab teeb tsa lub nti hauv lub qhov (socket).

C1 = 100 nF

R1 = 10 kΩ ib

Lub capacitor yuav tsum tau teeb tsa kom ze rau ntawm lub nti kom ua tau zoo tshaj plaws.

Thaum siv cov xaim hluav taws xob xaim rau lub cev muaj zog, ua tib zoo saib xyuas, vim tias lub dav hlau ntawm lub tshuab hluav taws xob zoo li ntsaws tawm thiab cais cov hlua hlau rau lub tshuab. Txhawm rau daws qhov no, txoj kev daws teeb meem zoo yog txhawm rau txuas cov xov hluav taws xob, thiab tom qab ntawd muab lub ntsej muag loj ntawm 2-ntu epoxy hla qhov sib koom,, cia nws kho, tom qab ntawd ntswj cov xov ua ke. Qhov no txo qis kev ntxhov siab ntawm tus kheej cov pob qij txha thiab yuav tsum tso lawv tawm. Yog tias koj tsis ua qhov no, lawv yuav tshem tawm ntawm lub sijhawm yooj yim tshaj plaws, tau lees paub.

Yog tias koj ua tus header pin txuas, thiab teeb tsa tus pin li no: [Ca1, Cb1, Ca2, Cb2] nrog Ca1 sawv rau Coil A, xaim 1 thiab lwm yam. ib ncig

Qhov ntsuas yuav xav tau qhov kawg txhawm rau ntsuas qhov xoom txoj haujlwm tiv thaiv. Kuv xav kom ua rab koob tawm ntawm cov hlau yog ua tau. Qhov no ua rau nws yoog raws thaum nws tsoo qhov kawg. Ib txoj hauv kev kom tau txais rab koob nyob rau hauv txoj haujlwm zoo yog txhawm rau txhawm rau rab koob ib ntus mus rau lub zog, ua kom lub zog hloov pauv, cia nws los so, thiab tom qab ntawd tshem tawm thiab rov lo kua nplaum rau ntawm lub qag, nrog rab koob so tawm tsam kawg. Qhov no ua kom haum cov koob nrog sib nqus cogging ntawm lub cav, thiab ua kom ntseeg tau tias koj lub koob yuav tsum ib txwm los so tawm tsam qhov kawg.

Kauj ruam 4: Epilogue

Vam tias koj tau nyiam qhov kev qhia luv luv no, thiab pom nws muaj txiaj ntsig. Yog tias koj tsim ib qho ntawm cov no, qhia rau kuv paub!

Hmoov zoo!

Pom zoo: