• sales

    +86-0755-88291180

Raspberry Pi Pico-Servo-Driver User Guide

Overview

Servo Driver Module For Raspberry Pi Pico, 16-Channel Outputs, 16-Bit Resolution.

Features

  • Standard Raspberry Pi Pico header, supports Raspberry Pi Pico series boards.
  • Up to 16-Channel servo/PWM outputs, 16-bit resolution for each channel.
  • Integrates 5V regulator, up to 3A output current, allows battery power supply from the VIN terminal.
  • Standard servo interface, supports commonly used servo such as SG90, MG90S, MG996R, etc.
  • Exposes unused pins of Pico, easy expansion.
  • Comes with complete resources and manuals (including Raspberry Pi Pico C/C++ 和 MicroPython demo).

Specification

  • Operating voltage: 5V (Pico) or 6~12V (VIN terminal)
  • Logic voltage: 3.3V
  • Servo voltage level: 5V
  • Control interface: GPIO
  • Mounting hole size: 3.0mm
  • Dimensions: 65 × 56mm

Pinout




Dimensions



Pico Quick Start

Download Firmware

  • MicroPython Firmware Download


  • C_Blink Firmware Download


Open Source Demo

MircoPython video example (github)
Raspberry Pi official C/C++ example program (github)
Raspberry Pi official micropython example program (github)
Raspberry Pi Pico Demo

Hardware connection

Connect the Driver board to Pico, please take care of the direction according to the USB silk screen printing.


Setup environment

Please refer to Raspberry Pi's guide: https://www.raspberrypi.org/documentation/pico/getting-started/

Raspberry Pi

1. Open a terminal of Raspberry Pi
2. Download and unzip the demo codes to directory Pico C/C++ SDK

sudo apt-get install p7zip-full
cd ~
sudo wget  https://www.waveshare.com/w/upload/3/31/Pico_Servo_Driver_Code.7z
7z Pico_Servo_Driver_Code.7z -o./Pico_Servo_Driver_Code.7z
cd ~/Pico_Servo_Driver_Code

c

  • The following tutorials are operated on Raspberry Pi. As CMake has multi-platforms and can be ported, you also can successfully compile on a PC in different ways.

To compile, make sure you are in the c directory:

cd ~/Pico_Servo_Driver_Code/c/

Create and enter the "build" directory in the folder, and add the SDK:
where ../../pico-sdk is the directory of your SDK.
There is a "build" in our sample program, just enter it directly.

cd build
export PICO_SDK_PATH=../../pico-sdk
(Note: Be sure to write the path where your own SDK is located)

Execute cmake to automatically generate Makefile files

cmake..

Execute make to generate executable files, the first compilation time is relatively long.

make -j9

After the compilation is complete, the uf2 file will be generated.
Press and hold the button on the Pico board, connect the pico to the USB port of the Raspberry Pi through the Micro USB cable, and release the button. After connecting, the Raspberry Pi will automatically recognize a removable disk (RPI-RP2) and copy the main.uf2 file in the build folder to the recognized removable disk (RPI-RP2).

cp main.uf2 /media/pi/RPI-RP2/

python

1. Flash the Micropython firmware and copy the pico_micropython_xxxxx.uf2 file into pico (detailed in the Windows tutorial below).

official firmware download

2. Open Thonny IDE on the Raspberry Pi (click the Raspberry Pi logo -> Programming -> Thonny Python IDE ), you can check the version information in Help->About Thonny.
  • To make sure your version has Pico support package, also you can click Tools -> Options... -> Interpreter to select MicroPython (Raspberry Pi Pico and ttyACM0 port.

As shown:

If your current version of Thonny does not have the pico support package, enter the following command to update the Thonny IDE.

sudo apt upgrade thonny

3. Click File->Open...->python/Pico_Servo_Driver_Code/python/servo.py to run the script.
As soon as the experimental phenomenon channel is connected to the servo, it will rotate from 0 degrees to 180 degrees, and cycle three times.

Windows

C

Download the demo

How to Use the Demo

Note: The pictures below are for reference only, the steps are the same.
1. Open the corresponding C program folder.

2. Open through the "Vs" coed and select the corresponding compilation tool.

3. Click the "build" button to compile.

4. Press the "Reset" button on the Pico-Eval-Board to reset the Pico, first press the BOOTSEL button and then the RUN button and then release the Reset button, the Pico can enter the disk mode without plugging and unplugging the Pico, and the UF2 file under the build file Drag and drop to the RPI-RP2 drive letter.

5. By now, Pico starts to run the corresponding program.

About the Demo

Underlying hardware interface

  • We have the underlying hardware package. Due to different hardware platforms, the internal implementation is different. If you need to know the internal implementation, you can refer to the corresponding directory.

You can see many definitions in DEV_Config.c(.h), in the directory: ...\c\lib\Config.

  • data type:
 #define UBYTE uint8_t
 #define UWORD uint16_t
 #define UDOUBLE uint32_t
  • Processing of module initialization and exit:
 void DEV_Module_Init(void);
 void DEV_Module_Exit(void);
  • PWM initialization processing:
 void PWM_initialization();
  • Interrupt handler:
 void on_pwm_wrap();
  • Define the channel used:
 #define CHANNE_N 0xFFFF // 0x0001 means 0 channel is open, 0x0000 means all channels are closed
  • Rotation angle:
 #define ROTATE_0 1700 //Rotate to 0° position
 #define ROTATE_45 3300 //Rotate to 45° position
 #define ROTATE_90 4940 //Rotate to 90° position
 #define ROTATE_135 6600 //Rotate to 135° position
 #define ROTATE_180 8250 //Rotate to 180° position

Python

1. Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
2. Download the pico_micropython_xxxxx.uf2 file and copy it to the recognized removable disk (RPI-RP2)

official firmware download.

3. Open Thonny IDE (Note: Use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3).
4. Click Tools->Settings->Interpreter, select Pico and the corresponding port as shown in the figure.

5. File->Open->servo.py, click to run, as shown in the figure, the program has been run:

The experimental phenomenon is exactly the same as the c program, and will not be repeated here.