Motor Controller

My Home Theater project requires the use of a number of electric motors to provide automation. The projector lift requires a single motor, and the screen requires 2 motors (the screen and the mask). I decided to use reversible 120 VAC motors for their torque and availability. I needed a way to control the motors from the HTPC for purposes of automating them. I came up these requirements for a motor controller:

I set about designing my own circuit based on a PIC16F877 MCU. Based on my previous experience with this MCU, I had every expectation that this project would not be difficult.

I prototyped the circuit in about a day and set to writing the assembly code using MicroChip's MPLAB software. The code was mostly complete by the end of the same weekend. The prototype doesn't show the actual sensors and relays that will be used in the final product. The circuit is capable of switching 2 120 VAC motors, up to 8 amps each.

I purchased and used EAGLE Layout Editor for schematic capture and board design. You obviously can't see much detail in this picture. I'm not sure if I want to share the design and code yet, as I might turn this into a real product someday. If you're interested, let me know.

I had the boards made by Olimex in Bulgaria as they had the best prices and the features I wanted. As you can see the boards turned out beautifully. The board is 4 1/2" wide and 4" high.

I spent some time after work one night and soldered on all the parts. The quality of the completed board surprises even me. The left side of the board contains the power supply complete with fuse and voltage regulator (the board takes 120 VAC power directly). The board is basically split horizontally with each half serving one motor. The blue terminal blocks on the top and bottom edges provide connections for the motor(s). The left block in each pair is for supplying switching power to the motor, the right block is for switching direction. Each block is connected to the DPDT (double pole, double throw) relay right next it. While a typical AC motor doesn't require all the provided connections, I opted to design it to handle just about anything; it can easily handle DC motors too.

The connections on the right edge are for, from top to bottom, rotary encoder for motor 2, limit switch for motor 2, RJ45 serial port, RJ?? (6 pos) port for programming/debugging, limit switch for motor 1, and rotary encoder for motor 1.

This is the board after mounting and testing. The only problem I uncovered was that I forget to supply a ground connection to the serial port. Very stupid, but easy to fix; just added a 1/2" wire to the back of the board. The board now works perfectly.

This part of the Home Theater Project is complete. After installing one of the motor controllers in the projector lift, I discovered a couple of bugs in the firmware. It was pain to unwire the board and bring it back to my computer to reprogram it so I added a bootloader before I reinstalled it. The bootloader allows me to upgrade the firmware over the serial port without having to physically touch the controller. I've since used this feature to add some configuration options to the firmware and works perfectly.