얕고 넓게

[Arduino] 3. I2C PWM Controller 본문

IT/Platform

[Arduino] 3. I2C PWM Controller

블랙오닉스 2022. 2. 3. 20:23

0. Spec.

Board: HW-170

HW-170 16 Channel PWM Servo Driver IIC Interface Shield Board Module PCA9685 Drive Board
Features:
1. PCA9685 chip is wrapped in the green power indicator of the central power input terminal of the small board.
2. It is convenient for you to insert 16 servo motors at a time in 4 sets of 3-pin connectors.
3. The servo motor plug is slightly wider than 0.1'', so you can put 4 pairs of 0.1''connectors.
4. Reverse polarity protection cascade design input on the terminal block.
5. Place on V+ line - a large capacitor in some fields you will need.
6. The maximum input voltage of the peripheral depends on the capacitance of this 10V1000uf.
7. All PWM output lines are placed - a 220 ohm series resistor to protect them and can be easily driven.

Specifications:
Voltage: DC5-10V
Power communication interface: IIC1 6-way servo control
Product size: 61mm*25mm*8mm/2.40*0.98*0.31''
Packing size: 110mm*70mm*8mm/4.33*2.75*0.31''
Package weight: 12g

V+: 5V~6V, Motor Power

VCC: 3.3V ~5V Board Logic Power

 

Chip: PCA9685PW

 

https://www.adafruit.com/product/815

 

Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface

You want to make a cool robot, maybe a hexapod walker, or maybe just a piece of art with a lot of moving parts. Or maybe you want to drive a lot of LEDs with precise PWM output. Then you ...

www.adafruit.com

1. 참고

https://m.blog.naver.com/aul-_-/221793940620

 

아두이노와 pca9685모듈로 MG946R 서보모터 다중제어하기

아두이노 우노나 나노같은 보드에서 여러개의 서보모터를 제어하려면, 핀이 모자르는 경우가 있다. 이럴 땐...

blog.naver.com

2. PWM 라이브러리 다운로드 (Visual Studio Code에서는 필요없음)

https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

 

GitHub - adafruit/Adafruit-PWM-Servo-Driver-Library: Adafruit PWM Servo Driver Library

Adafruit PWM Servo Driver Library. Contribute to adafruit/Adafruit-PWM-Servo-Driver-Library development by creating an account on GitHub.

github.com


3. 예제 코드

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

Adafruit_PWMServoDriver pwm=Adafruit_PWMServoDriver();

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("I2C PWM");
  pwm.begin();
  pwm.setOscillatorFrequency(25000000);
  pwm.setPWMFreq(50);
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
    for(int i=0;i<256;i=i+10) {
      int ra =  constrain(map(i, 0, 256, 150, 600), 150, 600);
      pwm.setPWM(0,0,ra);
      Serial.println(ra);
      delay(1000);
  }
}

* PCA9685의 내부 OSC의 오차 때문에 정확한 50Hz가 나오지 않음 -> Oscilloscope로 측정하여 조정 필요

* 150 ~ 500 정도까지만 동작

 

4. 연결

Arduino Nano I2C PWM Board Servo Motor
5V VCC  
GND GND  
A4(SDA) SDA  
A5(SCL) SCL  
  V+ (외부 5V)  
  검(GND) 갈(GND)
  빨(V+) 빨(V+)
  노(PWM) 주(PWM)

'IT > Platform' 카테고리의 다른 글

[Arduino] Sun Keyboard Converter  (0) 2022.02.03
[Arduino] 4. LCD 20x4  (0) 2022.02.03
[Arduino] 2. Gyro Sensor  (0) 2022.02.03
[Arduino] 1. PWM  (0) 2022.02.03
[Arduino] 0. 개발 환경  (0) 2022.02.03