PWM Generator

Not rated 21,437

Circuit Image

A pulse-width modulated (PWM) signal can be generated using a triangle wave and a comparator. The digital-to-analog converter (DAC) serves as the input signal, and the resulting output signal's duty cycle will be proportional to the input voltage. This PWM signal will be utilized to dim an LED. Construct the circuit depicted in Schematic 1. Connect the triangle wave generator to the node labeled Vtriangle and the DAC output to the node labeled Vdac. Adjust the DAC bits and observe the corresponding changes in LED brightness. It is recommended to connect Vdac and Vtriangle to an oscilloscope to visualize the signals as DAC bits are modified. If the triangle waveform is not functioning correctly, a function generator may be employed instead. Access the function generator by selecting the FGEN icon on the instrument launcher, and set the waveform parameters to a triangle output at 2.53 kHz, with a peak-to-peak voltage of 3.60 V and a DC offset of 1.52 V. Similar to the comparator circuit used in the triangle wave generator, when the positive input is lower than the negative input, the output will be low. Consequently, when Vtriangle exceeds Vdac, the output will be low. In this state, the output transistor behaves like a short circuit. The forward voltage drop for a yellow LED is approximately 2V, allowing the current through the LED to be calculated. When Vtriangle is greater than Vdac, the output is high. For the LP311 comparator, a high output means the output transistor is off, resembling an open circuit. In this scenario, no current flows through the LED, resulting in the LED being off. Given that the triangle wave is periodic and the DAC output voltage is fixed at a DC level, the current through the LED will manifest as a square wave with a duty cycle proportional to the DC level. An increased DAC output voltage will yield a higher current duty cycle, brightening the LED, while a decreased DAC output voltage will lead to a lower current duty cycle, dimming the LED. SPICE simulation results are provided to illustrate two Vdac values for a clearer understanding of the circuit's operation.

The circuit operates on the principle of pulse-width modulation, where the duty cycle of the PWM signal is directly influenced by the input voltage from the DAC. The triangle wave generator produces a continuous triangular waveform, which is compared against the DAC output voltage by the comparator. The comparator's output toggles between high and low states based on the relationship between the triangle wave and the DAC output.

When the triangle wave voltage (Vtriangle) rises above the DAC output voltage (Vdac), the comparator outputs a low signal, effectively turning on the output transistor, allowing current to flow through the LED. Conversely, when the triangle wave voltage falls below the DAC output, the comparator outputs a high signal, turning off the transistor and cutting off current to the LED. This switching behavior results in a PWM signal that modulates the LED's brightness based on the DAC's output voltage.

The duty cycle of the PWM signal can be calculated as the ratio of the time the output is high to the total period of the triangle wave. As the DAC output increases, the time the triangle wave is above this voltage increases, resulting in a higher duty cycle and a brighter LED. Conversely, a lower DAC output results in a shorter high state duration, leading to a dimmer LED.

The circuit can be simulated using SPICE to visualize the effects of varying the DAC output on the LED brightness. By observing the two different Vdac values in the simulation, one can gain insight into the relationship between the DAC output voltage and the resulting PWM signal characteristics. This setup serves as an effective demonstration of PWM principles and their application in controlling LED brightness.Using a triangle wave and a comparator, a pulse-width modulated signal can be created. We will use the DAC as our input signal and the resulting output signal will have a duty cycle that is proportional to the input voltage. We will then use the PWM signal to dim an LED. Build the circuit shown in Schematic 1 below. Hook up the triangle wave gener ator to the node labeled Vtriangle  and the output of the DAC to the node labeled Vdac.  Play around with the bits of the DAC and observe how the brightness of the LED changes. Try plugging Vdac and Vtriangle into the oscilloscope and observe them as the bits on the DAC are changed. If the triangle signal is not working properly, the function generator can be used instead. Open the function generator by clicking the FGEN  icon on the instrument launcher. Change the waveform settings to be a Triangle output, 2. 53 kHz, 3. 60 Vpp, and 1. 52 V DC offset. Just like the comparator circuit from the triangle wave generator, when the positive input is lower than the negative, the output will be low.

Therefore, when Vtriangle is greater than Vdac, the output is low. When the output is low, the output transistor looks like a short circuit. The forward diode voltage for a yellow LED is approximately 2V. Thus, the current through the LED can be calculated as: When V ­ ­triangle is greater than Vdac, the output is high. In the case of the LP311, when the output is high, this translates to the output transistor being off, which looks like an open circuit.

If the output transistor looks like an open circuit, then no current can flow through the LED, and therefore the LED is off. Since the triangle wave is periodic and the DAC output voltage is fixed at a DC level, the current through the LED will be a square wave with a duty cycle that is proportional to the DC level.

Higher DAC output voltage will result in a higher current duty cycle, which will make the LED brighter. Lower DAC output voltage will result in a lower current duty cycle, which will make the LED dimmer. The SPICE simulation results are shown below. Two values of Vdac are shown in the simulation for better understanding of the operation of the circuit.

🔗 External reference