Putting µControllers where they don't belong: Digital Resistance Box - Page 1
Forum section: electronics / projects

author: Haatveit
author_rank: Regular Contributor
timestamp: June 26, 2018, 01:27:26 am
content: I was casually browsing eBay (as you do) and stumbled upon some nice looking decade resistance boxes. Unfortunately, they cost a lot, so I quickly moved along. But the idea that I must for some unknowable reason get myself a resistance box stuck with me until later.Later...I was casually browsing DigiKey (as you do) and wound up looking at some nice resistors and rotary switches. Unfortunately, they cost a lot, so I quickly moved along. But the idea that I must for some unknowable reason get myself a resistance box stuck with me until later...Much later & some beer...µControllers. That's the solution to everything! So why not design a decade resistance box that is computer controlled! Yes! Of course. I must. Now the project will most definitely be way more expensive than it's worth, so it's approvedCurrently....So, relays, a microcontroller, an rotary encoder, a small LCD, some nice resistors, and a PCB seems to be in order. Here's what I'm thinking so far:Use a 1-2-3-4 connection scheme to minimize the number of switch elements, since, unless we're talking motor controlled rotary switches (), we want to use relays. So basically each decade block just needs 4 resistances and 4 relays, an you combine them in whatever series fashion required to get any resistance between 0x (short) and 10x the decade value. Ok, easy enough. But it could get pretty expensive or difficult to source the oddball resistances - may be better to just go for a pair from each block, and simply use more of them in series to get the oddball values... Will probably be awfully expensive regardlessI'll probably stick to something simple like a 0->10->111'110 Ω range, maybe one more block but it starts getting ridiculously expensive at that point I think. In my original idea using actual physical switches to make a "dumb box" I thought it would be sweet to use an extra switch position for a 1-2-3-4 range of Power resistors, ~30W or so. So you'd have a nice useful 1-10Ω 30W+ capable range built into the same box, using the same switches. Translating that to this ridiculous idea would be quite simple of course, just ... more, beefier, relays! The Power would be an entirely separate circuit so doesn't really affect the other parts at all.Not sure what kind of relays to use to minimize contact resistance. Reed relays are super tantalizing because they are compact, low current, mechanically durable, OK contact resistance (no worse or better than most bigger relays), and will last forever, as long as they are switched off-line, speaking of which; I would probably also add a "master" relay, one with beefier contacts and higher current rating, that would break the circuit before the Reed relays re-adjust, and then makes the contact back again afterwards. That way, the reed relays should never see any actual switching currents or anything of the sort. The master relay will take all that abuse, and will be specced to suit. Maybe? Not sure if that's useful at all.Probably use a pushable rotary encoder with maybe some extra buttons, for user interface. Don't want to clutter it up with a big fat keypad or anything.I could get away with a one-line character display, although looking at how pricing works out, it's almost stupid not to go with asmall graphical OLEDthese days. Having a graphical display would make it very easy to add a lot of features, although, there's not that many to add! Could easily get away with a one-line alphanumeric, using the last character as a function indicator.Features? Features!Well, it would function as a resistance box, obviously. Turn the knob, set the resistance, push the button, relays go satisfyingly clickety-clack, and there you go. But also, it would be trivial to add an instantaneously variable resistance mode, where you highlight the digit you want to change and "scroll" through it with the knob. It would only actually apply the resistance change after a very brief pause, as to avoid unnecessary relay chatter, but still keep it fast enough so that the feature isn't just annoying and useless. Could also easily add some primitive programmability, why not? Enter a program step by step, with desired resistance, and either set an overall step delay (limited to a sane minimum), or perhaps a step-by-step delay so that it's variable. And of course, no reason not to have a serial connection available with a simple command interface so that it can be remotely controlled by a PC.So that's where I'm at right now.Oh oh, also, finally I would likesome wayto calibrate or adjust the box. Sadly there's no such thing as negative resistors, so the alternative would be to bias the box towards 1Ω, with a trimmer in between - thus you can "trim out" the combined contact resistances of the box so that it starts at exactly 1Ω. Although I'm not sure how well that would work - I don't care about the 1Ω offset, but maybe that just means I also shouldn't care about the contact resistances?It's dumb. So, if anyone has any more bad ideas or suggestions..... Bring it on

