Reverse engineering those finicky little nylon gears you find in printers

Side note: A summary of something I’ve been using for many hardware hacks in the past while.

A lot of commercial machines use gears for transferring forces. Well, duh. It’s often necessary to change gearing around, though, and it’s nigh-impossible to find commercial solutions with appropriate ratios, tooth profiles, and mounting options. So usually I laser cut my own.

The easiest way to generate a gear that meshes with an unknown is to use Inkscape’s Gear extension. It needs circular pitch, which you find by:

  1. Measuring the gear’s outer diameter, OD
  2. Counting the teeth, N
  3. Getting diametral pitch: (N+ 2) / OD
  4. Calculating circular pitch: Pi / Diametral pitch

For the pressure angle, it’s a little more complicated. You need the base pitch:

  1. Use your digital calipers to measure right down in the gaps of two teeth
  2. Measure three teeth
  3. Subtract the two-teeth measure from the three-teeth one to get a single tooth
  4. Do the same for 5 and 4 teeth
  5. Take an average result of those to get an approximate base pitch measurement
  6. Base Pitch * Diametral Pitch = Pi * Cos(Pressure Angle)

Of course, that looks difficult and error-prone but generally you’ll only run into pressure angles of 14.5 or 20 degrees, so only do rough measurements pick the closest one.

 

For mounting holes, you’ll need to know how far apart to space them. Pitch diameter is what you need: Teeth / Diametral pitch

 

This is a quick summary of everything you need to know. There are a lot of dimensions associated with spur gears, and it’s good to know what’s what, but these are the only ones you actually need to make your own. All of these formulas are unitless, so pick and choose, as long as you match the same unit in Inkscape. I uses inches for these, but I tend to switch back and forth to metric with impunity for everything else.

Rapid PCB Prototyping

Like many (many many) engineering types, I have a goal of easy workbench PCB fabrication. I think I’ve done more research than most, however, and in this case, sharing the wealth means everybody wins.

I’ve posted this up here in its original form, but an updated version will live at the VHS wiki so that everyone can join in. So, without further ado, here are avenues I have approached, intend to approach, or discounted.

Objectives

To design a machine, method, or process to generate one-off printed circuit boards with the following conditions:

  1. Time from finished PCB layout to physical board must be less than 3 hours excluding setup.
  2. Traces for TSSOP packages must be possible (0.19-0.3mm traces, 0.65mm pitch).
  3. Two layers must be supported and properly aligned with minimal frustration.
  4. Board quality must be consistent and dependable.
  5. Minimal tool changes or chemicals.

Methods

Traditional

Toner Transfer

Works. Not well.

The traces are laser-printed in reverse onto some sort of glossy paper (e.g. magazine or photo paper), then transferred to a copper-clad board using a hot clothing iron or t-shirt press. The traces transfer to the board and act as an etch-resist.

Issues:

  • A dedicated clothing iron is required
  • Inconsistent transfer (i.e. gaps in solid areas)
  • Multiple layers are difficult to align

UV Exposure

Works. Not well.

The traces are laser-printed onto clear acetate, then overlayed on a copper-clad board and exposed evenly to UV light. The board is then washed in developer solution that either washes away the exposed portions of UV-sensitive chemical, or wash away then unexposed portion, depending on chemical process used. The traces that remain on the board act as an etch-resist.

Issues:

  • UV chemicals are required to coat the board OR
  • Presensitized boards must be used, which are:
  • More expensive
  • Inconsistent from different manufacturers both in exposure time and development time
  • Require handling in a darkroom
  • Require rushing the process so as not to allow ambient light to ruin process.

Laser Cutter

Spray Paint

Has potential.

The board is evenly sprayed with a single coat of paint. After drying, the laser cutter vaporizes the paint along where the traces should go. Remaining paint is left as an etch resist.

