Saturday, March 8, 2008

An update!

Well, a lot has happened since our last update, so I'll try to split it up.

ADC
Originally, we were using some ADC code we found on AVR Freaks. This code did single conversions, which is fine for some applications but obviously not for streaming audio. So instead we put the ADC in interrupt-driven mode and used the "ADC conversion complete" interrupt as its trigger. This is known as free running mode, and it improves the ADC's speed from 25 cycles/conversion to 13 cycles/conversion. Previously, we were using a timer to read the contents of the ADC at regular intervals (8,000 Hz). That was stupid. It resulted in lots of duplicate ADC readings because we would read the ADC output register several times between updates.

We chose a prescaler for the ADC clock that was around 8,000-9,000 Hz. That turned out to be Fcpu/64. When trying to decide on a prescaler, we mistakenly thought the frequency we were registering on our multimeter was the frequency of the ADC, and we were confused as to why it was half what we were expecting. Then we realized that it was because we were checking the frequency by watching a pin toggle each time the interrupt was triggered. It's an obvious mistake and not really worth explaining. Incidentally, it turns out the ADC tops out at around 11,400 conversions/sec when doing 8 bit conversions (slower when doing 10 bit).

DAC
First off, we got the DAC. That's pretty important. Other than that, it's a very straightforward component: send it parallel digital input (12 bits max) and it spits out analog. It can work transparently, which makes things very easy.

The receiver unit receives digital info from its XBee and places it in a circular buffer, which is currently 512 bytes for no particular reason. It also has a timer that plays samples at roughly 8,800 Hz, then deletes that sample after playing it.

With a little tweaking, we got the timer on the receiver to fire at approximately 8,800 Hz, which was about the rate the transmitter was sending at. Unfortunately, any slight difference between the transmitter and receiver rates results in a perpetual popping noise. This is because the two units will inevitably go out of sync and the receiver's buffer zeroes out.

One solution would be to make the DAC not zero out the buffer. Then the popping noise would not be as noticeable, although it isn't really all that noticeable to begin with. Otherwise, we would just have to tweak the clock seed until the receiver's speed is close enough to the transmitter's speed that the popping is not very frequent. I don't think it can be eliminated entirely.

No comments: