این آموزش بخشی است از: سروو موتورها
تمام ویدیوهای مربوط به سروو موتورها که مرتبط هستند، در اینجا فهرست شدهاند. لینک سایر ویدیوها در زیر این مقاله قرار دارد.
How to Use Continuous 360° Servo with Arduino
In this tutorial, we will learn how to control a continuous 360° servo using an Arduino. Unlike standard servos, continuous servos can rotate indefinitely in either direction, allowing for versatile applications. However, controlling their position requires understanding the commands sent to them and a bit of experimentation to find the right stopping values.
We will be developing a program that allows us to send commands via the Serial Monitor to rotate the servo left, right, or stop it. The code will include the necessary logic to interpret the ASCII values of the commands we enter. For clarification on the coding process, be sure to check the video at (in video at 12:30).
Hardware Explained
To implement this project, you will need a continuous 360° servo, an Arduino board, and a power supply capable of providing sufficient current (at least 500mA). The servo receives control signals from the Arduino, which uses pulse width modulation (PWM) to dictate the direction and speed of rotation.
The servo motor itself has three wires: power, ground, and control. The power wire connects to the power supply, the ground wire connects to both the power supply and the Arduino ground, and the control wire connects to a designated pin on the Arduino for signal transmission.
Datasheet Details
| Manufacturer | Generic |
|---|---|
| Part number | Continuous 360° Servo |
| Logic/IO voltage | 5 V |
| Supply voltage | 4.8–6 V |
| Output current (per channel) | 500 mA |
| Peak current (per channel) | 1 A max |
| PWM frequency guidance | 50 Hz |
| Input logic thresholds | High: >2.5 V, Low: <0.8 V |
| Voltage drop / RDS(on) / saturation | — |
| Thermal limits | — |
| Package | Standard servo housing |
| Notes / variants | Available in various sizes |
- Ensure a common ground between the Arduino and power supply.
- Use an external power supply for the servo to avoid overloading the Arduino.
- Experiment with stopping values to find the best performance for your servo.
- Monitor the servo temperature during operation to prevent overheating.
- Use a PWM signal to control the speed and direction of the servo.
Wiring Instructions
To wire your continuous 360° servo to the Arduino, start by connecting the servo power wire to an external power supply that provides 5V. The ground wire of the servo should be connected to the ground (GND) pin on the Arduino, ensuring that the power supply and Arduino share a common ground. The control wire of the servo will go to pin 9 on the Arduino, which is where the PWM signal will be sent from.
Double-check that your connections are secure, as loose connections can lead to erratic servo behavior. If your servo is of a type that can be powered directly from the Arduino, you may connect the power wire to the Arduino's 5V pin, but ensure the total current does not exceed what the Arduino can supply.
Code Examples & Walkthrough
The following excerpt demonstrates how to set up the servo and read commands from the Serial Monitor:
#include
Servo myservo; // create servo object to control a servo
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
In this code snippet, we include the Servo library and create a servo object called myservo. We also set up the serial communication at 9600 baud and attach the servo to pin 9.
Next, we have the main loop where we read incoming serial data and control the servo based on the commands:
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if (incomingByte == 108) { // 'L' command
myservo.write(0); // rotate clockwise
} else if (incomingByte == 114) { // 'R' command
myservo.write(180); // rotate counterclockwise
} else if (incomingByte == 60) { // stop command
myservo.write(60); // stop servo
}
}
}
This code checks if there is any data available in the serial buffer. Depending on the ASCII value of the input (e.g., 108 for 'L' to rotate clockwise, 114 for 'R' to rotate counterclockwise), it sends the corresponding command to the servo.
For complete code and additional details, please refer to the full program loaded below the article.
Demonstration / What to Expect
When you upload the code and open the Serial Monitor, you can enter 'L' to rotate the servo left, 'R' to rotate it right, or other values to experiment with stopping the servo. Expect to find various stopping values, as the servo's behavior may vary based on its quality and design (in video at 18:45).
Be cautious of how the servo reacts to the commands; if it does not stop as expected, try different values until you find the optimal stopping command. This may require some experimentation, especially to avoid overheating the servo.
Chapters
- Introduction (0:00)
- Hardware Explained (1:30)
- Wiring Instructions (3:45)
- Code Walkthrough (5:15)
- Demonstration (18:00)
Resources
- Arduino Servo Library Documentation
- Continuous Servo Manufacturer Datasheets
این آموزش بخشی از: سروو موتورها
- کنترل یک سرو موتور با دکمههای فشاری با استفاده از آردوینو
- Control a Servo Motor with a Push Button: Move Servo and Return SPB-1
- Control a Servo Motor with a Push Button: Move Servo in One Direction SPB-2
- Controlling a Servo Motor with a Push Button: Move Servo While Button Is Pressed (SPB-3)
- کنترل یک سروو با پتانسیومتر با استفاده از آردوینو
- کنترل یک سروو با پتانسیومتر و LCD1602 با استفاده از آردوینو
- کنترل سرو موتورها با استفاده از یک کنترل از راه دور مادون قرمز و آردوینو
- کنترل موتور سروو آردوینو با استفاده از پتانسیومتر
- کنترل موقعیت سروو با حرکات دست برای آردوینو
- Controlling Two or More Servos with Potentiometers Using an Arduino
- How to Control a 360° Servo with Three Push-Button Switches
- شِفر (کود) آردوینو و ویدیو برای کنترلکننده سروو PCA9685، 16 کاناله، 12 بیتی، V1
- Build an Arduino Servo Toggle Switch with a Push Button
/*
* نمایش کنترل سروو پیوسته (سروو ۳۶۰ درجه)
* این شِفر (کود) به شما اجازه میدهد تا یک سروو ۳۶۰ درجه را با یک فرمان از مانیتور سری کنترل کنید.
* این موتور سروو ۳۵۰ فقط برای سرگرمی است. نمیتوان از آن در کاربردهای واقعی که نیاز به موقعیتیابی دقیق دارند استفاده کرد. موتور پلهای یا موتور سروو گرانقیمت بگیرید.
*
* تغییر یافته توسط احمد شمشیری برای Robojax.com
* در روز یکشنبه، ۱ ژوئیه ۲۰۱۸، ساعت ۱۱:۰۹ صبح در اِجَکس، انتاریو، کانادا
* ویدئوی آموزشی این پروژه را تماشا کنید: https://youtu.be/b_xvu6wWafA
* این شِفر (کود) را از Robojax.com دریافت کنید
*
* شِفر (کود) اصلی توسط BARRAGAN <http://barraganstudio.com>
* این شِفر (کود) نمونه در دامنه عمومی است.
* تغییر یافته در ۸ نوامبر ۲۰۱۳
* توسط اسکات فیتزجرالد
* http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo; // یک شیء سروو ایجاد کنید تا یک سروو را کنترل کند.
// در بیشتر بردها میتوان دوازده شیء سروو ایجاد کرد.
int pos = 0; // متغیر برای ذخیره موقعیت سروو
int incomingByte = 0; // برای دادههای سریال ورودی
void setup() {
Serial.begin(9600);
myservo.attach(9); // سرو را به پایه ۹ متصل میکند به شیء سرو
}
void loop() {
// فقط زمانی داده ارسال کنید که دادهای دریافت کردهاید:
if (Serial.available() > 0) {
// بایت ورودی را بخوانید:
incomingByte = Serial.read();
// بگو چه چیزی داری:
Serial.print("received: ");
Serial.print (incomingByte);
if(incomingByte == 108){
Serial.println(" sent 0 Rotating CW ");
myservo.write(0);
}else if(incomingByte == 114){
Serial.println(" sent 180 Rotating CCW ");
myservo.write(180);
}else if(incomingByte == 60){
Serial.println(" sent Stopped ");
myservo.write(60);
}else{
Serial.println(" moving Randomly");
myservo.write(incomingByte);
}
}
}
منابع و مراجع
هنوز هیچ منبعی موجود نیست.
فایلها📁
هیچ فایلی موجود نیست.