Level shifting with fixed gain - Page 1
Forum section: electronics / projects

author: technix
author_rank: Super Contributor
timestamp: October 07, 2017, 01:22:59 pm
content: Do you have any methods to shift a control voltage up or down, optionally with a fixed gain? The input is ground-referenced voltage, and the output is a a floating MOSFET gate control.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 07, 2017, 02:26:13 pm
content: Sure, tons...- Floating voltage?- And its bandwidth or dV/dt?- Control voltage tolerance (gain + offset), distortion, bandwidth?Tim

author: technix
author_rank: Super Contributor
timestamp: October 08, 2017, 01:37:38 am
content: Quote from: T3sl4co1l on October 07, 2017, 02:26:13 pmThe output voltage referenced from the P-channel MOSFET drain pin is -2x the ground-referenced input voltage. So yes it is floating. I am not sure how much bandwidth is required for this PMOS LDO design, but I do wish it can limit the bandwidth somehow to keep things under control.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2017, 12:55:35 pm
content: Oh dear, an LDO? Why make one?Tim

author: technix
author_rank: Super Contributor
timestamp: October 08, 2017, 01:08:56 pm
content: Quote from: T3sl4co1l on October 08, 2017, 12:55:35 pmThe LDO is the third stage of my DIY network-connected mixed-mode bench power supply. The first stage is a fixed 19.5V/65W mains power supply, the second stage is a bypassable dual-phase synchronous rectifying tracking buck converter based on LM2642 chip, and the third stage is this digitally controlled LDO linear regulator centered around a STM32F303CCT6 chip.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2017, 01:27:26 pm
content: I always found the obsession with post-reg strange.Have you demonstrated a requirement for post-reg? Is the switcher really that noisy?Is it really not cheaper to filter it?Is the LDO even going to have enough gain and stability at high frequency to accomplish anything?Tim

author: technix
author_rank: Super Contributor
timestamp: October 08, 2017, 01:53:25 pm
content: Quote from: T3sl4co1l on October 08, 2017, 01:27:26 pmSo in your opinion a multi-phase buck converter with heavy output filtering can provide low enough ripple in most cases? (A STM32F3 here can be used to build a 3-phase synchronous buck converter with internal error amp and comparator.)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2017, 01:56:24 pm
content: Why does my opinion matter? Use numbers my friend.There are plenty of radios and test equipment using switchers in them. They can't all be wrong!Tim

author: Siwastaja
author_rank: Super Contributor
timestamp: October 08, 2017, 02:53:42 pm
content: Quote from: T3sl4co1l on October 08, 2017, 01:27:26 pm+1, at least once a month a new topic where a newbie is making their first or maybe second lab supply project, with a linear post-regulator (maybe I'm exaggerating a bit, but anyway).And, of course, usually totally ignoring the issue of linear reg PSRR even at the fundamental frequency of their switcher.Fast LDOs that can provide useful attenuation at the switcher ripple+noise frequencies of course do exist, but designing one is not trivial.But a buck lab supply could just easily be designed to use high enough frequency (500kHz? 1 MHz?), then add a slight compromise on the rise/fall times for EMI/noise, still decreasing the efficiency much less than the linear post reg would do, finally choose a bit larger inductor for lower current ripple% than some "usual" 30-40%. Stability (in a current mode controller, of course) over the frequency range is totally guaranteed and easy to achieve, and the design stays super simple.If this is not enough, an extra LC stage would do the trick, but it's not completely trivial and can be accidentally designed to be unstable or amplify noise on certain frequencies - just like the LDO post reg.So, unless the lab usage case is some super hyper special "mere mortals never do this using this outer space magic technology which needs super special ripple specs", you most likely get good enough results without LDO post reg. OTOH, if your case is the said special case, it won't be trivial to design the required LDO stage.So, my point in TLDR: lab supply with a linear post reg is quite a special, rarely needed, complicated and hard-to-design instrument. The odds are, you most likely don't need it.

author: Siwastaja
author_rank: Super Contributor
timestamp: October 08, 2017, 02:59:23 pm
content: Quote from: technix on October 08, 2017, 01:53:25 pmCan confirm, I have made a 2-phase peak current mode synchronous buck using STM32F334 & LT1999-20 & bootstrap gate driver. Simple HW design, low cost BOM, the comparator in the STM32 is really fast and can provide good peak current control by directly terminating each pulse. As always with STM32, some documentation & unspecified silicon bug issues that will take some design time.Even the internal DAC, which can be internally routed to provide reference level for the current comparator, is so quick (1 µs) that it can be used to generate all kinds of waveforms - or just to provide quickly-responding PID feedback loop for the voltage control - and current finetune (which may be needed for accurate current limit because the peak current controller does only give average current to about +/- 5% accuracy).If you do the basic peak current mode, be aware of subharmonic oscillation if you go above 50% duty cycle.My project was a battery charger/discharger/measurement system, but it could work as a source-sink lab supply as well.

author: technix
author_rank: Super Contributor
timestamp: October 08, 2017, 03:41:03 pm
content: Quote from: Siwastaja on October 08, 2017, 02:59:23 pmSo how to do the multi-phase current-mode control? I plan to use STM32F303CCT6 as the main controller chip, IR2101 as the gate driver and IPD09N03LA N-channel MOSFETs. INA138 is used as the high-side current sense amplifier but I can only afford using one for the output current sensing. Also is it possible to link TIM1 and TIM8 into producing a 6-phase buck converter?Also how to calculate the maximum amperage of the converter at low output voltage (like 3.3V from a 20V input) with 3 or 6 phases?

author: Siwastaja
author_rank: Super Contributor
timestamp: October 08, 2017, 05:25:57 pm
content: Quote from: technix on October 08, 2017, 03:41:03 pmI would seriously consider using current sense on each phase. The idea is to directly sense the inductor current in each inductor. This automatically guarantees perfectly stable system against all loads and all corner conditions (as long as you keep the comparator current setpoint well below the inductor saturation current). Anything else is a bit of a cheap kludge. Probably doable using the timers somehow, I think you could use the current comparator signal to trigger timer capture (in addition to changing the FET state in the relevant phase), then copy this pulse length value to the other channels that would just run compare match PWM. But it would always lag behind a bit.If you do a real pulse-by-pulse peak current mode controller, you could run out of the peripherals. STM32 is full of catches for the young players so to speak: the datasheet front page promises all kinds of peripherals, but can they work simultaneously? Can they work together? Are the pin mapping options good enough so that you can do what you want? It usually isn't, even in the biggest package.If you want to set the current limit phase-wise, you run out of DAC channels - it only has two. If you can use the same setpoint, make sure (see the reference manual) that you can actually route the same DAC signal to multiple comparators. Most of these limitations can be circumvented by adding external components, but that is probably not desirable.I just did two phases on STM32F334, I think three would have been the max. Then I copy-pasted the design and used the HRTIM synchronization signal for 45 deg phase shift so that I can run 4 phases.

author: technix
author_rank: Super Contributor
timestamp: October 09, 2017, 12:33:50 am
content: Quote from: Siwastaja on October 08, 2017, 05:25:57 pmDo I need multiple DACs for a multi-phase converter, since all phases are paralleled together? Also how to do high side current sensing without involving the expensive INA138?

author: Siwastaja
author_rank: Super Contributor
timestamp: October 09, 2017, 06:12:20 am
content: Use the money you save in not doing a linear-post reg stage to buy those high-side amplifiers with high enough bandwith that they can be in the direct peak current mode control loop, for each phase.Re DACs, you need to look for the reference manual to find out if you can use the same DAC signal for every comparator. Then you cannot fine-tune the inductor average currents separately, but that's totally unimportant. Every phase will have closely guaranteed peak current never exceeding the setpoint.Please also note that the "Advanced control" timers you are using might not be good for very high frequencies. I don't know; I used the HRTIM (of STM32F334) because it's explicitly designed for this kind of task. The "Advanced control" timers are designed for 3-phase motor control, which usually happens below 50 kHz. There is not enough time resolution to generate high frequencies at high resolution, needed for modern buck like you are doing, you definitely want to run it at at least 200 kHz if not 500 kHz or even 1M.This being said, in pulse-by-pulse peak current mode, you don't actually use the timer counters at all to generate the PWM, you just initiate the pulse at counter wrap-around and then the overcurrent signal terminates each and every pulse in an "analogue" way - the timing is only quantized by the synchronization of the signal. So the slower timers might be just fine. You'll have a lot of fun going through the 2000 pages of refman and datasheet just to confirm: "can I actually do this?" And when you finally have your answer, it's all bright and actual coding won't take long.All I can tell you is that I have confirmed STM32F334 to be capable of providing two simultaneous chains of a DAC, comparator, HRTIM output generation unit and differential ADC working together to give actual, exact pulse-by-current limit with additional current samples taken using ADC to measure average current.

author: technix
author_rank: Super Contributor
timestamp: October 09, 2017, 07:45:09 am
content: Quote from: Siwastaja on October 09, 2017, 06:12:20 amCan I do high side current sensing using just a normal RRIO op amp like TLC2274 or LMV321? If so I may be able to skip the much more expensive one-INA138-per-phase approach and use those cheaper chips.

author: Siwastaja
author_rank: Super Contributor
timestamp: October 09, 2017, 11:08:21 am
content: Well, maybe. "Specialized" high-side amps typically have the following selling points:- Lower input offset: because you measure very small voltages and don't want huge errors- High bandwidth: so you can use it in the control loop directly- Input common mode often goes well beyond both GND and Vcc pins.The last one is the important one: it's not untypical at all to use an amplifier powered from a 5V supply, so the output bounds to this and is directly usable on a microcontroller; but the input common mode canexceedthe 5V without any problems.In your project, I guess the input common mode would be all over the place between GND to +19V.

author: technix
author_rank: Super Contributor
timestamp: October 09, 2017, 11:29:14 am
content: Quote from: Siwastaja on October 09, 2017, 11:08:21 amWell I am going all out with INA138’s now since I found someone blowing off leftover stock: one for each of the three or four phases and one sensing the sum of the output.I won’t bother fine tuning inductor current. So how do I control the output voltage?

author: Siwastaja
author_rank: Super Contributor
timestamp: October 09, 2017, 12:10:31 pm
content: Measure with ADC quickly, run software PID in an interrupt handler: input = voltage error; output = current setpoint. The 1us DAC is good because you can adjust the setpoint so quickly.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 09, 2017, 12:11:47 pm
content: INA138 is too expensive? On a one-off project?You've spent orders of magnitude more, as time, just talking about it!Tim

author: David Hess
author_rank: Super Contributor
timestamp: October 10, 2017, 07:32:13 am
content: Quote from: technix on October 07, 2017, 01:22:59 pmBy fixed gain do you mean a gain of 1 which is advantageous when the level shift is within a feedback loop? Lots of old designs did this either using a zener diode or my favorite, a fixed current through a resistor although this is more complex. The zener diode or resistor can be bypassed with a capacitor to preserve AC response.I am not a fan of rail-to-rail input operational amplifiers because of the performance compromises involved.Quote from: technix on October 09, 2017, 07:45:09 amThe ancient LM301A bipolar, TL051 series JFET, and LF356 series JFET operational amplifiers make fine high side current sense amplifiers because their common mode input range includes their positive supply.For real bandwidth, a discrete high side current sense amplifier with a matched pair is much faster but I have very rarely seen this done. I think Zetex has an application note showing the idea.