Can some one please help me?? I am trying to achieve the following:
- Control a 5V DC motor using PWM signal
- Set the speed by tying a command via serial (set rpm)
- Measure the speed using an optical sensor
- Regulate the speed (with PID controller if possible or any simpler alternative)
I aleardy have a motor driver circuit and I have managed to get the motor running with a PWM signal.
Thank you! :)
I would suggest using this PID library: https://github.com/br3ttb/Arduino-PID-Library/.
You could then pass a desired speed via serial, and use that for the "Setpoint" variable.
For measuring the speed with an optical encoder, you could connect that to one of your external interrupt pins, and write an interrupt routine, that increases a variable by one on every interrupt, then calculate your speed in the main loop, there are a lot examples on this forum for this.
If you get stuck on specific issues, there is probably help available here.
I am also looking for such dc motor control specified above, for my project.
I was in dilemma whether to use PID controller or not
Can you tell me what is the importance of PID controller in the speed control of DC motor and also how to use it in speed control application in detail (sorry, I am a beginner)or a sample program using PID controller for speed control.
Thanks in advance
What is the motor driver IC you are using?
If it has an EN pin, simply use PWM signal to pulse the EN pin. This will effectively control the speed of the motor. I am using this technique with a L293D in an Arduino shield I built myself.
Another option is to have an adjustable voltage regulator (such as a LM317T) powering the motors, and have the Arduino control the variable resistance of the ADJ pin in the regulator. this can be done in two ways:
1) simply use a digital potentiometer (5Kohm, 8bits : enough for up to 20V output of the LM317 in 256 steps)
2) use a 74HC595 to control 8 resistors in a voltage divider that will be connected to the ADJ pin of the LM317T. I saw this method recently on a website, but never actually used it: too much work!
I am making an arduino quadcopter, and to use a Bluetooth transmission, I need to control a speed without a potentiometer. Will having the code to increase the speed of a dc motor, will this work
The speed value being the variable that will be increase
So the speed could also be sent over a serial communication like such:
So speed will be whatever is sent over serial communication.
Kinda confusing, but you can message me for more info.