author: KaneTW
author_rank: Frequent Contributor
timestamp: June 26, 2018, 01:37:33 am
content: Contact resistance shouldn't matter too much as long as you use Kelvin connections and provide 2 sense/2 current ports. Make sure that sense and current lines have the same impedance.

author: mbless
author_rank: Regular Contributor
timestamp: June 26, 2018, 03:10:28 am
content: Not quite the same, but here is resistance box with a mcuhttps://www.eevblog.com/forum/crowd-funded-projects/multichannel-resistor-substitution-box/

author: jbb
author_rank: Super Contributor
timestamp: June 26, 2018, 03:34:23 am
content: I’m sure that motor controlled decade switches would be no trouble at all :-)

author: EEVblog
author_rank: Unknown
timestamp: June 26, 2018, 03:46:08 am
content: I won't tell you details about David2's idea for a decade resistance box, suffice it say that when yours favorite tool is SolidWorks, everything looks like a 3D modeling problem

author: ejeffrey
author_rank: Super Contributor
timestamp: June 26, 2018, 03:51:23 am
content: A push button rotary and a 2 line LCD is the lazy way to design a MCU interface. It gets the job done of course, but it slow and annoying to use in many cases. A keypad is the way to go if you actually want to use this. If it is a nice keypad with some mechanical switches and not some crappy membrane switch it might even be as convenient to use as a traditional rotary switch. The downside is that you have to actually plan what features you want: up/down buttons to step a certain digit? You can do that, but you have to plan the buttons for it.Motorized rotary switches would have a certain undeniable style...

author: cellularmitosis
author_rank: Unknown
timestamp: June 26, 2018, 04:32:31 am
content: Cool ideas! Here some more:First, continue your search for a decade resistance box. The magic ebay search phrase you are looking for is "1432 decade". In the past 31 days, 8 such units have sold for under $50.https://www.ebay.com/sch/i.html?_from=R40&_nkw=1432+decade&_sacat=0&LH_TitleDesc=0&LH_TitleDesc=0&LH_Sold=1&LH_Complete=1These units are the older version of the 1433 which dave reviewed. The guts appear to be identical.There is a bit of risk though -- some of these units have the ass blown out of them from someone running way too much current through them (you'll immediately know if this was the case when you open it up).Second, if we're talking poor-man's digital decade box, consider using FETs for the switches rather than relays. Here are 100 FETs which have an on-resistance of 28 milliohms for $0.03 each:https://www.ebay.com/itm/100PCS-AO3400-A09T-5-7A-30V-SOT-23-N-Channel-MOSFET-SMD-transistor/252680099245?hash=item3ad4e855adIf you do go with relays, small-signal latching is the way to go (no self-heating == lower thermal emf). Alternatively, salvage the COTO relays off of some low-thermal-emf scanner cards (ebay search term "03497-66509").Also take a look at the GenRad 1434 manual. They manage to get away with 6 (equal) resistors per decade through some clever switching.

author: jbb
author_rank: Super Contributor
timestamp: June 26, 2018, 10:49:56 pm
content: Now I’m just being silly:How about a touch screen (and stylus) with handwriting recognition so you canwritethe desired value on the unit?

author: rs20
author_rank: Super Contributor
timestamp: June 26, 2018, 11:25:14 pm
content: To me, the primary advantage of using a microcontroller in this application is that the MCU can store theactualresistor resistances and contact resistances of the circuit, and therefore calculate which resistors to connect in series to most accurately attain the desired total resistance. This is in contrast to a manually operated resistance box, where theonlyway to achieve accuracy is to have perfectly trimmed, accurate resistors.Consider if you have resistors of value 2, 4, 8, ..., 1024 ohms. Consider that they're 1% tolerance each. (2 + .. + 512) = 1022, while (1024) = 1024. A difference of 2 ohms, as intended. But now consider the worst-case scenario: (2 + .. + 512) - 1% = 1012; (1024) + 1% = 1034. A difference of 30 ohms, meaning there's a big swath of 28 resistances which your box simply can't reach.How do we solve this? We abandon the requirement of having the resistors be perfectly a factor of 2 apart, and have them be a factor of (just a little less than 2) apart. Looking at the E48 series, you could go with 1.00, 1.96, 3.83, 7.50, 14.7, ... ohms. Just keep multiplying by 1.96, and you'll always find a E48 value very nearby. So now, looking at your list of problems:Expensive, super-accurate, custom-values resistors? No, perfectly standard E48 values where you can focus more on tempco than absolute accuracy.Low contact-resistance relays?As already mentioned, you can completely avoid this being an actual issue if your application allows 4-terminal kelvin connections.Or if you can float your ground and don't need to support large voltages, just use MOSFETs. Or, if you do go for a 2-terminal relay connection, you actually only care about tempco/repeatability of that resistance, not the absolute value (a consistent resistance can just be measured and calibrated out)Calibration? Justmeasurethe resistance delta as each resistor is swapped in, and program that into the EEPROM of the MCU. The code to then take that information, plus a desired total resistance, and figure out which combination of resistors comes closest is pretty trivial.One fun bonus possibility would be to incorporate a couple of 24-bit delta-sigma DACs measuring current and voltage. This would be a nice bonus feature on its own (resistance box with built-in "multimeter?"), but would allow it to self-monitor its own resistance on the fly. Or you relays could switch in the test.

