Skip to content

Commit ef1478d

Browse files
committed
docs : DC모터
간단한 연결, 간단한 제어 모터 드라이버 칩 필요 - 회전 방향 제어를 위한 별도 회로 필요 - 전용 전원 공급을 위한 별도 회로 필요
1 parent 78f246f commit ef1478d

File tree

1 file changed

+149
-1
lines changed

1 file changed

+149
-1
lines changed

부품&연결방법/모터.md

+149-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,144 @@
175175

176176
### ✔ DC 모터
177177

178+
- 연결 순서 -> 정회전, 역회전 가능
179+
180+
- 연결선2개 : VCC, GND
181+
182+
- PWM 신호로 속도 조절 가능
183+
184+
- 단점
185+
186+
- 결선후 정회전 역회전 선택 불가 -> 별도의 H브리지 회로 필요
187+
188+
![image](https://user-images.githubusercontent.com/54584063/84381999-e3456f00-ac24-11ea-8509-59a904ff0c78.png)
189+
190+
- 많은 전력 필요 -> 데이터 핀 출력으로 제어 어려움
191+
192+
- 전용 모터 드라이브 칩(L293D모터 드라이버) -> DC모터 제어
193+
194+
- L293D모터 드라이버
195+
196+
![image](https://user-images.githubusercontent.com/54584063/84382140-29023780-ac25-11ea-9a70-fe86b9dde024.png)
197+
198+
- 2개 모터 연결 가능
199+
200+
- 정회전, 역회전 선택 가능
201+
202+
- 속도제어 : PWM 출력 가능 핀 사용
203+
204+
- 모터 전용 별도 전원 제어
205+
206+
- 3개의 제어선
207+
208+
- enable : 모터 활성화
209+
210+
- PWMs : 속도 제어
211+
212+
- DIR : 방향 제어
213+
214+
- 연결방법
215+
216+
![image](https://user-images.githubusercontent.com/54584063/84382361-754d7780-ac25-11ea-80ea-2fb2fefc10d0.png)
217+
218+
![image](https://user-images.githubusercontent.com/54584063/84382668-f1e05600-ac25-11ea-9932-716e74e26231.png)
219+
220+
221+
- LAB
222+
223+
- DC모터 정화전 & 역회전
224+
225+
```c
226+
void loop(){
227+
// 모터 1 제어
228+
digitalWrite(enable1, HIGH);
229+
digitalWrite(DIR1, HIGH); //정방향
230+
digitalWrite(PWM1, LOW);
231+
232+
delay(4000);
233+
digitalWrite(PWM1, HIGH);
234+
delay(200);
235+
236+
digitalWrite(DIR1, LOW);
237+
digitalWrite(PWM1, HIGH);
238+
239+
delay(4000);
240+
digitalWrite(PWM1, LOW);
241+
delay(200);
242+
243+
digitalWrite(Enable1, LOW);
244+
}
245+
```
246+
- DC모터 회전속도 조절
247+
248+
```c
249+
void loop() {
250+
digitalWrite(Enable1, HIGH); // 모터 제어 가능 상태
251+
digitalWrite(DIR1, HIGH); // 정방향 회전
252+
for (int i = 255; i >= 0; i--) { // 모터 회전 속도 서서히 증가
253+
analogWrite(PWM1, i);
254+
delay(30);
255+
}
256+
digitalWrite(PWM1, HIGH); // 모터 정지
257+
delay(200);
258+
digitalWrite(DIR1, LOW); // 역방향 회전
259+
for (int i = 0; i < 256; i++) { // 모터 회전 속도 서서히 증가
260+
analogWrite(PWM1, i);
261+
delay(30);
262+
}
263+
digitalWrite(PWM1, LOW); // 모터 정지
264+
265+
delay(200);
266+
267+
digitalWrite(Enable1, LOW); // 모터 제어 불가능 상태
268+
}
269+
```
270+
- 버튼으로 DC모터 회전 방향 제어
271+
272+
```c
273+
void loop() {
274+
if (digitalRead(button_pin)) {
275+
direction = !direction;
276+
if (direction) // clockwise
277+
Serial.println("Clockwise...");
278+
else
279+
Serial.println("Anti-clockwise...");
280+
digitalWrite(DIR1, direction);
281+
digitalWrite(PWM1, !direction);
282+
delay(2000);
283+
}
284+
}
285+
```
286+
287+
- 가변저항 -> DC모터 속도 제어핀
288+
289+
```c
290+
void loop() {
291+
int reading = analogRead(A0);
292+
int speed = map(reading, 0, 1023, -255, 255);
293+
if (speed > 0) {
294+
digitalWrite(DIR1, HIGH); // 방
295+
int pwm_value = 255 - speed;
296+
analogWrite(PWM1, pwm_value);
297+
Serial.print(String("Reading : ") + reading);
298+
Serial.println(String(", Clockwise : ") + speed);
299+
}
300+
else {
301+
digitalWrite(DIR1, LOW); // 역방
302+
int pwm_value = abs(speed);
303+
analogWrite(PWM1, pwm_value);
304+
Serial.print(String("Reading : ") + reading);
305+
Serial.println(String(", Anti-clockwise : ") + pwm_value);
306+
}
307+
delay(1000);
308+
}
309+
310+
```
311+
312+
313+
314+
315+
178316

179317
### ✔ 연결방법
180318

@@ -200,4 +338,14 @@
200338

201339
- 0-180도 범위만 회전
202340

203-
- "Servo"라이브러리
341+
- "Servo"라이브러리
342+
343+
- DC 모터
344+
345+
- 간단한 연결, 간단한 제어
346+
347+
- 모터 드라이버 칩 필요
348+
349+
- 회전 방향 제어를 위한 별도 회로 필요
350+
351+
- 전용 전원 공급위한 별도 회로 필요

0 commit comments

Comments
 (0)