CR4® - The Engineer's Place for News and Discussion®


Previous in Forum: Need Air Mover Options for a Couple of Projects   Next in Forum: Material for Pipe Milk Dairy - Milk Transferring to Silo/Packing Machine
Close
Close
Close
16 comments
Guru
Engineering Fields - Engineering Physics - New Member

Join Date: Oct 2006
Location: MSP, MN
Posts: 607
Good Answers: 8

Precise Duty Cycle of PWM

11/03/2017 1:53 PM

I need my analog brain trust. As P/O a project I need to determine the duty cycle of a PWM signal. This signal will have frequency of 10hz to 100hz and duty cycle of 2% to 40%, both parameters constantly changing. And I need an output that has no ripple and no latency; i.e., it will reflect the duty cycle of the PWM as of the last pulse. I have come up with this insanely complicated circuit:

The PWM signal has it's 1 and 0 times converted to voltages (see pulse width to V).

These are added by op amp to get the period. Then a voltage divider (AD539 or similar) divides the input pulse by the period to yield the duty cycle.

1) Can you find problem(s) with this circuit?

2) Is there an easier way, given the strict output rqmnts? I really want to stay away from microprocessors and software. The last program I wrote was in Fortran..

Register to Reply
Pathfinder Tags: analog duty cycle PWM
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Comments rated to be "almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, rate them!
Guru
Engineering Fields - Electrical Engineering - Been there, done that, still doing it. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 12217
Good Answers: 774
#1

Re: Precise Duty Cycle of PWM

11/03/2017 2:11 PM

Well first off your operational amplifier has only positve feedback. Thus it will be a summing comparator with hysterisis.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 13468
Good Answers: 152
#2

Re: Precise Duty Cycle of PWM

11/03/2017 3:56 PM

This is way complicated. Duty cycle = average voltage / supply voltage.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply
Guru

Join Date: Mar 2007
Location: at the beach in Florida
Posts: 19243
Good Answers: 1127
#3

Re: Precise Duty Cycle of PWM

11/03/2017 4:01 PM

Don't know if this will be any help....but at least it gives some info

https://www.edn.com/design/analog/4330703/DDS-circuit-generates-precise-PWM-waveforms

..."Traditional PWMs use two op amps to generate a sawtooth waveform, a potentiometer to generate a dc reference, and a comparator to generate the PWM output. The advantage of this type of design is that the circuit is practical and inexpensive. Unfortunately, you cannot easily program the frequency without changing component values, and fine-frequency tuning is difficult. Another problem with this method is that accurate control of the duty cycle is difficult. You could use a digital potentiometer in place of the mechanical one, "....

Digital potentiometer

Analog PWM

http://www.ti.com/lit/ug/slau508/slau508.pdf

__________________
Life is like riding a bicycle. To keep your balance you must keep moving. A.E.
Register to Reply
Guru
Safety - Hazmat - New Member United States - US - Statue of Liberty - New Member Engineering Fields - Chemical Engineering - Old Hand

Join Date: Mar 2011
Location: Lubbock, Texas
Posts: 13468
Good Answers: 152
#4
In reply to #3

Re: Precise Duty Cycle of PWM

11/03/2017 4:11 PM

You can generate a controlled frequency using PWM functions in Arduino IDE with $cheap$ Arduino UNO, and control the duty factor with delay function.

__________________
If it ain't broke, don't fix it. Just build a better one.
Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that, still doing it. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 12217
Good Answers: 774
#5

Re: Precise Duty Cycle of PWM

11/03/2017 4:13 PM

I also have a very big problem with the stated attribute of no latency. Any analytic circuitry or program can only produce a result based on the previous edge, thus latency is a requirement.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru

Join Date: Apr 2010
Posts: 5748
Good Answers: 576
#6

Re: Precise Duty Cycle of PWM

11/03/2017 8:15 PM

It looks like it could work...v1 is the high time, v2 the low time + high time, v0 = v1/v2.

Your "pulse width to voltage" blocks would be integrators with a fixed voltage input. Select a voltage so that the integrator does not max out at the lowest frequency (longest period). You need 2 integrators, one fed with an inverting signal as shown.

There are a few things to consider. You want it to work continuously, so the output of each integrator needs to be stored until the end of the cycle, and each integrator needs to be reset for the next cycle.

So you need some logic so that when the input is high, it is integrating. When the input drops low, the output is latched and then the integrator is reset. I would drive a capacitor on the output of the integrator. Put a CMOS switch between the integrator and capacitor. Opening this switch will latch the voltage on the output capacitor (sample and hold).

Sample and Hold:

Another CMOS switch in parallel with the feedback capacitor of the integrator can be turned on to reset the integrator. (Delayed slightly after sample and hold)

One integrator is integrating while the other is reset allowing this thing to operate continuously.

http://www.learningaboutelectronics.com/Articles/4066-quad-bilateral-switch-circuit.php

To get the voltage ratio, I would use the AD534 which will give you the ratio of two voltages with the right connection:

http://www.analog.com/media/en/technical-documentation/data-sheets/AD534.pdf

I hope this helps. I think it will work. Please let us know how it comes out!

Register to Reply Score 1 for Good Answer
Guru
Engineering Fields - Engineering Physics - New Member

Join Date: Oct 2006
Location: MSP, MN
Posts: 607
Good Answers: 8
#7
In reply to #6

Re: Precise Duty Cycle of PWM

11/03/2017 9:12 PM

Thanks for the considered response, Rixter. I've built a slick PWM generator with variable duty cycle and frequency (see PWM generator) to test my design. AD has a bunch of chips that do voltage division; AD633 is only $11, but needs an op amp. AD539 is a little cheaper than AD534, but both seem to do the job. If no one finds a problem with my design I'll build the circuit and post results.

