Convert 0..5v PWM to 6,5..11,5v - Page 1
Forum section: electronics / projects

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 27, 2018, 04:19:25 pm
content: Hi, i am using this 8 bit mcu PWM to generate a control value, the power supply is 12 volt.I need 6,5 volt to 11,5 volt range, how do i convert the 0 to 5 volt PWM range ?I could add exact 6 FETs and a bit bias, or try 5, only it is to expensive.How would you fix this ?thanks

author: Benta
author_rank: Super Contributor
timestamp: December 27, 2018, 04:31:42 pm
content: Integrate and level shift using a couple of opamps.

author: wraper
author_rank: Unknown
timestamp: December 27, 2018, 04:39:27 pm
content: You don't even need to level shift. Just output PWM in 55-100% range and use Sallen-Key filter with a gain of 2,3https://electronics.stackexchange.com/questions/74877/gain-in-sallen-key-filter

author: ogden
author_rank: Super Contributor
timestamp: December 27, 2018, 04:53:30 pm
content: All you need - convert 5V PWM signal to 12V PWM using (logic) level shifter made out offewtwo transistors and as already said, use 55%-100% PWM range. On the output you may use same RC filter you already have.

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 27, 2018, 05:08:57 pm
content: Quote from: Benta on December 27, 2018, 04:31:42 pmThat is what i ask for.Quote from: wraper on December 27, 2018, 04:39:27 pmIs that filter schematic for single supply ?Quote from: ogden on December 27, 2018, 04:53:30 pmHow would i do that ?, you have any schematic ?

author: ogden
author_rank: Super Contributor
timestamp: December 27, 2018, 05:23:16 pm
content: Quote from: Jan Audio on December 27, 2018, 05:08:57 pmBy searching internethttps://electronics.stackexchange.com/questions/158817/generating-12v-pwm-from-5v-pwmThis one is closest to what I did mean:

author: wraper
author_rank: Unknown
timestamp: December 27, 2018, 05:25:31 pm
content: Quote from: Jan Audio on December 27, 2018, 05:08:57 pmPowered from +12V and GND in your case. Needs opamp with output able going to positive rail, basically any rail to rail opamp would work. You need negative supply for opamps only if you need negative output voltage.

author: wraper
author_rank: Unknown
timestamp: December 27, 2018, 05:31:03 pm
content: Quote from: ogden on December 27, 2018, 05:23:16 pmSallen-key with needed gain will have less parts and offer better signal filtering than this + RC.

author: Benta
author_rank: Super Contributor
timestamp: December 27, 2018, 05:38:54 pm
content: We need to know a little more:PWM frequency?Modulated signal frequency? (or is it DC?)Desired response time?Then it's possible to suggest a circuit.

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 27, 2018, 05:40:52 pm
content: I use PIC16 PWM.It is for DC.Response time dont matters, need to be realy smooth.

author: ogden
author_rank: Super Contributor
timestamp: December 27, 2018, 05:51:34 pm
content: Quote from: wraper on December 27, 2018, 05:31:03 pmCost is an issue here two BJT's are much cheaper than opamp. OP says that response time does not matter, so opamp-based filter have no advantages here compared to simple RC filter.

author: wraper
author_rank: Unknown
timestamp: December 27, 2018, 05:57:37 pm
content: Quote from: ogden on December 27, 2018, 05:51:34 pmCheaper than what, 10-30 cents for opamp? It has advantage of being second order filter and having buffered output, thus not depending on input resistance of what it drives.

author: ogden
author_rank: Super Contributor
timestamp: December 27, 2018, 06:33:32 pm
content: Quote from: wraper on December 27, 2018, 05:57:37 pmDoes < 3 cents/piece (qty 100) of MMBT3904 qualify? For slow application you can use just single transistor shifter as well. Yes, buffer of opamp is good "nice to have" feature. I am not against opamp-based filter, I just say that plain RC filter is most widely used, thus shall be offered first.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 27, 2018, 06:45:44 pm
content: Something like the following (example with a 10kHz PWM signal). The two LP stages get you a decent filtering. The plus is you keep your whole PWM dynamic range. Corollary is it will output ~6.5V even when the PWM signal is not running, which won't be the case with solutions which are just scaling without shifting.

author: Benta
author_rank: Super Contributor
timestamp: December 27, 2018, 06:55:11 pm
content: I'd do it like this:(quick and dirty sketch, sorry)You might even skip the first filter.It's the perfect application for my favorite R-R opamp, LMC6482 (no affiliation).

author: Zero999
author_rank: Super Contributor
timestamp: December 27, 2018, 07:30:17 pm
content: Quote from: SiliconWizard on December 27, 2018, 06:45:44 pmGood, except use an op-amp with a rail-to-rail output, such as the NJM2741, OPA342 etc.

author: Benta
author_rank: Super Contributor
timestamp: December 27, 2018, 07:44:42 pm
content: The OPA342 will not operate at 12 V. You'll need replacement smoke...The circuit also has a DC gain of over 1. Don't know if that's desired.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 27, 2018, 08:01:52 pm
content: Quote from: Zero999 on December 27, 2018, 07:30:17 pmThe OPA342 is a 5.5V max device AFAIK, so probably not this one.The NJM2741 would be a nice candidate but it doesn't seem available from the usual suppliers (Mouser, Digikey...)But that's right. A RR opamp. I picked this one as a cheap solution thinking it was RR, but memory didn't serve well and the simulation didn't show any issue going up to 11.5V, but the output is unloaded... (the spice model may suck too).Given the very modest BW requirements, the op can select pretty much any cheap RR opamp that can operate at 12V.A reasonably cheap, low-power and widely available candidate would be the TLV170 for instance.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 27, 2018, 08:06:02 pm
content: Quote from: Benta on December 27, 2018, 07:44:42 pmYes, it has a gain of 2. Because the summing network (R4, R5) actually divides the sum by 2.

author: Benta
author_rank: Super Contributor
timestamp: December 27, 2018, 08:26:15 pm
content: Quote from: SiliconWizard on December 27, 2018, 08:06:02 pmNo it doesn't. Do the math.

author: Zero999
author_rank: Super Contributor
timestamp: December 27, 2018, 11:50:07 pm
content: Quote from: Benta on December 27, 2018, 07:44:42 pmWhoops, I meant the OPA172, not the OPA342, which as you correctly stated has a maximum supply voltage rating of 5.5V.Quote from: Benta on December 27, 2018, 08:26:15 pmNo, the summing network divides the signal by just over 2. I can't be bothered to work out the exact figure at the moment. You work it out, if you want to know. Hint: R1 and R4 have an impedance of 110k and R2, R3 and R5 have an impedance of 105k454.I'd do something like this. The PWM frequency and ripple requirements weren't stated, so I didn't bother calculating the values of the filter components. I just plugged some values in which didn't cause any overshoot and gave a nice flat output in LTSpice.EDIT: I forgot the pre-filter. See my next post for the updated schematic.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 28, 2018, 12:13:49 am
content: Quote from: Benta on December 27, 2018, 08:26:15 pmIt approximately does. Not exactly ok, but it's close enough and limits the number of different resistor values. I get something like 11.6V for a 5V input. The op didn't state its requirements in terms of accuracy. You can always calculate resistor values for a more accurate overall gain if needed, but I didn't see the point. Given the need of the op, it didn't seem like he needed a precision design.---Calculated to get theoretical figures: I get approx.:Vout = 6.68 + 0.98*VinNote: you can replace R4 with a 95.3k resistor (existing value, but of course more expensive) to get better accuracy: Vout = 6.54 + 1.00*Vin

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2018, 10:07:21 am
content: I forgot a pre-filter is required, otherwise high frequencies will get through the Salen-Key filter, as the op-amp has a finite bandwidth. R4 can be split and another capacitor added.

