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?
Hey Everyone,
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!
Components:
2N7000
Silicon Labs EFM8 Sleepy Bee starter kit
12V DC motor
motorcycle battery
500ohm potientiometer
Diode
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!