Servo Motor Control Using Raspberry Pi Pico
by Manodeep in Circuits > Raspberry Pi
10788 Views, 6 Favorites, 0 Comments
Servo Motor Control Using Raspberry Pi Pico
A servo motor is a type of motor that can rotate with great precision. Normally this type of motor consists of a control circuit that provides feedback on the current position of the motor shaft, this feedback allows the servo motors to rotate with great precision. If you want to rotate an object at some specific angles or distance, then you use a servo motor. It is just made up of a simple motor that runs through a servo mechanism. If the motor is powered by a DC power supply then it is called DC servo motor, and if it is an AC-powered motor then it is called AC servo motor. For this tutorial, we will be discussing only the DC servo motor working. Apart from these major classifications, there are many other types of servo motors based on the type of gear arrangement and operating characteristics. A servo motor usually comes with a gear arrangement that allows us to get a very high torque servo motor in small and lightweight packages. Due to these features, they are being used in many applications like a toy cars, RC helicopters, and planes, Robotics, etc.
Servo motors are rated in kg/cm (kilogram per centimeter) most hobby servo motors are rated at 3kg/cm or 6kg/cm or 12kg/cm. This kg/cm tells you how much weight your servo motor can lift at a particular distance. For example, A 6kg/cm Servo motor should be able to lift 6kg if the load is suspended 1cm away from the motor's shaft, the greater the distance the lesser the weight carrying capacity. The position of a servo motor is decided by electrical pulse and its circuitry is placed beside the motor.
Supplies
1.GS90 micro servo motor
2.Raspberry Pi Pico
3.Jumper Wire
Connect the Servo Motor With Raspberry Pi According to the Schematic
NB:- If you have a 5v servo motor like me, connect it with the raspberry pi through a LOGIC LEVEL SHIFTER, otherwise it will not work.
Connect Raspberry Pi With PC, Write the Code Given, Save It As Servo.py and Run It.
from machine import Pin,PWM import utime MID = 1500000 MIN = 1000000 MAX = 2000000 led = Pin(25,Pin.OUT) pwm = PWM(Pin(15)) pwm.freq(50) pwm.duty_ns(MID) while True: pwm.duty_ns(MIN) utime.sleep(1) pwm.duty_ns(MID) utime.sleep(1) pwm.duty_ns(MAX) utime.sleep(1)
Downloads
Output
Now the servo will start rotating.