Cov txheej txheem:
- Kauj Ruam 1: HAIS TIAS YUAV UA LI CAS
- Kauj ruam 2: Yuav tsum kho vajtse
- Kauj Ruam 3: Circuit & Kev Sib Txuas
- Kauj ruam 4: Ua haujlwm
- Kauj ruam 5: CODE
- Kauj Ruam 6: VIDEO DEMONSTRATION
Video: Tswj Kev Siv MPU6050 Ntawm Arduino thiab ESP8266 Nrog HC-12: 6 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Hauv txoj haujlwm no, peb tab tom tswj txoj haujlwm ntawm servo motor siv mpu6050 thiab HC-12 rau kev sib txuas lus ntawm Arduino UNO thiab ESP8266 NodeMCU.
Kauj Ruam 1: HAIS TIAS YUAV UA LI CAS
Nws yog lwm qhov haujlwm IoT raws HC-12 RF-module. Ntawm no, cov ntaub ntawv imu (mpu6050) los ntawm arduino tau siv los tswj lub cav servo (txuas nrog Nodemcu). Ntawm no, cov ntaub ntawv pom tau kuj tau ua ntawm sab arduino qhov twg mpu6050 suab cov ntaub ntawv (kev sib hloov txog x-axis) yog pom nrog ua cov duab kos (tham tom qab). Yeej qhov haujlwm no tsuas yog sov me ntsis kom nco txog qhov sib txawv ntawm Imu & Servo tswj nrog Arduino thiab ESP8266 nodemcu.
OBJECTIVE
Lub hom phiaj ntawm qhov no zoo nkauj heev, Peb tab tom tswj txoj haujlwm ntawm Servo lub cev siv lub suab nrov ntawm IMU. Thiab txhua qhov ua ke lub suab thiab synchronized txoj haujlwm lub cev tau pom nrog Ua.
Kauj ruam 2: Yuav tsum kho vajtse
NodeMCU ESP8266 12E Wifi module
Solderless breadboard
Jumper hlau
MPU6050 accelo+gyro
HC-12 RF modules (khub)
SG90 Servo tsav
Kauj Ruam 3: Circuit & Kev Sib Txuas
Kev sib txuas yog ncaj nraim rau pem hauv ntej. Koj tuaj yeem ua lub zog pabcuam nrog 3.3V ntawm koj li Nodemcu. Koj kuj tseem tuaj yeem siv Vin los ua haujlwm pabcuam yog tias koj lub nodemcu muaj qhov hluav taws xob ntau ntawm tus pin ntawd. Tab sis feem ntau Lolin cov laug cam tsis muaj 5V ntawm Vin (nyob ntawm tus tsim khoom).
Cov duab kab hluav taws xob no tau siv EasyADA.
Kauj ruam 4: Ua haujlwm
Sai li sai tau cov duab kos pib, nws yuav xa lub suab (uas yog los ntawm -45 txog 45) mus rau hc12 tus txais ntawm Nodemcu uas tau teeb tsa nrog 0 txog 180 degree Servo txoj haujlwm. Ntawm no peb siv lub kaum sab xis ntawm -45 txog +45 degree yog li peb tuaj yeem yooj yim daim ntawv qhia ntawd mus rau txoj haujlwm Servo.
Tam sim no, koj tab tom xav tias yog vim li cas peb thiaj siv tau daim ntawv qhia kev yooj yim raws li hauv qab no:-
int pos = daim ntawv qhia (val, -45, 45, 0, 180);
Vim tias lub kaum tsis zoo xa los ntawm hc12 tus xa tawm tau txais raws li:
Ib nrab: (T) 0 txog 45 => 0 txog 45 (R)
Ib nrab thib ob: (T) -45 rau -1 => 255 txog 210 (R)
Yog li koj yuav tsum qhia nws rau 0 txog 180 li
yog (val> = 0 && val <= 45) pos = (val*2) +90; lwm tus pos = (tus nqi-210)*2;
Kuv tabtom zam txoj kev qhia hauv daim ntawv qhia vim qee qhov tsis raug uas tsis raug. Koj tuaj yeem sim qhov ntawd thiab tawm tswv yim nws ua haujlwm nrog koj
if (val> = 0 && val <= 45) pos = map (val, 0, 45, 90, 180); lwm pos = daim ntawv qhia (tus nqi, 255, 210, 0, 90); // Kev sib cav zaum thib 4 tuaj yeem yog 2 (koj tuaj yeem tshawb xyuas)
MPU6050 Pitch Angle Calculation
Kuv siv MPU6050_tockn lub tsev qiv ntawv uas yog raws li muab cov ntaub ntawv nyoos los ntawm IMU.
int pitchAngle = mpu6050.getAngleX ()
Qhov no yuav tau txais peb lub kaum sab xis ntawm kev sib hloov hais txog x-axis. Raws li koj pom hauv daim duab, kuv imu tau muab tso rau ntawm lub khob cij kom tsis txhob cuam tshuam nrog lub suab thiab yob. Qhov tseeb koj yuav tsum ib txwm pom lub axis luam tawm ntawm pawg thawj coj tawg.
Los ntawm lub tsev qiv ntawv no, koj tsis tas yuav thab plaub txog cov khoom siv hluav taws xob sab hauv ntawm kev nyeem ntawv tshwj xeeb rau kev ua haujlwm tshwj xeeb. koj tsuas yog qhia txoj haujlwm thiab koj ua tiav!
Btw yog tias koj xav xam lub kaum sab xis ntawm koj tus kheej. Koj tuaj yeem yooj yim ua nws raws li hauv qab no:
#suav nrog
const int MPU6050_addr = 0x68; int16_t AcX, AcY, AcZ, Temp, GyroX, GyroY, GyroZ; teeb tsa tsis muaj dabtsis () {Wire.begin (); Wire.beginTransmission (MPU6050_addr); Hlau.write (0x6B); Hlau.write (0); Wire.endTransmission (muaj tseeb); Serial.begin (9600); } void loop () {Wire.beginTransmission (MPU6050_addr); Hlau.write (0x3B); Wire.endTransmission (tsis tseeb); Wire.requestFrom (MPU6050_addr, 14, muaj tseeb); AcX = Wire.read () << 8 | Wire.read (); AcY = Wire.read () << 8 | Wire.read (); AcZ = Wire.read () << 8 | Wire.read (); Temp = Wire.read () << 8 | Hlau.read (); GyroX = Wire.read () << 8 | Wire.read (); GyroY = Wire.read () << 8 | Wire.read (); GyroZ = Wire.read () << 8 | Wire.read ();
int xAng = daim ntawv qhia (AcX, minVal, maxVal, -90, 90); int yAng = daim ntawv qhia (AcY, minVal, maxVal, -90, 90); int zAng = daim ntawv qhia (AcZ, minVal, maxVal, -90, 90); x = RAD_TO_DEG * (atan2 (-yAng, -zAng)+PI); y = RAD_TO_DEG * (atan2 (-xAng, -zAng)+PI); z = RAD_TO_DEG * (atan2 (-yAng, -xAng)+PI); Serial.print ("AngleX ="); // Suab Serial.println (x); Serial.print ("AngleY ="); // Yob Serial.println (y); Serial.print ("AngleZ ="); // Yaw Serial.println (z); }
Tab sis, nws tsis tsim nyog koj yuav sau qhov chaws no kom tau lub kaum ntse ntse. Koj yuav tsum paub qhov tseeb tom qab qhov xwm txheej tab sis siv tsev qiv ntawv ntawm lwm tus neeg muaj txiaj ntsig zoo hauv ntau txoj haujlwm. Koj tuaj yeem nyeem txog qhov no imu thiab lwm yam kev pom zoo kom tau txais cov ntaub ntawv lim dej ntau ntxiv los ntawm qhov txuas hauv qab no: Tshawb-mpu6050.
Kuv tus lej arduino ntawm qhov kawg kis tsuas muaj 30 kab nrog kev pab ntawm MPU6050_tockn lub tsev qiv ntawv yog li siv lub tsev qiv ntawv zoo yog tias koj tsis xav tau qee qhov kev hloov pauv tseem ceeb rau kev ua haujlwm ntawm IMU. Lub tsev qiv ntawv hu ua I2Cdev los ntawm Jeff Rowberg yog qhov muaj txiaj ntsig zoo yog tias koj xav tau qee cov ntaub ntawv lim dej siv DMP (Digital motion processor) ntawm IMU.
Kev koom ua ke nrog Kev Ua
Ntawm no Kev Ua Haujlwm yog siv rau kev pom cov ntaub ntawv hloov pauv ntawm x-axis ntawm IMU raws li suav los ntawm cov ntaub ntawv nyoos los ntawm MPU6050. Peb tau txais cov ntaub ntawv raw khoom tuaj hauv SerialEvent raws li hauv qab no:
tsis muaj dab tsi serialEvent (Serial myPort) {
inString = myPort.readString (); sim {// Parse cov ntaub ntawv // println (inString); Txoj hlua dataStrings = cais (inString, ':'); if (dataStrings.length == 2) {if (dataStrings [0].equals ("RAW")) {for (int i = 0; i <dataStrings.length - 1; i ++) {raw = ntab (dataStrings [kuv+1]); }} lwm tus {println (inString); }}} ntes (Kev zam e) {println ("Catch Exception"); }}
Ntawm no koj tuaj yeem pom kev pom kev hauv daim duab txuas hauv cov kauj ruam no. Cov ntaub ntawv txoj haujlwm tau txais ntawm qhov nodemcu kawg kuj tseem pom ntawm tus saib xyuas raws li qhia hauv daim duab.
Kauj ruam 5: CODE
Kuv tau txuas lub github chaw cia khoom. Koj tuaj yeem clone & nkhaus nws siv rau hauv koj cov phiaj xwm.
kuv_code
Cov repo suav nrog 2 daim duab kos rau kev xa tawm (arduino+IMU) & tus txais (Nodemcu+Servo).
Thiab ib qho kev kos duab. Lub hnub qub repo yog tias qhov no pab tau hauv koj qhov project.
Hauv phau ntawv qhia no, R- Txais & T- Tus Kws Tshaj Lij
Kauj Ruam 6: VIDEO DEMONSTRATION
Kuv yuav muab daim vis dis aus tag kis. Ua raws kuv kom tau txais kev ceeb toom.
Ua tsaug txhua tus!
Pom zoo:
ESP8266 - Kev Kho Vaj Tsev Nrog Timer thiab Kev Tswj Chaw Taws Teeb Ntawm Is Taws Nem / ESP8266: 7 Cov Kauj Ruam (nrog Duab)
ESP8266 - Dej Irrigation Nrog Timer thiab Kev Tswj Chaw Taws Teeb Ntawm Is Taws Nem / ESP8266: ESP8266 - Kev ywg dej nyob deb tswj thiab nrog sijhawm rau zaub zaub, paj vaj thiab nyom. Nws siv ESP-8266 Circuit Court thiab hydraulic / hluav taws xob valve rau cov chaw tso dej rau dej kom zoo.Qhov Zoo: Tus nqi qis (~ US $ 30,00) nkag tau sai Commands ov
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: 5 Cov Kauj Ruam (nrog Duab)
Qhov muag tsis pom kev Nrog ESP8266, Google Tsev thiab Openhab Kev Sib Koom thiab Kev Tswj Xyuas Web: Hauv Cov Lus Qhia no kuv qhia koj li cas kuv ntxiv kev siv tshuab rau kuv qhov muag tsis pom. Kuv xav kom muaj peev xwm ntxiv thiab tshem tawm qhov kev siv tshuab nws, yog li txhua qhov kev teeb tsa yog clip ntawm.Qhov tseem ceeb yog: Stepper motor Stepper tsav tswj bij ESP-01 Iav thiab teeb tsa
Yuav Ntsuas Li Cas Ntsuas Kev Siv Lub Hwj Chim ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob?: 6 Cov Kauj Ruam
Yuav Ua Li Cas Ntsuas Kom Tau Txais Kev Siv Lub Hwj Huam ntawm Kev Sib Txuas Lus Wireless hauv Era ntawm Kev Siv Hluav Taws Xob? Feem ntau IoT nodes yuav tsum tau siv lub roj teeb. Tsuas yog los ntawm kev ntsuas ntsuas lub zog siv ntawm lub wireless wireless peb tuaj yeem kwv yees kwv yees ntau npaum li cas roj teeb kuv
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: 6 Kauj Ruam
Arduino Neeg Hlau Nrog Kev Nyob, Kev Qhia thiab Qib Kev Sib Hloov (Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) Tswj los ntawm Lub Suab Siv Bluetooth Module thiab Kev Siv Tus Neeg Siv Hluav Taws Xob: Cov lus qhia no piav qhia yuav ua li cas thiaj tsim tau Arduino Robot uas tuaj yeem txav mus raws qhov xav tau (Forward, Backward) , Sab laug, Txoj Cai, Sab Hnub Poob, Sab Hnub Poob, Sab Qaum Teb, Sab Qab Teb) xav tau Kev nrug deb hauv Centimeters siv lub suab hais kom ua. Neeg hlau kuj tseem tuaj yeem txav tau tus kheej
Kev tswj hwm tus kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Li Tachometer: 5 Cov Kauj Ruam (nrog Duab)
Kev Tswj Tus Kheej ntawm RPM ntawm Lub Cav Siv Lub Tswv Yim Los Ntawm IR Raws Lub Tachometer: Muaj ib txwm xav tau rau kev siv tshuab txheej txheem, ua nws yooj yim/tsis txaus ntseeg. cov txheej txheem rau dej/siv dej rau peb daim av me me.Qhov teeb meem ntawm tsis muaj kab khoom siv tam sim no