How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
Thought I would share with you my very simple motor control design. It can control the speed of a small toy 12V DC motor or it can be used to simply turn on and off the motor.
Here is video showing it working!
Silicon Labs EFM8 Sleepy Bee starter kit
12V DC motor
Below is the circuit. The MOSFET acts as a switch that either lets the current flow or not depending on the input from the MCU. I am using a pulse width modulation or PWM to control the MOSFET. From this I can get a rough speed control by altering the duty cycle of the PWM. Alternatively, I can toggle a GPIO to just turn the motor on or off, full speed or stopped.
The code is very simple and just adjusts the overflow of the Programmable Counter Array(PCA) to control the switching period of the PWM. The PCA0CPH0 is the register that controls this overflow. Either increase or decrease it to change the duty cycle when a button is checked. You also have to be sure to check if you are at the max of 100% or min of 0%.
Let me know if you have any questions or suggestions. My next step is to add a transceiver I have to the board and make this a wireless motor control project!