Rotary Encoder Replacement  - Page 1
Forum section: electronics / projects

author: bostonman
author_rank: Super Contributor
timestamp: June 22, 2024, 12:35:40 am
content: I purchased another Agilent 54831M scope with a broken rotary encoder (and missing knob that I’ll need to 3D print).It’s 16 detents and not a push switch.Most likely I’ll need to find an alternate and retro fit it, but thought to try asking if anyone knows the manufacture or recognize the part number. A Google search didn’t reveal any significant matches when I tried 0321 or 1-2-16.

author: bostonman
author_rank: Super Contributor
timestamp: June 25, 2024, 03:35:52 am
content: I've continued searching for this encoder, however, I haven't had any luck with the exception of someone selling used ones on eBay for around $75.My assumption at this point is finding a replacement that I can retro fit in. Unfortunately I can't take any voltage measurements due to needing the entire oscilloscope assembled, and I didn't see any silkscreen markings to indicate voltages.Earlier I took some resistance measurements to get an idea of the pin configuration, but could use a bit of help.Since this is a Win95 based scope, I'm assuming this larger size encoder is due to older technology and not because it's a high power circuit. Does anyone disagree?With this being said, I'm guessing most modern sized encoders will electrically work, but I'm uncertain about pin configuration.Attached are the pins arbitrarily marked by me (1, 2, and 3) and found all the encoders have pin 1 common (Initially I thought this was Vcc, but, after looking at pin configurations online, I believe this is ground).Pin configurations as I turn the knob are as follows (keep in mind it's a 16 detent):At position 0 (shaft turned so the flat side is horizontal and the round part is on the bottom) - none of the pins have continuityOne click clockwise - pin 1 and 2 shortedAnother click clockwise - 1, 2, and 3 are shortedAnother click clockwise - 1 and 3 shortedanother click clockwise - no pins shorted (it seems to start over where it was at position 0 because another click clockwise shorts pins 1 and 2 again.With these measurements, does a certain configuration I should look for when buying a replacement?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 25, 2024, 06:16:52 am
content: Quote from: bostonman on June 25, 2024, 03:35:52 amThat looks like a conventional quadrature encoding.You may find the convention for CW-CCW varies, in which case you swap the quad pins.Does this spin 360', no stops, for 16 ppr ? What is the bushing dia and shaft dia ?>Is that locked to a legend, or is 12 or 20 or 24 ppr going to be ok too ?Mouser show a small screw bush 3315Y-112-016L ? Tho the image does not quite match the part ID ?lcsc have some 16 step switches, but they look mostly absolute Gray coded. (You can flip most to Quad with a 3ip XOR gate, but that needs power/gnd)

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 02:32:57 pm
content: Quote from: bostonman on June 25, 2024, 03:35:52 amThat seems to me to be a very odd pattern. Well, the pattern looks normal, but not with a detent at each position. I think the typical encoder would have both switches open at every detent (the same number of "pulses" per revolution as detents per revolution), or both switches either open or closed at each detent (twice as many detents as pulses per revolution). The picture below shows the pattern for the latter type, with detents shown as vertical dashed lines. But yours has a detent at each change of state of either switch. So it would be four times as many detents as pulses. A "pulse" is one complete cycle of both switches, which would be four state transitions.I've never seen an encoder like yours, but perhaps it provides a way of narrowing the search. But I don't know if pulses-vs-detents searches are possible. It doesn't look like Digikey would be helpful.If you are getting these readings when you turn the knob, in what sense is the encoder "broken"?

author: bostonman
author_rank: Super Contributor
timestamp: June 25, 2024, 03:06:14 pm
content: Uh oh, sounds like this encoder may be unique; not something I was hoping to hear.The encoder shaft is broken and why it needs to be replaced. This was one of the three issues listed when I purchased this scope (the main issue I easily fixed, the second is a damaged BNC which I haven't dug into searching for a replacement yet, and the third is a missing knob and broken encoder shaft). The knob can be 3D printed, the BNC I'm holding my breath, and this encoder I'm now concerned with.The encoder turns endlessly in both CW and CCW and the shaft length is (going by memory and having measured a good one) 0.55". The part numbers differ slightly and it seems the only difference is: the black shafts have detents and the blue shafts don't.Replacing it with 16 detents isn't exactly imperative, however, it won't be consistent with the other same model unit, so I'd prefer 16 detents. The biggest concern now is whether the pulses match a modern encoder.If I can't find one, I'll have to resort to paying $75 from the seller on eBay plus S&H.

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 03:13:56 pm
content: I searched on Digikey for 4 ppr encoders, and found this one:https://www.digikey.com/en/products/detail/cts-electrocomponents/288X232R161B2/270037As long as the shaft length is long enough, you can always cut it down to size with a Dremel tool. And if it has a push button, that wouldn't hurt anything.But if it's just the shaft that's broken, could you cut off what remains down to a flat plane, and epoxy a replacement shaft?

author: bostonman
author_rank: Super Contributor
timestamp: June 25, 2024, 03:36:56 pm
content: Cutting the shaft to length isn't an issue (I included shaft length just to provide details of my part). I considered exactly what you suggested with epoxy, but question the longevity of the epoxy holding.More than likely it will hold, but removing this PCB is such a pain that I'd hate to deal with the shaft breaking again in the future.The mechanical aspect of the encoder I somewhat grasp. When point A touches a pin before B, it's one direction; and when B touches a pin before A, it's the other direction.As for PPR, how can I tell whether the same pins will conduct per each detent? I would have assumed in all cases two pins are always conducting, it just matters which one touched first in the eyes of the IC that reads the pulses.

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 04:04:09 pm
content: It turns out Digikey also stocks the no-push-button version, which is the one you would want:https://www.digikey.com/en/products/detail/cts-electrocomponents/288T232R161A2/203827You would need to study the datasheet to see if this is even the matching orientation for what you have - 288T vs 288X or 288V. Then, it identifies the pins as A, B and C, with C being the common ground connection. And it has a truth table that shows which pins (A or B) go low as you turn the knob, presumably in the clockwise direction.https://www.ctscorp.com/Files/DataSheets/Encoders/encoders-288-datasheet.pdfBut if it looks like it will physicall fit, you may have to just buy one and see if it produces the same pattern as yours. I would expect that these switches follow an industry standard for pinout, but I can't guarantee that.Edit: Actually, it looks like the pinout is different from yours. You have the common at the end, and this one has the common in the middle.Edit2: However, if the encoder is held in place by the nut and washer, then you might be able to make the pinout whatever you need - just connect the encoder terminals to wires, and then to the board, but just not straight across.

author: bostonman
author_rank: Super Contributor
timestamp: June 25, 2024, 04:54:30 pm
content: QuoteThis was part of the retrofitting I planned. My main concern is finding one that produces the same pattern when turned, followed by fitting in the PCB hole, then detents, and a shaft length that's correct or too long and needs to be cut.I agree on industry standard, but this being a Win95 based scope, and possibly an Agilent part, who knows. Worst case I buy the$75$90 + $12 S&Hor whatever one from eBay, but with the scope purchase cost, parts, upgrades, etc... it puts me at what I could have purchased a working one for in good condition.I'll take a look at the links you provided.Also, mine has a tab that fits into a hole on the PCB. Most likely this is to secure it better than just the nut, however, soldering wires from pin to pads is probably enough extra mechanical security, so I'm not worried about this tab either.Update: if I understand the datasheet correctly, if A = 1 and B = 0, this means A is connected to ground only in this state. If this is the case, you may have found the correct pattern since (from what I interpret) matches the pattern I listed from measurements.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 25, 2024, 09:08:27 pm
content: Quote from: bostonman on June 25, 2024, 03:06:14 pm16ppr is less common, but they can be found.The ones in #5,#7 looks quite good, it is incorrectly tagged 4ppr, on the Digikey columns so missed a 16ppr search.

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 10:26:07 pm
content: Quote from: PCB.Wiz on June 25, 2024, 09:08:27 pmOh no, it's 4PPR. It's 16 detents per revolution, but only 4 pulses per revolution. Four detents per single pulse.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 25, 2024, 10:45:21 pm
content: Quote from: Peabody on June 25, 2024, 10:26:07 pmThey really should stop worrying about cycles in quadrature encoders and instead focus on edges.Most vendors talk about thenumber of resolvable positionswhen they talk about pulses and detents, which is what the user sees.CTS call this 'combination'No one really cares how many electrical full cycles might have happened.Even the CTS data sheet does not mention PPR, but they do talk about pulses, claiming a 4 bit Gray Code is a single pulseThe CTS webpage has newer 11/12 series parts following the more modern convention of detents = resolution, it's the older ones they mangle.

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 10:48:08 pm
content: Quote from: bostonman on June 25, 2024, 04:54:30 pmTraditionally, the truth tables are based on the assumption that the pin is held high with a pullup resistor when its switch is open, and is grounded when the switch is closed, pulling the line low. But of course it could be the opposite setup with pulldown resistors and Vcc. So really you just need to know when the switch is closed, which means the pin in question (A or B) is connected to the common pin. So rather than assuming a voltage, you would just test for continuity in resistance mode on your meter.If your encoder is an incremental quadrature encoder, as it certainly seems to be from your description, then the one I found will very likely work. Both should have a common pin and A and B pins, and produce the same pattern. The pinouts of C, A & B may be different. But I think that can be solved using wires that crossover going to the board. But the logic pretty much has to be the same. Starting from no continuity to any pin, turning CW first connnects A to the common, then B connects, then A disconnects, then B disconnects, and you 're back to the beginning.It would seem to me that you could buy the cheap part from Digikey for about $10 including shipping, and if it works you've saved a bunch of money. If it doesn't, you're out $10. And you can confirm when you get it that the output is the same. But I still urge you to study the datasheet to see if it's the right size and orientation.

author: Peabody
author_rank: Super Contributor
timestamp: June 25, 2024, 11:07:39 pm
content: Quote from: PCB.Wiz on June 25, 2024, 10:45:21 pmYes, I was uncertain what a "pulse" was, and still don't think it's a good term. But basically for coding purposes you have to know what exactly goes on between two detents. You want whatever that is to be a delta of 1 when decoded, but it could be a full "pulse" - a full cycle of both switches, which is four switch transitions. Or it could be two transitions. Or as in the OP's case, it could be one transition. He has to get one like his original or he'd end up getting a delta of 2, or even 4, on each detent. Or he'd have to rotate through two detents to get a delta of 1, or even four detents. That's assuming he can't change the firmware.Anyway, I think the disgram below shows what he has, based on his description.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 25, 2024, 11:11:34 pm
content: Quote from: Peabody on June 25, 2024, 11:07:39 pmYes, one detent per edge is the most common quad encoder. Anything else confuses users.

author: enut11
author_rank: Super Contributor
timestamp: June 26, 2024, 01:03:38 am
content: Quote from: bostonman on June 25, 2024, 03:36:56 pmA better way to fix a broken plastic shaft:Carefully drill a center hole in both parts. As it is difficult to align the holes perfectly, make one oversize. Use a steel pin and epoxy to finish the repair.

author: bostonman
author_rank: Super Contributor
timestamp: June 26, 2024, 03:08:04 am
content: Here is some irony.Trying for a long shot while at work, I dug into an old box of parts that will eventually be discarded and found an encoder (part number: 25LB22-Q) that appeared very similar to mine. It had 16 detents, shaft looked like a good length, etc...I brought it home and tried fitting it onto the board. With the exception of the back side circuit board on the encoder being a little long and the shaft slightly shorter (only by a mm or two), the thing fit perfectly. It even has a little plastic tab which ALMOST fit into the hole on the circuit board, but I managed to fit it after a little filing. With a dab of epoxy, it should sit nice and tight without the possibility of wiggling.Attached are measurements I took. This time I put both encoders aside each other to match pin measurements with the top being the shaft facing upwards and pins (labeled by me) going left to right 1-2-3 (I included a visual in the attachment).Click 1 and 3 are the two that are different, however, if I'm thinking about this correctly, the connections would be as follows (pin numbering as I'm calling it in my attachment):Original pin 1 is connected to new encoder pin 3Original pin 2 is connected to new encoder pin 1Original pin 3 is connected to new encoder pin 2If my wiring list is correct, and the encoder seems to fit perfectly, the question is: can this encoder be reverse meaning it really thinks it's turning CCW when turned CW, or is this something I'll need to figure out once it's assembled?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 26, 2024, 03:29:44 am
content: Quote from: bostonman on June 26, 2024, 03:08:04 amYou can reverse the apparent direction by swapping the 2 quad pins.

author: tunk
author_rank: Super Contributor
timestamp: June 26, 2024, 12:34:04 pm
content: Quote from: enut11 on June 26, 2024, 01:03:38 amYou could make a 3D printed template to center the drill.Filing the end flat may also help.

author: bostonman
author_rank: Super Contributor
timestamp: June 26, 2024, 02:30:38 pm
content: QuoteSo it needs to be tested to confirm the rotation direction? Would I be better off building a test circuit and comparing both encoders rather than assemble the entire scope?

author: Peabody
author_rank: Super Contributor
timestamp: June 26, 2024, 02:43:35 pm
content: The data in your new PDF does not match what you posted in reply #1 for the "original" encoder. Have you changed the pin numbering?Edit: Anyway, I agree with your conclusion:Original pin 1 is connected to new encoder pin 3 - BOriginal pin 2 is connected to new encoder pin 1 - AOriginal pin 3 is connected to new encoder pin 2 - CIf you connect it that way, you don't need to test for direction. It can't really be wrong.

author: bostonman
author_rank: Super Contributor
timestamp: June 26, 2024, 03:36:37 pm
content: QuoteMaybe I didn't explain correctly and/or added confusion - sometimes I have a habit of leaving out an important detail.Originally I measured the encoders still on the PCB which I accessed from the rear (i.e. back side of the encoder) of the PCB. First I figured out which position none of the pins were connected, placed them all in the same position (flat side horizontal with the curve on the bottom), and learned which pin was common to all the encoders. I arbitrarily numbered them 1, 2, and 3 (again from the back side of the encoder).Yesterday I placed the 'new' encoder and the 'broken' encoder that I removed from the PCB side-by-side, laid them with the back side on the bottom and shaft pointing up rather than taking one set of measurements from the back side and another from the front. The pins were facing me and I arbitrarily labeled them 1, 2, and 3; this allowed me to make sure I measured the same pins at the same points.In the PDF I attached yesterday, I drew a (poorly) laid out description showing this and adjusted all the measurements according to this pin measuring configuration.QuoteIs this true? What if the pins are tied together during a specific click, but A touched ground before B rather than B touching ground first.

author: Peabody
author_rank: Super Contributor
timestamp: June 26, 2024, 04:33:53 pm
content: The software will detect the pin transitions when they take place, and will keep track of the previous state. So if we define the A pin as the one that first connects to the C pin when turning the knob CW, then if you connect the A pin of the new encoder to the hole where the A pin of the old encoder was connected, the direction has to work the same as it did with the old encoder. But of course you can rig up a circuit to confirm that if you like.The key to decoding the encoder is the previous state. If you have a transition, and now pin A is connected to pin C, you have a +1 increment from a CW turn if previously neither pin was connected to C. But if the previous state was with both A and B connected to C, then you've had a -1 CCW transition.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 26, 2024, 07:56:20 pm
content: Quote from: bostonman on June 26, 2024, 02:30:38 pmIf the scope is a dog to assemble, then certainly a quick side by side circuit check with LEDs will be great.Then you canproveyou have it correct.

author: bostonman
author_rank: Super Contributor
timestamp: June 27, 2024, 12:48:06 am
content: My thought was pull up resistors with both leads connected to a scope. Then I could look to see which pulse occurs first.If it's software controlled where it looks for the previous stage, then the idea I had to conduct a bench test may not work unless I get some micro - and I lack knowledge/experience with getting an Arduino or Pi to interface (or even getting a program onto one).Disassembling the scope is a pain, but I've also learned the more something gets disassembled and assembled, the better chance of something breaking.

author: Peabody
author_rank: Super Contributor
timestamp: June 27, 2024, 01:12:22 am
content: The scope test would work fine with the C pin connected to ground. Then you just want the same sequence to be produced in both encoders as you turn the knob clockwise.

author: bostonman
author_rank: Super Contributor
timestamp: June 27, 2024, 01:26:20 am
content: Oh okay.Do I need to worry about "click 2" where pins 1,2, and 3, are all connected or just click 1 and 3?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 27, 2024, 02:44:48 am
content: Quote from: bostonman on June 27, 2024, 01:26:20 amYou want to check all 4 clicks/detents, but usually start at some 'zero' eg with both ON or both OFF, then set the scope to one shot trigger and spin the knob CW.

author: Peabody
author_rank: Super Contributor
timestamp: June 27, 2024, 02:54:35 pm
content: Quote from: bostonman on June 27, 2024, 01:26:20 amWell, click 2 would show the same whether A and B were correct or reversed. So the important ones are those where only one is low. And since you have a detent after each transition of either switch, you just have to measure the voltage at each successive detent. Starting with A and B high, first A will go low, then B will go low, then A will go high, then B will go high. A "leads" B, so to speak, as you turn clockwise.In fact, the datasheet for the 25LB22-Q suggests that the pins are labeled as A, B and C on the encoder.

author: bostonman
author_rank: Super Contributor
timestamp: June 27, 2024, 06:35:28 pm
content: The datasheet was helpful as far as the logic table, but I assumed one has to lead the other (so I did read it).Hopefully this weekend I’ll have time to rig a quick resistor pull up and measure things.

author: bostonman
author_rank: Super Contributor
timestamp: June 30, 2024, 02:50:17 pm
content: Yesterday I set up the old encoder and new one side-by-side with a pull-up resistor connected to the two pins, 5v to the resistors, and ground on the ground pin.I expected to see pulses, but, what I realized: when one pin is high, turning the encoder keeps it high, and the other pin goes low. So I didn't have a way of determining whether A and B were reversed.What I thought happened was the connections "break" and when clicked into the next position, A touches first and then B (or vice versa). This seemed like it was nothing more than a binary output.In any case, I've wired it onto the board and checked the resistance at all four turns comparing them to the adjacent one.The only part I'm holding my breath on is whether the back side of the encoder sticks out too far and may cause clearance issues. It's a few mm longer, but hopefully today I'll reassemble the front panel and will know.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 30, 2024, 07:53:13 pm
content: Quote from: bostonman on June 30, 2024, 02:50:17 pmThat's why I suggested testing with LED's (or a 2 channel storage scope, if you have one)

author: bostonman
author_rank: Super Contributor
timestamp: July 01, 2024, 01:07:40 am
content: QuoteI used a four channel digital scope, but one channel stayed high and the other would drop, so I couldn't compare pulses.In any case, the whole scope was back together, the encoder fit well, but something happened because now it doesn't power, so I had to start disassembling it again.Since it worked before I disassembled it and doesn't now, a wire or connector must not be seated well. Long story short, I managed to get it powered by removing some connectors, so I'm in the process of trying to figure out what's going on.I was all happy to test the encoder and now I'll need to wait.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: July 01, 2024, 02:15:54 am
content: Quote from: bostonman on July 01, 2024, 01:07:40 am?In both cases, properly connected with pullups, should give two pins that pulse.In this type of test, I would not try to test both on one capture, but capture one pair CW, and then compare the screen grab of that, with the second test.

author: bostonman
author_rank: Super Contributor
timestamp: July 01, 2024, 02:37:31 am
content: Weird.As an example, if A and B were high, and the next click brought (let's say B) to a low, I only saw B drop. Maybe I didn't trigger the scope properly and missed it.I'll try it again once I get my scope back up and running (I have two of these encoders).

author: Peabody
author_rank: Super Contributor
timestamp: July 01, 2024, 03:30:52 am
content: Quote from: bostonman on July 01, 2024, 02:37:31 amYou didn't miss anything. Your encoders just have one transition for each detent. Other encoders have two, or even four, transitions between detents, and you would see pulses on your scope between detents. But yours just has one.If A and B are high, the one that goes low on the first detent, turning clockwise, is theA pin. Just make sure the A pin of the new encoder is soldered where the A pin of old encoder originally went.

author: bostonman
author_rank: Super Contributor
timestamp: July 05, 2024, 01:23:29 am
content: QuoteFrom what I can tell, I figured out the problem. I removed the front panel and noticed a small ribbon cable dangling. It must have somehow came out due to not seating it well. After re-seating it and haphazardly reassembling it for testing purposes, the unit powers normal.The odd thing: at a random point when it wasn't working, it somehow began working normal (minus the power button wasn't doing anything). Immediately upon plugging in AC, the scope would boot. Eventually it stopped working again, so that threw me for a loop because I was looking for a looks connector on the Acquisition Board since I had removed it.Since I finally got it to boot, I decided to let it go all the way to test the encoder. I turned it several times CW and CCW, and the waveform span and shrunk as expected. It physically fits well, the shaft is a mm or two shorter (hardly noticeable) but won't affect supporting a 3D printed knob, and possible a larger diameter shaft which isn't an issue since I'm 3D printing a knob.Now I need to reassemble and tinker with a 3D print for the knob someone was kind enough to create for me.The only other upgrades is adding another 256MB RAM, a SSD, and duplicate my other SSD that has XP on it (I have a backup SSD for my other scope, so I'll use that in a duplicator).As always, I appreciate all the help, in this case, with the encoder. This will (hopefully) be my second fully working Agilent 54831M (which will be upgraded to the other 1GHz BW model once I remove a resistor) thanks to the help of everyone on here.