DC Motor and Encoder for Position and Speed Control

by tzeqianghun in Circuits > Arduino

12852 Views, 2 Favorites, 0 Comments

DC Motor and Encoder for Position and Speed Control

WeChat Image_20200619130501.jpg

Introduction

We are a group of UQD10801(Robocon I) student from Universiti Tun Hussei Onn Malaysia(UTHM).We have 9 group in this course.My group is group 2.Our group's activity is DC motor and encoder for position and speed control.Our group's objective is control the DC motor rotate with the speed we needed.

Description

Driving electromotors needs a high current. In addition, spinning direction and speed are two important parameters to be controlled. These requirements can be handled by using a microcontroller (or a development board like Arduino). But there is a problem; Microcontrollers cannot provide enough current to run the motor and if you connect the motor to the microcontroller directly, you may damage the microcontroller.For example, Arduino UNO pins are limited to 40mA of current which is far less than the 100-200mA current necessary to control a small hobby motor. To solve this, we should use a motor driver. Motor drivers can be connected to the microcontroller to receive commands and run the motor with a high current.

Material Preparation

WeChat Image_20200619123016.jpg

Reqiured Material

For do this activity,we need to prepare:

-Arduino UNO R3

-2 Potentiometer with 10kOhm

-2 DC motor with encoder

-Power supply with 12V and 5A

-H-bridge motor driver

-2 push button

-8 resistor with 10kOhm

-Jumper wires

-Breadvroad small

Pin Connection

WeChat Image_20200618225254.jpg

1.For the left side motor connect to Arduino UNO 3:

-Channel A to pin 2

-Channel B to pin 4

2.For the right motor connect to Arduino UNO 3:

-Channel A to pin 3

-Channel B to pin 7

3.For the potentiometer 1 connect to Arduino UNO 3:

-Wiper to A4 analog

4.For potentiometer 2 connect to Arduino UNO 3:

-Wiper to A5 analog

5.For push button 1 connect to Arduino UNO 3:

-Terminal 1a to pin 8

6.For push button 2 connect to Arduino UNO 3:

-Terminal 1a to pin 9

7.For H-Bridge Motor Drive connect to Arduino UNO 3:

-Input 1 to pin 11

-Input 2 to pin 6

Coding

WeChat Image_20200619135659.jpg

You can download the coding for test the DC motor that can rotate.This coding can help you to make the DC motor rotate and work.You must download this coding to your PC for the next step.

Testing the DC Motor

WeChat Image_20200619141129.jpg

So,aftet you download the coding from the previous step,you must open it in your Arduino IDE that already installed in your PC or use Tinkercad in the online.And that,upload this coding to your Arduino board via USB cable.If you use the Tinkercad on the online,you just upload this coding to the "Code"that shown in the photo.After you upload the coding source,you can run the DC motor.If you use the Tinkercad,you must press"Start Simulation" for start this system.

Result

WeChat Image_20200619141512.jpg
WeChat Image_20200619141830.jpg

After we start the simulation,we can see both of the DC motor is rotate but different direction.When we see the "Serial Monitor",M1's direction is clockwise and M2's direction is anti-clockwise.

Video

DC motor and encoder for position and speed control