# Making a square wave which has two different kinds of pulse width

I am going to make a square wave which has two different kinds of pulse width.At first,i think i can use the digital logic gate to finish it,however,after taking lots of time for trying,i still can't make it,so i come here to ask for help or suggestion.

The square wave i needed is as below x and y means i don't care about its length,x can be bigger or smaller than y

• By what logic will those pulses come out? Random? Deterministic? What purpose? – a concerned citizen Apr 19 '18 at 12:19
• "x and y means i don't care about its length" Does this mean x and y can be "anything" (literally) or they need to be variable and if so what's the range? Do you intend to build with logic gates only or do you have uC? – mike65535 Apr 19 '18 at 12:22
• x and y are the range.i mean,i don't care x or y is 10us or 15us.if there is a component ,in the virtuoso cadence, can solve my problem,i will use that component.However,if there is no that component ,i think only digital logic may help me to solve this problem – XM551 Apr 19 '18 at 12:43
• Do you need to do this with 'hardware' or can you use a microcontroller? – Colin Apr 19 '18 at 12:48
• You could probably achieve this with a 555 timer and a decade counter or two. – Colin Apr 19 '18 at 12:50

Use two different timers and sum them together with a summing op amp: simulate this circuit – Schematic created using CircuitLab

You have multiple options:

• Using a timer, set a timer to the next time and change the GPIO value.
• Using PWM, and set a timer to change it at the next flank/up.
• Using a timer, and finding a 'common' multiplier, e.g. 1 us and check within the timer (interrupt) to change the GPIO or not. You can optionally use DMA.
• Is there a component in the virtuoso cadence? – XM551 Apr 19 '18 at 12:43
• I never heard of virtuoso cadence, sorry. – Michel Keijzers Apr 19 '18 at 12:44

Use a 16 MHz clock signal and feed it into a 4 bit binary counter. Then decode the outputs to give you a match to the output signal you want: - • i surf the internet for the 4 bit binary counter for a little bit.but it seems that 4 bit binary counter produce a square wave for a single kind of pulse width – XM551 Apr 19 '18 at 13:45
• It produces a binary count of 16 of which you can decode a value using extra logic. – Andy aka Apr 19 '18 at 16:05

This will do what you want. simulate this circuit – Schematic created using CircuitLab

While a 74161 is shown, 74LS/74HC/74HCT will all work.

If you step through the 16 possible output states of a 4-bit binary counter, you can verify the output logic.

For a 1 MHz clock, X will be 7 usec, and Y will be 4 usec.

And, just for extra credit, you can do all the output logic using a single 74/74LS/74HC/74HCT00 quad 2-input NAND gate.

And if you're actually going to use this in a logic circuit, you should feed the output through a D flip-flop triggered by the input clock to avoid skew glitches.

This is just my simple schematic,using two switch and two different kind of pulse width for each. Schematic Last wave is the output,the first and the second are the control voltage for each switch