Home‎ > ‎Projects‎ > ‎

Scanner Hack project

I have had this scanner hack on You Tube since August 2009

I have been using this scanner as shown in "Flatbed scanner hack PCB etching assistant part 1" to help me with etching printed circuit boards, I used to just stand over the work bench rocking the pyrex tray back and forth for 10 to 12 minutes while breathing in the fumes, now that might sound like fun but when I make my boards I try to make 3 or 4 different boards in the one day to make the best use of my PCB developer and etching solutions, so once  the board is etching I start to set up and expose the next PCB.

This is where this scanner hack comes into the picture
I had found a few large old scanners on the side walk  now the old scanners were built like tanks, very heavy and large but inside they still could only fit an A4 page.
Most have a parallel interface with another pass through parallel port, some very old ones have SCSI ports and a few had USB but most now are of the very slim type and all use USB, the slim type are not good for hacking  they just dont have enough oomf and are very flimsy.
I had put a couple of the TANK scanners aside until I could think of how to make use of them, I had a look around You tube and found some people gutted them keeping only the case and glass to make into a Printed circuit board UV exposure unit, now thats fine but i already had made my own UV exposure unit as well as a light table for inspecting PCB artwork and etched boards.
Looking at the heavy duty scanner arm moving back and forth I wanted to make use of all that great drive train in the scanner it had 3 gear stages and a belt drive, a guide rod on one side and a plastic wheel on the other, the scanning arm was nice and wide so I tried putting some weight on the arm while turning the first gear, the arm moved without the belt slipping, the belt will slip if the arm cant move, this is a clutch made using a spring to hold the last part of the belt drive so if to much weight is put onto the scanner arm the spring will compress and cause the belt to slip, this feature protects the plastic gears from having their teeth stripped (OUCH).

                               Here is Part 1 of the scanner in action on You Tube

Flatbed Scanner Hack part 1

I then started to increase the weight on the arm one kilogram then two, just after 2 KG the belt slipped as i turned the first gear so that was the limit.
The next step, how was this back and forth action going to help my PCB etching or did it need to rock up and down like a see saw, so I removed the belt from the drive so the scanner arm could move back and forth freely just riding on its guide rod and plastic wheel, I then set up my pyrex dish and poured in 250 ml of water this is the same amount of solution I use to etch a 4x6 inch PCB and started to slide the scanner arm back and forth trying to set up a nice wave motion.
After playing with this setup for an hour I found that the scanner arm does not have to move in large strokes, a small stroke then a sudden stop and reverse direction is what it took to set up a smooth wave motion without splashing any liquid.
This wave motion is destroyed if to much liquid is used so you will have to experiment with your size of dish, now I had an idea of what it would take to set the solution in motion and get that nice wave action going.

Now came time to work out how to drive the stepper motor, in the 2nd You Tube video I open up the lid to show the electronics that drive the stepper motor as well as the optical sensor to act as a limit switch.

Flatbed Scanner Hack part 2

Why do we need to have a limit switch?
well lets skip ahead a little and talk about this, if you look at the scanner you will find an optical limit switch, in my scanner this limit sensor was on the moving scanning arm and at the end of travel the sensor beam was broken by a plastic tab but on other scanners the limit sensor might be fixed to the frame and as the scanner arm moves toward the sensor it breaks the beam. 
                                    This is what the sensor looks like on my unit

This type of limit sensor is called an infrared photo interrupter, you can use the one you find in your scanner but mine was part of the scanning arm and i could not remove it in one piece so I used one from an old HP laser printer I found.
The reason the limit is there is because with all the plastic gears used in the drive train we have a fair amount of play or slack as the gear teeth mesh together, try twisting the final stage gear, that will be the large gear the belt is connected to, twist back and forth with your fingers and you will find there is play in the gears.
On my scanner the motor is held on a metal frame with two screws, I was able to loosen the screws and bring the motor a little closer to it's first stage gear so now there was less play in the gears, don't over tighten the screws as this can cause the gears to bind.

When the scanner is scanning a page it does so in one direction, as long as it's moving in one direction the slack in the gears is not an issue but when the arm changes direction the slack means that a small amount of error has now introduced itself so it's as if the stepper motor has missed a few steps, now the scanner arm needs to return to it's start position so it's ready for the next scan this is why the sensor is there so it stops in the exact position it needs to. If you have a working scanner and you try to scan a page you will find that when you turn on your scanner it will move forward a little then come back to it's sensor, this is just to make sure the scanner head is in the right position and that the slack in the gears has been taken up.

When we mod our scanner we want to move back and forth all the time so we need the sensor to act as a limit switch, for example we move until the limit is hit then move back for about 255 steps then move back the other way again until the limit is hit, this way we count steps in one direction and just wait until the limit is hit in the other direction, the slack or play in the gears is now not an issue, without the sensor the error due to gear slack will build up to such a point that the scanner head will crash into the the end wall of the scanner case, it will be out of control and not know it's position.

