Difference between revisions of "Pi-servo-HAT"

From SB-Components Wiki

(Created page with "<div class="row"> <div class="large-8 column"> == Raspberry Pi Servo HAT == 16 Channel Servo Driver HAT for Raspberry Pi is a motor driver HAT from which one can control up...")
 
 
(13 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
   <div class="large-8 column">
 
   <div class="large-8 column">
 
== Raspberry Pi Servo HAT ==
 
== 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 LEDs 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.
+
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 ===
 
=== Features ===
Line 28: Line 28:
 
== Pinout ==
 
== Pinout ==
 
<table class="wikitable">
 
<table class="wikitable">
<tr> <th> Motor Driver HAT  </th>  <th> BCM</th> </tr>
+
<tr> <th> Servo Driver HAT  </th>  <th> BCM</th> </tr>
 
<tr><td> VCC  </td>  <td> 5V  </td></tr>
 
<tr><td> VCC  </td>  <td> 5V  </td></tr>
 
<tr><td> GND  </td>  <td> GND  </td></tr>
 
<tr><td> GND  </td>  <td> GND  </td></tr>
Line 38: Line 38:
 
== Installation ==
 
== Installation ==
 
==== Python ====
 
==== 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.
 +
[[File:Pi_Servo_HAT.png|600px]]
 +
 
 +
* Now connect Servo motor on any servo port ranging between 0-15.
 +
 
 +
* Clone Github repository by running below command in terminal.
 +
<source lang="shell"> https://github.com/sbcshop/Raspberry-Pi-Servo-Driver.git </source>
 +
 
 +
* It will clone the repository in the '/home/pi' location, To enter cloned repository, enter the below command.
 +
<source lang="shell">cd Raspberry-Pi-Servo-Driver </source>
 +
 
 +
* Now run the below command to execute the python code.
 +
<source lang="shell">sudo python3 servo_controller.py </source>
 +
 
 +
* 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 <source inline> controller.Set_Pulse(15,i)  </source>
 +
<source lang="python">
 +
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) 
 +
</source>
 +
<br>
  
 
== Resources ==
 
== Resources ==
 +
<b> Github </b>
 +
* [https://github.com/sbcshop/Raspberry-Pi-Servo-Driver Source Code]
 +
 +
<b> Datasheet </b>
 +
*[https://learn.sb-components.co.uk/images/e/ea/PCA9685_datasheet.pdf PCA9685 DataSheet]

Latest revision as of 10:53, 25 June 2021

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

Servo 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