High Current Sourcing Sine Wave Generator

A Class-D amplifier based sine-wave source (up to 30 Vpp, 1.4 A) for BH characterization of magnetic materials, designed from scratch.

Code on GitHub

Group members: Omkar Nitsure, Ojas Karanjkar, Kushal Gajbe and Vaibhav Garg.

Introduction

Magnetic materials are used in many applications and in many different kinds of equipment for their special properties. But before using them, we need in-depth knowledge of their characteristics, which requires BH characterization. In BH characterization, we apply a sinusoidal voltage of varying amplitude and frequency across the magnetic material and measure the current it draws. The current and voltage can then be used to compute B and H. The area enclosed by the BH curve indicates the power dissipated in the material. This and other information is vital for choosing the right material for a specific application.

So we need a source that can generate a sinusoidal voltage with varying amplitude and frequency and supply the current drawn by the magnetic material. The aim of our project is to design such a source.

This problem can be tackled with either a digital + analog or a purely analog approach, and we tried both. We designed an analog-only circuit based on a Class-AB amplifier, and for the digital + analog approach we used a Class-D amplifier based circuit. Let’s discuss both approaches in the following sections.

Target Specifications

We were required to build a source satisfying the following constraints:

  • Output frequency = 2–3 kHz
  • Output sine amplitude = up to 30 Vpp
  • Current sourcing capacity = 1–1.5 A
  • Added functionality: let the user change the frequency on the go using a knob
  • Display the current frequency on an LCD screen for ready reference

Class-AB Based Circuit

In this approach, we designed a circuit that can be broken down into a voltage-amplification stage and a current-sourcing stage connected in cascade. The circuit diagram is as follows:

Circuit diagram of the Class-AB amplifier based design
Circuit diagram of the Class-AB amplifier based circuit

The above circuit gave the required output, but there was an issue: a lot of power was dissipated in the BJTs, which would have required big heat sinks, and a lot of power would have been wasted on top of the unavoidable loss due to eddy currents. We tried changing many parameters but could not reduce the power loss to the desired level. While searching for a solution, we came across the Class-D amplifier, which does not have this power-loss issue. After a lot of brainstorming, we decided to scrap this approach and continue with the Class-D amplifier.

Class-D Amplifier

A Class-D amplifier consists of a full-bridge MOSFET circuit. Each of the 4 MOSFETs is driven by a different PWM signal across its gate-source. The two MOSFETs in the same leg get complementary PWM signals, such that their ON times are separated by a non-zero dead time.

This dead time ensures that the MOSFETs have enough time to change state, so that both MOSFETs in a leg never turn on together and short Vdd to GND.

The duty ratios of the PWM signals vary sinusoidally, which makes the output sinusoidal. The duty ratios of the 4 PWM signals are as follows:

\[d_{1} = \frac{1}{2} + m \sin(\omega t)\] \[d_{2} = \frac{1}{2} - m \sin(\omega t)\]

Then d3 and d4 are just the complements of d1 and d2 respectively, separated by the dead time.

Full-bridge MOSFET based Class-D circuit
Full-bridge MOSFET based circuit

A. Simulations

We performed LTSpice simulations of the Class-D amplifier for our required specifications and got the desired results. We generated the sinusoidally varying PWM signals by feeding a triangular wave and a sine wave into a comparator. We kept zero dead time, assuming perfect switching of the MOSFETs. The MOSFETs switched at 100 kHz, and we tested the sinusoidal outputs for frequencies up to 3 kHz, which was our target specification. We also checked the power dissipation in the entire circuit (in all components) and found it to be in the mW range. So this approach let us generate large-amplitude sine waves at frequencies up to 3 kHz without any heat sink at all! The approach has some cons, but that is the trade-off for excellent efficiency. Its main limitation is the saw-tooth noise generated by MOSFET switching, whereas a purely analog approach adds no such noise. The simulation results are given below: the output voltage across the inductive load at the edge of our required specifications, and the corresponding current drawn by the inductive load, which is well within our specifications.

Simulated output voltage across the load
Output voltage across the load
Simulated current through the inductive load
Current through the inductive load

B. Choice of BOM and Justifications

The bill of materials for our circuit is as follows:

Bill of materials
Bill of materials

Gate drivers: The PWM output cannot be given directly to the gates of the MOSFETs, as the back-currents generated while a MOSFET turns off would certainly damage the GPIO pins of the microcontroller. We wanted a gate driver that amplifies the 3.3 V rail-to-rail logic coming from the microcontroller to 15 V rail-to-rail logic. We also wanted a high current-sinking capacity, which allows switching at a much higher frequency. Thus we chose the 2ED020I12-FI gate driver from Infineon.