author: Haatveit
author_rank: Regular Contributor
timestamp: June 27, 2018, 12:06:59 am
content: Some pretty cool ideas and thoughts here so far, I'll have to think a little bit about what the scope of this project would be. I seem to always end up making something that is about a thousand times more complex than what I originally wanted...Quote from: rs20 on June 26, 2018, 11:25:14 pmThis idea popped into my head as well, although it does mean that each and every box will need quite a lot of attention before it's usable. I usually make at least a half-hearted attempt at keeping things easy to build and sell as kits - it's something I want to get into doing more. But it usually means trying to avoid lots of fine adjustment and tinkering with each unit, since that can easily take a lot more time than the actual assembling of the thing. Of course for a one-off it's an irrelevant concern...Quote from: rs20 on June 26, 2018, 11:25:14 pmI must admit I don't understand the kelvin connection solution to the problem, as proposed twice in the thread. How does a kelvin connection to the box help when there's 20 relay contacts in series on the inside? I feel like I must be missing something obvious here... In the imaginary use case of using this resistance box to adjust some piece of equipment for example, I personally would put more value in knowing the resistance I'm asking for is actually correct, rather than knowing how wrong it is by using a kelvin connection. But like I said, I might be misunderstanding or missing the point.I did look at MOSFETs and i expected they could offer much lower "contact resistance", and even nice low-RdsOn ones are relatively cheap. But I will admit I'm not super familiar with the characteristics of MOSFETs, wouldn't they have pretty unpredictable behavior depending on the voltages and currents being applied? I guess if it's variable but still much lower than a relay it's still a win, perhaps.Quote from: rs20 on June 26, 2018, 11:25:14 pmThis also occurred to me and it's a very tempting addition. Although it would make it a much more complicated project than intended, once again, but then again... It's a very cool feature. At least being able to display some simple measurements like voltage and current across the resistor with a modicum of accuracy would be a cool addition.Quote from: EEVblog on June 26, 2018, 03:46:08 amWell, you know, play to your weaknesses, forget your strengths, or how does it go....

author: CopperCone
author_rank: Super Contributor
timestamp: June 27, 2018, 12:08:56 am
content: if you want a crazy design on a decade resistance box look at the one that machinist that posts/used to post on this forum made, he length matched thick copper silver plated conductors that were like 8 awg or something, silver brazed, etc, it was very good equipment that made you think of the physics involved with resistance measurement quite well.https://www.youtube.com/user/ROBRENZ/videosspecificallyNevermind, not as good as I thought (well not crazy, it is well/over built), I don't remember where I saw that crazy thing I am describing. Maybe it was a teardown or something, regardless it was better built then my northrup or ESI resistance standards.I thought I saw something brazed with pure silver with something like 1/4 inch thick conductors somewhere lol

