Introduction: Picaxe Servo PCB for Dimmer Switch

About: I wish I could change my screen name
Do you want to be able to control your window blinds via the web, with your cell phone or with a remote control?  (NO!) Me neither.  Although those are very cool ideas, what I want is a switch on the wall next to my light switch.  I've designed a PCB that replaces the one found in a Leviton dimmer switch to turn it into a servo controller.  I'm also giving you the design and showing you how you can make your own.


Note:  I'm not going to get into mounting the servo into the window blind.  There are too many variables and each install is going to be unique depending on the servo and the blind.  Plus, there isn't much to tell.  The servo dropped right in after making a simple mount bracket and adapter.





Step 1: Materials

Supplies

Leviton Dimmer Switch

Radio Shack Parts
1/8" Stereo Panel-Mount Audio Jack (Option A)
Size K Coaxial DC Power Jack
Copper-Clad PC Board

PICAXE-08M Servo Driver Kit - AXE024 (Option 1)
   I purchased the above kit for convenience but you don't need all the components that come with it so it's probably wiser to purchase the following components separately.

PICAXE Components (Option 2)
   8 pin IC socket
   PICAXE-08 microcontroller
   22k resistor (red red orange gold)
   10k resistor (brown black orange gold)
   330 resistor (orange orange brown gold)
   33uF tantalum capacitor (2 required)
   100nF polyester capacitor
   1N4001 diode
    3.5mm stereo socket (Option B)

6V Regulated Power Supply

Misc
   Jumper Wires - you'll need four.  You can make your own or purchase something like this.
Servo wire or a light gauge 3 wire wire

If you haven't used PICAXE before, you'll also need to download their free software and purchase a download cable

Step 2: About Leviton Dimmers and Programming Socket

On my switch, I placed the download socket on the face of the switch so I could re-program the PICAXE without removing it removing the switch from the wall.  I refereed to this as "option A".  I started with an old Leviton switch and when I saw the hole for the led, it seemed like a natural thing to do.  The problem was, it was Ivory and I wanted white.  I bought a new white Leviton switch and noticed the plate was different.  The new Leviton switches have a smaller hole for the LED to make room for an on/off switch.  Fortunately, the parts were interchangeable so I used the old plate with the white switch.  

Long story short, it's going to be hard to find a white switch that will easily allows for a face mount download socket.  There is an alternative...

Option B - the PCB allows for a board mount socket the same way most PICAXE boards do.  If you do this, you will have do drill a hole in the switch housing as shown in the last image.  This is a cleaner look and once you have a solid code, you shouldn't need to reprogram the chip anyways.  If I make another one, I'll use this option.

Step 3: Getting Started

Attached is a zip folder containing every drawing format I could output.  You will need to find one that works with your software.   If you have made your own PCB before, you are probably off and running.   If you haven't made a PCB before, I'll walk you thru how I did it.  This was my first time.  I gathered a lot of information from the following sites:

http://fullnet.com/~tomg/gooteepc.htm#1
http://www.riccibitti.com/pcb/pcb.htm
http://www.youtube.com/watch?v=Q6WJqjVleG0

I'll still walk you through my experience but I encourage you to look at those sites.

Start by printing the image onto a magazine page using a laser printer.  The magazine page should be one that has minimal ink on it.  Tape the magazine page to a piece of printer paper to help support it through the printer.  When you print, you are trying to get as much toner onto the magazine page as possible so turn off the toner saver and put the quality to the highest settings.  Also, make sure you don't scale the image.

Step 4: Transfer Image to PCB

This was the hardest part for me.  It took me about 10 tries to get this to work properly.  Fortunately, I was able to cut 5 blanks from the copper clad and if you screw up, you can clean off the blank and start again.  What ended up working was to tape the image to the copper clad and to the table.

Using a hack saw or band saw, cut the copper clad to a size a little larger that the print.  Scrub with scotch brite until it's shinny then clean with acetone.

Center the image on the copper clad, fold at two ends and tape.

Turn over and tape other two ends to table. 

Use an iron on it's highest setting and use pressure.  I tried to use pressure alone but it didn't work well.  I had to go back and forth smoothly to heat everything evenly.  This can be tricky because if you press too hard while you are sliding the iron around, the image can move and you have to start over.  I can't give you an exact procedure but it was about two minutes with the iron.

IMPORTANT:  It seemed to be important to not have the tape over the copper clad where the iron is going to be.  On my previous tries,  I taped right across the middle of the entire board.  The area under the tape heated up differently than the other areas and I didn't get a good transfer.

