Normally, one would use a DC blocking cap in the analog world. I wanted to do that, but I need the low pass filter even more in the ADC front end.
I am sampling a bipolar signal with an ADC by offsetting the input, so at the end of the day, I am still dealing with DC offsets.
Calibration
The DC offset of the system is measured and subtracted off. So far, that's what I have done and it work great so far. I have notices the source only have a few mV of offsets. The front end opamp circuits would probably add another few mV. Normally this is not a big problem, but the offsets are affecting how small a signal I can detect in my code. There are a few ways of removing DC offsets in a sample.Averaging
The samples are averaged. The average is the DC offset. That works for post processing when you have accessing to a lot of samples. It gets a bit tricky when I have small blocks of data. I have tried doing this, but this seems to mess up my volume.High Pass filter
A high pass filter can be used as DC block by having the filter frequency set close to 0Hz. This is what I found on a datasheet sample circuits. I tweaked the values until I get something that works well with parts I have. i.e. no overshooting, fast settling, right DC offset.LTSpice simulation of a high pass filter |
Frequency/Phase response of filter |
Output vs input waveform |
I found some online calculator and examples for the filter coefficient, but the numbers are very close to unity, so that it would requires some fixed point calculations. I am not sure if the truncation errors would be significant when I am dealing with small numbers without a lot of resolution. I tried one example code on a forum and the offset for my small signal comes out to be 0.
Trying to do this with fancy DSP math might not be what I want.
Cheats
The daughter card has 4 analog signals. Other than part counts/board space, there are no reasons why the audio detection can't be done in analog circuits and simply send back 2 digital signals. This was the original design before I try to do everything in the uC.Reality Check
May be I am over thinking. I am going to look into this.Averaging is what I am using in the new version of firmware. Found my problem in the volume calculation. I should have removed the DC offset before calculating the volume. This actually works well without fuzz.
I haven't reverse engineered the $0.30 Class D amplifier yet, but back of my mind thinks that the gain in the Class D amplifier might be set too high. For a low power amplifier, the chip has up to 24dB voltage gain (~15x) depending on the external components. I have since reduced the gain of the speaker amplifier to about 3.5X by replacing the external components here.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.