author: rs20
author_rank: Super Contributor
timestamp: June 27, 2018, 01:34:17 am
content: Quote from: Haatveit on June 27, 2018, 12:06:59 amReally? You just write the calibration routine once (which is just the box switching in different resistors, then asking the user to input the measured resistance.) Then each buyer of the kit just activates that routine once. Seems reasonable to me? Also, even without the calibration, the code could have decent defaults built in, and would thus be accurate to 1% even before calibration.Quote from: Haatveit on June 27, 2018, 12:06:59 amWhoops, good point. Regarding the four-point connection, I was thinking of something like page 9-3 ofhttp://assets.fluke.com/manuals/5450A___imeng0000.pdf(also see EEVBlog #544). But silly me, that arrangement is constrained to a string of resistors that the relays can select a start and end point. I think you're right, it's impossible to have a string of resistors and short certain ones out in a Kelvin connection style.MOSFETs have perfectly fine characteristics, the difficulty though is that you have to drive them with a gate voltage relative to the (MOSFET's) source terminal voltage. This becomes a real pain when the mosfet is floating halfway down a resistor string. If I were doing this, I'd probably use a SSR ("Solid State Relay") which is basically an optoisolator with a MOSFET as the output device. Something likeTLP241A. It might seem a little bit expensive if you need 10-20 of them, but keep in mind:Much lower power and more consistent* resistance than a real relay, and probably way cheaperMuch easier to drive than a relay or floating MOSFET (the input side looks like an LED, just drive it directly from the MCU)* Remember, if the MCU does calibration, it's only the unpredictability of resistance that matters. If the relay/MOSFET/SSRalwayshas a resistance of exactly 170 milliohms, that means it can be calibrated out perfectly.Quote from: Haatveit on June 27, 2018, 12:06:59 amUp to you of course. I'm not sure it'smuchmore complicated... it's just an ADC chip.

author: Haatveit
author_rank: Regular Contributor
timestamp: June 27, 2018, 03:33:20 am
content: Fair points and good explanations, thanks!Good idea with the SSR's. Didn't even consider that, but that makes it real easy, and should be very repeatable / predictable. I'll look into that for sure! Though, I must admit I have a strange love for the sound of lots of relays clicking in unison...Also seems hard to find SPDT versions of those SSR's, but that can probably be worked around. Would need two of them and an inverter per switch.Quote from: rs20 on June 27, 2018, 01:34:17 amI think I misunderstood your initial suggestion - I see what you mean now, I guess it wouldn't take long to run it through the routine once.I like this project... Might sit down to try part out a prototype of sorts, or maybe I can put something together from the parts bin. I feel like the majority of time investment would be the code, and that can be more or less done without the hardware. Easy to set up a simple representation of the internals to test it with.Quote from: CopperCone on June 27, 2018, 12:08:56 amPretty interesting design either way, but I'm sure thatdefinitelyends up being a whole lot of not-cheap.

author: magtux
author_rank: Newbie
timestamp: June 27, 2018, 10:27:05 am
content: Ok, so I've actually done this in the past for my Family's T&M company.http://alliedelec.co.in/product/digital-resistance-box/It was targeting more ATE equipment and priced around $100 bucks at the time so not impressive but it had nice 0.1% custom made resistors sourced locally.From experience, get a bigger cabinet. Also, you need a lot of power to drive all the relays. We also later made a LCR meter, but reading this thread, it makes sense to have made a complete solution that can compensate and adjust for any lead resistance and TC changes.Hmmm, maybe there is a product idea there. If you're interested, I can help you design it.The most expensive parts are the resistors. The design gets way way more complicated as your minimum resistance goes down. If all you need is a few hundred volts of isolation, it's easy to do.Do people actually need DRBs ?For comparison here is the dial version we use to sell for $50 bucks.http://alliedelec.co.in/product/decade-resistance-box-drb/

author: Siwastaja
author_rank: Super Contributor
timestamp: June 27, 2018, 03:33:37 pm
content: Quote from: rs20 on June 27, 2018, 01:34:17 amFor a DIY kit, manual calibration is a bit tedious - maybe not too bad but, worse, requires the user to have an accurate meter over the whole intended operating range.On the other hand, this calibration is utterly trivial in small-scale production environment - just connect an off-the-shelf multimeter with enough accuracy and a serial port to the device MCU and let them do the magic in a few dozen seconds automatically. Easy to scale up by getting more meters, and they are not expensive nowadays as the data link feature is now considered a low-end basic feature on multimeters.I think this is a textbook example for building a simple factory calibration line.

