Difference between revisions of "Servo Driver HAT"

From Waveshare Wiki
Jump to: navigation, search
Line 13: Line 13:
 
== Introduction ==
 
== Introduction ==
 
Servo Driver HAT for Raspberry Pi, 16-Channel, 12-bit, I2C Interface
 
Servo Driver HAT for Raspberry Pi, 16-Channel, 12-bit, I2C Interface
 +
==How to use==
 +
{{Servo Driver HAT Manual}}
 
==Resources==
 
==Resources==
 
*[https://www.waveshare.com/w/upload/1/1b/Servo_Driver_HAT_User_Manual_EN.pdf User Manual]
 
*[https://www.waveshare.com/w/upload/1/1b/Servo_Driver_HAT_User_Manual_EN.pdf User Manual]

Revision as of 08:28, 7 November 2020

Servo Driver HAT
Servo Driver HAT
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

Introduction

Servo Driver HAT for Raspberry Pi, 16-Channel, 12-bit, I2C Interface

How to use

Using with Raspberry Pi

To use this module, we provide python examples for test PCA9685, WiFi remote control and bluetooth remote control.

Enable I2C Interface

Open a terminal and run the following commands:

sudo raspi-config 
Choose Interfacing Options -> I2C -> Yes.

Reboot Raspberry Pi:

sudo reboot

RPI open i2c.png

Install libraries

sudo apt-get updata
sudo apt-get install python-pip 
sudo pip install RPi.GPIO
sudo apt-get install python-smbus

Downalod the demo codes and unzip

You should start the Raspberry Pi, open a terminal and run the following commands:

sudo apt-get install p7zip-full
wget https://www.waveshare.com/wiki/File:Servo_Driver_HAT.7z
7zr x Servo_Driver_HAT.7z -r -o./Servo_Driver_HAT
sudo chmod 777 -R Servo_Driver_HAT
cd Servo_Driver_HAT/Raspberry\ Pi/

Python Examples

Open a terminal and runt the following comamnds:

#For python2
cd ~/Servo_Driver_HAT/Raspberry\ Pi/
cd python/
sudo python PCA9685.py
#For python3
cd ~/Servo_Driver_HAT/Raspberry\ Pi/
cd python3/
sudo python3 PCA9685.py

Expected result: Connect a servo to Channel 0, the servo will rotate.

WIFI Remote Control

Open a terminal and run the following commands:

cd Wifi-Control/
sudo python main.py

Please connect the Raspberry Pi and telephone to the same WLAN network. Data will be transmitted by TCP protocol. After running the program, the IP address will be displayed and the port number is 8000.
Open the APP and choose the WIFI control, input the IP address and the port then connect.
Servo driver hat wifi.png
It enters the control page if connected successfully. You can click the button to control the four servos (Channel 0 to Channel 4).
Servo driver hat wifi1.png
You can also connect it with QT software on Windows PC.
Servo driver hat wifi2.png

Note: You can download the APP and the QT software from the Resources part.

Bluetooth Remote Program

Execute:

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get install pi-bluetooth bluez bluez-firmware blueman
sudo usermod -G bluetooth -a pi
sudo vi /etc/systemd/system/dbus-org.bluez.service
sudo reboot

Start/add SPP, and turn on the Bluetooth device.

sudo vi /etc/systemd/system/dbus-org.bluez.service

Servo driver hat bt.png
After restarting the Raspberry Pi, enter the hciconfig command (similar to the ifconfig command) to check the Bluetooth service.
Servo driver hat bt2.png
If you see the hci0 device, the Bluetooth has been turned on. If not then no Bluetooth device is recognized.
Run the following command to start the program.

cd Servo_Driver_HAT/python/Bluetooth-Control
sudo ./Bluetooth.sh

After the program runs, you will be prompted to wait for the Bluetooth connection, choose the Bluetooth remote control on the mobile app, click scan, discovers the Raspberry Pi device, and connects.
Servo driver hat bt3.png
After connecting the program, enter the control interface, and click the button to remotely control the forward and reverse rotation of the servos of channels 0~4.
Servo driver hat bt4.png
Note: If the received command is incorrect, you may need to configure the command sent when the corresponding button is pressed and released in the APP.
Servo driver hat bt5.png
Note: The default discovery time of Raspberry Pi is only 180s. If you want to always discover and pair, you can configure it by modifying the following files.

sudo vi /etc/bluetooth/main.conf

Find the following two statements and uncomment them.
Servo driver hat bt6.png
The program is compatible with python3, just replace python with python3 when running.
For more information on Raspberry Pi wifi and Bluetooth remote control, please refer to AlphaBot2:
http://www.waveshare.com/wiki/AlphaBot2
https://www.waveshare.com/wiki/AlphaBot2

Resources

Software

Datasheet

Support

If you require technical support, please go to the Support page and open a ticket.