Automatic Window Blinds Controller (PICAXE)
by biochemtronics in Workshop > Home Improvement
274822 Views, 391 Favorites, 0 Comments
Automatic Window Blinds Controller (PICAXE)
For a long time I just waited until I got home in the afternoons to open my blinds, but my plants suffered from a lack of light. They were not dying by any means, but they were not healthy, and their growth was severely stunted. I needed to find a way to open and close my blinds automatically when I was not at home.
An automatic blind opener is not a new invention. They have been available for years. However, even the low end models cost in excess of a hundred dollars per window. Some models and styles can cost ten times that much. Most use IR remote controls. Other available activation options include timers, RS-232 interfaces, and light sensors. I needed a controller with a light sensor that would open my blinds in the mornings and close then in the evenings. However, I was not willing to pay what I thought was an unreasonable price for a simple light activated motor. Being the Maker that I am, I knew I could design and build what I needed and do it for a lot less money than what any commercial units cost.
Because I am a big fan of the versatile and inexpensive PICAXE microcontrollers, it was a given that I would design and build my window blinds controller around that chip. I decided to use the PICAXE -08M which is an 8 pin DIP with loads of features including several inputs and outputs, analog to digital converters, a pulse width modulatior, an IR transceiver option, and more features and extras than you would think would fit into its tiny package.
If you have not used PICAXE microcontrollers before I would suggest purchasing the 08M starter pack for around $12.95. It comes with the micro controller, a software CD, a serial download cable, a proto board, a battery holder, and all the basic parts you need to get started with the PICAXE system.
PICAXE 08M Starter Pack
The PICAXE system was originally designed for educational use and is. It is an excellent system for beginners and experts alike. The PICAXE software is simple to learn and use. It uses simple Basic commands that are easy to understand because they actually make sense. You even have the option of writing programs using flow charts. I usually start my projects using flow charts option and later convert them to Basic commands when I start tweaking the program. Best of all, the PICAXE software is freeware. You can download it and all of the manuals from the official PICAXE website.
Official PICAXE Web Site
I must admit that I got a little side-tracked in the beginning of this project. I decided to play around with the IR remote control options built into the PICAXE -08M. It was neat to use an old television universal remote control to open and close my blinds at will, but that did nothing to help solve my problem. I finally found my focus again and went to work designing this project.
After several weeks of electronic hardware, software, and mechanical tweaking I finally came up this design. It is simple, easy to build, does a great job, and is just plain cool. If you have any spare or salvaged parts lying around you can build the whole thing for a lot less than $15.00. If you have to buy everything you can still build this project for around $20.00 including the batteries.
I really enjoyed designing, building, and tweaking this project and I learned a lot in the process. Now my plants get the light they need, my other projects are not shining through the open window blinds at night, and I feel better knowing the blinds will close at night whether I am there or not.
***************************************************************
Be sure to check out the "Take it Further" ideas in step 12.
They are sure to spark your imagination and make you
want to fire up that old soldering iron and get busy
on a truly fun and practical project.
***************************************************************
Biochemtronics
.
The Parts You Will Need
- PICAXE -08M Micro Controller, Spark Fun Electronics $2.95
- ULN2003A Darlington Array, BG Micro #ICSULN2003 $.59
- DPDT 5.0V Relay, BG Micro # REL1106 $1.29
- Solarbotics GM3 Gear Motor, 224:1 6V, Maker Shed Store or Solarbotics $5.50
- 3.5mm Stereo Jack, BG Micro #AUDCA017 $.36
- 4 X 1.5V AA Battery Holder, BG Micro #BAT1068 $.79
- Battery Snap (9V style), BG Micro #BAT1033 $.25
- LM7805T 5.0V, 1A, Regulator, BG Micro #REG7805T $.40
- Small Project Box, BG Micro #ACS1157 $1.95
- Small Proto Board (2 3/8), BG Micro #ACS1433 $.89
- 8 Pin Dip Socket, BG Micro #SOC1036 $.10
- (2) 16 Pin Dip Sockets, BG Micro #SOC1038 $.08
- Light Dependent Resistor, Radio Shack #276-1657 (5 pk) $2.99
- (2) SPST Switches, BG Micro #SWT1043 $.20 for both
TOTAL $15.90
You will also need the following items:
- Resistors: 1 each of 10K, 22K, and 100K (>= 1/4 Watt)
- Wire, solder, small bolts and nuts, Velcro strips
RECOMMENDED SUPPLIERS:
BG Micro
BG Micro Web Site
I am only a hobbyist and I don't spend a lot of money on projects, but the people at BG Micro have always treated me like I was their most important corporate customer. That kind of service is nearly impossible to find these days. Add that to their great parts selection and low prices and you have a winning combination.
Maker Shed Store
Maker Shed Web Site
I love checking out their stuff at Maker Faire
Your own stash of surplus and salvage parts.
"To invent you need a good imagination and a pile of junk"
Thomas A. Edison
There is also a schematic below for easier viewing. Right click on the schematic and choose "save as" to save a copy to your computer.
How the Controller Works
At the heart of my design is the versatile and inexpensive PICAXE microcontroller. The PICAXE is very sensitive to supply voltages. Take the voltage much over 5 volts and you will smoke it. Powering the PICAXE directly with 4 AA batteries (6.0v) will destroy it so don't even try it. It works well when powered with 3 AA cells (4.5v).
In my design I wanted to use 4 AA cells for two reasons. First, the extra AA battery would provide a little more time between battery changes. The second reason - because a 4 cell battery holder looks better sitting on top of the controller project box than a 3 cell holder does.
My design uses a light dependent resistor (LDR) hooked up to one of the PICAXE's analog to digital converter (ADC) inputs to monitor the outdoor light level. The ADC sets a program variable to some value between 0 and 255 depending on the intensity of the light shining on the LDR. I have mine set to open the blinds at 250. This keeps them from opening at the crack of dawn and waking me up too early. I have it set to close the blinds at 200 which is about an hour after sundown when it is just starting to get dark outside. You will need to tweak these settings to adjust the controller for your particular light levels and personal preferences. I do need to give you a word of warning here. If you use this controller in your bedroom, you need to be prepared for the blinds to open at any minute in the mornings. It would be really easy to get caught in an embarrassing situation if they opened at a time you were not expecting them to.
When the light shining on the LDR reaches a certain level (either dark or light depending on whether it is morning or evening)) the PICAXE turns on one or both outputs. The PICAXE outputs have a maximum load of 20mA which is not enought to power the relay or motor directly so I used a Darlington Array.
The Darlington Array is simply a set of 7 electronic switches that allow a low current (the PICAXE outputs) to switch a high current (The relay and motor). I used 2 of the array channels (1&2 tied in parallel) to switch the relay on and off, and the remaining 5 channels (3-7 also in parallel) to switch the motor current on and off. The array also has circuits built in that protect the rest of the circuit from voltage spikes created by inductive loads (e.g. relays and motors).
The relay I used is a small 5.0v DPDT relay that fits nicely into a 16 pin DIP socket. I hooked the motor leads up to the 2 common (COM) terminals of the relay and fed the motor outputs from the darlington array to both sets of normally closed (NC) and normally open (NO) contacts in a crisscross pattern. When the relay is off the motor turns in one direction. When the relay is activated the polarity reverses and the motor turns in the opposite direction. I am sure there are other ways to do this but I like this setup.
The PICAXE does have a pulse width modulator (PWM) built in that you could use to control the motor speed, but with the Solarbotics gear motor that wasn't necessary. If you use some other type of motor you might want to use the PWM program command it to slow it down a little. Whenever I reverse the motor, I activate the relay about 10mS before the motor current is turned on. This keeps the relay contacts from arching and should make them last a lot longer.
I included code in the program to prevent the controller from trying to open the blinds when they are already open and from closing them when they are already closed. This works fine except for when the controller is first turned on. When power is first applied the controller is going to try to open or close the blinds regardless of what the light levels are. For this reason, you need to manually set the position of the blinds to the opposite of what they need to be before you power up the controller (e.g. close them if it is during the day and open them if at night).
Modify and Mount the Gear Motor
Remove the rod from the blinds that you normally turn to open and close them. You will notice a small hole in the flat piece on the top end of this rod. Get a drill bit about the same size as that hole (about 3mm). Drill a hole in the motor shaft at about the same distance from the end of its shaft as the hole is from the end of the rod.
Mount the motor to the bottom of the project box using 4-40 bolts and nuts. Note that there is a small nipple sticking up on the side of the motor that goes towards the project box. Place a small washer over the nipple to keep the project box straight with the bottom of the project box when the bolts are tightened. The drilled end of the motor shaft should be sticking up like in the picture. This will allow you to mount the project box to the blinds while keeping the motor shaft in a position that will allow the hook on the spindle coming out of the blinds to go through the hole in the motor shaft.
Go ahead and put the hook through the hole in the motor shaft, and hold the project box against the blinds at the top of the window. Drill a small hole through the back of the project box and into the top of the blinds. Do not screw the project box to the top of the blinds yet. This hole will be used later to mount the controller to the blinds using a self tapping screw.
Build the Circuit on the Proto Board
I suggest that you first build the circuit on a breadboard. This will get you familiar with the circuit and components and allow you to test it out before soldering everything up. I temporarily mounted the gear motor and project box to the blinds and ran wires down to the breadboard circuit so I could test and tweak the circuit and software before actually putting it all in the project box.
Add the Position Adjustment Switches
Drill Holes in the Project Box
Put the wires through their respective holes in the project box and solder them to their proper place on the proto board.
NOTE: Don't solder the motor wires to until you have everything else installed and ready to go. Just use jumpers to connect the motor to the controller during the testing and tweaking steps. This will make it easier to reverse the motor wires if the motor runs the wrong direction and tries to open the blinds when it should be closing them.
Install the Light Dependent Resistor
In this position it "looks" outside when the blinds are open and directly at the blinds when they are closed. I found that this arrangement works best because enough light shines through the blinds to make the controller open the blinds in the morning and the project box blocks any lights in the room from shining on the LDR and keeping it from closing the blinds in the evening.
Mount the Controller to the Blinds
- Attach the battery holder to the controller box using Velcro.
- I added a label to the front of my controller so I would know what each switch does when I need to make position adjustments.
Program the PICAXE
The actual code starts after the line below:
symbol Relay = 1
symbol Motor = 2
BEGIN:
readadc 4,b1
' this line measures the outside light level
if b1 > 240 then goto OPEN
' increase this number (240) to make the blinds open later in
' the morning - decrease it to open earlier
if b1< 200 then goto CLOSE
' increase this number (200) to make the blind close earlier in
' the evening - decrease it to close later
goto BEGIN
OPEN:
if b3 = 1 then goto BEGIN
' this command prevents the blinds from trying to open again if
' they are already closed
high Relay
pause 10
' this command delays applying current to the motor until the
' relay contacts are closed
High Motor
pause 6600
' adjust this number (6600) to tweak the blind open position
' increase to open more - decrease to open less (see note below)
low Motor
pause 10
' this command delays opening the relay contacts until after
' current is cut off to the motor
low Relay
let b3 = 1
' this command prevents the blinds from trying to open again if
' they are already closed
goto BEGIN
CLOSE:
if b3 = 2 then goto BEGIN
' this command prevents the blinds from trying to close again if
' they are already closed
high Motor
pause 6150
' adjust this number (6150) to tweak the blind closed position -
' increase to close more - decrease to close less
' (see note below)
low Motor
let b3 = 2
' this command prevents the blinds from trying to close again if
' they are already closed
goto BEGIN
' NOTE: when making adjustments to the open and closed blind
' positions, it is usually best to adjust only one of these
' settings as each will affect the other
Setup the Controller
The tweaking needs to be done at some time other than early morning or late evening so the controller won't be opening and closing the blinds automatically while you are trying to make adjustments.
If you do this step during the day you will need to manually close the blinds using the adjustment buttons before you download the program to the controller.
If you do this at night, you will need to manually open the blinds using the adjustment buttons before downloading the program to the controller.
This is necessary because as soon as the program is downloaded to the controller it is going to open or close the blinds depending on whether it is light or dark outside.
Once the program is downloaded and the blinds have either opened or closed automatically you will need to either cover the LDR or shine a bright light (use a flashlight) on it to make the controller operate.
Adjust the Open and Close pause times in the program to make the blinds stop in the fully open and closed position.
I manually set the open position and only adjusted the close pause time to get the blinds to close fully. It may take several cycles of this to get the controller to stop in the desired fully open and fully closed position each time.
My controller still gets off a bit over the course of a couple weeks or so of opening and closing, but a quick tweak of the adjustment buttons on front of the controller gets everything back where I want it.
You could use a 360 degree servo motor or a stepper motor instead of the gear motor I used. I am sure this would result in much better position accuracy but the cost of the project will increase significantly. With the money I saved using the cheaper gear motor I can build two more complete controllers for my living room and just manually tweak them every 2 or 3 weeks.
Alternate Setup Method
However, easier is not always better so read this carefully before you decide which method you want to use.
This alternate method requires that you open the blinds and use the position adjustment switches to set the open position exactly where you want it. That's it. You are finished. The setup is complete. However, you need to know that this method will possibly shorten the controller's battery life with the additional unecessary motor operation.
If you decide to use this method, you may want to increase the close pause time in the program by a thousand or two (1-2 seconds of motor run time). This will insure that the blinds close completely. This won't present a problem for the blinds or the controller. Most blinds can be turned several more turns after the blinds are actually closed with no problem and the gear motor has a slip clutch built in to prevent ripping its guts out in a stall.
Taking It Further
I am not posting this instructable for you to copy my work. I am posting it to give you an idea of one way it can be done. Take what I have done, add your own ideas, and make your own project. I would love to see the improvements and changes you come up with. Here are a few options, changes, and modifications I have thought about using with this project:
BUILD IT CHEAPER - You could use 3 AA batteries and forget about the voltage regulator, solder wires directly to the battery holder and eliminate the battery snap, solder the ICs directly to the proto board without solder tail sockets, program the PICAXE on a starter pack proto board and leave the 3.5mm stereo jack and 2 resistors out of the finished product, and use an Altoids can or other salvaged enclosure instead of the plastic project box. If you could also find a suitable salvaged motor you could build this project for less than $5.00.
USE IT AS AN ENERGY SAVINGS DEVICE - It would be very easy to adapt this project to help save energy and money by reducing your heating and air conditioning costs. The controller could be adapted to close your blinds in the summer during those times of the day when the sun shines directly in your window. This would cut down on the heat that enters the room. You could even add a temperature sensor so it would keep the blinds open during the peak sun times in the winter but close the blinds during those times in the summer.
USE SOLAR POWER - You may want to consider using rechargeable batteries and a small solar panel to operate your controller. This should work great if your window gets direct sunlight. My window does not so this was not an option for me. Using 4 rechargeable AA batteries would also eliminate the need for the voltage regulator as rechargeable batteries only deliver 1.2 volts compared to the 1.5 volts regular batteries deliver.
POWER THE CONTROLLER WITH 120 VAC - If you don't mind having a cord hanging down from the controller you can use a 7.5 DC or greater volt wall wart (power supply) to power the controller. You could always use a cord the same color as the blinds and hide it from view between the blinds and window. That way you can forget about changing batteries. The only problem with this option is that whenever your power blinks, the controller is probably going to either open or close the blinds. If they are open when the power blinks it may try to open them again and the software won't prevent it. I wish I could figure out a way to prevent this I so far I have not. Maybe you can figure out a way to do it. A better way of doing this would be to power the controller with a wall wart and a small backup battery.
USE AN IR REMOTE CONTROL - It is a simple matter to convert this controller to operate using an old universal television remote programmed to send Sony codes. You just leave off the LDR, add an IR receiver and capacitor, and make a few minor changes to the software and presto - an IR remote control blinds opener.(See the options schematic and/or metafile below) I started out with opening my blinds by remote control and closing them automatically but found it impractical for my use. I have tried to figure out a way to allow the controller to operate using either method but hit a brick wall. The command that receives the IR signal locks the PICAXE up tight and won't do anything else until it receives a valid IR signal. I could not figure out a way to get around this but maybe you can. I think that would offer the best of both modes if it can be done.
USE DIFFERENT MOTORS - As I mentioned earlier, you could used a 360 degree servo or a stepper motor and get much better precision. For me, the cost of the other motors just isn't worth it but that may not be the same for you. You may already have a servo or stepper you can use. It would only take a few minor changes to the program to make it work so if you have them or want them then go for it.
ADD AN ANALOG MOTOR RUN TIME ADJUSTMENT - I have thought about adding a 100K pot, using the ADC command on an unused PICAXE input pin, and using the resulting data variable to make adjustments to the motor run time without having to reprogram the PICAXE with a computer if I want to change it. You could do something like letting the ADC data from the pot = b5 and then using a command like pause b5 to control the motor run time. You would probably have to use another command like let b5= b5 x 100 or something to get the time into the needed range. (See options schematic and/or metafile below)
MAKE THE LIGHT SENSISTIVITY ADJUSTABLE - Replacing the 100K in the LDR ADC circuit with a pot would allow you to control the light sensitivity without having to reprogram the PICAXE. This along with the motor run time adjustment above would allow you to control all critical functions without a computer. (See options schematic and/or metafile below)
USE A DIFFERENT MICROCONTROLLER - This controller would be easily adapted to nearly any microcontroller. I use the PICAXE because of its ease of use, versatility, and low cost. The PICAXE -08M only costs about $3.00. Some microcontrollers can cost 10 times that much and more. I just cannot see me putting $30.00 worth of microcontroller into every project I build. I want to keep it simple and I need to keep it inexpensive. The PICAXE is hard to beat in these two areas. Using a regular PIC would be even less expensive, but that would require that I buy a $40.00 or more PIC programmer. Even worse, I would have to learn to program in C. I think I would rather have a root canal.
ADD A LOW BATTERY INDICATOR - Because this controller is actually an important factor when it comes to my home security, I am planning to add a low battery indicator circuit to my unit. There are quite a few under voltage components available that would be suitable for this purpose. Adding one should be a very simple matter. Right now I am monitoring the battery voltage of my unit to see exactly what voltage things start going crazy at. When I get the details worked out I will post the schematic here.
USE THIS PROJECT TO CONTROL ANOTHER PROJECT - Using the IR transceiver functions of the PICAXE -08M it would be very easy to use this blinds controller to operate another 08M based project. Adding an IR emitter to this blinds controller and an IR receiver module to a different controller would allow you to do all sorts of things. You could turn on a lamp or nightlight when the blinds shut in the evening or you could turn on a radio or coffee maker when the blinds open in the morning. If you have multiple windows in one room you could make one controller a master with an IR emitter and the others slaves with IR receiver modules so that when the master opens or closes its blinds all the other blinds in the room do the same at the same time. The possibilities are truly infinite.
.
Go Green With Solar
(1) Solar Cell (6V, 50mA) #277-1205 $15.99
(4) AA NiCd Batteries (1.2V, 700mA) #23-9033 $15.96
(1) 1N4001 General Purpose Diode #276=1101 $.99
TOTAL $32.94
See what I mean. Converting this project to solar increases the price from around $15.00 to almost $50.00 per window.
DO THE MATH - The batteries in my controller last somewhere around 5 weeks before I need to change them. I buy brand name batteries in packs of 24 so they cost me around .40 cents each. The controller takes 4 of them so it cost me $1.60 every time I change them. Figuring I change them one time every 5 weeks that means I can change them 20 times (almost 2 years) for what the solar option will cost. And before you start thinking that after 2 years your controller is going to operate for nothing, you need to realize that the life of NiCd batteries is only around 2 years when they are charged and discharged at regular intervals according to the manufacturers recommendations. That is not going to happen with this project so the NiCds are probably not going to make it much beyond 1 year before they need replacing.
As you can see - going solar sounds good, but not many people really want to make the initial investment or deal with the long term disadvantages. If you go green you probably need to do it for more noble reasons than saving money.
If you are really serious about going green, you need to forget about building this controller, and just open and close your window blinds by hand.
.
Similar Circuit for Use With Window Shades
Downloads
Make, Hack, and Enjoy
Watch a Youtube Video Of This Project
.
Thanks
I hope it will inspire you with new ideas of your own.
As Thomas Edison said,
"To invent you need a good imagination and a pile of junk".
Thanks Again,
Randy
.