author: Haatveit
author_rank: Regular Contributor
timestamp: June 27, 2018, 04:16:37 pm
content: I think as a DIY kit I would probably just make sure it's well understood that the calibration will only be as good as the best multimeter you own. But it would be pretty simply to do the cal after assembly, if someone wants that.Even if the calibration routine is "manually entered" it would be pretty quick, the MCU just goes step by step automatically and asks you to input the reading on your meter.Quote from: magtux on June 27, 2018, 10:27:05 amInteresting! I figured something like this would have been done before, but haven't seen too many examples of it, certainly not commercial.A lot of of it comes down to location. Where I live, this type of equipment, even the dial versions, simply do not exist. There is no used market. Heck there isn't even a brand-new market. It's nonexistant. And on the extremely rare occasion that you do find something for sale - it's going to be priced 10x what it would be in, say, the US. Because it's rare, they don't know what it is, it looks special, therefore it's worth 400$.This all means international purchases are the usually the only options for gear, and that always also means import duties and shipping fees. The end result is that, even though lots of people are keen to point out 50$ options on the web, it'll cost 150$ by the time it's in my hands.So basically, building your own ends up being a viable alternative. It'll never be 50$ no matter what I do, but at least I can get some fun out of the project, and learn something new. The latter two are really the most important for me most of the time. I don't particularlyneeda DRB or a dial version for that matter. But I want oneAnd designing my own seems like a lot of fun.

author: german77
author_rank: Regular Contributor
timestamp: June 27, 2018, 05:34:04 pm
content: Why not make a DC electronic load. And measure the input voltage, calculate the current in the µC for a given resistor value and you got a digital resistance box.You could even make some cheap selector box made of cheap switched rotary encoders, or jumpers. with some multiplexing, some indicador lights and a battery. And you can have a portable digital resistance box that doesn't need any external cables that it's fairly accurate for slow signals. but could handle high currents.I think that's the next project I would make, I already have everything on hand.

author: Rolo
author_rank: Regular Contributor
timestamp: June 27, 2018, 05:48:41 pm
content: Or follow the KIS principle, keep it simple.

author: CopperCone
author_rank: Super Contributor
timestamp: June 27, 2018, 07:06:31 pm
content: Quote from: Rolo on June 27, 2018, 05:48:41 pmso long your not having fun from programming or developing advanced systems or worried about throughput that's a great solution

author: CopperCone
author_rank: Super Contributor
timestamp: June 27, 2018, 07:12:24 pm
content: Quote from: german77 on June 27, 2018, 05:34:04 pmwithout stating the obvious, I wonder if simulated resistors in the high ranges could provide good RF performance with specific metrics compared to trying to make the same resistors using films, but I am saying this out my ass without giving any thought to comparing the magnitude of the parasitics

author: german77
author_rank: Regular Contributor
timestamp: June 28, 2018, 01:04:51 am
content: Quote from: CopperCone on June 27, 2018, 07:12:24 pmI know those problems, a film resistor will be always better, that's why I said only slow signals. I wouldn't put more than 1 kHz on this circuit. It's more like a fun project to make with a µC than anything else. I may post the performance of this project in this forum and test it to it's limits.This idea it's as crazy as using relays to change the resistance. If he really wanted a cheap easy resistance box, the solution has been posted above with the jumpers.

author: magtux
author_rank: Newbie
timestamp: June 28, 2018, 08:27:41 am
content: No DRB even with Film Resistors is going to be performant at RF. The best ones I've seen go up to Audio Range. I'm talking about Gold Plated $5000 DRBs used by Space Agencies. The use case is only for calibration of instruments. Really, there is no way to make a variable resistance that works well at High Frequencies. The change in resistance creates a change in the signal path and will change associated parasitics and impedances.

author: SiliconWizard
author_rank: Super Contributor
timestamp: June 28, 2018, 04:15:42 pm
content: Quote from: EEVblog on June 26, 2018, 03:46:08 amAs the saying goes, "If all you have is a hammer, everything looks like a nail."Got some idea to distract him though: a lot of mechanical engineers I worked with have told me that the big boys don't use SolidWorks.