In the second You Tube video you can see I have mounted the optical sensor to the base of the scanner on a small PCB but you could also have it mounted on your main driver PCB, I did it this way so i could play around with the position, a small plastic tab was then glued to the moving scanner arm so it blocks the sensors infrared beam at the end of travel, if you look at the first video you will see the scanner arm only needs to move a few centimeters to set up the wave motion.

If you like you could use a mechanical limit switch instead of the optical type and this is shown in the diagram below,
position the limit switch so that the scanner arm can contact the switch.

                                                                  Click on the diagram to enlarge

                                                                  Electronics to drive the Scanner

Rather than just show the circuit I used lets break it up and start with the stepper motor and the driver circuit, to drive the stepper motor we are going to use the ULN2803 eight darlington array IC.
By using this IC in the way shown below we only need to use 2 output pins of our microcontroller to drive the stepper motor.

                                                                  Click on the diagram to enlarge

You will notice that inputs 7 and 8 are not used so if you like they can be used to drive a relay or solenoid etc anything up to 500mA or you can even tie the 2 inputs together and tie the 2 outputs together to drive up to 1 Amp at 12 volts, drive the input pin high from a spare output pin on your microcontroller to turn on a relay for example.

Most of the large old scanners are driven from 12 Volts Dc, to keep my power circuit simple
I just used a 12 Volt DC plug pack to supply the stepper motor then this goes to a +5 Volt regulator to supply the microcontroller and the +5 Volt part of the 2803 driver.
For the Zener diode I used a 1 watt type but 400mW will do as well, resistors are 1K Ohm 1% 0.5 watt type but 5% carbon is fine.

In this first diagram i have not shown the microcontroller so you can adapt this circuit to any micro you like, in my version I use the Picaxe 08M this is the 8 pin device and is perfect for this project, we use 2 of the output pins on the picaxe to drive the stepper motor and we use one of the input pins to monitor the optical limit switch, two spare pins are left on the Picaxe 08M and they can be used to perform additional tasks that I will show in the future.

   The stepper motor

Most scanners I have taken apart use 5 wire unipolar stepper motors, the driver circuit above will drive a 5 wire or a 6 wire stepper.
In the case of a 6 wire stepper motor each center tap power wire is brought out rather than tied together internally as in the 5 wire version, just tie together the two power lines of the 6 wire motor and treat it as a 5 wire motor.

Ok time to have a look at the stepper motor diagram

                                                                       Click on the diagram to enlarge

The first item to get out of the way is to separate the five wires, one of the wires will be the center tap power wire and then two wires for coil 1-3 and another two wires for coil 2-4.
Before you do anything lets just try our luck, have a look for a model number on the motor, you might have to remove the motor to see this number and enter this into a google search
If luck is on your side you might find some data on your motor that shows the color of each wire and what each wire does, for example    red        common power
                                                                        brown     coil 1
                                                                        black      coil  3
                                                                        orange   coil  2
                                                                        yellow    coil  4

If you can't find a motor model number then we need to use a multimeter to measure the resistance of the wire pairs, with 5 wire motors we can only find the center tap power wire
so that's one out of the way.
Now we could just guess and say that the red wire is the power wire but this is not always the case, lets use a 5 wire stepper motor i have and try to find the power wire.

Lets take the brown wire first, measure the resistance across the brown and black wires
brown - black    = 153 ohms         now lets do brown and orange
brown - orange = 153 ohms         next we try brown and yellow
brown - yellow  = 153 ohms         next take brown and red
brown - red      =  76.5 ohms        so this tells us the power is red or brown

lets keep going,   take the black wire and the orange      black - orange  = 153 ohms
                            now black and yellow                           black - yellow   =  153 ohms
                            and black and red                                black - red        =  76.5 ohms
                            so again the red wire had about half the resistance, it's starting to look like red is the one but just to make sure we can keep going so lets take the orange wire and the yellow wire    orange - yellow  =  153   ohms   and now orange and red
                                  orange - red       =   76.5 ohms   so the red is the center tap power wire, this is the wire we feed +12 Volts into.

Unless we found the motors model number and data in our google search then we now have 4 wires left to work out but we can't use the above method when the motor has 5 wires, but if the motor has 6 wires coming out you can use the above method to find each coil and each power wire, in this case just tie the power wires together and call one coil set 1-3 and the other set as 2-4.

Now back to our 5 wire motor.
There are a few ways I found online to help work out the coil pairs but here is one way I used and it seems to work for me.
I used a 6 volt battery but you can use a 12 volt or even a 9 volt for this test
lets put aside the power wire (red on my motor) as we wont need it for this test
take two of the wires say the brown and black wires, touch one on the + of the battery then while holding your thumb and finger on the shaft touch the other wire on the negative and keep removing and touching, if the motor jiggles each time you touch the negative then the two wires are from the same coil pair so lets just call this pair 1-3
so the other 2 wires we can call pair 2-4.

