Ks0258 keyestudio 16-channel Servo Motor Drive Shield: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
==keyestudio 16-channel Servo Motor Drive Shield==
<br>[[File:KS0258.png|500px|frameless|thumb]]<br>


[[image:KS0258.png|thumb|800px|right|keyestudio 16-channel Servo Motor Drive Shield]]
<br>
==Introduction==
==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.
When we are doing robot experiments, it needs to use multiple PWM ports to drive the servo motor, however, the commonly-used Arduino UNO R3 only has 6 PWM ports, really not enough. This allows you to use this expansion board, which is directly stacked on the Arduino UNO R3 board. It can drive up to 16 servos and use I2C input, occupying A4 and A5 pins of UNO. <br>
The shield also comes with PCB double-sided holes, which can be used to solder with components to build up prototyping circuits.
<br>[[File:图片1- ks0258.png|700px|frameless|thumb]]<br>


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


== Related Explanation of Interface ==
<br>[[File:KS0258-1.png|500px|frameless|thumb]]<br>


== Wiring Method ==
<br>
Stack on the UNO R3 board, as shown below:
==Details==
*'''Dimensions:''' 69mm x 54mm x 24mm
*'''Weight:''' 20g
<br>[[File:图片2- ks0258.png|700px|frameless|thumb]]<br>
 
<br>
== Interface Explanation  ==
<br>[[File:Ks0258 pinout.jpg|700px|frameless|thumb]]<br>
 
 
== Simple Hookup==
Simply stack the shield onto [http://wiki.keyestudio.com/index.php/Ks0001_keyestudio_UNO_R3_BOARD  UNO R3 board ]. <br>
<br>[[File:KS0258-2.png|700px|frameless|thumb]]<br>


<br>[[File:KS0258-2.png|500px|frameless|thumb]]<br>


== Sample Code ==
== Sample Code ==
*Copy and paste the code below to [http://wiki.keyestudio.com/index.php/How_to_Download_Arduino_IDE  Arduino IDE ]. <br>
*Or [https://drive.google.com/open?id=1YDzJsMsh73CfSdYTp9wnSdedQanG6fzj  click here ]to download the code. <br> 
*[https://drive.google.com/open?id=1uSpbRoHXHS3WPgWmKU0ex4NOjDMh0Z5j  Click here] to download the libraries ''Adafruit_PWMServoDriver.h'' <br>
'''Note:''' Before compile the code, do remember to add the libraries inside the libraries folder of Arduino IDE.
<pre>
<pre>
/***************************************************  
/***************************************************  
   This is an example for our Adafruit 16-channel PWM & Servo driver
   This is an example for our keyestudio 16-channel PWM & Servo driver
   PWM test - this will drive 16 PWMs in a 'wave'
   PWM test - this will drive 16 PWMs in a 'wave'


   Pick one up today in the adafruit shop!
   The Servo Shield uses I2C to communicate, 2 pins are required to   
  ------> 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
   interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4


   Adafruit invests time and resources providing this open source code,  
   keyestudio invests time and resources providing this open source code,  
   please support Adafruit and open-source hardware by purchasing  
   please support keyestudio and open-source hardware by purchasing  
   products from Adafruit!
   products from keyestudio !
 
  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
  ****************************************************/
  ****************************************************/


Line 58: Line 72:


   pwm.begin();
   pwm.begin();
   pwm.setPWMFreq(1600); // This is the maximum PWM frequency
   pwm.setPWMFreq(50); //maximum is 1600
      
      
   // save I2C bitrate
   // save I2C bitrate
   uint8_t twbrbackup = TWBR;
   //uint8_t twbrbackup = TWBR;
   // must be changed after calling Wire.begin() (inside pwm.begin())
   // must be changed after calling Wire.begin() (inside pwm.begin())
   TWBR = 12; // upgrade to 400KHz!
   //TWBR = 12; // upgrade to 400KHz!
      
      
}
}
Line 69: Line 83:
void loop() {
void loop() {
   // Drive each PWM in a 'wave'
   // Drive each PWM in a 'wave'
   for (uint16_t i=0; i<4096; i += 8) {
  // "safe" limits of 200 and 400 are used here to protect servos with undetermined end stop points
   for (uint16_t i=200; i<400; i += 4) {
     for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
     for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
       pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
       pwm.setPWM(pwmnum, 0, i);
     }
    }
     delay(2);
   }
   }
}
}
</pre>
</pre>
<br>