When you are done with the iron, don't peel back the paper.  I know it's tempting but it's better to put it in soapy water and let the water dissolve the magazine page.  It's dissolves very easily in water (that's why we use it) leaving behind just the toner.

Step 5: Small Fixes and Disolve Copper

Fix small flaws with nail polish and a toothpick.  I've actually seen a video where a guy laid out an entire board with nail polish.  Remember, we are trying to complete a circuit so it doesn't have to be pretty.  Electricity can go around corners.

After the polish dries, put the board in etching solution and keep it moving.  I used an old lunchables container to hold my etching fluid.  The extra compartments came in handy to hold my toothpicks after being in the solution.

Learn from my mistakes... I didn't keep it moving and the board was sitting in the solution on an angle.  When I checked on it, the top was clear but the debris from the top rolled down the board preventing the lower portion to etch.  Think of the board covered in wax.  If you heated it evenly, the top would still clear first and then slide down hill covering up the bottom.   So, you need keep agitating it.  Some people create bubbles from a fish tank air pump to accomplish this.

Don't leave it in the solution any longer than you need to.  When you are done with the etching, you can clean the toner off the board with acetone or a jack hammer.  JK

Step 6: Take Apart Dimmer and Save Parts

There are 4 screws holding on the housing.  Remove these. 

De-solder sliding potentiometer. 

I'm not going to show a schematic using a voltage regulator but this board can accept one.  If you want to use different voltages and use a voltage regulator, you can de-solder the voltage regulator socket. 

Step 7: Drill Holes

To drill most the holes which are .8mm,  I purchased a carbide tipped drill set off of ebay for about $20.  Attached is an image describing the unique holes. 

Cut the board to size using a table saw or hack saw.  Cut away the inside copper line running around the perimeter.

After drilling the 3/8" hole, I used a nibbler  to form the square hole for the power jack.

Now is also a good time to make the modifications to the switch housing.  The switch housing has two small slots for wires to pass through.  We need to open on up to the same size as the power jack hole on the PCB board.  The other slot will allow the servo wires to pass through.

If you are going to use "Option A" download socket, you need to make a hole in the switch cover.  Turn the switch cover over and you'll see a local think area where the LED used to be.  Drill out the depression slightly larger that what it was.

If you are going to use "Option B" download socket, you need to make an additional hole in the housing.

Step 8: Solder in the Components

Use the attached schematic to position the components.  The pdf is scaled the same size as the board so, if you wanted, you could print and iron this directly onto the top side of the PCB.  I got so excited assembling this that I forgot to take pictures so I'll supplement with some CAD images.

Step 9: Finished

Now you need to assemble the switch, power it up and download a program.  For the motorized window blind, I'm using the following code. 

'pins
symbol myservo = c.1 'rename pin 1 to "myservo"
symbol mypot = c.4 'rename pin 4 to "mypot"

'variables
symbol currentpot = b0 'pot position
symbol moveservo = b2
symbol invert = b4 'invert pot value
symbol oldposition = b6 'old position servo values
symbol myloop = b7
symbol potmax = b8
symbol potmin = b9


'constants
symbol servolow = 60 'lower servo limit
symbol servohigh = 240 'upper servo limit
symbol repeat = 100 'number of loops to kill time


idle:
readadc mypot, currentpot 'read pot
if currentpot < potmin then 'if change in position then...
  goto active  'goto active
elseif currentpot > potmax then
  goto active
  endif   'otherwise...
goto idle   'repeat


active:
gosub scalesub  'calculate servo position
servo myservo, moveservo 'turn on servo and move it
for myloop = 1 to repeat 'loop to let servo move
readadc mypot, currentpot 'moniter pot
if currentpot < potmin then 'if change in position then...
  goto active  'goto active
elseif currentpot > potmax then
  goto active
  endif   'otherwise...   'otherwise...
next myloop    'loop to kill time
low myservo    'turn off servo
goto idle


scalesub: 'input currentpot / output moveservo and reset last know position
potmax = currentpot + 1
potmin = currentpot - 1
if potmax = 0 then
  potmax = 255
  endif
if potmin = 255 then
  potmin = 0
  endif
invert = 255 - currentpot 'invert values
moveservo = servohigh-servolow/15*invert/17+servolow 'scale pot values
return




I've attached the 3D data in it's native form (Catia V5 R19), STEP and IGES.  If you want it in a different format, you can download it from this site.  You'll have to sign up (free) but it'll give you an option to download it in any format you want.

If there is a lot of interest, I can do an instructables on how to mount the servo in the blinds.  Because my blinds are 2" , the servo I used, HITECH HS-225MG,  fit in the blind housing with no modification to the housing other than two screw holes.   I think a 1" blind is more common and there are other instructables out there on how to accomplish this. 

I hope I did a decent job.  This is many firsts for me.  First Instructable, first time etching a PCB, first time using a microcontroler, first time using a servo.  Maybe I'm not qualified to publish this.

ShopBot Challenge

Participated in the
ShopBot Challenge