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:
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);
}
}
gvanto , look to the lptscope code. it reads lpt with more than 100 K samples per sec . That is where windows programming knowledge comes to business . I do not see very big difference between reading and writing to lpt port . Dig into its code and see how the port access thread is implemented there . You should somehow raize you task priority within windows to get faster access to port
Regarding lpt max speed in ECP mode it should allow speed of more than 1 megabyte per sec .
Dear sir,
I think that with a good C source code you should be capable of sending up to 500k samples/s to your DAC. this is my prev experience and I think that it is possible.