When I wired my home for home control years ago, I ran wires to the frame of the three windows in the master bedroom with the idea of some day installing motorized window treatments. Then about 10 years ago I installed motorized pleated shades and added them to my home control system. This worked great for years until one of the shades began to operate flaky. The shade would stop in the wrong position or not move at all. I disassembled the shade and removed the existing motor and controller which you can see below.
The controller was actually pretty sophisticated. There's a DC motor and gearbox with an encoder as well as a controller board. The black color you see above is not from overheating but is painted to protect the encoder led from false signals. I had to provide the height of the opening when I purchased the shades and I believe that the encoder count for full open must be embedded in the controller. The shade could be controlled by either an IR remote control or a button on a small pendant. I just paralleled a relay output from my controller across the button contacts. If power was lost, the controller lost it's position and would not respond until it received an up signal from the IR remote at which time the shade would go up until it reached the top and then reset the top position. After that, the shade could be controlled from the controller.
After inspection, the problem was that the gearbox shafts were supported in the metal side frames of the gearbox without any type of bushing or bearing. Finally one of the shaft holes wallowed out to the point that the gears would not reliably engage. There did not appear to be a simple way to repair the assembly so I started to look for a replacement. Not surprisingly the shade motor assembly was obsolete and the original manufacturer no longer had any replacement parts. I did locate a company at blindsparts.com that claimed to have the part and even had a picture online. Although the price was $300. I decided to order one to save time. The company immediately charged my card but, despite numerous calls, never shipped the part. I finally had to get a credit from American Express. I would definitely not recommend them.
I looked at buying a new shade but the prices ranged in the order of $450. - probably as much as I paid for all 3 when I first purchased them. Since it was time for a new approach, I decided to add my own motor and design a controller.
There are actually lots of DC motor/gearbox combinations available these days - mostly due to the popularity of robotics. After quite a bit of research I settled on a 75:1 Metal Gearmotor with a 48 CPR Encoder, Item #2286 from Pololu Robotics & Electronics. This would physically fit in the shade header and already had the encoder built in. Here's what the motor looks like:
All I had to do now was couple the output shaft to the shaft in the shade and then mount the motor/gearbox assembly. For a coupling I just used a 1/2" diameter by 1" long aluminum spacer from McMaster Carr that I drilled out on either end to match the corresponding shaft diameters and then added a couple of set screws to ensure there was no slippage.I tried to use a mount that I also purchased from Pololu but couldn't really get it to fit in correctly. I finally ended up making some mounts from some poly that I had laying around on my CNC. This worked out really well and the final assembly was very clean.
I developed the software using the BascomAVR compiler. I've used this software for a long time and find it to be fast, powerful, and easy to use. The shade control is really pretty simple. The two encoder inputs are set up as pin change interrupts and a simple interrupt routine tracks the position of the shade in encoder counts. After powering up the circuit, the red LED is illuminated and the automatic control is disabled. You then need to use the manual up button to raise the shade to the top position and press the calibrate button momentarily after which the yellow LED flashes one time to indicate that this is the zero or top position. Then you need to use the manual down button to lower the shade to the bottom position and press the calibrate button for 2 seconds after which the yellow LED flashes several times and the current encoder reading is stored in EEPROM as the bottom position count. Now the green LED is illuminated and automatic control is enabled. In automatic each time the auto button is pressed or the home controller closes it's connected relay, the shade moves in the opposite direction of it's last travel until the correct position is reached.