Issues:

  • Laser power/speed must be fine-tuned to vaporize paint layer with excess copper heating (cut paths widen when copper acts as a heat-sink).
  • Paint layer is undesirably thick. May not be an issue?
  • Paint layer is difficult to apply evenly.
  • Vaporized paint leaves a residue that interferes with etching. Clean it with hydrogen peroxide or very very mild acetone bath?

Sharpie

Has potential.

Copper-clad is covered in Sharpie (permanent marker ink). Laser appears to “burn in” sharpie layer and make it resistant to acetone. After acetone bath, burnt in layer is left as etch-resist.

Issues:

  • Layer evenness is very difficult to achieve. Ink bath and rubber rollers will be attempted.
  • Acetone bath dilution must be tweaked.

Sugar

Laser printer toner is effectively sugar as a binding agent and carbon as a colourant. Because colour is unnecessary, sugar alone was attempted to be used as an etch mask.

Doesn’t work.

  • Laser cutter has “air assist”, airstream designed to push slag through the workpiece as it is cutting. It blows the sugar off the copper instantly.
  • Using water to form a paste, still difficult to consistently achieve thin traces.

Toner

Doesn’t work. Bad idea. Not dumb enough to try this.

Issues:

  • See above for air assist issues.
  • Nigh-impossible to work with cleanly.
  • Biohazard.

May be do-able on custom laser-diode CNC platform.

Acrylic Trench

Works. Not well.

Laser etch traces into acrylic medium. Fill etched area with conductive paint.

Issues:

  • Thick traces.
  • High trace resistance.
  • Can’t be soldered onto.

Printers

Inkjet

Works. Not well.

Modify printer to print traces directly onto copper-clad. Use as etch resist.

Issues:

  • Typical inkjet ink is a dye as opposed to a pigment and is water-soluble. Ink cartridge must be filled with special MISPRO pigment:
  • Expensive.
  • Messy to refill.
  • Runny/blurry edges.
  • Double sided boards have alignment issues.

Laser

Works. Not well.

Laser printer can be modified to print directly onto copper-clad. Use as etch resist.

Issues:

  • Larger printed areas have inconsistent fill/gaps.
  • Alignment issues for 2-layer boards and multiple passes to fill in gaps.

Wax Inkjet

Works. Current status unknown.

Jeff Gough had some success with this. A piezo inkjet head (as opposed to a thermal inkjet head) used by Epson printers can be modified with a heated reservoir to print directly with wax.

Issues:

  • Print heads eventually had clogging issues.

Dye-Sublimation

Has potential.

Dye-sub is now available for the consumer market with Canon’s Selphy line of printers. It works through a thermal print head sublimating wax or resin into a gas, then allowing to to solidify onto the print medium. It should work as an etch resist.

Potential issues:

  • Sublimation results in soft edges, may lead to improperly etched traces if print resolution is too low.
  • May rely on special coatings on print medium for ink to bind properly.
  • Water insolubility may rely on final clearcoat layer that is printed.

Thermal Transfer

Has potential.

Similar to dye-sub.

Issues:

  • Printers are expensive, niche, and difficult to find in appropriate sizes.

Thermal Wax Transfer

Has potential.

Similar to dye-sub. Replace ink transfer cartridges with wax paper or similar. Thermal print heads should transfer etch resist wax to copper-clad.

Issues:

  • Very likely.

Wax Printer

Has potential.

Some Xerox Phaser printers use a solid wax block as ink. Would work as an etch resist.

Issues:

  • Only available on business lines.
  • Expensive.
  • Huge.
  • May be difficult to modify to accept copper-clad.

3D Printer

Has potential.

Single layer of plastic laid down as etch resist.

Issues:

  • Accuracy?

Mechanical

CNC Milling

Works. Not well.

Issues:

  • Messy.
  • Requires babysitting.
  • Limitations on trace sizes.
  • Endmill bits are expensive.

Vinyl Plotter

Works. Not well.

Issues:

  • Terrible accuracy.
  • Results in the strangest looking PCBs imaginable.

Electrical Discharge Machining

Has potential.

