Author Topic: Precise (Vp-p) PWM from MCU  (Read 2057 times)

0 Members and 1 Guest are viewing this topic.

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Precise (Vp-p) PWM from MCU
« on: January 16, 2022, 06:22:25 am »
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 topic

A

Edit: TL431 is not fast and probably not suitable to use the way described in the circuit attached
« Last Edit: January 16, 2022, 07:27:29 am by Axel_sr »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13130
Re: Precise (Vp-p) PWM from MCU
« Reply #1 on: January 16, 2022, 07:52:46 am »
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 a 74LVC1T45 dual 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.
« Last Edit: January 16, 2022, 01:11:57 pm by Ian.M »
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #2 on: January 16, 2022, 08:38:26 am »
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
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: au
Re: Precise (Vp-p) PWM from MCU
« Reply #3 on: January 16, 2022, 10:20:33 am »
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.
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #4 on: January 16, 2022, 10:34:16 am »
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).

This is what I have now and try to improve. The regulator I am using has 1% accuracy over the temperature range.

A
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: au
Re: Precise (Vp-p) PWM from MCU
« Reply #5 on: January 16, 2022, 11:05:33 am »
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.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: Precise (Vp-p) PWM from MCU
« Reply #6 on: January 16, 2022, 11:32:16 am »
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
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #7 on: January 16, 2022, 01:13:37 pm »
you could at least buffer the shunt regulator.

Yes, 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
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: au
Re: Precise (Vp-p) PWM from MCU
« Reply #8 on: January 16, 2022, 01:31:28 pm »
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.
« Last Edit: January 16, 2022, 01:34:59 pm by moffy »
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #9 on: January 16, 2022, 01:47:17 pm »
SMD is fine, including UFDF like this:
https://www.digikey.fi/fi/products/detail/onsemi/NLSV1T244MUTBG/1792838

But 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/2391542

MCU 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
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: au
Re: Precise (Vp-p) PWM from MCU
« Reply #10 on: January 16, 2022, 02:38:30 pm »
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.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19990
  • Country: gb
  • 0999
Re: Precise (Vp-p) PWM from MCU
« Reply #11 on: January 16, 2022, 05:57:57 pm »
you could at least buffer the shunt regulator.

Yes, 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
How 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
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #12 on: January 16, 2022, 06:06:54 pm »
>How about the 74HC4053
In 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 C
This 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
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13130
Re: Precise (Vp-p) PWM from MCU
« Reply #13 on: January 16, 2022, 07:26:13 pm »
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. 
 

Online moffy

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: au
Re: Precise (Vp-p) PWM from MCU
« Reply #14 on: January 16, 2022, 11:31:16 pm »
The ADP3333ARMZ-5-R7, is SOIC with 0.8% initial accuracy, 5V. Datasheet: https://www.mouser.com/datasheet/2/609/ADP3333-1503462.pdf and available at Mouser.
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Precise (Vp-p) PWM from MCU
« Reply #15 on: January 17, 2022, 03:34:07 am »
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.

No 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 voltage at all, just a current), so can be run from any supply you like. A 74HC4053 will operate quite quite happily at a VDD of +3.3V under those circumstances.



That is going to require a -ve rail (to deal with the whole inverting amplifier thing) but the 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 us some clue 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 RDSon non-linearity with the voltage across the switch.
« Last Edit: January 17, 2022, 03:41:49 am by Cerebus »
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline AccountRemovedPerUsersRequestTopic starter

  • Regular Contributor
  • *
  • !
  • Posts: 117
  • Country: ee
Re: Precise (Vp-p) PWM from MCU
« Reply #16 on: January 17, 2022, 06:10:40 am »
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
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13130
Re: Precise (Vp-p) PWM from MCU
« Reply #17 on: January 17, 2022, 07:44:48 am »
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.
« Last Edit: January 17, 2022, 10:45:57 am by Ian.M »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf