Automatic Blind Opener Using EV3
by TJSBear in Circuits > Gadgets
900 Views, 3 Favorites, 0 Comments
Automatic Blind Opener Using EV3
I have a set of roller blackout blinds in my bedroom which I often forget to open or shut in the morning or the evening. I want to automate the opening and closing, but with an override when for when I am getting changed.
Potential Ideas or Solutions
After looking on various sites such as YouTube, Instructables and Thingiverse I found that the most common solution was to motorise the spool that wound and unwound the blinds using a stepper motor or a servo. I found 2 main options with various advantages and disadvantages.
Idea 1: Spool method where the motor and gearing is housed inside the spool. This has the advantages that it is a neat and elegant method, but has the disadvantages that it requires major modification to the blind, the cord is no longer usable, and the assembly would be very difficult to access for maintainance when implemented.
Idea 2: cord method where the motor and gearing is housed on the cord. This has the advantage that it is simpler and the assembly could be easily accessable. However it has the disadvantage that it could be ugly and bulky, as well as the fact that it has to be attached to the sill when implemented.
I prefer the cord method as is a much simpler solution that does not inhibit the manual use of the cord, and the blind will not require any major modification. I plan to make it as covert and compact as possible when I make the final version with an ESP8266.
Making the Assembly
I did this project using my Lego mindstorms EV3 which has functionality I need to show the project could work, and I am familiar with the software which definitely helped a lot. Since the blind uses a ball chain to drive the spool, which Lego gears are incompatible with, I decided that the best solution was to design a gear with the correct ball spacing on the outside- with the standard “cross-shaped” hole in the centre, where I would then 3D print the design. At this point I also made a calibration button and attached a light sensor to my window as well as button to act as the override.
Designing the Blind Gear
I disassembled the blind to see how the crank looked in more detail. During the disassembly I found a small 16-tooth gear which was held in place by a tensioned coil, this was the part I was looking for. After designing a replica of the gear, I added the required Lego-compatible holes, printed the 3 separate parts and finally bonded them together with superglue. I had initially problems with making the part Lego compatible, in the sense that my 3D printer hadn’t the resolution to make the “x” hole sufficiently, however it had no problems with the circular holes either side of it. So I replaced the “x” with a circular hole and it printed fine. Then, after a small amount of testing I could see that it could handle the torque and the weight from the blind. I will link my designs for the gear below or you can find it on Thingiverse at: https://www.thingiverse.com/thing:4101263
Coding the Blind
I wanted code that would automatically open and shut the blind when it got to a specific light level, but that also had an override button so that one could still open or shut the blind when they wanted to. I have linked my GitHub with the final version of the code here:https://github.com/TJSBearGithub/AutomaticBlindEV3Code
The code for the project took me several days to complete, I had the basic logic of the program working correctly with the light sensor, however the momentary override button was not functioning correctly. It did alter the state of the blind upon being pressed, but it lacked the “latching” function that would mean the blind would stay in the position- meaning the blind would immediately roll it back to what it was before. I fixed this using a “wait until” block, linked to a logic OR gate that read the values of the light sensor and touch sensor, which I will explain below.
The code starts by calibrating the motors and blind, starting with the blind fully open and lowering it until it hits the touch sensor at the bottom, counting how many quarter turns it takes to get to the bottom, which is saved as the “RotationsNeeded” variable. Then it writes "false" to the “BlindOpen” variable which is used to track the position of the blind. At this point the code splits off into 4 loops.
One of these loops is the “Buttonstate” loop which continually publishes the state of the button to a variable called “ButtonPressed”. This eliminates the need for multiple button blocks to be placed on the script.
The second loop is the “Light or dark” which continually compares the light level outside my window, to a constant defined earlier in the code. If the result is below that constant, the loop will write “false” to the “ItIsLight” variable, whereas if it is above the value it will write “true”.
The third loop contains a numerical list of 3 options which basically tells the blind what to do, 0=blind down, 1=blind up, 2=do nothing because blind is in the correct place. The loop starts by reading the “BlindShould” variable which specifies the correct task the blind should be doing, then carries out that task, alters the “BlindOpen” variable to the correct option and then becomes idle until the “BlindShould” variable is changed where it repeats. It uses the “RotationsNeeded” value as well as a +/- 100% power to move the blind fully open or closed.
The fourth and final loop is the most complex, it is the “Decider” loop which handles all of the data and decides what to do with each permutation. It does this by using logic based “forks in the road” where "button is pressed", "Light level", "Blind open" are the true or false questions. All of the permutations have a hard coded response, which is either 0=blind down, 1=blind up or 2= do nothing - this value is written to the “BlindShould” variable which is then handled by a previous loop. Some responses will then wait for either the “ItIsLight” and/or “ButtonPressed” variable to change before finishing the script, this is only the case for the button activated permutations as otherwise it would immediately try to correct its position meaning the blind would return to its original state. This process is then looped to make a robust and relatively simple automatic system, which can easily added to and be debugged. Phew.
Downloads
Finishing Touches
I decided afterwards to wire up a 9V power supply to my EV3 using using some wooden dowels and screws as "batteries", this made the product unreliant on batteries and prevented me from having to change the batteries every couple of days.
Evaluation of the Project
I think that the project went well overall, I ended up with a working prototype for the Automatic blinds assembly, which I can take all of the relevant information I found during the project and implement into the final version. I successfully coded the device, and later have found no major issues with the code so far. I would have liked to make the device more visually appealing but once again it is a proof of concept and I will be putting some effort into making it look good when I make the final version with an ESP8266. When I do the project again I will design the motor to sit inside the blind as that would be easier to conceal. The biggest lesson I've learnt is to debug logically and think through, document and test my code before I implement it.