Electrical arc from brass wire to workpiece removes material in a very controlled and accurate manner to isolate traces. Reaction happens in a dielectric such as mineral oil or distilled water.

Issues:

  • Difficult to design machine for precision.
  • Expensive.
  • Terrifying.

Electro-Chemical Machining

Doesn’t work.

Workpiece is set up as an anode while electrode is used as a cathode. Reaction takes place in a conductive electrolyte, such as salt water.

Issues:

  • Extremely inaccurate.

Actually

I prefer to do most of my laser-cutting purely in 2D. The open-source vector software Inkscape totally rocks my socks off, and I can design things about three times faster using that than anything else.

 

When a design gets a little complicated, though, or it’s hard to see how everything fits together, it’s sometimes easier to model everything in 3D right from the start. So I built a linear actuator with SolidWorks.

 

If you can’t see, it’s a DC motor that rotates a threaded rod, with that slider piece in the middle holding a captive nut and a rod. You drive the motor, the rod goes in (or out).

 

This was just a proof-of-concept to see how it all fit together. I wasn’t really happy with:

  • The amount of material it used up
  • The physical size
  • Way too much friction in the system
  • Possible strength issues in the rod
  • No way to read or track the rod position.

Solution: Mark II.

  • Replace the DC motor with a stepper
  • Triangular chassis for less material usage and size
  • #10 threaded rod instead of 1/4″, also for size
  • Add some bearings
  • Triple up the actuator rod.

It’s very slow, but that’s simply a matter of choosing different motors and is acceptable for now.

The bearings I had on hand are standard axial bearings; totally not suited to radial loads. That’s something I’ll have to come back to. I saw a method of laser-cutting the races to make custom thrust bearings recently, I’ll have to see if that’s appropriate for this application.

Terrible picture, will be replaced

Terrible picture, will be replaced

20 Percent Time

Laser-etching is a modern process that effectively carves a 1-bit image onto a material. A lot of very cool images can be made with it, given enough artistic talent. I’m not one of them.
Fortunately, all that heavy lifting has been done for me by artists far more talented than me. In the 16th century (and on), making and selling prints was popular with European artists.

That means that there’s a wealth of royalty-free images out there that lend themselves excellently to laser-etching, simply by googling the term “woodcut.”

 

Here are a couple things I’ve been doing in the background while designing something else.

Gears gears gears gears gears

After moving again at the beginning of December, I’ve realised that I’ve built a lot of things, but nothing could really be called pretty in the conventional sense. There’s a lot of room in my new place, and I need something I created to display. Visitors should be able to come into my house (after being invited, please) and say, “Oh hey, that’s a cool x, where did you get it?”

Yeah, I don’t have anything like that

 

It’s time to change that.

 

I built a clock. I have a working version of all the mechanics down. It moves like a well-oiled machine. Well, more like an unlubricated wooden machine. Because, you know, that’s what it is.

 

Pictures!

 

 

Right now I’ve built a quick motor-running test board, and I’m starting to design the rest of the electronics. Pretty soon, I’ll be drawing out an exploded-view diagram, and I should be able to package this as a kit. We’ll see what happens.

I’ll have video up soon.

 

Problems right now:

I’m using old HD motors because I like the short form-factor, but early tests are pointing to them not being powerful enough.

I’ve got three avenues for solutions, I’ll do some analysis and report back.

Closing the Loop

Here is the motor that I’ll be using. I don’t know if I mentioned this already, but I’ve got a big bag of these things. I don’t know where they originally come from, and I can’t find any sort of datasheet or description on the internet.

 

But that’s okay. I can work around that. I didn’t even know what kind of motors they were until I poked around with a multimeter. Turns out they’re brushless DC motors, which is pretty cool for both accurate positioning and speed, but relatively difficult to control.

Here’s the pinout, from left to right:

BLDC Pinout

  1. Winding A
  2. Hall Effect sensor A
  3. Winding B
  4. Hall Effect sensor ground
  5. Winding C
  6. Hall Effect sensor B
  7. Hall Effect sensor power
  8. Hall Effect sensor C

