Change to the waveform shaping trying to reduce IMD.

This commit is contained in:
Stephen Olesen 2015-07-02 19:31:16 -06:00
parent 7db28bff0e
commit 6ff2791963
1 changed files with 12 additions and 4 deletions

View File

@ -45,16 +45,24 @@ void loop() {
} }
} }
const uint8_t amplitudeShape[41] = {
255, 241, 228, 215, 203, 191, 181, 171, 161, 152, 143, 135, 128, 121, 114, 107, 101, 96, 90, 85, 80, 76, 72, 68, 64, 60, 57, 54, 51, 48, 45, 42, 40, 38, 36, 34, 32, 30, 28, 27, 25
};
// This will trigger at 8kHz // This will trigger at 8kHz
ISR(ADC_vect) { ISR(ADC_vect) {
static uint8_t tcnt = 0; static uint8_t tcnt = 0;
TIFR1 |= _BV(ICF1); TIFR1 |= _BV(ICF1);
// Wave shaping // Wave shaping
PORTD |= _BV(2); PORTD |= _BV(2);
if(tcnt < 32) // TODO: Improve how this would perform.
dds.setAmplitude(tcnt<<3); if(tcnt < 82)
if(tcnt > (255-32)) dds.setAmplitude(amplitudeShape[(82-tcnt)/2]);
dds.setAmplitude((255 - tcnt)<<3); if(tcnt > (255-82))
dds.setAmplitude(amplitudeShape[(tcnt-173)/2]);
//else if(tcnt > (255-64))
// dds.setAmplitude((255 - tcnt));
//else dds.setAmplitude(255);
dds.clockTick(); dds.clockTick();
if(tcnt++ == 0) { // Next bit if(tcnt++ == 0) { // Next bit
//PORTD ^= _BV(2); // Diagnostic pin (D2) //PORTD ^= _BV(2); // Diagnostic pin (D2)