# How to change duty cycle in square wave

I'm using AD9833 to generate sine, triangle and square wave. Square from IC has 0,65V amptlitude and 50% duty cycle. I would like in simple way change duty cycle this square signal from 0-100%. Using potentiometer or uC. I have only one ideas, generate PWM from uC, but AD9833 is easier to control frequency.

edit I designed this layout I want use 3 potentiometer to set duty cycle, ampltiude, and signal offset. You can check the correctness? In spice everything is okay. V1 and V3 is AD9833 output

• Welcome to EE.SE. Please note that this is not a free design service so you should show what you understand about your problem and where you are stuck. You are also missing specifications from your question: what is the voltage level?; what is the logic family, if relevant?; what is the min and max duty cycle required. If English is not your first language then add this to your user profile so we can make allowances. Commented Jun 30, 2018 at 16:57
• The AD9833 has a triangle-wave output. By feeding this into one input of a comparator and adjusting the voltage on the other input using one of your potentiometers you can adjust the duty cycle on the comparator output. Add a schematic of an attempted solution into your question (there's a built-in CircuitLab button on the editor toolbar) and we'll get the question re-opened and help you out. Notice how much your question changed when you added the details? Commented Jun 30, 2018 at 17:23
• The square wave input needs a precise stable input and Vref to Pot with same accuracy from -Vp to +Vp to get 0 to 100% but this must be outside the loop to remain accurate. This is THE broad Answer to a broad question , put on hold from narrow view. Commented Jun 30, 2018 at 17:27
• AD9833 datasheet page 16 Vout Pin can indeed be configured to provide a triangle output. See Table 15, set OPBITEN=0 and Mode=1 to get triangle output from AD9833 VOUT (this is the essentially DDS phase accumulator). Feed that into the comparator, and the output from the comparator will be a square wave with duty cycle determined by the comparator threshold. Given VOUT is in the range 0.038V to 0.65V (page 3), then adjust the comparator threshold centered around 0.344V (50% duty cycle). Commented Jun 30, 2018 at 21:03

Is impossible to use triangular with comparator, because IC has one output for square and triangular. [From question comments.]

simulate this circuit – Schematic created using CircuitLab

Figure 1. A comparator will convert a triangle wave to a square wave while allowing pulse width modulation.

By adjusting R1 the switching threshold varies and this will adjust the pulse width.

Figure 2. Input and output when varying R1 from V3 to V2.

There may be some trouble at either end of the pot if the triangle peaks or troughs have any variation in amplitude. This would manifest itself at the low-end as a variation from low pulse-width to continuous 0 V and at the high end from high pulse-width to continuous 5 V.

• AD9834 is pretty much the same chip but it has adjustable amplitude that is extremely easy to control using AD5620 (I've done it before with great results). Do you think it might be more precise to change the amplitude with fixed comparator threshold than change threshold with fixed amplitude? Commented Jul 1, 2018 at 17:18
• I have no idea. I never heard of either chip before this question. Post your idea as an answer but maybe wait to see if the OP responds to comments before spending any time on this. Commented Jul 1, 2018 at 17:21