Finding the windings was easy, I just checked the resistance between pins. My highly sophisticated method for finding the sensor pins, though, was putting a voltage across them and watching for smoke. I guessed wrong the first time, so, uh, make that three motors I’ve sacrificed, all told.

The output on the Hall sensors(powered by 3v) are very low, so they need to be hooked up with a differential amp to a potentiometer. The motors draw about 800mA at full load.

Because I have a whole bunch of these motors, I’ve been doing research for the absolute cheapest way of controlling these. Most of the controllers chips I’ve found are right around the $15, which is ridiculous.

So I built a quick test protoboard because it was cleaner than a breadboard, but it ended up getting a little complicated.

 BLDC protoboard

How I’ve got it right now:

Closed loop BLDC motor control
Closed loop BLDC motor control

 While building this, I finally found an affordable solution, the MC33035. It was about $2. But hey, at least I’m intimately familiar with these motors in a way that a one-chip solution wouldn’t give me, right?

Here’s the test-code for PIC that I wrote. I still have maybe 30 of these motors, so they definitely could come into play in future projects. So, one-chip solution aside, I’d add forward/reverse control, PWM speed, and potentially speed/position feedback so I could include a PID loop. That would be pretty cool.

#include <htc.h>
//Int osc, wdt disabled, mclr disabled, bor, fscm
__CONFIG(0x3F1B);
#ifndef _XTAL_FREQ
 #define _XTAL_FREQ 96000
#endif
//HALL EFFECT
#define PHALLA RA0
#define PHALLB RA1
#define PHALLC RA2
#define SENSEA RB5
#define SENSEB RB4
#define SENSEC RB3
void forward(void) {

    //AC', AB', B'C, A'C, A'B, BC'
    if(PHALLA == 0 && PHALLB == 0 && PHALLC == 1) { //Step 1
        PITCHA = 1;
        PITCHC = 0;
        ENB = 0;
        ENA = 1;
    } else if (PHALLA == 0 && PHALLB == 1 && PHALLC == 1) { //Step 2
        PITCHA = 1;
        PITCHB = 0;
        ENB = 1;
        ENC = 0;
    } else if (PHALLA == 0 && PHALLB == 1 && PHALLC == 0) { //Step 3
        PITCHC = 1;
        PITCHB = 0;
        ENA = 0;
        ENC = 1;
    } else if (PHALLA == 1 && PHALLB == 1 && PHALLC == 0) { //Step 4 
        PITCHC = 1;
        PITCHA = 0;
        ENB = 0;
        ENA = 0;
    } else if (PHALLA == 1 && PHALLB == 0 && PHALLC == 0) { //Step 5
        PITCHB = 1;
        PITCHA = 0;
        ENC = 0;
        ENB = 1;
    } else if (PHALLA == 1 && PHALLB == 0 && PHALLC == 1) { //Step 6 
        PITCHB = 1;
        PITCHC = 0;
        ENA = 0;
        ENC = 0;
    } 
    SENSEA = ~PHALLA;
    SENSEB = ~PHALLB;
    SENSEC = ~PHALLC;

}
void main(void){
    ADCON1 = 0x07; //disable ADC
    CMCON = 0x07;
    TRISC = 0x00; //Port C Tris output
    TRISB = 0x00; //Port B Tris output
    TRISA = 0xFF; //Port A Tris input 

    while(1){
        forward();
    }
}

Edit, 6/12/2017:

It’s very weird to see something from legitimate sources start to appear as grey market goods, several years later.

I came across this and this item on AliExpress.

In case those links disappear (likely), it’s billed as: AIYIMA 2pcs Micro DC Brushless Motor 22MM Planetary Gear Motors External Rotor With Hall. The markings on the visible label read 4086013, 172336, and XF08F4901147. On the product page itself, the motor claims to be a AIYIMA-A4F321. The markings on the version I have, however, read 15246014, 172289, and XF04B4000507. Hopefully that helps someone.

