AVR DDS3 first tests

2016-01-26 18:46  
Declaration:We aim to transmit more information by carrying articles . We will delete it soon, if we are involved in the problems of article content ,copyright or other problems.

Soldering is finished next step is to run fast tests on AVR DDS signal generator to make sure everything works as expected. It appears that rush design has its own consequences but with few tweaks it works.

?First of all errors found on board.:

In zeroing offset voltage circuit resistor R5 value was left 100k – should be 33.33k;In filter circuit C2 was 33pF should be 18p;Filter switch connected wrong – it should not short filter but disconnect its output when not used;Filter op amp pins 6 and 7 were left unconnected. Solder bridge fixes this;RESET2 line needs pullup resistor. Alternatively internal pull-up can be enables in Atmega328 PB1 pin;RESET1 line needs series 0.1uF cap in order to work with Arduino bootloader;Resistors footprints are too small (4mm) could be 6.3mm to fit ones I have;Bad PCB ground pouring results in parasitic op amp capacitance. It results in signal ringing and overshooting. Partially can be fixed with feedback capacitor. But needs new PCB where ground plane is removed around trace to inverting input.

Running simple code

In order to test both microcontrollers and analog part I wrote couple simple programs for each MCU. First simply displays demo text on LCD just to make sure it works. More info on programming LCD is here. More interesting part is signal generation and analog circuit. To output test signal I used signal tables stored in internal microcontroller FLASH and sent samples to port using pgm_read_byte() function in an endless loop. Here is a fragment of code:

const uint8_t squarewave[] PROGMEM= //square wave
{
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
	0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
void signalOUT(const uint8_t *signal)
{
	uint8_t i;
	i=0;
	do
	{
		PORTD=pgm_read_byte(&signal[i  ]);
	}while(1);
}

int main(void)
{
	PORTD=0x00;//set initial zero values
	DDRD=0xFF;//set D port as output
    while(1)
    {
		signalOUT(sawtoothwave);
    }

}

Lets see how it appears on oscilloscope. First of all lets see how sinewave performs.

Sine wave seems to be OK as it doesn’t have fast rising edges. Different talk begins when generating square wave:

Here things look bad. Due parasitic capacitance on negative feedback input of operational amplifier signal overshoots and rings. Lets try to pass this signal through filter:

Filter removes overshooting and ringing but also distorts signal itself by integrating it – not the best solution. PCBs are already made – we cannot remove ground plane but we can try to compensate parasitic capacitance by adding small capacitor in parallel with feedback resistor.

Added 6.8pF cap and things started look better:

Didn’t have slightly bigger cap like 10pF – it would remove whats left of ringing. For now I’m gonna leave 6.8pF here. Hope better PCB tracing will remove this problem.

Triangle signal looks good as there is no sudden signal level change:

Saw tooth signal has same problem as square – on sharp edges there is a ringing left.

Speaking of Signal offset and amplitude control – it works like a charm as modeled here. There aren’t noticeable distortions in all control range as there were on AVR DDS V2.0.

If you have any other thoughts about removing signal ringing or have suggestions on better PCB tracing and ground planes please leave a comment. Download?avrdds3_3 files with fixes made so far. Here is also a program test files for running LCD on Atmega328P and generating signals on Atmega88.


Reprinted Url Of This Article:
http://www.scienceprog.com/avr-dds3-first-tests/