Switchable voltage divider - Page 1
Forum section: electronics / beginners

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 19, 2017, 11:39:46 pm
content: I have a need to create a switchable voltage divider, under the control of a microcontroller. I'd be using it to switch among a range of resistors (approx. 3 to 47K, linearly) to create an RC timing circuit with selectable delay.Immediately I thought of using a 4051 analogue multiplexer IC. However, as I read the datasheets, I realise this doesn'tquitemeet my needs.The problem is with the voltage range I'll be working with. The signal the mux. needs to switch will be 12V, but I will be controlling it with a 5V MCU. If I make VDD of the 4051 12V, the digital input low/high thresholds are no longer compatible - low threshold would be around 3.5V, and high around 9V. But, if I make the VDD 5V, I can't use that to switch 12V, as even though 4051s are specified to handle 20V+, there is the limitation that the analogue signal level cannot exceed the difference between VDD and VEE.Are there any different 8-way analogue muxes that will meet my needs?Or is my only choice the obvious solution of just running the 4051 at 12V and putting a level-shifter between it and the MCU (perhaps a 40109)?

author: pigrew
author_rank: Frequent Contributor
timestamp: May 19, 2017, 11:54:07 pm
content: Another option could be using a "digital potentiometer", some of which are able to support the voltages you're asking about.

author: amspire
author_rank: Super Contributor
timestamp: May 19, 2017, 11:54:12 pm
content: The solution may be simple depending on the circuit. A diagram would help. You are describing two things - a voltage divider and a RC timing circuit and without more info, it is very vague.If the resistors connect to 0V, a simple mosfet per resistor would do the job. Or you may be able to switch capacitors instead of resistors.Or it could be that instead of resistors, you can use a programmable current source controlled by the micro.Micros can be great at providing voltage division (via PWM) and timing (via interrupts) so it may be there are many alternatives.

author: RandallMcRee
author_rank: Frequent Contributor
timestamp: May 20, 2017, 12:35:19 am
content: Many, many analog switches have the level shifter built in.I have a bunch of DG411s that will do this, for example. For your application it would probably be preferable to have each independent switch control a resistor in the ratio of 1-2-4-8 providing, of course, 16 possibilities. Since you have a microcontroller this is simple and easy.Like amspire says, there are many other ways as well.http://www.vishay.com/docs/70050/dg411.pdf

author: danadak
author_rank: Super Contributor
timestamp: May 20, 2017, 12:38:24 am
content: A PSOC with Wavedac component will generate sine, tri, saw, square, pulse,custom. If control is data drive, or sent over link, simple call to Wavedac willchange freq. PSOC has many com interface components. If control is someanalog signal that use internal A/D and use results to control freq.See attached project screen shot.Another way is to use PSOC current source driving a cap and use a comparatorto control cap discharge. Think SAW wave. Highly linear, broad range, you canV control its freq via several methods, eg. A/D....Attached screen shot.Regards, Dana.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 20, 2017, 02:38:17 pm
content: Quote from: pigrew on May 19, 2017, 11:54:07 pmThanks for the idea, but I did have a look at digital pots and decided that wasn't an avenue worth pursuing. The vast majority of ICs didn't support the voltage necessary, many were non-linear, and the ones that did were far too over-complicated with all sorts of features I don't need. Not to mention relatively expensive too.Quote from: amspire on May 19, 2017, 11:54:12 pmLet me give a little more info. What I am attempting to accomplish is to add functionality to an existing system without physically modifying any of its component parts. It has what is essentially a 9-position potentiometer knob that is used as part of an RC timing circuit that adjusts the length of a regular on/off cycle period of a relay that controls another part of the system. What I want to do is automatically adjust this timing based off a tertiary input signal from outside the system. The potentiometer in question is actually off-board on this device, connected by a small 2-pin Molex connector, so it is ideally placed to be substituted by my circuitry - i.e. to be 'plug-n-play'. So, this is why I am simply looking to replicate the functionality of this pot via a switchable resistor network, and not a more holistic solution.Quote from: RandallMcRee on May 20, 2017, 12:35:19 amThanks for the suggestion. I don't think the DG411 will be suitable, but I saw there is also an 8:1 mux in the same family, the DG408. Do you think this will do what I need?Shame they're so expensive, though... I can buy 10 4051s for the price of one DG408!Another couple of thoughts occurred earlier regarding this thing.Firstly, you may have noticed that I said above that the existing control knob hasninedistinct positions, but that I was looking at aneight-way mux. This is because the ninth position of this pot is actually zero ohms, which I think I can handle separately, without resorting to, say, a 16-way mux just to get one extra channel. My idea was to take advantage of the inhibit input on the 4051 (or equivalent). If I have an NPN transistor in parallel across the input and output, with its base controlled by the inhibit line, turning that on will turn off the entire 4051 and turn on the transistor, shorting the input to the output and effectively making the 'zero' ohm setting. Will this work, or is it not that simple?Schematic to illustrate:The second thought was about switching time. The existing control pot is continuous, even though it has nine distinct positions, I measured no break in contact when changing position. However, using something like a 4051 will introduce a switching delay time (they are break-before-make, I believe), even if it is tiny. Is it a concern, when part of an RC timing circuit or will this have negligible effect?

