I looked around various google DIY pages, and got ideas on how to figure out what's what, but none of them really took me step by step.
So here goes...
Step 1 (lots of effort, can't describe how to do this easily): remove outer casing of a printer so you're left with the basic drum roller carriage. This one's easier to start with than the linear serial encoder strip one that runs along with the ink carriage.
Here's what you'll see:
If you were to look at that disc's edge under higher power, you'd see that it's actually made up of a bunch of really little lines.
There's a DC motor that controls the little gear at the bottom right. That drives the belt, which drives another gear assembly at a slower rate, causing the disc with the serial encoder bands to turn.
The fun parts are the disc with the markings on it, and the thing that has 09852 and 9920 written on it. That assembly has an LED on one side and two light sensors on the other. As those little lines block or reveal the LED light, the light sensors can see what's happening.
Step 2: Remove the board. Fortunately, it was one screw with a T8 head. Try not to scratch up the disc as it's coming off.
T8 wrench head |
Lefty loosey |
Board is off now |
The board has that cool chip on it, but there's a white shield over the connections. If you look closely, you'll see a little tab that suggests that the white piece was pressed on and then clicked into place.
So you can pry the U-shaped white part in the middle up, and then slide the whole thing over the tab to remove it. I used a teeny flat head screwdriver for this, like one of those eyeglass repair kit ones.
And voila (grave accent over "a", do not say "viola"), you can see two wires going up.
Now here I was guessing which side of the chip was the LED and which had the sensors. Visual inspection on the other side showed a couple of things. First, the upper part (the one with the 09852/9920 written on it) is thicker. Second, looking inside the slot, it had a circular opening, whereas the other side appeared flat. So both those things suggested that the top was the light emitting side, and the lower side was the light-receiving side.
You might also barely notice that two of the board pins connect to the two, revealed upper bars. I did a continuity check with a multimeter just to make sure I knew which ones connected. From the perspective of the shot above, the pin closest to the letters "U1", and the middle pin two away from it, were the ones connecting upward.
Continuity check -- multimeter said "beeeeeeep" for this pin and the one two away from it. |
I continued on, assuming the two upper leads would connect through an LED. As such, I could test the diode using my multimeter. You can find many videos online that describe how to use a multimeter's diode setting to check to see the orientation and voltage drop across a diode.
Set to diode mode |
Somewhere around here, I went astray and measured things incorrectly. My multimeter, when connected "correctly" across the diode, shows a number briefly and then shows "1". If there is no connection it shows "1" without blinking. Otherwise, it shows the voltage drop.
I didn't get things right the first time, and thankfully didn't burn out the circuit when I got Vcc and Ground reversed. Usually that's a Very Bad Idea.
Anyway, let's call the pin nearest the U1 marking 1, and then go 2, 3, and 4 from there. For this sensor, connecting black to 1, and red to 3, I got that "blink" behavior. No other combinations (tested across all pin pair combinations in both directions) yielded that.
Step 5. Look at the opposite side for wiring
Here's what the board looks like when it's flipped upside down. I was intrigued by the resistor and capacitor but couldn't really figure out what the resistor was for.
With this turned upside-down, the diode pin ordering is reversed, so think of them from top to bottom as 4,3,2,1.
So here in the blog I'm going to cheat and skip around how I messed up in figuring out what this thing was. More on that later. But instead of leaving a bad diagram in the blog, I'm supplying the correct diagram here.
Here's what I eventually figured out. Break out some kind of drawing program (in my case Photoshop Elements), and trace it out and you get this:
It turns out that the resistor R1 on the PCB isn't in the circuit at all. If I recall, that connected to wires that connected to another assembly at the back of the printer, and those might have connected through to a simple light blockage sensor (optosensor) or physical switch. Basically, the board's resistor R1 joins up from Vcc to that other wire and probably a physical switch caused it to connect back to the wire I labeled "UNUSED", so it doesn't do anything for me.
At the same time, that meant the LED in the 09852/9920 chip didn't have any resistance protection, at least not from the resistor on the board. Well, as it turns out based on what I read elsewhere, there's an internal resistor in the sensor itself.
It makes sense that GND and the voltage line are connected via the capacitor C1. That typically is done to quell ripples in voltage.
That leaves the other two lines coming back from the 09852/9920 chip, and they're directly wired to the original wire bundle. So I'm assuming those are Sense A and B, which will let me know what's going high and low as the disc turns.
Step 6. Initial output testing.
I initially wired up 3V and 5V through a 220 ohm resistor to the LED. As it turns out I got that backwards in early testing, because I didn't know how to read my multimeter. I thought a constant reading was telling me voltage drop across and indicating that I had proper direction, but that's not how my multimeter works.
Since I got those backwards, there was no way the LED was going to light. Furthermore, even if I had gotten the wires in the right order, I might have had too much resistance for the circuit to do anything, because I didn't know there was an internal resistor.
Step 7. Despair
Because I got that all wrong, I gave up for a bit. I then returned to web searches to see what they might yield, and found this:
http://reprap.org/wiki/Optical_encoders_01
This was my "Aha!" moment.
There were two big clues on that page. First, they went into some detail explaining how to do diode-setting measurements with my multimeter to try to figure out power and ground, which entailed measuring in diode mode across all pin pairs in both directions, and making a chart. But more importantly, they said that almost all these kinds of sensor chips run at 5V, and the ones with only 4 pins have a built-in resistor for the LED.
The reprap site recommends fully extracting the chip from its board, and gives suggestions on how to do that. For my purposes, I wanted to retain the existing board. Otherwise, it'd be too hard to re-mount and get lined up again. Through inspection of the board, I'd already determined that I'd disconnected everything else so that was good enough.
So... I re-measured the pins for the chip I have, and eventually determined that the pin closest to the U1 marking is ground, then sense A, then Vcc 5v, then sense B.
Once I had determined the proper direction, I put 5v across the LED and inspected the sensor. Sure enough, a visible red light could be seen inside! I wasn't sure if the light would be at a visible wavelength or IR.
I then put the board back where it came from, connected up the multimeter to ground and one of the sense pins, and *slowly* rotated the DC motor. Sure enough, the output from the sense pin would start wandering around, roughly between 0.5V and 4.5V. And the output on the other sense pin wasn't the same all the time, which is to be expected.
-------------
Next step: I don't have an oscilloscope handy so I can't tell how clean the voltage signals are for the signal lines. I'm just going to assume they look ok since I'm just messing around.
I originally got into this project because I'd seen ways in which you could build the remainder of the circuit to figure out direction and count ticks electronically. There are some diagrams out there that use flip-flops in sequence to buffer up the results, and there are ICs pre-built. I'm looking at the US Digital LFLS7184-S as examples. (I also wonder if one of these chips is built onto the printer already somewhere.) I don't want the Arduino to have to capture interrupts to sum up the number of ticks that have gone by. I don't trust the clock frequency of the Arduino to measure things accurately. It'd be much better if that were done electronically, and then the Arduino can dip it and get a summary count.
----
Here are some more pretty pictures.
Disc says that it's 1800 count (I think CT means count) and 200 lines per inch |
You can see all the little lines here. |
I took apart the carriage board and unsoldered the sensor from it. I accidentally broke the plastic covering that they use to hold the sensor in place, so if I ever use it again, I'll have to find some way to make sure it stays down. I think part of the job of the gray covering is to protect wires, but its more important job is to make sure the sensor doesn't bend upward from the PCB.
The carriage board was a multilayer job, so it was hard to tell where the leads were going, and really impossible to know if I could disconnect the sensor from existing circuitry by just cutting leads. So instead, I had to remove it.
Removal started with desoldering a number of large capacitors that were in the way. They prevented me from lifting the gray cover off of the sensor, and I wasn't sure if I could just desolder with the plastic in place (for fear of melting the plastic). In desoldering, I found that it really worked well to add some solder to the existing points first, then solder-sucker it, then clean up with wick. It came out quite easily after that point.
The pin readings on the carriage sensor were very similar to those on the rotary disc sensor, so I just wired it up the same way and slid the strip through to see if I could get readings from the sense pins, and I could!
End result: I have a rotary sensor and a linear sensor, and more printers that I can mess with beyond that.
So now how do I use it?
I'm tempted to make the linear codestrip and sensor act as some kind of musical instrument, like an electronic slide whistle. There's gotta be a better use than that, though. I've seen some YouTube videos that show how you can make an inverted pendulum, too. But now that I've seen those videos, I know that that's been done.
Why did I do this originally? To detect when step motors don't actually complete a step. Using one of these encoders could give me the feedback I want to make sure a step really happened.
Next step remains: build up the rest of the circuitry to actually count the sense A and B signals and accumulate them.
Hi man, great info you posted, great work and effort invested here, not only researching but documenting this, thanks, big thanks, I was having the same doubts and issues but you brought great light here.
ReplyDelete