The first link is a plastic shaft version I haven’t seen before, while the second link is the metal version that looks identical to my own.

Pie-faced

There’s a new tool on the block, you might have heard of it. They call it a Raspberry Pi, and it’s neither infinite, nor raspberry-flavoured (I checked).

It’s a System on a Chip, or a tiny computer.

A big part of its selling point was that it was $25. This kinda got shifted up to “yeah, $25, but $35 for the really useful one, and then with shipping you’re probably not going to see one for less than about $45.”

So the economy aspect got lost a little bit. People started selling $20 cases, and $150 screens, and I think it’s all a little ridiculous. I’m not using it to replace my desktop computer here.

The beauty of an inexpensive and highly portable computer is that you can give it one task, set it, forget about it, and just go buy another one when you want to play with the platform again. You don’t need a large screen for that, usually.

 

With all of that in mind, I set about looking for the cheapest LCD I could find. I ended up with a replacement screen for a Nokia N77 cellphone. It costed $4.75. A little more research, and I even found someone who was driving them with an Arduino, and that’s most of the battle. The only problem is that it uses a hard-to-find proprietary connector. So that sat on the back-burner for a while.

 

Recently, an eminent change-of-address has spurred on a new project. And, suddenly, I need a small LCD again. After doing some re-evaluation, I’ve changed tack somewhat.

I’ve decided to go with a Nintendo DS Lite screen, and here’s why:

  1. You can get a digitizer to add touchscreen capabilities.
  2. It’s only a modest price bump. About $8 for the screen, and $1.50 for the touchscreen.
  3. They are far, far easier to consistently be able to source from eBay or any number of repair shops.

So I just pulled the trigger on that. While waiting for my shipment to arrive, I poked around for what other people have done with them.

Plenty of people have gotten the touchscreen to work with Arduino, PIC, and Windows. From what I understand, it’s just a couple of potentiometers.

No one really has any information about the LCDs, though, which is strange. Eventually I found a datasheet (via this guy) and an RPi framebuffer driver project. The DS screen isn’t on there, but the datasheet looks pretty straightforward.

I guess I’ll find out when it gets here.

Final pictures

Software

I’ve opened up two sacrificial motors, and they definitely seem to have some sort of on-board Hall effect sensors. I haven’t looked for the pinout yet, but chips were all labelled 1036 for one of the motors, and J588m for the other one. Google turns up nothing about these (that I can find).

The motor connector has eight pins, three of which are used up by the motor windings A, B, and C. That means two of the remaining pins are probably VCC and GND. The last three pins must be the Hall sensor outputs.

Currently, I’ve only got the motor running in open loop. That results in a working, but pretty crappy rotation. When I have some time, I’ll grab the feedback, and close the motor loop. Here’s the PIC code I have right now:

 

#include <htc.h>

//Int osc, wdt, mclr disabled, bor, fscm
__CONFIG(0x3BD4);

#ifndef _XTAL_FREQ
 #define _XTAL_FREQ 4000000
#endif

//Pres butan
#define PITCHFW    RA4
#define PITCHRV    RA3

#define YAWFW    RA2
#define YAWRV    RA5
//Outputs

//Motor variables (RC0, RC1, ETC)
#define PITCHA    0
#define PITCHB    1
#define PITCHC    2

#define FLOATA    3
#define FLOATB    4
#define FLOATC    5

//String constants
#define PITCHMOTOR    1
#define YAWMOTOR    0

//AC', AB', B'C, A'C, A'B, BC'
#define FORWARD        0
//BC', A'B, A'C, B'C, AB', AC'
#define REVERSE        1

unsigned char iPortCValue, iPitchStep, iYawStep;

void set_bit(unsigned char iAddress, unsigned char bBit) {
    iPortCValue |= (1<<bBit);
    PORTC = iPortCValue;
}    

void clear_bit(unsigned char iAddress, unsigned char bBit) {
    iPortCValue &= ~(1<<bBit);
    PORTC = iPortCValue;
}    