author: rstofer
author_rank: Super Contributor
timestamp: May 20, 2017, 02:54:06 pm
content: The transistor idea will work under two circumstances:1) The emitter portion of the control circuit is at ground and that ground is common with logic ground.2) The 0.2V VCESat is acceptable. The transistor will not create 0 Ohms.

author: amspire
author_rank: Super Contributor
timestamp: May 20, 2017, 03:18:11 pm
content: Your circuit should work. You could replace the transistor and resistor with a mosfet such as the common 2N7002 with the gate directly to the inhibit input. You do not need to use the inhibit input as the transistor shorting the output makes it irrelevant.Make sure you get a proper 4051 (like the CD4051) and not anything beginning with 74xxxxx. Also it is not a bad idea to add two schottky diodes to the capacitor to make sure the voltage can not get to 0.5V less then the 4051 -ve or 0.5V over the 4051 +ve rail.Another option may be to just have a single resistor, and have 4 capacitors and 4 2N7002 transistors or NPN transistors with a base resistor and a reverse diode collector to emitter. All the drains or emitters are connected to the -ve/0v rail and one of the transistors does the short. The other 3 transistors are switching in a capacitor C, C/2 and C/4. You have a capacitor C/8 permanently connected to the resistor. This will give you the possible capacitances C/8 (the fastest time constant), 3C/8, 5C/8, 7C/8, 9C/8, 11C/8, 13C/8, 15C/8 (the slowest time constant) and of course you have the short. You get a 15:1 range of time constants. This method doesn't use any 4051. It may be a good idea to have a high resistor across the "Off" capacitors. Whether this works or not depends in exactly how your RC time constant circuit works. We do not have the circuit so we do not know what is triggering the time constant and what is affected by the time constant.

author: Zero999
author_rank: Super Contributor
timestamp: May 20, 2017, 04:45:32 pm
content: Quote from: danadak on May 20, 2017, 12:38:24 amWhat voltage will it work up to? Most of the products, like that I've seen are restricted to 6V at most.

author: KL27x
author_rank: Super Contributor
timestamp: May 21, 2017, 12:57:52 am
content: QuoteWell... how long are the delays? There's a difference between picoseconds and hours.If this was a real concern you could instead of switching resistors in/out, recalculate the values so you could put them all in parallel. With all 8 in parallel, the total resistance is 3.9K. Then you remove 1 resistor, you're left with 10K. And so on. Of course you couldn't use a 4051. And trying to formulate the equation for that is making my heard hurt. Perhaps use micro with 8 free io, and optocouplers to FETs... not elegant in the pcb, though.QuoteTransistor can mean FET, though.Have you already considered bypassing the RC timing circuit, altogether, and switching it out for your own, controlled via micro? Or is the pot the part that is easily physically accessible?

author: Brumby
author_rank: Unknown
timestamp: May 21, 2017, 09:05:44 am
content: I was wondering if you might try an alternate approach....Rather than switch out resistors for the timing circuit, work out theeffectof each resistor in the timing circuit and then emulate anequivalentsignal.I have no idea if this is in any way practical or possible with the system you have, but it is just an idea.

