Tuesday, August 25, 2026

Class D AM transmitter build

I built a Class D AM transmitter with mostly recycled parts based on what I learned when I wrote the previous post. The only parts that weren't junk were the TC4426A MOSFET driver and the FPGA board.

Unlike in the virtual example, it needs the square wave to range from +/- 1 instead of just 0-1. To do that, you need 2 MOSFET's connected to the sides of a center-tap transformer and controlled by opposing square waves. That makes it so both sides are alternately sending power to one side of the transformer while the other one is off. Since they have opposing polarity, they make a fluctuating magnetic field. At first I thought that you could do it with just 1 MOSFET but that would be Class E and you would want to use an oscilloscope to make sure that it's turning off exactly when the output crosses 0.

Here is a schematic of what I built



TR1, TR2, and L1 are from PC power supplies, with TR1 being optimized for high switching frequencies around 500 kHz instead of 60 Hz. TR2 was from a different power supply and I chose it because one side had high inductance.

Q1 and Q2 are the MOSFET's. As you can see, I used 6[0]R280E6's from a switching power supply. These are rated for up to 600 volts and since the max RF stage voltage is 56, even the inductive spike from the output transformer can't burn them out. They're wired with common source (negative) so I could do push-pull with both of them operating as low-side switches which meant that I didn't have to do anything annoying like having one N-MOSFET on the low side and one P-MOSFET on the high side and have to use a high-side driver and bootstrap components for the higher voltage on the high side. P-MOSFET's are also slower so this means both sides switch equally fast.

L1 was a random inductor that I found. It's supposed to stop RF from going back to the power supply since switching power supplies can misinterpret that as an overload and turn off for protection. I originally tested this with a 19-volt switching power supply and it kept turning off until I added that. It eventually started happening again so I started using LiFePO4 (lithium iron phosphate) batteries instead.

TR2 was another random power supply transformer. This is used as a modulation transformer. In the previous post, I talked about using the audio to change the voltage to the RF stage. I thought about using a 6[0]R190E6 MOSFET for that since I had one and got my FPGA board to read WAV audio from a microSD card and play it to the headphone jack with PWM but decided to use a modulation transformer and stereo so I could test the RF stage sooner.

A modulation transformer works by passing the power supply voltage as DC in series and inducing the audio on it so you have fluctuating DC. You just connect a high-power speaker driver to the other side. I used a stereo from by the road and connected the left speaker output to the transformer. With 12 volts from 1 battery, I didn't have to turn up the volume much before the signal started clipping. You would want to turn it up more with a higher input voltage. This is because you want AM to be just below clipping and a higher DC input voltage needs to fluctuate more to get close to 0.

For the DDS, I needed 2 opposing square-wave outputs. This sets the output frequency. You can divide the main clock evenly which gives you fractional powers of 2 like half, quarter, etc. or you can generate arbitrary frequencies with a phase accumulator and tuning word. I wrote some Verilog code that generates opposing square waves on 2 GPIO pins based on a tuning word. The tuning word is

round((desired_frequency / clock_frequency) * 2bits)

where bits is how many bits are in the phase accumulator which is a variable or "register" as it's called in logic design that holds the current phase offset. To generate the output at whatever frequency, you just output the most-significant bit (MSB) while adding the tuning word on every cycle of the main clock. For example, to get 600 kHz with a 32-bit phase accumulator, the tuning word would be round((600000 / 12000000) * 4294967296) or 214748365 and I would just have to add that to the phase accumulator on every 12 MHz clock cycle. It's going to overflow and wrap which is what we want.

C1 is a bypass capacitor. It lets the MOSFET driver quickly get a lot of power. The 12-volt power supply can deliver enough but it takes time to get it over the wire and the power supply has to notice that the voltage is lower and compensate and MOSFET's have to switch really fast so this capacitor gives it a quick source while it waits for the power supply to recharge it.

R3 and R4 are gate resistors. They're supposed to help with ringing so the MOSFET gate drive stabilizes faster.

R1 and R2 are pulldown resistors. They guarantee that the MOSFET's will be perfectly off with nothing connected. This is important because MOSFET gates are capacitors and they can randomly turn on a bit from tiny charges in the air or from your finger. This is bad because you only ever want MOSFET's to be perfectly on or off. 10k ohms is enough to keep them off without wasting much power from the gate driver.

The TC4426A is an inverting driver so I think it would turn the MOSFET's on with a logic 0 input (I didn't test that because I didn't want to burn them up). This means that you have to be extremely careful about how you turn on the entire setup. This means you can't turn on the RF stage with the MOSFET's until you're sure that the FPGA is on and supplying opposing logic signals to the driver. If it's not supplying 2 signals, then one of the MOSFET's would probably stay on if the driver sees a logic 0. If one or both of them stay on, that would make a short circuit through the coil. I think a switching power supply would see that as an overload and turn off but large batteries would probably just melt something. MOSFET's often fail on which means they're stuck on when they burn out so you would have a short circuit until you replace it. A large battery would supply a lot of current and probably melt something. Another problem is that the TC4426A seems to have floating inputs so if you don't also use pulldown resistors on the FPGA side, it just amplifies whatever value it sees which can also burn out the MOSFET's. I didn't want to use pulldown resistors on the FPGA side so I was just really careful to not turn on the RF stage until I made sure the DDS inputs were connected.

