Video making this project, you can see here:
To make this project, you will need following hardware:
1. Motor with encoder https://amzn.to/2RHsCRj
2. H-bridge L298 https://amzn.to/2QS2FeI
3. Arduino UNO https://amzn.to/2P58O7s
4. Motor base http://bit.ly/2DZJOZV
The motor with encoder, you can choose any DC motor but you need to know how many pulse of encoder per revolution. In case you don't know, you can make simple program with Arduino, then rotate motor shaft to know how many pulse of encoder per revolution. In my case, it is 200 pulses per revolution.
About software, you will need Arduino IDE to program Arduino UNO, and Visual Studio to make HMI on computer In my case, I use Visual Studio 2008, you can use newest version if you can
Make circuit like this diagram, it's easy for Arduino fan: encoder from motor will connect to pin 2 and 3; H-bridge is used to control motor speed, then pin 4, 5 and 6 will connect to H-bridge. And, output of H-bridge is connected to motor
Then install the circuit to motor base like picture
Arduino Code
Arduino code will do:
(1) Calculate motor speed
(2) Send motor speed to Computer
(3) Calculate PWM pulse (base on PID algorithm)
(4) Push result of PWM to H-brigde
The entire of code for Arduino UNO can be download at http://bit.ly/2P7CQbC
Code Works at Computer
Visual Studio 2008 is used to make HMI program, in which:
(1) Send speed setting to Arduino
(2) Send PID gain to Arduino
(3) Receive motor speed, show on graph
Note that, communication between Arduino and Visual Studio by COM communication
The code can be download at http://bit.ly/2PqlYvQ