author: danadak
author_rank: Super Contributor
timestamp: May 21, 2017, 06:54:23 pm
content: The WAVEDAC component maxes out, for Vdd = 5V, at about 4V peak topeak for the waveform, swing from Vss to 4V. If you need larger swing thenexternal OpAmp would have to be used.Regards, Dana.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 22, 2017, 02:59:14 pm
content: Quote from: rstofer on May 20, 2017, 02:54:06 pmI'm not too worried about whatever small amount of resistance the 'zero' transistor will have. So long as it's no more than a couple-hundred ohms, it should be fine. The existing potentiometer has a 13K resistor in series before it to set the base resistance anyway, so plus/minus a few ohms is no big deal.Quote from: amspire on May 20, 2017, 03:18:11 pmYes, thanks, I think a MOSFET might be a better choice here, for reasons I have discovered and will describe further below.Quote from: KL27x on May 21, 2017, 12:57:52 amNow I have examined the DG408 datasheet in more detail, I find it says total transition time is specified as 160-250ns, and break-before-make interval is 10ns. I guess this is not a big deal after all, and will have sod-all effect?Quote from: KL27x on May 21, 2017, 12:57:52 amAh, yes, I see. And just thinking about attempting to work out all the necessary values to arrange the resistors in parallel is making my head hurt too.Quote from: KL27x on May 21, 2017, 12:57:52 amYes, the pot is the only part that is easily modifiable/substituted. The rest (well, except an start/stop switch) is all on one PCB, and would require butchering the circuitry to modify it in any way.I was examining the existing circuitry a bit closer yesterday, as there was one aspect of it I still didn't understand, but while doing so I discovered something that throws a slight spanner in the works.Firstly, the part I wasn't sure about was how the RC timing circuitry that switched the relay managed to reset itself. I wasn't immediately seeing how that happened. What I figured out was that the mechanism that the relay activates has a 'home' switch that works as follows:1. The home switch, which is SPDT, is by default connected to ground.2. When the relay activates the mechanism, after a very short period, the home switch is toggled and takes over the power feed to the mechanism, ensuring that the mechanism always completes its cycle, regardless of what the user does with the controls.3. When the cycle completes, the mechanism returns to the home position and toggles the home switch back to ground.This home switch's output is also actually what is connected to the other side of the electrolytic capacitor that is in the RC timer (which appears to be a non-polarised one, as it doesn't have a stripe).I put together a simulation to better understand what's going on, and discovered that when the home switch goes back from +12V to ground, the other side of the timing capacitor goes negative! Of course, this is what causes the relay to turn off, and the delay period to begin again as the cap re-charges. But this has ramifications for my planned additions, does it not? It needs to handle the input terminal being +12V while the output terminal potentially is -12V!That's not all. The start/stop switch is actually between the cap and the transistor/relay part of the circuitry. This means that after the device has been on for a little while, but not started, the cap will be fully charged with +12V. When started, the cap will start to discharge, but not by much before the home switch kicks in and transfers +12V to the other side of the cap, which means the first side will jump to potentially +24V!I screen-capped the simulation running that shows both these things:Now, I think I can handle the over-voltage by inserting a diode to +12V right after the pot (or indeed my substitute circuitry). According to the simulation, this prevents the over-voltage surge. However, I'm not sure how to handle the negative. Can't simply put a diode to ground, as that stops the whole thing working - itneedsto be able to go negative.I don't think the negative voltage will have any effect on the MOSFET, as a 2N7000 is rated for 60V VDS. But what about the analog mux? I'm not sure what to do about that.

author: pigrew
author_rank: Frequent Contributor
timestamp: May 22, 2017, 03:22:21 pm
content: Quote from: HwAoRrDk on May 20, 2017, 02:38:17 pmWhat price point are you looking for? For example, the microchip MCP41HV31-104E/ST could work. It is a 100k pot that supports a 36 V analog range and is linear, costing about US$1.50. It's controlled using SPI, so would need three GPIO pins from the micro.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: May 22, 2017, 04:32:26 pm
content: Quote from: pigrew on May 22, 2017, 03:22:21 pmI think I recall seeing that chip - the 50k version. That was one of the ones that ended up in the 'over-complicated' category.

author: VEGETA
author_rank: Super Contributor
timestamp: May 23, 2017, 11:09:52 am
content: You could use MOSFETs to switch between them since they have low Rds. However, if you really wanna use a good solution then you might wanna try E-POT which is a digital potantiometer, it is SPI or I2C device that interfaces with MCU.Good luck