For the antenna, you would want to either ground one side and connect an antenna to the other, or connect both sides to a dummy load. I currently live far enough from everyone else that I was able to just use a short wire for a while without worrying about building a filter until I accidentally touched one side and burned myself. I realized that the feeling and the mark it left were almost the same as when I accidentally touched a ballast output wire for one of my sodium streetlights and that gave me the idea to use a sodium light as a dummy load. Sure enough, it lit up and fluctuated with the audio which looked cool.

I used a large Pentium 4 heatsink for the MOSFET's. I also saved a thermistor from one of the power supplies and verified its output in ice water and room air with a voltmeter and an online calculator. The heatsink is cooled with a 120/240-volt EC (electronically-commutated) fan.

The yellow and blue are the DDS inputs









I unplugged my phone from the audio cable so I could take the pictures




An RF burn from touching the transformer output


This looks like a mess so as the YouTuber grav3yardgirl would say, "Does this THING really WORK?" Yes it does and I took some SDR recordings to demonstrate.

As you can see, after I was sure that it was safe with 12 volts, I tried 24 volts and it still worked and the light got brighter. After that, I tried it with my 56-volt power supply and it still worked and the light got so bright that it started turning a bit yellower and making a dot crawl pattern before resetting the power supply over and over. I think this was because it finally got hot enough to vaporize the sodium which lowered the resistance and made it use more power than the 56-volt power supply could handle. A family member also reported hearing buzzing in their wired headphones toward the end.

Here is a video on Odysee showing the signal and audio quality. It was really quiet (probably low modulation) so I had to turn up the volume after recording it. I left some silence at the beginning so you could see how clean the carrier is.

https://odysee.com/class_d_am_transmitter_test_20260824:5b4a5b7bbbcb57dcf65cd6c86562fb9d0424d61f

Tuesday, August 11, 2026

Class D AM

Years ago I learned about a type of AM transmitter (more like RF stage) called Class D that is really efficient and flexible. The regular way of transmitting AM involves generating a carrier sine wave at the desired frequency and changing its amplitude with the audio, but that requires (1) a good/clean/stable sine wave source and (2) a device that can change the output voltage based on an audio signal. The simplest way to do part 2 is with an amplifier like a vacuum tube or transistor, but the problem is that those are linear devices so they're inefficient. What you actually want is a switching device.

As a kid, I always wondered why power supplies couldn't just be some series resistors. I also experimented with linear regulators (a chip-controlled variable resistor that maintains a constant voltage at the output) and wondered why they got so hot and assumed that I must be using them wrong. What I didn't realize was that they're the same thing and that that doesn't work because of Ohm's law.

The problem is that lowering a voltage with resistance wastes all the energy that the resistor is reducing by. For example, if you use a linear voltage regulator to convert 120 volts DC to 5 volts 1 amp to charge a phone, the input would also use 1 amp which would be 120 watts but since the output is only 5 watts, that's 115 watts of waste that is going to be released as heat which is incredibly wasteful. The way to fix that is with a switching power supply. Those work by switching the high voltage on and off really fast but (usually) leaving it on for way less time than off so the output only gets tiny slices of the higher voltage which gets averaged to a lower voltage. This is how good dimmers work and why some LED's flicker and look annoying.

This square-wave switching can also be used to generate AM radio. A square wave is a sine wave at the fundamental frequency plus all of the odd harmonics. You obviously wouldn't want to transmit that because it would pollute other frequencies like an arc transmitter, but if you add a low-pass filter (removes everything above its frequency), you get just the original sine wave at the desired frequency. This is your carrier. You can use whatever good square-wave source you want, such as an FPGA or a dedicated DDS (direct digital synthesis) chip. Some people even do it with microcontrollers like a Raspberry Pi or Arduino/ESP32. I prefer precise and exact timing so I've been using an FPGA. It sounds like the output would be unstable but dividing a higher square-wave clock from a crystal and using that either directly or in a DDS design can produce an extremely clean and stable carrier for an AM station.