author: mikerj
author_rank: Super Contributor
timestamp: December 28, 2018, 02:50:30 pm
content: Quote from: SiliconWizard on December 28, 2018, 12:13:49 amThat is a gain of less than 1.

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 28, 2018, 02:51:29 pm
content: I think i go with SiliconWizard schematic :Can it be used for DAC signal also ?Can it be used for whole range ?@Zero your circuit is wrong, the PIC16 can not have more then exact 10K for impedance, it can charge not decharge, pulldown resistors required.

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2018, 03:28:51 pm
content: Quote from: Jan Audio on December 28, 2018, 02:51:29 pmMy circuit is not wrong!The load of the PIC impedance will have a lower, not an upper impedance limit. Post the datasheet for the PIC16.You're connecting it to the output of the PIC, which is more than capable of driving 100k of impedance. Indeed it's better than SiliconWizard's circuit, in that it derives the reference from the regulated 5V rail, rather than 12V which presumably isn't that well regulated and has a Salen-Key filter which will give a smoother output. It also less accurate at meeting the 6.5V to 11.5V specification and requires the PIC to sink more current, than the circuit I posted, although this can easily be changed by altering the resistor values.Please note that this isn't a free electronic design service: people contribute on a voluntary basis so be gracious even if you don't get exactly what you're looking for!

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 28, 2018, 04:27:37 pm
content: Quote from: Zero999 on December 28, 2018, 03:28:51 pmYes it is, and by helping you learn.No pulldown resistor needed in your circuit then ?

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2018, 04:47:18 pm
content: Quote from: Jan Audio on December 28, 2018, 04:27:37 pmNo this place is not a free electronics design service and I thought you were the one asking for help? I'm always willing to learn though. Please enlighten me, if I've missed something.No pull-down resistor is required in my circuit. Why do you believe a pull-down resistor is necessary? A PIC can both sink, as well as source current.If you're after a 6.5V output in the case of the PIC becoming disconnected, then you didn't specify that and SiliconWizard's circuit won't do that either.

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 28, 2018, 05:12:33 pm
content: It has only 10 to the capacitor.Note that 10K also can be to much.Instead i use two 4K7 resistors with 2 capacitors.Dont give something if you dont like to do so, dont complain afterwards.Free electronic design service : very nice.

author: ogden
author_rank: Super Contributor
timestamp: December 28, 2018, 05:24:40 pm
content: Quote from: Jan Audio on December 28, 2018, 05:12:33 pmSuch attitude may backfire easily. Many seeing your arrogance may avoid to help you in the future. I am ignoring you from now.

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2018, 05:30:06 pm
content: Quote from: Jan Audio on December 28, 2018, 05:12:33 pm4k7 is a lower impedance which is worse.Fine, it looks like you're the expert, post your brilliant design, or stop trolling.

author: wraper
author_rank: Unknown
timestamp: December 28, 2018, 05:47:05 pm
content: Quote from: Jan Audio on December 28, 2018, 04:27:37 pmThe only thing we usually get by helping others is wasting out time with no benefit gained. FWIW if I spent all of the time helping others here to earn money instead, I'd get quite an additional income. More than most of the people earn on full time job where I live.

author: Zero999
author_rank: Super Contributor
timestamp: December 28, 2018, 05:54:33 pm
content: I have learned from helping others, but that's normally the exception to the rule.Normally I find it rewarding, but there are exceptions.

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 29, 2018, 02:13:43 pm
content: Besides does a robot generate your circuits ?Quote from: ogden on December 28, 2018, 05:24:40 pmNo.What does it mean then : not free electronic service ?, i,m not paying.That is saying you dont want to give anything for free ?

author: Simon
author_rank: Unknown
timestamp: December 29, 2018, 02:32:19 pm
content: Quote from: Jan Audio on December 29, 2018, 02:13:43 pmYou are missing several points. Perhaps you need to improve your attitude. This forum is not about users like you rocking up and making demands for help and being served a fully functional design. It is about talking about the various aspects of a problem / design / solution and helping you to help yourself in deciding the best way forward. If all you are going to do is demand help and reply with arrogance your days here if not your hours will be shortly numbered!

author: ogden
author_rank: Super Contributor
timestamp: December 29, 2018, 02:50:46 pm
content: Quote from: Jan Audio on December 29, 2018, 02:13:43 pmThere are many other "goods" besides money.Yes - I do not like to help those who are ungrateful and disagreeable.

author: wraper
author_rank: Unknown
timestamp: December 29, 2018, 03:13:35 pm
content: Quote from: ogden on December 29, 2018, 02:50:46 pmSame here. Already added Jan Audio to ignore list.