Register to Reply
Guru

Join Date: Apr 2010
Posts: 5748
Good Answers: 576
#8
In reply to #7

Re: Precise Duty Cycle of PWM

11/03/2017 9:55 PM

It looks good on paper to me. Building a test circuit is the way to go.

One of these days, maybe I'll get back to building circuits. I used to do it all the time, first on a breadboard, and when I got the design working, on a perfboard with wirewrap sockets. There is a lot of satisfaction in dreaming up a design and seeing it work.

Register to Reply
Guru
Engineering Fields - Engineering Physics - New Member

Join Date: Oct 2006
Location: MSP, MN
Posts: 607
Good Answers: 8
#14
In reply to #8

Re: Precise Duty Cycle of PWM

11/04/2017 11:35 AM

Is there anything so satisfying as breadboarding a circuit and seeing it work? Well, yes, but they all involve naughty stuff. Here's my PWM generator:

I bought a couple of these "proto boards" many years ago, and have gotten good use of them.

Register to Reply
Guru

Join Date: Apr 2010
Posts: 5748
Good Answers: 576
#16
In reply to #14

Re: Precise Duty Cycle of PWM

11/05/2017 4:01 PM

That's the same breadboard I have. I built +5 V and +/- 12 V power supplies in a metal box and mounted the breadboard on top.

I used to use a slit-n-wrap (184-1) to wirewrap a circuit after I had it perfected, using wirewrap IC sockets and wirewrap pins for the discrete components. You can wire multiple pins together with a continuous wire run with the slit-n-wrap, which reduces the effort of building a circuit.

http://www.mouser.com/catalog/specsheets/574WIRET.pdf

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that, still doing it. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 12217
Good Answers: 774
#9
In reply to #7

Re: Precise Duty Cycle of PWM

11/03/2017 10:15 PM

I've used all three analog ratio chips and there is one inherent problem with them. They become unstable and oscillate when the denominator approaches zero. Be very careful with the circuitry for the denominator to prevent this.

Speaking of the denominator circuitry, if you don't change the input polarity to the op amp that generates V2 then this output will always sit at the positive rail, information will be lost. If you swap polarities then V2=k(Vpwp+Vpwn). {Voltage Pulse Width Positive -> Vpwp, k is the combined transfer function of pulse width to voltage and the feedback resistor}

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru
Engineering Fields - Engineering Physics - New Member

Join Date: Oct 2006
Location: MSP, MN
Posts: 607
Good Answers: 8
#10
In reply to #9

Re: Precise Duty Cycle of PWM

11/03/2017 11:38 PM

This seems to be a preferred noninverting summer:

op amp summer What do you think?

Register to Reply
Guru
Engineering Fields - Electrical Engineering - Been there, done that, still doing it. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 12217
Good Answers: 774
#12
In reply to #10

Re: Precise Duty Cycle of PWM

11/04/2017 7:39 AM

Notice in your link that the feedback resistor connects the output to the inverting (-) pin and a fourth resistor is also connected from the inverting pin to ground. Your sketch has the inverting pin directly connected to ground.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Power-User

Join Date: Sep 2016
Location: SPAIN
Posts: 164
Good Answers: 7
#11

Re: Precise Duty Cycle of PWM

11/04/2017 5:41 AM

Here is a practical advice.

The only industry, as far as I know, where microprocessors are not used, and this types of circuits need to be optimized, is the aerospace industry. If that is not your case, it will be way more useful for you to learn the basics of programming before continuing with this task, or if you prefer it, get a freelancer to do the programming for you. Upwork has plenty of people willing to do it very cheap.

On the other hand, I remember being stunned by your old post PWM-to-PWM-Converter-But-No-Microprocessor, where you wanted 400Hz bandwidth at the output. Here, the best you are getting is about 100 times less, which is anything other than nice! I wonder how much your goal has changed since then.

__________________
Building the future!
Register to Reply
Guru
Engineering Fields - Engineering Physics - New Member

Join Date: Oct 2006
Location: MSP, MN
Posts: 607
Good Answers: 8
#13
In reply to #11

Re: Precise Duty Cycle of PWM

11/04/2017 11:12 AM

Hi Ivan. This thread is P/O my other thread. I know how to convert the voltage from this circuit into the PWM (fixed freq ∼400hz) to drive the servo; that's the easy part. It's this sensing of the input duty cycle that had me stumped for awhile.

Register to Reply
Power-User

Join Date: Sep 2016
Location: SPAIN
Posts: 164
Good Answers: 7
#15
In reply to #13

Re: Precise Duty Cycle of PWM

11/05/2017 9:40 AM

If I had to do it personally, I would use a micro to count on-time cycles, count off time cycles, and divide.

Doing that with OPAMP would be on time integrate, off time integrate... and then what? Scale? I do not even know if that is possible.

The most unusual solution other than a microprocessor I could recommend you would be using 4000 and 5400 series ICs (7400 series if you are in the MIL industry). You will not have to deal with any programming language, but you will have to draw many electronic circuits.

You can also do the digital logic in a FPGA. After all: it would not be cheaper, but it certainly would be smaller and easier to troubleshoot!

__________________
Building the future!
Register to Reply
Register to Reply 16 comments
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Comments rated to be "almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, rate them!
Copy to Clipboard

Users who posted comments:

Ivanov327950 (2); James Stewart (2); redfred (4); Rixter (3); SolarEagle (1); SSCpal (4)

Previous in Forum: Need Air Mover Options for a Couple of Projects   Next in Forum: Material for Pipe Milk Dairy - Milk Transferring to Silo/Packing Machine

Advertisement