We have to drive a 500W motor using a PIC 16F877A, measure its RPM and also feeding it back to micro controller to displaying its real-time speed on a 16×2 LCD Character Display.
There are many solution available for motor control from more efficient motor driving IC to making your own h-bridge or using a high side or low side switching control.
We will be using low side switching technique to control the motor as it is possible to control a high wattage motor with least amount of parts and circuit complexity.
You could use any power supply SMPS or Linear just it need to deliver the same voltage which motor will be needing (for us it was 24V your will depend on the motor). We will be using a Plate type transformer which will deliver 24V at 20A (max), then we will be a using a single phase bridge rectifier called as KBPC3510 which has maximum rating of 1000V at 35A (max). We will be providing four 23000uF electrolytic capacitor so that the ripple produced will be low even at higher currents. LCD & Micro-Controller will be working on 5V so we will be using a LM7805 which will deliver 5V at 1A (max).
The micro we will be using is PIC 16F877A whose data sheet is linked here. I chosen it due to its number of I/O ports and its memory.
LCD used her is generic 16 x 2 character display, we can use it in 4 bit or 8 bit mode, for this project we will be using it in 4 bit mode as it saves us precious i/o pins and we don’t have much data to push to the LCD so the 8 bit mode is not needed.
Here is the image in which you can see the connections to be made with the micro, note that only four data pins are going to the micro and others are grounded, hence the 4 bit mode.
(Please do note the pin number when connecting LCD with the micro in the real world as the pin layout in the image is not exactly same as in real IC itself). Data Sheet for LCD is here though you may not need to refer it.
Mosfet Driver Circuit –
Here we are using four IRF540 in parallel configuration to increase the current capacity of the circuit, each mosfet is rated for 100V and 28A which is around 2800W of power transfer but if we used only one mosfet then the 500W (for what we are designing) flowing through the mosfet will heat it up a lot (please check its data sheet for exact heat calculations). So after few back of the envelop calculations I found four mosfet will be good enough which actually makes it capable of transferring 11.2 kW of power. (Note that you can also use it with 2 or less mosfet by providing proper heat sink). We have used PC817 opto-coupler to keep the high power side isolated from the micro-controller.
There are various methods of measuring RPM using driven motor configuration, IR pulse detecting, using hall effect sensor. Here we will be using driven motor configuration, RPM measurement is done by the a secondary motor which is connected with main motor using a belt and pulley. This motor gives 35V at maximum RPM which is then converted in to 4V (using voltage divider circuit) to maintain it in 0-5V range of micro, then it is fed back to micro on analog (pin no 2) which is then converted back in to RPM in micro-controller then displayed by using LCD.
Micro-controller programming is done in Mikro C, code is well commented so its easy to understand. All the code can be downloaded from the download section below.
Motor’s positive is directly connected to the 24V power supply, then “P3” of the motor driver is connected to the negative terminal of the motor and point “P4” to the negative terminal of the power supply (ground).
Micro Controller board is powered by LM7805 5V DC output, the pin no 17 is the PWM output which is the connected to the 220 ohm resistor in series then to a red LED then to pin 1 of PC817 on motor driver broad then its pin two is grounded.
Power supply connections will differ with the type of supply you choose. Other connections are covered in the gerber files. All download links are given down below.
Reference and Links-
Special thanks to Siddhant Sawant.
All gerber files, code and other related file for this project – Link
Please share this post and if you build this project, notify me and send me your modifications, I will update this blog and give you a shout out for that.
Do read the disclaimer linked in the bottom.