Pi-servo-HAT

From SB-Components Wiki

Raspberry Pi Servo HAT

16 Channel Servo Driver HAT for Raspberry Pi is a motor driver HAT from which one can control up to 16 motors simultaneously. If you're building a robot with a lot of moving parts, or if you need to monitor a lot of servo motors with PWM yields, the microcontroller's limited PWM yields will be a big problem. The most important thing you can do to solve this problem is to obtain a 16-Channel 12-Bit PWM/Servo Driver.

Features

  • Adjustable frequency PWM up to about 1.6 kHz
  • Up to 16-Channel servo/PWM outputs, 12-bit resolution for each channel (4096 scales)
  • 3 pin connectors in groups of 4 so you can plug in 16 servos at once
  • This board/chip uses an I2C 7-bit address
  • 40-Pin GPIO accessibility
  • I2C controlled and power supply connector
  • Compatible with all the Raspberry Pi Models such as 4B, 3B+, 3, 2, B+, A, Zero, Zero W, etc.

Specifications

  • Power supply: 5V OR 6V (power supply connector)
  • Servo voltage: 5V
  • Logic voltage: 3.3V
  • Driver: PCA9685
  • Control interface: I2C/GPIO
Pi Servo HAT
Buy it From : Click Here

Pinout

Motor Driver HAT BCM
VCC 5V
GND GND
SDA GPIO 2
SCL GPIO 3

Installation

Python

  • Stack Servo HAT on Raspberry Pi.
  • Now connect the external power supply of 6V - 12V DC on the Green connector as shown below, Turn on the adapter and it will power the Raspberry Pi.

Pi Servo HAT.png

  • Now connect Servo motor on any servo port ranging between 0-15.
  • Clone Github repository by running below command in terminal.
https://github.com/sbcshop/Raspberry-Pi-Servo-Driver.git
  • It will clone the repository in the '/home/pi' location, To enter cloned repository, enter the below command.
cd Raspberry-Pi-Servo-Driver
  • Now run the below command to execute the python code.
sudo python3 servo_controller.py
  • If you are using any other pin for servo motor (between 0-15) then change the default servo pin to the designated pin in code i.e controller.Set_Pulse(15,i)
if __name__=='__main__':
    controller = I2C_Controller(0x40, debug=False)
    controller.setPWMFreq(50)
    while True:
        for i in range(500,2500,10):
            controller.Set_Pulse(15,i)   #setting 15th pin of the servo header(forward direction)
            sleep(0.05)
    
        for i in range(2500,500,-10):
            controller.Set_Pulse(15,i)   #setting 15th pin of the servo header(backward direction)
            sleep(0.05)


Resources

Github

Datasheet