gvanto
Member level 1
I have built a little DAC converter to work on the parrallel port.
I am using Dev-Cpp to output the samples of a cosine wave (see code below) in C++...
The fastest output frequency I can get from the DAC is just under 700 Hertz (ie. the fastest possible 'for' loop I can think of). This is using 255 samples/perdiod - less samples can obviously get a higher frequency output at the expensive of resolution.
This is a little dissapointing as I was hoping to be able to construct frequencies of up to say 20KHz at least.
Im using an 800MHz CPU laptop btw.
Any help/advice on increasing the output speed (can it be done?) would be greatly appreciated. I have heard that using direct memory access (DMA) is faster but I havent got the faintest idea where to begin and whether the increase in speed is significant?
Eventually the idea was/is to implement a digital (audio) filter in software - is this feasible or shall I just not bother?
Help much appreciated,
gvanto
Code:
I am using Dev-Cpp to output the samples of a cosine wave (see code below) in C++...
The fastest output frequency I can get from the DAC is just under 700 Hertz (ie. the fastest possible 'for' loop I can think of). This is using 255 samples/perdiod - less samples can obviously get a higher frequency output at the expensive of resolution.
This is a little dissapointing as I was hoping to be able to construct frequencies of up to say 20KHz at least.
Im using an 800MHz CPU laptop btw.
Any help/advice on increasing the output speed (can it be done?) would be greatly appreciated. I have heard that using direct memory access (DMA) is faster but I havent got the faintest idea where to begin and whether the increase in speed is significant?
Eventually the idea was/is to implement a digital (audio) filter in software - is this feasible or shall I just not bother?
Help much appreciated,
gvanto
Code:
Code:
int N = 255; //Number of samples/period
int k;
double pi = 3.1459;
while(1) {
for(k=0;k<=N;k++)
{
result = 0.5 * cos(2*k*pi/N) + 0.5; // Halve wave, + add 0.5 DC to get +ve only
value = ceil(result * 255);
Out32(BASE_ADDRESS, value);
}
}