Square wave Duty Cycle shifter - help

Jerry-Hat-Trick

Joined Aug 31, 2022
827
Maybe you could double the frequency with an XOR gate and comparator and use a flip flop to divide the frequency back down again? With the right selection of RC components in the doubler circuit (which won't have a 50% duty cycle) you can probably get this to work and the halved frquency should have a 50% duty cycle..... I think.

But I still prefer the ATtiny85 solution with minimal components and really simple code. I urge you to learn the Arduino IDE, you'll be overwhelmed with ideas about what you can do with it.
 

Ian0

Joined Aug 7, 2020
13,133
Maybe you could double the frequency with an XOR gate and comparator and use a flip flop to divide the frequency back down again? With the right selection of RC components in the doubler circuit (which won't have a 50% duty cycle) you can probably get this to work and the halved frquency should have a 50% duty cycle..... I think.
Afraid not - you get what you put in, or 1-D.
The XOR gate outputs a pulse on every edge, so for a 1kHz squarewave with 30% duty cycle, you get a pulse at zero, a pulse at 300us, and a pulse at 1ms. Divide that by two and you are back where you started, or you might have 70% duty cycle.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
827
Afraid not - you get what you put in, or 1-D.
The XOR gate outputs a pulse on every edge, so for a 1kHz squarewave with 30% duty cycle, you get a pulse at zero, a pulse at 300us, and a pulse at 1ms. Divide that by two and you are back where you started, or you might have 70% duty cycle.
Thanks. What about halving the frequency with a JK flip flop toggling when the input goes high, and then doubling that frequency?
 

LowQCab

Joined Nov 6, 2012
5,101
This whole setup seems to be morphing into a Rube-Goldberg-Device.

Maybe it's time to re-think the entire arrangement from scratch,
instead of trying to "fix" something that didn't work properly in the first place,
with an additional Circuit that's just going to complicate matters even more.

We still don't know what this concoction of devices is supposed to accomplish.
.
.
.
 

Thread Starter

ilgadget

Joined Mar 2, 2025
12
Maybe you could double the frequency with an XOR gate and comparator and use a flip flop to divide the frequency back down again? With the right selection of RC components in the doubler circuit (which won't have a 50% duty cycle) you can probably get this to work and the halved frquency should have a 50% duty cycle..... I think.

But I still prefer the ATtiny85 solution with minimal components and really simple code. I urge you to learn the Arduino IDE, you'll be overwhelmed with ideas about what you can do with it.
I'm a little disheartened.
Honestly I imagined it wouldn't be easy. At this point the only real solution would be with an ATtiny. I have to find someone to help me for the moment with code and then, as Jerry rightly advised, it's time for me to learn to do it too, but I imagine it won't be something immediate.
Anyway I have to compliment this forum and obviously its participants, I didn't imagine I would find so much participation and solidarity, thank you so much!
 

Thread Starter

ilgadget

Joined Mar 2, 2025
12
Unfortunately the source is an immutable and irreplaceable fact.
The only solution is the external modification of the duty cycle or nothing.
I am now increasingly convinced that the most likely solution could be the addition of a micro.
 

sghioto

Joined Dec 31, 2017
8,634
Somethi
The only solution is the external modification of the duty cycle or nothing.
Something doesn't add up here.
It was mentioned that the oscillator was third party and cannot be modified, OK.
However you must have access to the output of this oscillator if trying to modify the duty cycle.
Lets say we did the modification with a circuit and it works.
Where will the output of this circuit connect?
What am I missing here?
 

crutschow

Joined Mar 14, 2008
38,529
Unfortunately the source is an immutable and irreplaceable fact.
The only solution is the external modification of the duty cycle or nothing.
So here's a non-micro circuit using an integrator along with a CMOS 555 to adjust the duty-cycle of a varying frequency input signal to 50% at the output:

The 555 is configured as a one-shot which is triggered on the input signal falling edge.

The integrator output provides negative feedback via the Q1 constant-current source to vary the charge current of the 555 C3 timing capacitor.
This controls the one-shot time and thus the output duty-cycle so that the integrated average of the output voltage is 1/2 the supply voltage [V(Ref)], which means its duty-cycle is 50%, independent of the frequency or the input duty-cycle.

The LTspice sim shows it settles in about a half second to different frequencies (green is 30Hz and yellow is 200Hz).

The op amp needs to be a rail-rail output type.

1741146737244.png
 
Last edited:

Thread Starter

ilgadget

Joined Mar 2, 2025
12
So here's a non-micro circuit using an integrator along with a CMOS 555 to adjust the duty-cycle of a varying frequency input signal to 50% at the output:

The 555 is configured as a one-shot which is triggered on the input signal falling edge.

The integrator output provides negative feedback via the Q1 constant-current source to vary the charge current of the 555 C3 timing capacitor.
This controls the one-shot time and thus the output duty-cycle so that the integrated average of the output voltage is 1/2 the supply voltage [V(Ref)], which means its duty-cycle is 50%, independent of the frequency.

The LTspice sim shows it settles in about a half second to different frequencies (green is 30Hz and yellow is 200Hz).

The op amp needs to be a rail-rail output type.

View attachment 343772
Good evening all from here.
Thank you so much to all for very kind attention to my request.
Special thank to crutschow for this nice and simple circuit sewn to my request.
I am anxsious to try it and I'll get up to date you.
Again I want to express my gratitude.
 

boostbuck

Joined Oct 5, 2017
1,044
An alternative could be a short pulse output 555 triggered on the rising AND falling edges of the input, followed by a flip-flop to divide the result back to the original frequency at 50% duty cycle.
 

Ian0

Joined Aug 7, 2020
13,133
An alternative could be a short pulse output 555 triggered on the rising AND falling edges of the input, followed by a flip-flop to divide the result back to the original frequency at 50% duty cycle.
Afraid not - you get what you put in, or 1-D.
The 555 outputs a pulse on every edge, so for a 1kHz squarewave with 30% duty cycle, you get a pulse at zero, a pulse at 300us, and a pulse at 1ms. Divide that by two and you are back where you started, or you might have 70% duty cycle. (I might have said this before)
 

Ian0

Joined Aug 7, 2020
13,133
Here’s my twopenceworth.
IMG_1740.jpegDivide by two to give a squarewave, integrate to give a triangle.
Compare with half supply reference to give a square wave with 90° phase shift, then exclusive or to give a square wave at the original frequency.
Not great - needs lots of different parts, and the choice of resistor to keep the DC level in the integrator gives a choice between accuracy and settling time.
What I can’t understand is why something would not saturate at 50% duty-cycle but would at 30%. Sounds back-to-front to me.
Also anything that saturates at 1kHz would saturate much more easily at 200Hz, even with the same duty cycle.
And if duty cycle makes it saturate, then the simple act of putting a capacitor in series would stop it.
So much here that we haven’t been told, which is making the solution unnecessarily difficult.
 
Top