author: Haatveit
author_rank: Regular Contributor
timestamp: June 29, 2018, 03:02:10 pm
content: Well, turns out the problem of finding the optimal combination to get a desired result, when the resistors you have to pick from are not ideal, is an interesting mathematical problem. It also turns out to be NP Complete. It's a variation on theKnapsack Problem.But we can make successive approximations. I chose to do it the naive and dumb way. I'm sure this can be done more cleverly with a b-tree or something like that, but I usually solve the idea in the dumbest, simplest way first just to see that it actually works... I could also stop the search if we've found an exact match, or a match within an acceptable tolerance, AND I could start in the middle and perform a sort of pseudo-binary-search. Currently it just runs through all of it regardless, just to prove to myself that it actually works.4 decades, 10-10k5 decades, 1-10k(In this particular example the valuesareideal, but it does the same with floating point values)Given any arbitrary "box of treats" (resistors), it'll figure out what combination comes the closest to the desired value, and generate the switch matrix to make it happen. Literally just a matter of shifting the switch bits out to a daisy chain shift register or whatever else and there you go, it'll get you the closest possible based on the actual values of your particular box of resistors.I solved it by basically walking through all possible configurations and recording the error, and storing the best combination when a lower error combo is found. It uses almost no memory, but does takeCode:(decades*resistors) * 2^(decades*resistors)iterations to complete. So, for a 4 decade box that's 1M iterations, for a 5 decade box it's 20 million. Which is basically instant on my PC, 11ms, but yeah... Probably too slow on a µController.Now that I know I can get the code to work, it might be time to hack together some sort of prototype! I haven't really decided how to do the switching yet. You need twice as many optos as you do relays, so even though the price of low-RdsOn optos is lower, you still end up paying more than if you just went with relays, and I think relays will ultimately behave better. But I might as well try both.

author: rs20
author_rank: Super Contributor
timestamp: June 29, 2018, 03:34:49 pm
content: You're missing some important observations that can massively reduce the number of calculations required.First: adding a resistor in series always increases the resistanceSecond: the largest resistance always dominatesWith these two observations in mind, you can implement a totally naive recursion which tries turning the largest resistor either on or off, recursively calling itself each time to try the second largest resistor (recursing all the way down to the smallest resistor.) Naively, this would try every possible comination. HOWEVER, before doing the recursion, have it calculate with all the remaining smaller resistors turned on, and all the remaining resistors turned off. The resistances produced by all possible permutations have to fall between those two extremes, so if the desired value is not in (or very very near) that range, this branch of the recursion is a dead end and should not be followed any further.For example, say you're in the recursion branch that has committed to use the 40000 and 20000 ohm resistors, so a total of 60000 ohms so far. Adding all the remaining resistances adds (10 + 20 .. + 10000) = another 21100, so 81100. So if the desired resistance is 90000 or 50000 or 20 ohms, clearly using the 40000 and 20000 resistors and not using the 30000 resistor is a dead end, and you can avoid trying the 8192 permutations of the remaining 13 smaller resistors.This optimization reduces the number of computations in a 30-resistor array from 1,000,000,000 to about 120, or more like 60 if you really optimize it well (especially if you use near power-of-2 spaced resistors). So a pretty decent optimization I'd say, and brings it easily within the realms of a uC.

author: Haatveit
author_rank: Regular Contributor
timestamp: June 29, 2018, 03:51:38 pm
content: I appreciate the advice there, and I'll try to keep it in mind when I sit down to improve this thing. But I will admit I am not a programmer, and although I have vague memories of recursion and binary searches from C, I'm far from able to take what you said and actually implement itHence why I take the most naive approach first. Else I tend to get stuck doing something other than what I wanted (programming vs designing a cool system), and give up on it entirely because I lack the knowledge to actually perfect those aspects of the idea.

author: CopperCone
author_rank: Super Contributor
timestamp: June 29, 2018, 04:11:31 pm
content: If you desifn a good open source system with a solid circuit someone might program the math voodoo for you.I dpnt think anyone would trust that kind of stuff for calibration on equipment though. Not for anything serious.

author: rs20
author_rank: Super Contributor
timestamp: June 30, 2018, 01:54:39 am
content: Quote from: Haatveit on June 29, 2018, 03:02:10 pmNo you don't. Just have all the resistors in a string, and have one opto per resistor (arranged so that the opto is "shorting out" the resistor).[ Assuming that by "opto" you're referring to SSRs ]Quote from: Haatveit on June 29, 2018, 03:02:10 pmIn what sense?