Once you have a square wave at the frequency you want, you use it at the gate of a MOSFET or GAN FET to switch it perfectly on and off really fast like a power supply. This gets filtered and sent to the antenna. Because FET's are really efficient, they hardly get hot if you do it right even with several watts of output power but you have to use a gate driver because logic pins are fast (like megabits/second or faster) for other logic circuits but power circuits require something heavy-duty that can take a weak but fast information signal and turn it into amps of power in nanoseconds to charge and discharge a FET gate. If you use an audio signal or a logic signal that is slowed down by trying to drive something heavy-duty, the FET will spend a while between perfectly on and perfectly off and operate in its linear region and become a variable resistor like a linear regulator and get really hot and self-destruct in seconds. You can buy a gate driver like the TC4426A or build your own totem pole driver with regular transistors to drive a MOSFET fast enough but you need a different type if you use a GAN FET.

A solid carrier isn't really useful so how do you get the audio into it? Normally you would want to get as close as possible to a 50% duty cycle for the RF PWM but you could modulate the duty cycle with the audio. This works and makes recognizable audio but you would need a REALLY fast FET to switch fast enough for it to make sense because the PWM needs to be able to cover your audio waveform levels (the same as the bit depth on the computer). For example, if you have a 12 MHz FPGA board like mine and divide the clock to 600 kHz, you only get 20 total clock cycles for every RF PWM cycle (ideally 10 on and 10 off). If you lower the carrier frequency to 300 kHz (longwave) then you get 40 (ideally 20 on and 20 off). With 40 clock cycles per RF PWM output cycle, you could do 5-bit audio with a bit of overhead but that sounds horrible and you would need to be able to switch your FET at close to 12 MHz which is hard even with good recent devices because you have to watch out for parasitic stuff on the PCB traces.

A much better solution is to maintain a 50% RF PWM duty cycle on the RF stage and modulate the power going to it. To do that, you should convert your audio signal to PWM at a lower frequency and use that to drive a FET, filter the output to remove the switching frequency, and use the smooth amplified audio output as the input voltage for the RF stage. Here is a comparison.


There's a guy in the UK called John Stretch A.K.A. Stretchyman who builds custom transmitters like this for AM and lower shortwave frequencies. I bought one from him once (totally for a ham AM net ðŸ˜‰) and I can confirm his build quality and the clean output signal. With his transmitter, I was able to reach across much of the eastern US at only about 45 watts PEP with a longwire antenna in a tree and I didn't even need a fan for the transmitter. Here is a link to his YouTube channel. https://www.youtube.com/channel/UCnDdvpAi7FcSrETGwc6dT0Q. There are also a lot of similar options on eBay with more frequency coverage if you search for terms like "DDS".

I lost my "Stretchy" transmitter in an accident so I was wondering if I could build one that's good enough for now. To test that method before building one, I wrote a C++ program to modulate the square wave and generate a WAV file that I could play in HDSDR. I tried the modulated PWM duty cycle method first but it looked and sounded terrible so I asked Google's new search AI for advice and it told me about the modulated input voltage method. I updated the code to do that and then it looked and sounded amazing. Here are some things I noticed.

This is how the raw output looks in Audacity (that's as much as I could zoom in because the sample rate is 12 MHz).


This is how it looks in HDSDR. Notice all the harmonics and other dirty output even though all we want is the one signal at 600 kHz, and how there's a lot of energy right at DC. The reason it appears every 300 kHz is because I upsampled the audio to that rate to try and simulate PWM output at that frequency. If you leave it at 48 kHz then those will appear about every 50 kHz above and below the desired frequency


We can clean that up with "sox" and a bandpass filter. The high-pass filter at 550 kHz takes care of the lower interference and also the DC offset.

sox --ignore-length 12mhztest.wav 12mhztest_bpf_550k-650k.wav sinc -L 550k-650k

It's now a sine wave centered around 0


The harmonics and other mess are gone but it's still not completely clean. This is mostly because this is the only signal in the file and it's very strong so it's overpowering the virtual receiver. We can add some noise in Audacity so it's a bit weaker to make it more like a real-world signal. I mixed the signal with white noise with an amplitude of 0.03 for the next picture.

That looks a lot more like something you'd pick up over the air. Let's zoom in.

I included the audio waterfall so you could see the hard cutoff that I added at 15 kHz when I was doing the broadcast audio processing in Audacity. I think the remaining wider parts are from clipping.

You really don't want to just transmit stuff over the radio without processing it with something like an expander or Thimeo StereoTool. These make it sound better over the radio and help to maximize the modulation and amplify the higher frequencies so the signal is easier to hear when the band conditions are bad. As I currently understand it, a good audio processing toolchain should keep the sound close to clipping the whole time so the signal is rectangular like in the picture. Here is a quality example on Odysee just to make sure it doesn't get a copyright strike. For this file, I downmixed to mono, used Thimeo StereoTool's AM processor with pre-emphasis including the NRSC modified 75 µS one and 3 dB AM Brilliance, manually amplified the musical notes at the beginning, and used a 15 kHz low-pass filter.

https://odysee.com/softwarepwmamtransmittertest:dceb3749b76458e81ea61c6d0a7ca30721104556