Cov txheej txheem:

Wireless Servo Control: 6 Kauj Ruam
Wireless Servo Control: 6 Kauj Ruam

Video: Wireless Servo Control: 6 Kauj Ruam

Video: Wireless Servo Control: 6 Kauj Ruam
Video: Управление 32 сервомоторами с помощью PCA9685 и Arduino: V3 2024, Kaum ib hlis
Anonim
Wireless Servo Tswj
Wireless Servo Tswj
Wireless Servo Tswj
Wireless Servo Tswj

Txoj haujlwm no tswj hwm kev sib hloov ntawm servo wirelessly los ntawm kev siv lub zog (pob qhov rooj). Kev sib hloov yog txwv rau 180 degrees.

Kauj Ruam 1: Cheeb Tsam

Cheebtsam
Cheebtsam
Cheebtsam
Cheebtsam
Cheebtsam
Cheebtsam

Txoj haujlwm no suav nrog

  • 2 Arduino UNO cov laug cam nrog USB txuas cable
  • 2 nRF24L01-2.4GHz RF transceiver modules (rau kev pab nrog cov qauv no xa mus rau
  • 2 lub qhov (socket) adapter (lub hnab ev ntawv) rau nRF24L01
  • 1 xaiv Arduino Tau Tshaj 328 ProtoShield Prototype Expansion Board
  • 1 siv
  • 1 analog potentiometer
  • soldering hlau thiab solder
  • xaim
  • rab koob nosed pliers
  • insulating qhwv, Kuv siv daim kab xev hluav taws xob

Kauj ruam 2: Server Board

Neeg rau zaub mov Board
Neeg rau zaub mov Board

Lub rooj tsav xwm neeg rau zaub mov suav nrog tus qauv xa xov, daim thaiv npog (uas txuas ncaj qha rau Arduino pawg thawj coj tsuas yog ib txoj hauv kev), thiab servo. Kuv tau txiav txim siab suav nrog daim phiaj thaiv kom tsis txhob muaj lub khob cij clumsy thiab muab txoj haujlwm thiab ua tiav tag nrho.

Cov cai thiab cov peev txheej hauv web suav nrog hauv cov npe teev qhia ntxaws txog qhov kev sib txuas ntawm tus xa xov. Kuv txiav txim siab los txuas cov kev sib txuas es tsis txhob siv kev sib txuas ib ntus zoo li hauv cov phiaj xwm yav dhau los. Txij li thaum kuv yog tus pib, Kuv tau insulated txhua qhov sib txuas nrog cov kab xev hluav taws xob (lawv tsis zoo nkauj).

Cov ntaub thaiv npog lub rooj sib tham ncaj qha rau Arduino pins. Ua ntej txuas daim phiaj thaiv, kuv txuas hauv av thiab 5volt pins rau lub rooj tsav tsheb nrog cov xaim thiab cov laug. Kuv kuj tau siv cov khoom sib txuas '5volt thiab cov xov hlau hauv av mus rau daim phiaj thaiv kab hlau, tom qab ntawd thaum kawg txuas Arduino rau daim thaiv npog.

Qhov kev pabcuam tau txuas rau 3volt tus pin rau lub zog thiab tus lej digital 2 rau kev sib txuas lus.

** Nco tseg: tsuas yog tom qab ua tiav qhov kev tsim no kuv tau pom tias kuv cov laug cam Arduino tsis zoo ib yam. Kuv tus neeg xa xov xa hluav taws xob tau siv los ntawm 5volt kev tsheb nqaj hlau ntawm daim phiaj thaiv, thaum cov neeg siv khoom xa xov hluav taws xob tau siv los ntawm 3volt tus pin, txawm hais tias kuv tau raug coj los ntseeg tias lub luag haujlwm ntawm lub adapter adapter ntawm lub transceiver yog los muab qhov hluav taws xob kom raug. Txhua yam kuv tuaj yeem hais tau tseeb yog tias cov cai tau muab sib phim nrog cov teeb tsa uas qhia hauv cov duab tsim cov txiaj ntsig piav qhia.

Kauj Ruam 3: Server Coder: Luam thiab Muab Tshuaj

// SERVER CODE/ * NRF24L01 Arduino CE> D8 CSN> D10 SCK> D13 MO> D11 MI> D12 RO> Tsis siv GND> GND VCC> 5V */// transceiver thaiv

#suav nrog

// servo lub tsev qiv ntawv

#suav nrog

// transceiver tsev qiv ntawv

#Txhais Servopin 2

// tshaj tawm servo tso tawm tus pin

ServoTimer2 pab;

// tshaj tawm lub npe servo

RH_NRF24 nrf24;

// tshaj tawm lub npe transceiver

int timeOUT = 0;

// sib txawv rau servo

pulse = 90;

// sib txawv los khaws cov mem tes

void teeb tsa ()

{serv.attach (Servopin); // servo cov khoom

Serial.begin (9600); // transceiver khoom

yog (! nrf24.init ())

Serial.println ("init ua tsis tau tejyam"); // serial monitor cov khoom yog (! nrf24.setChannel (12)) // teeb tsa channel rau 125 Serial.println ("setChannel ua tsis tiav"); yog (! nrf24.setRF (RH_NRF24:: DataRate2Mbps, RH_NRF24:: TransmitPower0dBm)) Serial.println ("setRF ua tsis tau tejyam"); // serial saib cov khoom}

void lub voj ()

{yog (nrf24.available ()) {uint8_t buf [RH_NRF24_MAX_MESSAGE_LEN]; uint8_t len = sizeof (buf); yog (nrf24.recv (buf, & len)) // serial monitor khoom {Serial.print ("tau thov:"); pulses = strtol ((const char*) buf, NULL, 10); // cov ntaub ntawv hom hloov khoom

int prin = daim ntawv qhia (mem tes, 750, 2250, 0, 180); // cov ntaub ntawv hom hloov khoom

Serial.println (prin); serv.write (mem tes); // ua rau servo txav}}

}

Kauj Ruam 4: Pawg Neeg Siv Khoom

Pawg Neeg Saib Xyuas
Pawg Neeg Saib Xyuas

Cov neeg siv khoom lag luam suav nrog tus qauv xa xov thiab lub hwj chim. Lub transceiver module yog txuas tib txoj hauv kev ** raws li cov neeg rau zaub mov pawg thawj coj saib xyuas tshwj tsis yog tias tsis muaj daim phiaj thaiv, nws tau txuas ncaj qha rau hauv Arduino board pins.

Lub ntsuas hluav taws xob siv 5v, hauv av, thiab txuas nrog rau tus pin analog 2.

** Nco tseg: raws li tau hais hauv qib server server, kuv Arduino boards tsis zoo ib yam. Hauv qhov no tus xa xov hluav taws xob tau xaim mus rau tus lej cim 3.3V, ncaj qha nyob ib sab rau 5V tus pin, tab sis ntxiv, txhua yam zoo li ua haujlwm tau zoo.

Kauj Ruam 5: Tus Neeg Siv Khoom Code: Luam thiab Muab Tshuaj

// CLIENT CODE/ * NRF24L01 Arduino CE> D8 CSN> D10 SCK> D13 MO> D11 MI> D12 RO> Tsis siv GND> GND VCC> 5V */// transceiver thaiv

#suav nrog

// transceiver tsev qiv ntawv

cov potpin = A2; // potentiometer delaration

koj val;

char tempChar [5];

Txoj hlua valString = ""; // cov ntaub ntawv hom hloov khoom

RH_NRF24 nrf24; // transceiver khoom

void teeb tsa ()

{Serial.begin (9600); yog (! nrf24.init ()) Serial.println ("init ua tsis tau tejyam"); // Qhov pib tom qab pib yog 2.402 GHz (channel 2), 2Mbps, 0dBm yog (! Nrf24.setChannel (12)) Serial.println ("setChannel ua tsis tiav"); yog (! nrf24.setRF (RH_NRF24:: DataRate2Mbps, RH_NRF24:: TransmitPower0dBm)) Serial.println ("setRF ua tsis tau tejyam"); } // transceiver khoom

void voj () {

val = analogRead (tus pin); // potentiometer khoom

val = daim ntawv qhia (val, 0, 1023, 750, 2250);

valString = nqi; Txoj hlua str = (valString); str.toCharArray (tempChar, 5); // datatype hloov khoom nrf24.send (tempChar, sizeof (tempChar));

}

Kauj Ruam 6: Lus Cim Txog Txoj Cai:

Txoj Cai muaj qee qhov txwv kev daws teeb meem kev ua haujlwm nyob rau hauv daim ntawv ntawm kev tawm tswv yim los ntawm tus lej saib hauv Arduino software interface. Thaum saib cov ntawv saib xyuas los ntawm SERVER code (ctrl + ua haujlwm + M), koj yuav tsum muaj peev xwm pom lub xeev ntawm lub zog ntsuas hauv daim ntawv ntawm tus lej ntawm 1 thiab 180.

Tsis tas li, ntawm no yog lub tsev qiv ntawv rau wireless thiab servo:

www.airspayce.com/mikem/arduino/RadioHead/

github.com/nabontra/ServoTimer2

Pom zoo: