Friday 1 December 2023

Pulled a blinder and then curtains.

We have a roller blind behind plantation shutters in our bedroom to block out the light. To get a better light seal I mounted it back to front, close to the frame of the shutters. That means the ball chain chord that raises and lowers it is a bit awkward to use as it partly behind the blind.

Some blinds are geared, so that the pulling force required is less, but ours isn't. It is six foot long and I also added some steel balls to the tube that runs along the bottom to make it hang straighter. Therefore it needs quite a strong pull to raise it, so I always had a plan in the back of my mind to automate it and in August I finally started working on a design.

I have a random collection of gearmotors, so I pulled out one that seemed about the right speed and torque and printed a pulley to mesh with the ball chain and fit the shaft.

Short Heatfit inserts that I bought from Stefan at CNC Kitchen are great for printed gears and pulleys.

A quick test with a battery showed it easily had enough torque to raise the blind, taking only about 200mA at 12V, but the ball chain likes to jump out of the pulley. It would need an impractical amount of tension on the chain to keep it in, pretty obvious really given the shape of the pulley teeth.

My solution was to trap the chain between two such pulleys and use the second to drive a threaded shaft with a nut that slides along it and triggers limit switches. The up limit switch is adjustable on a slide mount to fine tune the opened stopping position. The down switch is fixed but I can adjust the idler pulley on the shaft to adjust that limit first.

My original plan was to use 6mm studding in 6mm bearings but I found that it was a very loose fit, so I use 8mm studding and turned shoulders on each end to fit the bearings with my CNC lathe. I used a collet in the spindle nose to avoid marring the thread.

I tested this with a two way / two pole toggle switch to set the motor direction and the limit switches wired in series with diodes to bypass them, so that the motor can only back away from either switch once triggered. I mounted it to the wall with a printed bracket and was able to test the mechanism worked mechanically and seemed reliable.

For the electronics I decided to use an ESP8266 module running Tasmota firmware and control it from my Home Assistant server that runs on a Raspberry Pi MK4. In Home Assistant the blind just looks like two switches, open and close. I set up automations to open it at 8 AM and close it at sunset. Tasmota is configured with two interlocked relay outputs with timeouts and two buttons for manual operation. 

To drive the motor I had an L6203 full bridge driver chip lying around from RepRap days but I can't even remember where it came from. It's rated to 3A, so overkill in this application but I haven't had any use for it in about 14 years, so I thought I might as well use it up. The only problem was its package is a Multiwatt11 that doesn't have its pins on a 0.1" grid. I found I could fit it on a perfboard at 45° but it was looking like the electronics were going to be embarrassingly large compared to the mechanism. 

Around the time I was thinking about this a member of the marketing department of PCBWay coincidentally left a message on my blog offering free PCBs in return for a review, so I decided to take them up on their offer and use a PCB to make the electronics much smaller than I could make it on perfboard.

It is about 10 years since I last designed a PCB. For one off projects I normally just scribble a schematic on paper and then use perfboard, or for mains projects I use Veroboard and remove all the unused tracks to get enough creepage clearance. It is a lot quicker than designing a PCB with CAD and getting it manufactured and shipped but most of that is waiting time. So PCBs are worth while for more complex projects or ones like this where I might need more than one.

I downloaded the latest version of KiCad, which was more than 1GB! It must have changed a lot since I last used it but seemed fairly easy to use.

It is powered by a separate 12V power supply, so the cable to the window is just figure of 8 flex and it actually fitted through a gap under the shutter's frame. A tiny buck regulator from AliExpress provides 3.3V for the ESP-12F module. 

The limit switches cut the inputs to the H-bridge, so it doesn't rely on the firmware to not crash the blind. In fact, the Tasmota firmware just turns the outputs on for a fixed time that is just a bit longer than it takes to open the blind, about 30 seconds.

I thought it would be a good idea for the state of the blind to be discoverable remotely, so I used the normally open contact of the limit switches to pull two spare ports low. This was a mistake however because the GPIO2 port is connected to the blue LED on the ESP12-F module and is defined as an output, at least during start up. As these connections actually allow the firmware to crash the blind I decided to not connect them and two pin connectors could be used.

The buttons allow manual control of the blind. Pressing once starts the blind moving in the specified direction and pressing again stops it, so you can manually position the blind anywhere on its travel.

The programming connector is only needed once to load the Tasmota firmware because it can be updated over the air after that. So I don't solder it to the board and in fact there isn't room for it in the case.

The PCB design is an odd mix of through hole and surface mount because those are the parts that I had to hand. 

Because I wasn't paying for it I used four layers to simplify the routing. The inner layers are ground and 12V.

I also went for a routed outline because space was so limited that I needed a cut-out in the corner to miss the limit switch. I also only had space for one screw hole, so I printed rails in the case to hold the left side and the front right corner, so rounded corners make it easier to slide into place.

This is how tight the packaging got:

