Optical encoder motor control for printer slide unit

 Posted by:   Posted on:   Updated on:  2020-07-12T18:22:58Z

Using a printer slide unit with Arduino requires getting information about the optical encoder and measuring the strip density

I disassembled an old inkjet printer without working cartridges. Buying replacement ink cartridges was not worth because the price of both black and white and color ink cartridges equals the price of a new printer. I couldn't throw away the printer without taking any usable electronic and mechanic parts from it. To my surprise, the cartridge holder is placed on a metallic sliding unit that seemed interesting.

Cheap design though. Plastic block sliding on metal axis, but since it did its job in the printer, it may work elsewhere too. However, instead of using a stepper motor to control the sliding unit, the manufacturer has chosen a closed loop system with a regular DC motor and an optical encoder with a strip. That's the approach for most home-use printers. When looking for a way to control such a system with Arduino I didn't quite found something that worked.

Optical encoder motor control for printer slide unit

The printer slide unit with a custom encoder PCB

My printer was a Deskjet 2050 from HP. The slide unit is marked with CB760. The DC motor is C9050-60003, manufactured by Mabuchi Motor Co., Ltd (I've recognized their logo) and very common for HP printers (it can even be bought as replacement part). Unfortunately, there is a total lack of information regarding its specifications. While it's able to move the sliding block when powered with as low as 0.5 V, I would definitely want to know its normal supply voltage. So far, I've powered it with 12 V PWM and it seems to have enough speed and power without even warming. But, keeping in mind that printer supply was 33 V, the motor could have been powered by the printer motherboard with anything below this voltage. In the end, getting a proper motor voltage is done by trial and error (just be careful with the error part - you may "fry" the motor's coil).

Encoder strip

The unit position and movement distance are calculated using an optical encoder and a striped band. Mine is marked CB760 (as the entire unit) followed by some other numbers. It doesn't matter though, as long as there is no public information regarding its lines density. It's important to have an accurate measure of the travelled distance, therefore I had to calculate the strip LPI (lines per inch) value. A good way of doing this is to scan the strip at 1200 DPI. These things usually come with 150 or 300 LPI, so unless you suspect a higher LPI, there's no need to scan it at a higher resolution. Scan the strip to TIFF or PNG, then crop the image containing a length of scanned strip at precisely 1200 pixels (that's exactly one inch of your strip). Next comes the boring part. Count the lines. They should be clear and more than 1 pixel wide. Here's a piece of my strip scanned at 1200 DPI:

Scanned strip shows 150 lines per inch

Scanned strip shows 150 lines per inch

Optical encoder

It's getting harder. Now I have to interface a totally unknown device and get proper results. It's important for the optical encoder to be in its usual place and with its "known" strip. For me this required making a small PCB to replace the original one although I could have used an ugly yet working solution of cutting all tracks to encoder and soldering my own wires to the original PCB. This is the original PCB (what's left of it) next to mine (if by any chance you're reading this because you have the same sliding unit, the design for this PCB is available at the end of the post).

The advantage of using an encoder over a plain optical switch is the possibility to detect movement direction. If only distance is required, just one encoder output may be used. Knowing the direction allows precise positioning additional parts (no endstop switches are required - homing is performed by moving the unit to the left until the encoder no longer detects lines).

The original encoder PCB and the new one mounted on the sliding block

The original encoder PCB and the new one mounted on the sliding block

This encoder is a 6-pin type, 2 for the IR LED and 4 for the double receiver. Check Transmissive optical sensors (HomoFaciens) for an overview of optical switches and encoders. On my PCB the LED is powered via a 200 ohms current limiting resistor and the capacitor you see is a 470 nF filter on the supply lines. Have a look at the schematic to understand how I got only 4 pins on the connector.

Finding the encoder pinout shouldn't be too hard. Ground is all over and supply voltage track is usually wider than the others. The LED may be wired straight to VCC with a resistor to GND, but also straight to GND with a resistor to VCC. There may be no LED resistor at all on the encoder PCB and be placed on motherboard.

Optical encoder PCB schematic

Optical encoder PCB schematic

I would later realize that I forgot to add some silkscreen markings for the pins of the connector. I managed to get wiring wrong and fortunately nothing bad happened.

Getting the sensor to work is again trial and error. What's the best LED resistor value? I have no idea where they placed that resistor, because I didn't find it on that small PCB. I assumed the LED is a regular LED and fitted it with a 200 ohms resistor, which would usually result in less than 10 mA current when powered at 3.3 V. If you own an ATmega328 tester (LCR-T4, GM328A) you can find the LED forward voltage and compute the resistor for a precise current. Speaking of supply voltage, that's another missing information. If you are able to power the printer and measure what comes to the encoder that would be great. Otherwise, use 3.3 V and hope it will work.

Since I own a cheap logic analyzer, I made use of it. I powered my encoder PCB and connected the two encoder outputs to the analyzer. Everything worked as expected when I moved the block by hand.

Encoder output when moving the sliding block

Encoder output when moving the sliding block

Conclusion

By now I gathered sufficient information to be able to interface this to a development board. Precise positioning may require PID control algorithm which I will adjust for this purpose in the follow-up post. As promised, you can download here the KiCad project for the new encoder PCB.

2 comments :

  1. "if by any chance you're reading this because you have the same sliding unit"...
    Exactly my situation. Thanks for the info!

    ReplyDelete

Please read the comments policy before publishing your comment.