Electronic – Using a LM311n in a class D amplifier as comparator

audioclass-dcomparator

I'm making a class D amplifier as a school project, and we are currently at a stage where we simply need to add the comparator. But the comparator (LM311n) does not seem to run as intended.

My cicuit setup

My triangle and audio wave are both lifted above ground and referenced to an artificial ground at 5 V.

The signal we get from the comparator is weird looking:

current output from circuit

The triangle wave is running at 250 kHz and the audio is running at around 10 kHz.
Both audio and triangle is running as intended so I figure my problem is with the comparator as the signal is kind of messed up.
Anyone know how I can use the LM311n as a normal comparator to make the PWM signal that drives a speaker? If so I could really use input on how to do so.

Best Answer

The comparator is possibly too slow (200 ns response time) and has an open collector output. The open collector output will undoubtedly contribute to the main problem of the exponential rise. This is also due to the 10k interacting with the o-scope input capacitance (maybe 10pF). Together they form a low pass filter of 3 dB point of about 1.6 MHz and therefore severely restrict the rise time.

I'd consider using a MAX999 comparator run on a 5V rail driving logic level MOSFETs feeding the speaker. To do this you'll need to arrange for your audio signal and triangle wave to be limited to within the 5V rail. I'm not ruling out a different comparator with a push-pull output but I don't think you'll ever get great success with driving a speaker (~ 8 ohms) directly.