I modelled the board in OpenSCAD because the 3D model from KiCad didn't have the switch positions at the correct height from the board. I could only import it as an STL file whereas with an OpenSCAD model I can query the hole and component positions.

I extracted the component placement data from the footprint positions file that KiCad produced using a python script. This needs a lot more work to make it general though because through hole PCB footprints have the origin on pin one, whereas NopSCADlib has the origin in the centre.

I did all this modelling and the case design while the boards were being manufactured by PCBWay

I uploaded the design to PCBWay on the 12th of September and impressively they were dispatched on the 15th. The quoted build time was  4-5 days. I really liked the way the website shows you which stage they are at in the process as they progress. Four layers involve extra steps. 

Clicking on the "View Details" links shows videos explaining each process step.

I also ordered a solder paste stencil for the surface mount parts and this was made as the last step. I expected it to be made in parallel but it didn't add much to the time as it seems to a be fast process.

The package was picked up in Shenzhen by FedEx on the 16th and delivered in the UK on the 20th, so only 8 days from order to delivery. The minimum order was five PCBs but I actually received six. I think probably they make an extra one in case one fails the quality checks but if they all pass they send you it. I vaguely remember that used to happen sometimes when we ordered prototype PCBs at work.

The PCBs are great quality.  All the features are well aligned and the outline was very accurate as it fitted my 3D printed case perfectly. 

The solder stencil worked well. I forgot that the apertures might need to be smaller than the pads, depending on the stencil thickness, to get the correct amount of solder paste. I just used the default file exported from KiCad and it seemed to give the correct amount of solder.

Here it is populated:

I chose a white solder mask to match the white PLA I used to print the case in case any of it was visible but that wasn't really necessary, green would have been fine.

I used a T-962 reflow oven to solder the surface mount components. It was the first time I had used it since buying it from Elektor a year ago, so I had to apply the upgrades detailed here:

This was replacing the masking tape with Kapton tape, adding a cold junction sensor for the thermocouples and replacing the firmware with an open source version.

I used leaded Chip Quik solder paste on the default oven profile for leaded solder and it worked great without any calibration. I mainly use leaded solder at home because it gives better results. In this case it has the advantage of not reflowing the internal parts of the ESP-12F module, which I assume uses lead free solder.

Here is the finished unit installed. I used white PLA, so hopefully it wont melt in the summer sun.

Flushed with success of this project, my wife wanted me to automate some curtains to keep the house warmer in winter. It was a race against time to get it working before our last holiday.

The gearmotor I used (Nidec GMAG 404 327) was nice because the motor has a transorb mounted on the armature to stop the back EMF from the coils causing sparks, which generate wide band RF interference. I looked it up and found out it now costs £162.36 from RS components, so I looked for a cheaper alternative for the curtains.

I found this DF-ROBOT FIT0492-A from PiHut for £11.40:
It was a challenge to make a gear_motor class in NopSCADlib that can draw both but I manged to do it, with a lot of parameters.

So it is possible to make the blind controller with the cheaper motor, although making the design handle both motors was also tricky because the clash avoiding constraints are different for each motor because their shapes are so different.

I haven't tested this version but it should work. I published the design as a NopSCADlib project here:

I designed a curtain puller around this new motor.

It clamps around the curtain pole, which has a hole drilled through it for the shaft. A length of picture cord goes from one bobbin, around the idler pulley clamped to the other end of the pole and back again to the other bobbin. The curtain rings at the open ends of the curtains are each attached to the forward or return cord so that they move in opposite directions.

The motor shaft has a printed spur gear to drive the threaded rod which activates the limit switches. It also acts as a coupler for an extension shaft to drive the bobbins.

It nearly worked but I ran out of time to finish it before going on holiday. I couldn't get enough grip with the 3mm grub screws because the heads would strip first. I need to replace them with M4 to get more grip. Hopefully it will work then, with perhaps some guides to stop the cords tangling.

I built 12V power supplies using some potted modules cased in a short piece of aluminium box section for fire safety.

To turn the module into a PSU you need to add a mains filter, a transorb and fuse to the AC end and a couple of filter capacitors to the DC end.

In summary, I populated three of the PCBs and they all worked first time. The PCBs were only \$25.97 for 5 pieces in 4-5 days, if I had been paying for them. The solder mask was \$10 in 1-2 days. FedEx shipping \$22.89.

Now that I have got my reflow oven set up I will make more use of PCBs and SMT parts. PCBWay make it very quick and easy to get good quality PCBs for a good price. They also offer PCB assembly, CNC machining, sheet metal fabrication, 3D printing and injection moulding but I haven't explored those. Hopefully I can do my own 3D printing!


  1. Great job, care to share a full components list, and the Gerber file? Never used an oven before wonder if it's worth the investment.

  2. I added a link to the project on GitHub where you will find the Gerber's and parts list.

    1. It is possible to hand solder the board. I did the first one with a soldering iron and fine solder.

  3. It doesn't cost me anything. I signed up to Blogger for free in 2007 and it has since been taken over by Google.