Ks0258 keyestudio 16-channel Servo Motor Drive Shield

From Keyestudio Wiki
Jump to navigation Jump to search

keyestudio 16-channel Servo Motor Drive Shield


thumb

Introduction

When we are doing robot experiments, it needs to use multiple PWM ports to drive the servo motor, however, the common used Arduino UNO R3 only has 6 PWM ports, so it is not enough.This allows you to use this expansion board, which is directly stacked on the Arduino UNO R3 board and can drive up to 16 servos. It uses I2C input, just occupies A4 and A5 of the Arduino UNO R3 board. The expansion board contains PCB double sided holes ,which can direct to solder with components to build up prototyping circuits.

Specification

  • 1.I2C input, to control 16-channel PWM output
  • 2.Servo power supply independent V + input up to 6V
  • 3.Logic signal and logic power independent output 3-5v
  • 4.Frequency of 40-1000Hz
  • 5.Number of channels: 16-channel
  • 6.Resolution: 12-bit

Related Explanation of Interface


thumb

Wiring Method

Stack the shield onto UNO R3 board, as shown below:


thumb

Sample Code

Download the Libraries: [1]

/*************************************************** 
  This is an example for our Adafruit 16-channel PWM & Servo driver
  PWM test - this will drive 16 PWMs in a 'wave'

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/815

  These displays use I2C to communicate, 2 pins are required to  
  interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
// you can also call it with a different address you want
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);

void setup() {
  Serial.begin(9600);
  Serial.println("16 channel PWM test!");

  // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
  // some i2c devices dont like this so much so if you're sharing the bus, watch
  // out for this!

  pwm.begin();
  pwm.setPWMFreq(1600);  // This is the maximum PWM frequency
    
  // save I2C bitrate
  uint8_t twbrbackup = TWBR;
  // must be changed after calling Wire.begin() (inside pwm.begin())
  TWBR = 12; // upgrade to 400KHz!
    
}

void loop() {
  // Drive each PWM in a 'wave'
  for (uint16_t i=0; i<4096; i += 8) {
    for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
    }
  }
}

Test Result

Burning the code on Arduino UNO R3, then connect 16 servo motors as shown below, you can see them rotate in succession.


thumb

Resources

PDF
https://drive.google.com/open?id=1rtiMdKdGpKqqF8wotvG5ot_psiA9YoJP

Get the Adafruit PWM Servo Driver Library
https://drive.google.com/open?id=1gjrvdgtFi74pZgccaPbZOMbZNVux1fvE

Get One Now

Official Website

http://www.keyestudio.com/keyestudio-16-channel-servo-motor-drive-shield-black-environmental-friendly.html