- 개발 환경 : Rasberry Pi 4B (Ubuntu 18.04 / ROS melodic)
- 준비물 : 아두이노 메가, 엔코더가 있는 DC 모터(FIT0450) X 2
- 참조 : https://www.youtube.com/watch?v=q1u_cC-5Sac&t=69s
STEP1. 아두이노에 모터드라이버(TB6612FNG) 및 엔코더 모터(FIT0450) 연결
- 아래의 그림과 표를 참조하여 엔코더 모터 및 모터드라이버를 아두이노에 연결합니다.
Motor Driver | Arduino | Motor | 모터 외부전력 |
A0UT | - | Motor A | - |
BOUT | - | Motor B | - |
STBY | Pin10 | - | - |
PWMA | Pin4 | - | - |
AIN1 | Pin9 | - | - |
AIN2 | Pin8 | - | - |
PWMB | Pin5 | - | - |
BIN1 | Pin11 | - | - |
BIN2 | Pin12 | - | - |
5V | VIN | - | - |
GND | GND | - | - |
VSEL(외부전력) | - | - | VOUT |
- | GND | - | GND |
Pin2 | encoderA1 | ||
Pin3 | encoderA2 | ||
Pin18 | encoderB1 | ||
Pin19 | encoderB2 |
* 참고로 엔코더 핀은 반드시 2, 3, 18, 19에 꽃아야합니다. (아두이노 메가 기준)
https://www.arduino.cc/reference/ko/language/functions/external-interrupts/attachinterrupt/
- 아래 링크의 rosserial motor 코드와 합친 버전입니다.
https://do-9un6.tistory.com/13
- 엔코더 값으로 모터 움직이기
- 엔코더 코드와 rosserial 코드 합치기
- 라이브러리
'작업 일기' 카테고리의 다른 글
ROS- PS4 Joystick teleop (0) | 2022.03.22 |
---|---|
아두이노 Wheel encoder를 이용한 Navigation (0) | 2022.02.09 |
Hector SLAM (0) | 2022.01.18 |
Arduino와 ROS로 DC 모터 x2 제어하기 (0) | 2021.12.29 |
라즈베리파이 4B(Ubuntu 18.04)에 Pi Camera V2.1 연결하기 (0) | 2021.12.24 |