Blue Pill: The STM32 minimum board called Blue Pill was more than sufficient for our application. It could generate the 4 independent PWM signals. It also has an ADC, which we used to provide a knob for changing the output frequency, and we needed 4 additional pins to write the current frequency value to the LCD display. The Blue Pill satisfied all of these requirements.

RC filter at the input of the gate driver: This low-pass filter removes the high-frequency peaks in the PWM outputs of the microcontroller.

MOSFET: We wanted to produce sinusoidal output signals of 30 Vpp, so the Vds rating of the MOSFETs must be larger than this value. We also wanted to source currents of up to 2 A, so the Ids rating must be larger than this value. We also wanted a power MOSFET capable of very fast switching. The IRF840 satisfied all of these constraints, so we chose it for the circuit.

LC filter at the output: We had to use a low-pass filter at the output of the Class-D amplifier to remove the saw-tooth noise added by switching. We could have used an RC filter, but that would have caused a large power loss in the resistor, so we chose an LC filter of appropriate value, which does not cause any power loss.

Microcontroller Programming

We generate the PWM signals with sinusoidally varying duty ratio using the STM32 Blue Pill microcontroller. The microcontroller clock frequency is 8 MHz. The internal circuitry increases it so that the timers (which we used) get a frequency of 64 MHz, while the ADC sampling frequency is 8 MHz. We chose a switching frequency of 100 kHz, which is almost 33 times the maximum rated frequency of our system and well within the maximum switching frequency of the power MOSFET. We kept the cut-off frequency at 12 kHz, which is less than 10 times the maximum rating. Let us now see how we generated the PWM signal with a sinusoidally varying duty ratio.

A. PWM Generation

We used 2 channels of TIM1 on the STM32. Each of these channels has a register named CCR, which can be used to set the duty ratio. We stored the values for one cycle of the sinusoidal signals corresponding to d1 and d2 in memory, and read those values after a frequency-dependent delay. This let us generate a sinusoidally varying PWM. A dead time was also provided to ensure proper switching without any shorting that might damage the MOSFETs. We used a constant dead time of 0.125 µs.

B. ADC Interfacing

We wanted to give the user a simple knob to set the desired output frequency. The knob is a potentiometer whose ends are connected to the GND and 3.3 V pins of the microcontroller. The middle pin is connected to the ADC, and the voltage read by the ADC is mapped to the appropriate frequency. The ADC is sampled every 1000 cycles, so that we don’t sample “too often”.

C. LCD Interfacing

We also interfaced an LCD with the system, so that the user can see the current output frequency in real time and adjust the knob accordingly to set the frequency of their choice. The interface uses 6 pins, 4 of which are the actual data pins. We write the frequency value every 1000 cycles, right after sampling the ADC, so that we don’t write to the LCD “too often”. The CAD model was designed so that the LCD is clearly visible to the user.

LCD showing the output frequency on the final prototype
LCD in the final prototype

D. Microcontroller Pinout

The final microcontroller pinout, after configuring all the GPIO pins and interfacing the ADC and the LCD, is as follows:

STM32 pinout configuration
STM32 pinout

Schematics

Having selected the Class-D amplifier as the base of our power amplifier, we started designing the complete circuitry for our prototype. As we have seen so far, our circuit consists of 3 main parts:

  1. Microcontroller: for generating the PWM signals.
  2. Gate drivers: for interfacing the microcontroller with the MOSFETs.
  3. Full-bridge MOSFET circuit.

In our circuit, we directly used the Blue Pill, a miniature alternative to the NUCLEO-F103RB STM32 evaluation board. We went with the Blue Pill simply because it has all the features of the NUCLEO board that we needed and is smaller in size.

However, one issue with the Blue Pill is that it does not have the on-board programmer/debugger that the NUCLEO board has, which makes flashing code onto it harder. We had to use an ST-Link debugger every time we wanted to flash our code onto the Blue Pill.

The next part of our circuit is the gate drivers. We chose the 2ED020I12-FI IC manufactured by Infineon. The IC can sustain high voltages of up to 1.2 kV and supply currents of up to +1 A / −2 A. The PWM signals generated by the Blue Pill were fed to the gate drivers through the RC filter, which reduces the spikes caused by switching in the microcontroller.

A major part of the gate-driver circuitry is the bootstrap circuit at the high-side output of the gate driver IC. The bootstrap circuit supplies the bias for the high-side FET. When the low-side FET is ON, the HS pin and the source of the high-side FET are pulled to ground, and the bootstrap capacitor is charged to Vdd. When the high-side FET is turned ON in the next cycle, the bootstrap capacitor discharges some of its charge into the gate of the FET, creating a positive Vgs and turning the FET on. A Schottky diode is used as the bootstrap diode because it can switch at high frequencies. Calculating the bootstrap capacitance is an important step in designing the bootstrap circuit. It is calculated with the following formula:

