Position: Index > Led Circuit >

AVR controlled signal generator-first impression

2014-12-13 13:41  
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.


Lazy evening. I decided to take couple shots of couple generated signals. Without going to deep in to timings I wrote couple algorithms to make sure the signals are generated correctly at all voltage range 0-5V. First is Sawtooth signal using asm in AVRStudio:




.INCLUDE "m8def.inc"
.DEF tmp = R16 ; Multipurpose register
        ldi tmp,0xFF;  Set all pins of Port D as output
        out DDRD,tmp
sawtooth:
        out PORTD,tmp
        inc tmp
        rjmp sawtooth

Sawtooth.jpg

(My oscilloscope is really old so sorry for bad quality) <p > Second signal Triangle. This one I programmed using WinAVR toolset.

int main (void)
{
uint8_t x=0, y=0;
atmega8init();
    for (;;) /* Note [6] */
	{
	if (y==0)
	{
		x  ;
		if (x==255) y=1;
	}
	else 
	{
		x--;
		if (x==0) y=0;
	}
PORTD=x;
}
    return (0);
}

Triangle.jpg

It is obvious that signals are generated correctly at all voltage interval 0-5V.

Later I will probably use signal (pulse, sawtooth, triangle, and sinusoid) tables stored in flash memory. EEPROM memory is too small to store all signals but I am going to use it for last configuration storage that every time you switch that generator, the last settings would be loaded. And I still didn’t decide what language to use for programming the device. C would be much easier and faster, but I will loose speed. The maximum signal frequency would be much lower than using pure ASM. But ASM programming takes much more time to implement. Any comments while I will be assembling the box?


Reprinted Url Of This Article:
http://www.scienceprog.com/avr-controlled-signal-generator-first-impression/