Ulawulo lweServomotor ngePWM kunye neArduino

Sele sibonakalisile kwibhlog Arduino (https://www.ikkaro.com/kit-inicio-arduino-super-starter-elegoo/) Kwaye enyanisweni zivela kwiiprojekthi ezininzi kubandakanya le (https://www.ikkaro.com/node/529)

Ngoku masiqhubeke phambili kancinci kwaye masenze moderate imiqondiso ngobubanzi ukubetha (PWM), oku kungasetyenziselwa umzekelo ukuphatha ii-servomotors ezinje ngale zichazwe apha (https://www.ikkaro.com/introduccion-al-aeromodelismo-electrico/) okanye i-rgb leds phakathi kwabanye. Kulabo abangaziyo ukuba yintoni i-PWM, yindlela yokumodareyitha eyenziwa kumqondiso kwaye isebenza "ukuhambisa ulwazi ngejelo lonxibelelwano okanye ukulawula ubungakanani bamandla athunyelwa kumthwalo" (Wikipedia)

Ii-servomotors zilawulwa ngeentambo ezi-3: enye yevolthi elungileyo, enye yomhlaba kunye nenye yesiginali yokulawula, emiselweyo kwi-PWM.

I-Arduino yenxalenye yayo ineziphumo ezi-6 zedijithali ezinokuthi zisebenze njengeziphumo ze-PWM (ezi zizikhonkwane: 11, 10, 9, 6, 5, 4) kunye nethala leencwadi elilungiselelwe ukuphatha iinkonzo. Ke siza kusebenzisa enye yezo mphumo ukwenza iimvavanyo zethu zokuqala zokulawula i-servo motor.

Ikhowudi yomzekelo wethala leencwadi le-Arduino linokusisebenzela, siqhagamshela i-voltage kwi-5v, umhlaba ukuya kwi-gnd kunye nophawu lokulawula lwe-servomotor (eyona izayo imodareyithwayo kwi-PWM) kwenye yezikhonkwane ze-arduino ezine-PWM, umzekelo kule khowudi ukuya kwipini yedijithali 9.

// Shayela
// ngeBARRAGAN

# kuquka
 
Servo myservo; // Yenza into ye-servo ukulawula i-servo
                // ubuninzi bezinto ezisibhozo ze-servo zinokwenziwa
 
int = 0; // Umahluko ukugcina indawo yeservo
 
ukuseta okungenanto ()
{
  myservo.attach (9); // Ifakela i-servo kwipini 9 kwinto ye-servo
}
 
 
iluphu engenanto ()
{
  for (pos = 0; pos <180; pos + = 1) // isuka kwi-0 degrees iye kwi-180 degrees
  {// kumanyathelo e-1 degree
    ukubhala (ukubhala); // xelela i-servo ukuba iye kwindawo eyahlukileyo 'pos'
    ukulibaziseka (15); // ulinda i-15ms kwi-servo ukufikelela kwisikhundla
  }
  for (pos = 180; pos> = 1; pos- = 1) // isuka kwi-180 ukuya kwi-0 degrees
  {                               
    ukubhala (ukubhala); // xelela i-servo ukuba iye kwindawo eyahlukileyo 'pos'
    ukulibaziseka (15); // ulinda i-15ms kwi-servo ukufikelela kwisikhundla
  }
}

Le khowudi ingasivumela ukuba sijikeleze umncedisi ukusuka ku-0º ukuya ku-180º uze uphinde ubuye ku-0º.

Okuninzi kuza ngokukhawuleza.

[kugqanyisiwe] Eli nqaku lalibhalwe ngu ErSame nge Ikkaro [/ ibalaselisiwe]

Ukuba ungumntu ongaphumliyo njengathi kwaye ufuna ukusebenzisana ekugcinweni nasekuphuculweni kweprojekthi, unokwenza umnikelo. Yonke imali iya kuthenga iincwadi kunye nezixhobo zokuvavanya kunye nokwenza izifundo

Shiya amazwana