If for example we took the brown wire and put it on the + of the battery, now I take the yellow wire and put it on the negative, the motor might make one step but each additional time i touch the negative the shaft does not move so this tells me the wires are not from the same coil pair.

For now it does not matter that we call one pair 1-3 and the other 2-4 but once the software is working and we tell the motor to go forward but it goes backward then we just reverse the pairs or we can just change the software so the scanner arm travels in the direction we want.

Wow that took a long time to just work out the wires but if all that made you dizzy then don't worry about it, as long as the power wire is correct then it's not hard to fix any problems.
Once the microcontrller is working and we tell it to go forward but the motor just vibrates that means that our wire pairs are wrong, just leave the wire in coil 1 and swap around coil 3 and 2 now the motor should work.

                                                                            The microcontroller

The final part of our circuit is the microcontroller, You could use any type of micro to drive the scanner as it just uses two output pins to drive the stepper motor and one input pin to monitor the limit switch.
My first love in micros was the Picaxe 08M, this is a very simple and low cost easy to program micro
it does not even need a special programmer and is a great starting point for anyone, as your projects get more complex
you can go for the more powerful picaxe chips, lets have a look at the picaxe circuit.

                                                                   Click on the diagram to enlarge
In the above diagram we find a simple +5 Volt fixed regulator circuit that is run from the original scanner plugpac or if you dont have the original then any +12VDC plug pac that can supply from 500mA to 1 Amp.
The Picaxe and the driver IC need +5V and the stepper motor is run direct from +12V

The In circuit serial programming header and its two resistors must stay with the picaxe at all times and dont forget to fit a 100n (0.1uF) bypass capacitor across the supply pins of the picaxe to help with noise on the circuit.

as I used output 0 to drive one of the stepper driver pins I need to add a small 2 pin shorting block to Isolate this pin from the driver IC while I'm downloading my program into the picaxe.
This Output pin 0 is a shared pin on the Picaxe 08M, its also the Serial output pin when a program is loaded
so we should remove the shorting block when loading a new program and the put the block back in place when ready to run.

Our 08M Picaxe has 8 legs and you will see that legs 1 and 8 are the +5V power.
Legs 2 and 7 are used for the in circuit serial programming
after this we dont need to refer to legs anymore but we now refere to the i/o pins of the chip
lets go back to leg 7, when this is not being used to load a program into the Picaxe it can be an Output pin
it is called Output pin 0 and will be used to drive one of the driver pins
next down is leg 6 also called pin 1, this can be an input or output pin but in our circuit we use it as an output
Leg 5 is pin 2 not used in our circuit (for now)
Leg 4 is called pin 3, this pin can only be used as an input pin and we will use it to monitor our limit switch.
Leg 3 is called pin 4 (not used).

The unused pins 2 and 4 can be used later on to drive a relay or an LED or even to monitor the temperature using a Dallas DS 18B20 digital temperature IC.

                                                           Firmware for the Picaxe 08M                                                             

The firmware to drive the stepper motor and monitor the limit switch is super simple but depending on your motor and how far your scanner head needs to move you might need to modify the code  to setup a nice smooth wave motion.
Also before the scanner is turned on, the head should be to the left  of the limit switch but not hitting the limit.

                 'scanner pcb etch table driver program for picaxe 08m version 1.0

                 if pin3=0 then start         'if optical is triggered goto start
                 if pin3=1 then setup       'if optical is not triggered goto setup

                toggle 1                           'move to the right until the sensor is hit
                pause 1                           'wait for 1ms
                toggle 0
                pause 1
                if pin3=0 then start          'if sensor is hit goto start
                goto setup

                for b0=0 to 254
                toggle 0                           'move to the left for 255 steps
                pause 1                           'wait for 1ms
                toggle 1
                pause 1
                next b0
                goto setup

Thats all there is to the software, its just a matter of playing around with the steps and the delay to get it going for your setup, but to start just use the above code and then change it if needed.
look at the       toggle 1
                       pause 1
                       toggle 0
                       pause 1

this moves the scanner head to the right , the pause 1 is a 1 millisecond delay, if your motor stalls try a 2ms delay
if you need to change the pause line be sure to change them all to 2ms.

to move to the the left we change the order to   toggle 0
                                                                           pause 1
                                                                           toggle 1
                                                                           pause 1
if you find you need less steps to set up a good wave motion then change the number of steps number from 254 to around 220 or 200.
The program will keep running the scanner head left and right unil you turn off the power
dont allow very bright light to hit the optical limit switch as this might allow the head to get past the limit and crash into the right side of the scanner case, (yes it happened to me while looking into the scanner with a torch).

OK thats all for now, take a break and look at some photos, click on each photo to enlarge.

View inside with the lid off


Driver PCB and power supply           

IEC power input,switch and all wiring from an old PC power supply

PCB close up, original driver board was also in this position

Original scanner drive train

Optical limit sensor from a non working HP LaserJet 6L printer

From above with lid on

Power supply from an old Linksys router and rectifier board from a canon printer