DC Motor Position Control

by AnnaMai in Circuits > Arduino

6324 Views, 8 Favorites, 0 Comments

DC Motor Position Control

1 thumb 4.png
0.png
1.png
2.png

This instruction will show how to control motor position via Local web network.

Now you can use smart phone or iPad connected to network, then type address of local web server of motor From here, we can control motor position disk by rotating the disk on web page when we touch the disk on webpage, it will send position setting to web server of motor, then rotate motor disk to reach that position setting on real time

Watch the video!

https://www.youtube.com/watch?v=bRiY4Qr5HRE

Hardware Needed

3.png

To make this project, we will need

1. nodeMCU https://amzn.to/2PPo5e0

2. H-bridge L298 https://amzn.to/2QS2FeI

3. Motor with encoder https://amzn.to/2RHsCRj

4. Motor base http://bit.ly/2DZJOZV

The heart of nodeMCU is ESP8266 which allow us connect to local wifi network. It also has GPIO and interrupt, PWM function like others Arduino microcontroller

The motor base is made from MDF wood 3mm thickness, cut by laser cnc machine.

Circuit Design

circuit.png
15 real model (1).JPG
15 real model (3).JPG
15_DSC0413 no71.jpg

Take a look at circuit design, motor encoder is connected to input pin 4, 5 in which pin 4 also acts as an interrupt pin to count rotation of motor

Pin 12, 13 acts as output pin to control motor moving forward or backward with helps of H-bridge L298

Pin 14 is used with PWM function to control motor speed, in this project, it just push out stable PWM to reduce speed of motor

Then, we made circuit into motor base like the picture.

Arduino Code Works

7.png

Main part is HTML code which is used for local web screen

Full code can be download here http://bit.ly/2ZkMivK

Java script library is used to make circle disk, and pass value to nodeMCU. The Java lib needed to load to file system of nodeMCU

Load the Code to NodeMCU

4.png
6.png
5.png

There are two part to load:

1. Java lib to file system of nodeMCU

The lib is save in folder next to project file, we have to install the tool called "data upload" tool into Arduino directory tool, then restart Arduino IDE.

To upload Java lib, choose following: Tools> ESP8266 Sketch Data Upload

Wait about 1 minute to upload the lib.

"Data upload" tool can be downloaded here http://bit.ly/2tMZWfF

2. Program to node MCU

Using upload function to upload the code as usual Arduino.

Test It

That's it! From now, you can use mobile phone or iPad connected to wifi network to control motor position.