\[C_{g} = \frac{Q_{g}}{V_{Q1g}}, \qquad V_{Q1g} = V_{DD} - V_{\text{BootDiode}}\]

where \(Q_{g}\) is the gate charge (from the MOSFET’s datasheet) and \(V_{\text{BootDiode}}\) is the forward voltage drop across the bootstrap diode.

For the IRF840, the maximum gate charge from the datasheet is 63 nC, and for the 1N5822 Schottky diode the forward voltage drop is 0.525 V, with Vdd = 15 V. Plugging these values into the formula gives \(C_{g} \approx 4.35\) nF. The bootstrap capacitance should be chosen such that \(C_{\text{boot}} = 10 \times C_{g}\), so the bootstrap capacitor should be at least 43.5 nF. We also need a bypass capacitor on Vdd, which should be at least 10 times the bootstrap capacitance, so \(C_{\text{bypass}}\) should be at least 435 nF.

Finally, once we have the pulses at the output of the gate drivers, they are passed to the respective gates of the FETs through a resistor.

The output is taken between the sources of the two high-side FETs. An electrolytic capacitor is connected between Vdd and GND, and ceramic capacitors need to be connected between the drain and ground of each FET. A simple low-pass filter at the output removes the spikes due to switching.

Class-D amplifier full-bridge schematic
Class-D amplifier

We also added a knob to control the frequency. The knob is connected to a 10 kΩ potentiometer. The voltage at the middle terminal of the potentiometer is sensed by the ADC in the Blue Pill and mapped to the corresponding frequency value, which is displayed on an LCD. Putting all the parts together, we get our final circuit schematic.

Full circuit schematic
Full circuit schematic

Intermediate Testing

A. PWM Generation

We generated the PWM signals using the STM32, as described in the Microcontroller Programming section, and tested them. The output is shown below.

Oscilloscope capture of the PWM output
PWM testing

B. ADC Interfacing

We successfully interfaced a potentiometer with the microcontroller using the ADC.

C. Breadboard Testing

Circuit under test on a breadboard
Breadboard testing

PCB Design

We designed the PCB using KiCad. We followed standard layout rules, such as obtuse angles between tracks, decoupling capacitors and correct component placement. We used both SMD and THT components in our design: mostly SMD components for the decoupling capacitors and the gate driver IC, and screw terminals for connecting the inputs to the PCB. The Blue Pill is mounted on the PCB using a breakout board.

PCB layout in KiCad
PCB layout
Assembled PCB with all components
PCB with all components
PCB for the breakout board
PCB for the breakout board
Final assembled PCB
Final PCB

CAD Design

For our CAD design, we initially planned a 3D box structure using Fusion 360. The design involved careful planning to keep certain components accessible from the outside while the prototype remains inside the box.

A. Design Requirements

  1. LCD display: the design has an open area for the LCD display, so that users can read the frequency without obstruction.

  2. Inputs and outputs:

  • Power supply: a 5 V supply is provided through a USB cable, which is also used for flashing code onto the STM32 microcontroller.
  • External supplies: Vdrive and Vdd are supplied externally.
  • Output access: the output across the capacitor is accessible through an opening in the box.
  • Potentiometer: a potentiometer mounted on the box controls the frequency of the prototype, so an opening is needed for it as well.
3D CAD design of the enclosure
3D box CAD design

However, after discussing the design with the faculty, we concluded that 3D printing the box was not possible, so we used laser-cut acrylic sheets instead.

We used MakerCase to create the DXF file with the sheet thickness and the length and width of each side of the box. After importing this DXF file into Fusion 360, we cut out the same regions as in the 3D box design.

Acrylic sheet layout for the enclosure
Acrylic sheet design for the box
Top side of the enclosure
(a) Top side
Bottom side of the enclosure
(b) Bottom side
Front side of the enclosure
(c) Front view side
Side view of the enclosure
(d) Side view
Dimensions and open areas in the design

Final Prototype

Final assembled prototype
Final prototype

Results

Oscilloscope capture of the final sine-wave output
Final output sine waveform

Our final output waveform is a sine wave designed for the characterization of magnetic materials. The circuit is powered by three sources: Vdrive, Vdd, and a 5 V supply via USB to the Blue Pill. The output signal is measured across a 470 nF capacitor. Our setup achieves a current rating of 1.4 A, with the peak-to-peak voltage (Vpp) reaching up to 30 V at a frequency of 500 Hz.

Oscilloscope capture of the high-side gate driver output
Gate driver output

The gate driver output shown is for the high side. As expected, it amplifies the PWM signal from the microcontroller: we achieve an 18.6 V peak-to-peak output from the gate driver.

Oscilloscope capture of the microcontroller PWM output
Microcontroller output

Above is the microcontroller PWM output, which is the input to our gate drivers. Its peak-to-peak voltage is 3.84 V, which the gate drivers amplify to 18.6 V.