== Test Result ==
== Test Result ==
Burning the code on Arduino UNO R3, then connect 16 servo motors as shown below, you can see  
Done uploading the above code to UNO R3. Then connect 16 servo motors shown below, finally you should see 16 servos rotate successively.
them rotate in succession.
<br>[[File:KS0258-3.png|600px|frameless|thumb]]<br>


<br>[[File:KS0258-3.png|500px|frameless|thumb]]<br>


<br>
==Resources ==
==Resources ==


'''Datasheet'''<br>
'''Download libraries and code: '''<br>
'''PDF '''<br>
 
http://www.keyestudio.com/files/index/download/id/1505354620/
https://fs.keyestudio.com/KS0258
'''Get the Adafruit PWM Servo Driver Library'''<br>
 
http://www.keyestudio.com/files/index/download/id/1505354621/
 
<br>


==Get One Now ==
==Get One Now ==
*[https://www.keyestudio.com/keyestudio-16-channel-servo-motor-drive-shield-for-arduino-p0339.html    '''Official Website''']
*[https://www.aliexpress.com/store/product/Keyestudio-16-channel-Servo-Motor-Drive-Shield/1452162_32830961097.html?spm=2114.12010612.8148356.64.1e95276fWVKZK9  Shop on Aliexpress]
*[https://www.ebay.com/itm/Keyestudio-16-Channel-12-bit-PCA9685-Servo-Motor-Drive-Module-Board-for-Arduino/132746581592?hash=item1ee8501658:g:hyYAAOSwUC1bV0NP  Shop on eBay ]
*[https://www.amazon.com/KEYESTUDIO-16-channel-12-bit-Shield-Arduino/dp/B0797JK4RW    Shop on Amazon]






[[Category: shield]]
[[Category: Shield]]

Latest revision as of 11:16, 22 December 2023


keyestudio 16-channel Servo Motor Drive Shield



Introduction

When we are doing robot experiments, it needs to use multiple PWM ports to drive the servo motor, however, the commonly-used Arduino UNO R3 only has 6 PWM ports, really not enough. This allows you to use this expansion board, which is directly stacked on the Arduino UNO R3 board. It can drive up to 16 servos and use I2C input, occupying A4 and A5 pins of UNO.
The shield also comes with PCB double-sided holes, which can be used to solder with components to build up prototyping circuits.
thumb


Specifications

  • I2C input, controlling 16-channel PWM output
  • Servo power independent input V+, up to 6V.
  • Logic signal and logic power independent output 3-5V
  • Frequency: 40-1000Hz
  • Channels: 16-channel
  • Resolution: 12-bit



Details

  • Dimensions: 69mm x 54mm x 24mm
  • Weight: 20g


thumb


Interface Explanation


thumb


Simple Hookup

Simply stack the shield onto UNO R3 board .

thumb


Sample Code

Note: Before compile the code, do remember to add the libraries inside the libraries folder of Arduino IDE.

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

  The Servo Shield uses I2C to communicate, 2 pins are required to  
  interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4

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

#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(50); //maximum is 1600
    
  // 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'
  // "safe" limits of 200 and 400 are used here to protect servos with undetermined end stop points
  for (uint16_t i=200; i<400; i += 4) {
    for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
      pwm.setPWM(pwmnum, 0, i);
     }
    delay(2);
  }
}


Test Result

Done uploading the above code to UNO R3. Then connect 16 servo motors shown below, finally you should see 16 servos rotate successively.
thumb



Resources

Download libraries and code:

https://fs.keyestudio.com/KS0258



Get One Now