void delay_motor(void) {
    unsigned char i, e;
    for (e = 0; e < 6; e++) {
        for(i = 0; i < 170; i++) {
            asm (" nop ");
            //__delay_ms(1);
        }
            CLRWDT();
    }
}

void move(unsigned char iDirection) {

    delay_motor();

    //AC', AB', B'C, A'C, A'B, BC'
    switch (iPitchStep % 6) {
        case 0:        //AC'    AB'C'    
            PORTC = 0x29;
            break;
        case 1:        //AB'    AB'C    
            PORTC = 0x19;
            break;
        case 2:        //B'C    A'B'C    
            PORTC = 0x34;
            break;
        case 3:        //A'C    A'BC    
            PORTC = 0x2C;
            break;
        case 4:        //A'B    A'BC'    
            PORTC = 0x1A;
            break;
        case 5:        //BC'    ABC'    
            PORTC = 0x02;
            break;

    }
    if(iDirection == 1) {
        iPitchStep++;
    } else {
        iPitchStep--;
    }        
}    

void main(void){
    OSCCON = 0xF1;    //Internal osc
    TRISC = 0x00;    //Port C Tris output
    TRISA = 0xFF;    //Port A Tris input    
    iPortCValue = 0;
    iPitchStep = 0;
    iYawStep = 0;
    int i = 0;

    while(1){

        //if(RA2 == 1) {

            for (i = 0; i < 36; i++) {
                if(RA5 == 1) {
                    move(1);
                } else if (RA4 == 1) {
                    move(0);
                }
            }
            for (i = 0; i < 200; i++) {
                delay_motor();    
            }
        //}            

    }
}

Problem identification. The doldrums.

At this stage in the game, this project is on a clear path to completion, with no major revisions in sight. What I’d like to do is identify some issues that have made themselves apparent during the build and tweaking processes. Some are things that I would fix in the version 2, if one were to exist. Some I need to fix right now.

This also marks the end of the “let’s build something cool!” phase and into the “ugh. WHY isn’t this working?” phase. It’s a lot harder to stay interested in finishing, but I’m going to power through.

Here’s where I’m at:

  1. Limited rotation: any rotational movement that goes too far would tangle up cables that are driving the pitch gear motor. Everything in this system is designed to be battery-powered, so the obvious solution would be to mount the yaw motor on the rotating platform. That could mesh with an inside gear that’s been fixed to the base.
  2. Non-prime gears: this is one of the topics that have come up while doing ongoing research for what constitutes a “good” mechanical design. Generally, teeth shouldn’t continually mesh with exactly the same tooth and the opposing gear. That’s a good way to cause excess wear through dirt or inconsistancies in the the teeth hitting the same spot every time. To make sure that doesn’t happen, you want the gears to be co-prime. Right now, my two gear sizes have 55 teeth, and 280 teeth. That’s no good. Fortunately, 281 is prime, so that neatly solves that problem. The pitch gear doesn’t ever rotate all the way through, so that doesn’t fix the issue for those mates, but there’s nothing I can do about it, so why worry?
  3. Catching: the top gear(I’ve been calling it the pitch gear) catches up between the two gears providing support. When it gets caught, the gear likes to try and shove the rear support struts up and out of the base. This is the only problem(so far) that I haven’t foreseen. Fortunately, I was able to move that top support gear a little closer to the bottom portion using some holes that already existed. Anything less than 90 degrees seems to do the trick.
  4. Squeezed bearings: I used some flat washers on either sides of the bearings, but that still caused too much friction for them to rotate properly. I need to find some smaller nylon washers, or maybe flanged bearings.
  5. Wobbly base: the lower gear(I’ve been calling it the yaw gear) is mostly just sitting on a huge bolt that I had kicking around. I was hoping it would work, but no dice. It doesn’t quite. The gear wobbles around in relation to the base just enough to lose contact with the motor gear. When I can get some more laser cutting in, I’ll build another base with an additional cage around the bolt to provide more support.