Ks0194 keyestudio Micro Servo: Difference between revisions
Keyestudio (talk | contribs) No edit summary |
Keyestudio (talk | contribs) |
||
(21 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==keyestudio Micro Servo== | ==keyestudio Micro Servo== | ||
<br>[[File: | <br>[[File:Ks0194- servo.png|500px|frameless|thumb]]<br> | ||
<br> | |||
==Introduction== | ==Introduction== | ||
Servomotor is a position | Servomotor is a position control rotary actuator. | ||
<span style=color:red> (You can achieve 180 degrees by adjusting the rotation angle of the motor in the code)</span>It mainly consists of housing, circuit board, core-less motor, gear and position sensor. | |||
Included with your servo motor you will find a variety of white motor mounts that connect to the shaft of your servo. You may choose to attach any mount you wish for the circuit. It will serve as a visual aid, making it easier to see the servo spin.<br> | |||
The | '''Working principle:''' <br> | ||
The receiver or MCU outputs a signal to the servomotor. The motor has a built-in reference circuit that gives out reference signal, cycle of 20ms and width of 1.5ms. The motor compares the acquired DC bias voltage to the voltage of the potentiometer and outputs a voltage difference. | |||
The IC on the circuit board will decide the rotate direction accordingly and drive the core-less motor. The gear then pass the force to the shaft. The sensor will determine if it has reached the commanded position according to the feedback signal. | |||
Servo motors are used in control systems that requires to have and maintain different angles. When the motor speed is definite, the gear will cause the potentiometer to rotate. When the voltage difference reduces to zero, the motor stops. Normally, the rotation angle range is among 0-180 degrees. <br> | |||
Servo motor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange colors (different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal line. | |||
<br>[[File:ks0194-2.png|600px|frameless|thumb]]<br> | |||
The rotation angle of servo motor is controlled by regulating the duty cycle of PWM (Pulse-Width Modulation) signal. The standard cycle of PWM signal is 20ms (50Hz). <br> | |||
Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotation angle from 0° to 180°. <br> | |||
But note that for different brand motor, the same signal may have different rotation angle. <br> | |||
<br>[[File:180度舵机.png|600px|frameless|thumb]]<br> | |||
<br> | |||
== Parameters == | |||
*Operating voltage: DC 4.8V〜6V | |||
*Angle range: about 180°(in 500→2500μsec) | |||
*Pulsewidth range: 500→2500μsec | |||
*No-load speed: 0.12±0.01 sec/60(DC 4.8V); 0.1±0.01 sec/60(DC 6V) | |||
*No-load current: 200±20mA(DC 4.8V); 220±20mA(DC 6V) | |||
*Stop torque: 1.3±0.01kg/cm(DC 4.8V); 1.5±0.1kg/cm(DC 6V) | |||
*Stop current: ≦850mA(DC 4.8V); ≦1000mA(DC 6V) | |||
*Standby current: 3±1mA(DC 4.8V); 4±1mA(DC 6V) | |||
*Operation temperature: -10℃〜50℃ | |||
*Save temperature: -20℃〜60℃ | |||
*Motor wire length: 250 ± 5 mm | |||
*Dimensions: 22.9mm*12.2mm*30mm | |||
*Weight: 9± 1 g (without servo mounts) | |||
<br> | |||
==Connection == | ==Connection == | ||
After mastering basic knowledge, let's learn how to control a servo motor. In the experiment, need a servo motor and several jumper wires. <br> | |||
===Connection for UNO R3:=== | ===Connection for UNO R3:=== | ||
<br>[[File:ks0194-4.png|500px|frameless|thumb]]<br> | <br>[[File:ks0194-4.png|500px|frameless|thumb]]<br> | ||
<br> | |||
===Connection for 2560 R3:=== | ===Connection for 2560 R3:=== | ||
<br>[[File:ks0194-5.png|500px|frameless|thumb]]<br> | <br>[[File:ks0194-5.png|500px|frameless|thumb]]<br> | ||
Line 19: | Line 50: | ||
Compile a program to control the motor to rotate to the commanded angle input by the user and display the angle on the screen.<br> | Compile a program to control the motor to rotate to the commanded angle input by the user and display the angle on the screen.<br> | ||
<br> | |||
==Sample program== | ==Sample program== | ||
There are two ways to control a servomotor with Arduino. One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and use that signal to control the positioning of the motor. Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be easier but it can only control two-contact motor because for the servo function, only digital pin 9 and 10 can be used. The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power. | There are two ways to control a servomotor with Arduino. <br> | ||
One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and use that signal to control the positioning of the motor. <br> | |||
Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be easier but it can only control two-contact motor because for the servo function, only digital pin 9 and 10 can be used. <br> | |||
The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power. | |||
<br> | |||
===Method 1:=== | ===Method 1:=== | ||
====Sample program A==== | ====Sample program A==== | ||
<pre> | <pre> | ||
Line 62: | Line 96: | ||
</pre> | </pre> | ||
<br> | |||
===Method 2:=== | ===Method 2:=== | ||
Let's first take a look at the Arduino built-in servo function and some of | Let's first take a look at the Arduino built-in servo function and some of common statements.<br> | ||
1. attach(interface)——select pin for servo, can only use pin 9 or 10.<br> | * 1. attach(interface)——select pin for servo, can only use pin 9 or 10.<br> | ||
2. write(angle)——used to control the rotate angle of the servo, can set the angle among 0 degree to 180 degree.<br> | * 2. write(angle)——used to control the rotate angle of the servo, can set the angle among 0 degree to 180 degree.<br><span style=color:red> (You can achieve 180 degrees by adjusting the rotation angle of the motor in the code)</span> | ||
3. read()——used to read the angle of the servo, consider it a function to read the value in the write() function.<br> | * 3. read()——used to read the angle of the servo, consider it a function to read the value in the write() function.<br> | ||
* 4. attached()——determine whether the parameter of the servo is sent to the servo pin.<br> | |||
* 5. detach()—— disconnect the servo and the pin, and the pin(digital pin 9 or 10) can be used for PWM port. <br> | |||
Note: | '''Note:''' the written form of the above statements are " servo variable name. specific statement ()", e.g. myservo. Attach (9). <br> | ||
Still, connect the servo to pin 9.<br> | Still, connect the servo to pin 9.<br> | ||
<br> | |||
====Sample program B==== | ====Sample program B==== | ||
<pre> | <pre> | ||
#include <Servo.h>/ | #include <Servo.h> | ||
bar Sketch>Importlibrary>Servo, or input | /* define a header file. Special attention here, you can call the servo function directly from Arduino's software menu bar Sketch>Importlibrary>Servo, or input | ||
#include <Servo.h>. Make sure there is a space between #include and <Servo.h>. Otherwise, it will cause compile error.*/ | |||
Servo myservo;// define servo variable name | Servo myservo;// define servo variable name | ||
void setup() | void setup() | ||
Line 88: | Line 123: | ||
</pre> | </pre> | ||
<br> | |||
Above are the two methods to control the servo. You can choose either one according to your liking or actual need. | Above are the two methods to control the servo. You can choose either one according to your liking or actual need. | ||
<br> | |||
==Resources== | |||
https://fs.keyestudio.com/KS0194 | |||
== Buy From == | |||
*[https://www.keyestudio.com/free-shipping-keyestudio-micro-servo-sg90-0-180-degrees-for-arduino-smart-car-robot-aircraft-ce-certification-p0261-p0261.html '''Official Website''' ] | |||
*[https://www.aliexpress.com/store/product/Free-shipping-9g-steering-gear-servo-25cm/1452162_32251766734.html?spm=2114.12010615.8148356.2.42502b6bqPNSEz '''Shop on Aliexpress'''] | |||
[[ | [[Category:Module]] |
Latest revision as of 08:14, 28 April 2021
keyestudio Micro Servo
Introduction
Servomotor is a position control rotary actuator.
(You can achieve 180 degrees by adjusting the rotation angle of the motor in the code)It mainly consists of housing, circuit board, core-less motor, gear and position sensor.
Included with your servo motor you will find a variety of white motor mounts that connect to the shaft of your servo. You may choose to attach any mount you wish for the circuit. It will serve as a visual aid, making it easier to see the servo spin.
Working principle:
The receiver or MCU outputs a signal to the servomotor. The motor has a built-in reference circuit that gives out reference signal, cycle of 20ms and width of 1.5ms. The motor compares the acquired DC bias voltage to the voltage of the potentiometer and outputs a voltage difference.
The IC on the circuit board will decide the rotate direction accordingly and drive the core-less motor. The gear then pass the force to the shaft. The sensor will determine if it has reached the commanded position according to the feedback signal.
Servo motors are used in control systems that requires to have and maintain different angles. When the motor speed is definite, the gear will cause the potentiometer to rotate. When the voltage difference reduces to zero, the motor stops. Normally, the rotation angle range is among 0-180 degrees.
Servo motor comes with many specifications. But all of them have three connection wires, distinguished by brown, red, orange colors (different brand may have different color). Brown one is for GND, red one for power positive, orange one for signal line.
The rotation angle of servo motor is controlled by regulating the duty cycle of PWM (Pulse-Width Modulation) signal. The standard cycle of PWM signal is 20ms (50Hz).
Theoretically, the width is distributed between 1ms-2ms, but in fact, it's between 0.5ms-2.5ms. The width corresponds the rotation angle from 0° to 180°.
But note that for different brand motor, the same signal may have different rotation angle.
Parameters
- Operating voltage: DC 4.8V〜6V
- Angle range: about 180°(in 500→2500μsec)
- Pulsewidth range: 500→2500μsec
- No-load speed: 0.12±0.01 sec/60(DC 4.8V); 0.1±0.01 sec/60(DC 6V)
- No-load current: 200±20mA(DC 4.8V); 220±20mA(DC 6V)
- Stop torque: 1.3±0.01kg/cm(DC 4.8V); 1.5±0.1kg/cm(DC 6V)
- Stop current: ≦850mA(DC 4.8V); ≦1000mA(DC 6V)
- Standby current: 3±1mA(DC 4.8V); 4±1mA(DC 6V)
- Operation temperature: -10℃〜50℃
- Save temperature: -20℃〜60℃
- Motor wire length: 250 ± 5 mm
- Dimensions: 22.9mm*12.2mm*30mm
- Weight: 9± 1 g (without servo mounts)
Connection
After mastering basic knowledge, let's learn how to control a servo motor. In the experiment, need a servo motor and several jumper wires.
Connection for UNO R3:
Connection for 2560 R3:
Connect the motor to digital pin 9.
Compile a program to control the motor to rotate to the commanded angle input by the user and display the angle on the screen.
Sample program
There are two ways to control a servomotor with Arduino.
One is to use a common digital sensor port of Arduino to produce square wave with different duty cycle to simulate PWM signal and use that signal to control the positioning of the motor.
Another way is to directly use the Servo function of the Arduino to control the motor. In this way, the program will be easier but it can only control two-contact motor because for the servo function, only digital pin 9 and 10 can be used.
The Arduino drive capacity is limited. So if you need to control more than one motor, you will need external power.
Method 1:
Sample program A
int servopin=9;// select digital pin 9 for servomotor signal line int myangle;// initialize angle variable int pulsewidth;// initialize width variable int val; void servopulse(int servopin,int myangle)// define a servo pulse function { pulsewidth=(myangle*11)+500;// convert angle to 500-2480 pulse width digitalWrite(servopin,HIGH);// set the level of servo pin as “high” delayMicroseconds(pulsewidth);// delay microsecond of pulse width digitalWrite(servopin,LOW);// set the level of servo pin as “low” delay(20-pulsewidth/1000); } void setup() { pinMode(servopin,OUTPUT);// set servo pin as “output” Serial.begin(9600);// connect to serial port, set baud rate at “9600” Serial.println("servo=o_seral_simple ready" ) ; } void loop()// convert number 0 to 9 to corresponding 0-180 degree angle, LED blinks corresponding number of time { val=Serial.read();// read serial port value if(val>='0'&&val<='9') { val=val-'0';// convert characteristic quantity to numerical variable val=val*(180/9);// convert number to angle Serial.print("moving servo to "); Serial.print(val,DEC); Serial.println(); for(int i=0;i<=50;i++) // giving the servo time to rotate to commanded position { servopulse(servopin,val);// use the pulse function } } }
Method 2:
Let's first take a look at the Arduino built-in servo function and some of common statements.
- 1. attach(interface)——select pin for servo, can only use pin 9 or 10.
- 2. write(angle)——used to control the rotate angle of the servo, can set the angle among 0 degree to 180 degree.
(You can achieve 180 degrees by adjusting the rotation angle of the motor in the code) - 3. read()——used to read the angle of the servo, consider it a function to read the value in the write() function.
- 4. attached()——determine whether the parameter of the servo is sent to the servo pin.
- 5. detach()—— disconnect the servo and the pin, and the pin(digital pin 9 or 10) can be used for PWM port.
Note: the written form of the above statements are " servo variable name. specific statement ()", e.g. myservo. Attach (9).
Still, connect the servo to pin 9.
Sample program B
#include <Servo.h> /* define a header file. Special attention here, you can call the servo function directly from Arduino's software menu bar Sketch>Importlibrary>Servo, or input #include <Servo.h>. Make sure there is a space between #include and <Servo.h>. Otherwise, it will cause compile error.*/ Servo myservo;// define servo variable name void setup() { myservo.attach(9);// select servo pin(9 or 10) } void loop() { myservo.write(90);// set rotate angle of the motor }
Above are the two methods to control the servo. You can choose either one according to your liking or actual need.
Resources
https://fs.keyestudio.com/KS0194