From 6ff2791963e2540f25709030761a8af6ce42a797 Mon Sep 17 00:00:00 2001 From: Stephen Olesen Date: Thu, 2 Jul 2015 19:31:16 -0600 Subject: [PATCH] Change to the waveform shaping trying to reduce IMD. --- examples/PSK31-Transmit/PSK31-Transmit.ino | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/PSK31-Transmit/PSK31-Transmit.ino b/examples/PSK31-Transmit/PSK31-Transmit.ino index 1bd827c..a71f9c1 100644 --- a/examples/PSK31-Transmit/PSK31-Transmit.ino +++ b/examples/PSK31-Transmit/PSK31-Transmit.ino @@ -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 ISR(ADC_vect) { static uint8_t tcnt = 0; TIFR1 |= _BV(ICF1); // Wave shaping PORTD |= _BV(2); - if(tcnt < 32) - dds.setAmplitude(tcnt<<3); - if(tcnt > (255-32)) - dds.setAmplitude((255 - tcnt)<<3); + // TODO: Improve how this would perform. + if(tcnt < 82) + dds.setAmplitude(amplitudeShape[(82-tcnt)/2]); + 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(); if(tcnt++ == 0) { // Next bit //PORTD ^= _BV(2); // Diagnostic pin (D2)