Precise (Vp-p) PWM from MCU - Page 1
Forum section: electronics / projects

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 06:22:25 am
content: Hello.I am trying to improve output of a constant current circuit that is illustrated on top level in the attached images. Precision (and minimizing temperature drifting) is priority. Using U2 as a buffer (image: U2buffer) is easy, but precision is depended on the supply voltage. Maybe using a zener the way described in the image "TL431" is an option. Well.. maybe there is an "industrial standard solution" for this (?)The answer for the first follow-up question: I have not set the target precision level. This is more like fundamental discussion of the topicAEdit: TL431 is not fast and probably not suitable to use the way described in the circuit attached

author: Ian.M
author_rank: Super Contributor
timestamp: January 16, 2022, 07:52:46 am
content: You need to switch between your output Vref ('Accurate 5V') and analog ground. If analog ground isn't directly tied to digital ground, use a SPDT analog switch chip, but beware of its on resistance which may be non-linear with respect to channel voltage and vary between the NC and NO paths. However its far more likely that you have a common ground, and then you can use a simple CMOS buffer. e.g. if you are feeling cheap, any 74HCT gate powered from a reference voltage in the range 4.5V to 5.5V, possibly paralleling gates in the chip for lower output resistance, or you could use a74LVC1T45dual supply level translating buffer with its direction pin tied high or low to make it unidirectional, the input side Vcc pin fed 3.3V and the output side Vcc pin fed your precision output reference voltage. Its equivalent resitance when the output side is fed near 5V is typically under 20 ohms.

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 08:38:26 am
content: Thanks for bringing analog SPDT on the table. Just realized that maybe I can do this to get pretty precise signal in terms of Vpp. ADR5044 is precise enough for this application but not sure how well generic transistors maintain CE voltage.A

author: moffy
author_rank: Super Contributor
timestamp: January 16, 2022, 10:20:33 am
content: Ian.M is correct, use CMOS gates or switches, as they behave as a low value resistor when ON and a very high value resistor when OFF(neglecting charge injection and leakage currents). Bipolar(BJT) transistors are fundamentally non linear and have relatively high temperature dependence when switched. They also can saturate which has its own issues.Instead of using a shunt regulator you should use a series reference/regulator with plenty of filter caps, both electro(100uF) and high value ceramic(10uF) as well as low value ceramic(0.1uF).A good example of using CMOS in a precision circuit is Jim Williams and what he calls his "Zoo circuit" because he came up with it watching some monkeys at the zoo, very entertaining and informative story.

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 10:34:16 am
content: Quote from: moffy on January 16, 2022, 10:20:33 amThis is what I have now and try to improve. The regulator I am using has 1% accuracy over the temperature range.A

author: moffy
author_rank: Super Contributor
timestamp: January 16, 2022, 11:05:33 am
content: But a shunt regulator has a relatively high output impedance vs a series regulator, so you will be modulating your "precise reference" a lot more than a series, you could at least buffer the shunt regulator.

author: Zero999
author_rank: Super Contributor
timestamp: January 16, 2022, 11:32:16 am
content: An analogue switch is the way to go. See the post linked below, which adds a filter, to smooth the PWM to DC, which can be skipped, if not required.https://www.eevblog.com/forum/beginners/pwm-to-analog-10v-what-have-i-done-wrong/msg3766505/#msg3766505

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 01:13:37 pm
content: Quote from: moffy on January 16, 2022, 11:05:33 amYes, definitely!I started to like the "74LVC1T45", but availability for this and equivalents is not good at the moment with hand-soldering friendly package.A

author: moffy
author_rank: Super Contributor
timestamp: January 16, 2022, 01:31:28 pm
content: Any of the following should do, and they tend to be available in a through hole DIP package: 74C04, 74C14, 74HC04, 74HC14, 74HCT04, 74HCT14 some others as well but most of the rest tend to be SMD packages. CMOS switches should work as well. Just note that the 74Cxx are slower than the 74HCxx or 74HCTxx. The 74HCTxx will work with 3.3v or 5v logic signals on the input whereas the 74HCxx are designed for 5v input logic signals only. I am assuming that the logic runs of a 5v supply.

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 01:47:17 pm
content: SMD is fine, including UFDF like this:https://www.digikey.fi/fi/products/detail/onsemi/NLSV1T244MUTBG/1792838But these are a bit nasty (and looks like availability of level-shifter is limited to these at the moment):https://www.digikey.fi/fi/products/detail/nxp-usa-inc/NVT2001GM-115/2391542MCU is 3V3 so 74HCT could be my option. And maybe I should stick with components I have been using for long time and not to try anything fancy like precision zener diodes. Just leaving those for young players... :-)A

author: moffy
author_rank: Super Contributor
timestamp: January 16, 2022, 02:38:30 pm
content: The L78M05A (5V regulator) has an initial tolerance of 2% at 25C and a drift of 0.01% per degree C. If you can calibrate out the initial tolerance it might be suitable as your reference.

author: Zero999
author_rank: Super Contributor
timestamp: January 16, 2022, 05:57:57 pm
content: Quote from: Axel_sr on January 16, 2022, 01:13:37 pmHow about the 74HC4053, which is in a nice through hole package. If you just need a single channel, then connect them all in parallel, for a lower on resistance.https://assets.nexperia.com/documents/data-sheet/74HC_HCT4053.pdf

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 16, 2022, 06:06:54 pm
content: >How about the 74HC4053In deed. This is also a good option.>The L78M05A (5V regulator) has an initial tolerance of 2% at 25C and a drift of 0.01% per degree CThis is good. I tried to find something in SOT-23, but somehow temp drift is not a typical parameter in filters. Anyone has a good option in mind?A

author: Ian.M
author_rank: Super Contributor
timestamp: January 16, 2022, 07:26:13 pm
content: If you go with 74HC (i.e *not* HCT) you'll need to level shift your 3.3V logic signal as it wont quite meet the specs for minimum logic high level. It will probably work but isn't 100% reliable.

author: moffy
author_rank: Super Contributor
timestamp: January 16, 2022, 11:31:16 pm
content: The ADP3333ARMZ-5-R7, is SOIC with 0.8% initial accuracy, 5V. Datasheet:https://www.mouser.com/datasheet/2/609/ADP3333-1503462.pdfand available at Mouser.

author: Cerebus
author_rank: Super Contributor
timestamp: January 17, 2022, 03:34:07 am
content: Quote from: Ian.M on January 16, 2022, 07:26:13 pmNo need. Put the analog switch at the virtual earth of an inverting op amp and it'll only see a few mV (it doesn't need to see the reference voltageat all, just a current), so can be run from any supply you like. A 74HC4053 will operate quite quite happily at a VDDof +3.3V under those circumstances.That is going to require a -ve rail (to deal with the whole inverting amplifier thing)butthe OP may find themselves in need of a negative rail anyway, they will almost certainly want one if they want to get a zero output at some point. PWM works very poorly at the ragged edges, duty cycles of 1% or 99% tend to misbehave. It's best to design these PWM driven analogue sources for more moderate duty cycles, 10% to 90% at the outside. If you want 10% (or 20%) duty cycle to represent a zero output then you're going to find yourself wanting a -ve rail anyway because you're either going to need a -ve reference as well as your +ve reference, or you're going to need a fixed pulldown on the analogue side of things.It would be helpful if the OP gave ussomeclue as to the parameters he's trying to work within. He's said "Precision (and minimizing temperature drifting) is priority" but not given us any clue what that means to him. Is a 'precise' output 0.1% or is it 10ppm? Is good temperature stability 100ppm/ºC or 1ppm/ºC? What's his acceptable ripple, and what's his acceptable settling time? A design that settles to 0.1% in 1 second with a tempco of 100ppm/ºC is a very different beast to one that settles to within a few ppm in 300ms with a few ppm of ripple and say 10 ppm/ºC tempco. (The later figures are not random, I've an LTSpice simulation that does that, but it steals a patented design for the reference switch that doesn't come out of patent until 2025 so it wouldn't be helpful to share for exactly that reason).Edit: In case it isn't obvious, using current though the switch rather than voltage also gets rid of that nasty RDSonnon-linearity with the voltage across the switch.

author: AccountRemovedPerUsersRequest
author_rank: Regular Contributor
timestamp: January 17, 2022, 06:10:40 am
content: Hello, Thank you all very much. This is more I can ask. I have now new ideas on how to improve PWM signal stability. It is a big factor how well the constant current circuit works - and how well the measurement circuit behind it works. Currently, the constant current is driven by MCU and suspect it can be improved. Is that true... well... I will found out after testing.A

author: Ian.M
author_rank: Super Contributor
timestamp: January 17, 2022, 07:44:48 am
content: Yes, that works. However my comment stands if using a 74HC logic gate or buffer @5V Vcc.Another way with the analog switch would be to use an OPAMP and four matched precision resistors (0.1% or better). Use two to divide the reference by two, and two to make the OPAMP non-inverting gain x2. That would keep the voltage the analog switch has to handle within the 3.3V logic rails, avoiding the need for a negative supply. However, as Cerebus points out, RRIO OPAMPs aren't actually very good when operating hard against their rails, so a positive supply >>5V and a negative supp;ly are desirable.