Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Parallel port programming, help needed!

Status
Not open for further replies.

gvanto

Member level 1
Member level 1
Joined
Aug 17, 2004
Messages
41
Helped
4
Reputation
8
Reaction score
0
Trophy points
1,286
Activity points
442
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:
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);
			  
        }
      }
 

You could try to calculate the values first, then store them in a look up table, circuler buffer, then step through the table outputing the values.
 

Thanks but I think you're referring to a hardware solution (non-PC) right?

(I dont see how in C this would make things any faster)

If so, thats OK yeah could prob use EPROM or something but it doesnt really help me for the purpose of what im trying to do (please see my message above again :)
 

No, the calculations take a lot of time, do them first, store the results in an array, and then step through the array, much faster!
LOOP:

for(k=0;k<N;k++)
Out32(BASE_ADDRESS, array[k]);
 

thanks btbass,

this however, is for a simple cosine wave output. i would like to, eventually, have an input (ADC) stage through the serial port (probably - is USB much faster than the serial port?) FOLLOWED by some DSP operations all done in C software, THEN output it on the par. port.

my nut in my head tells me this is gonna require a hell of alot of processing power (slightly more than the calculation of a cosine value).

Do you reckon this is a feasable plan?

a friend of mine just bought a commercial USB-based bitscope (PC-based oscilloscope) and its incredible how fast it is - is this because USB is much faster than par. port?

regards & thanks for your help,
gvanto
 

Yes, usb is much faster. USB 1 full speed is 12MHz and USB 2 high speed is up to 400MHz.
 

Those math functions should run at megahertz on your machine. The typical PC parallel port speed is very roughly one million INs or OUTs per second, depending on motherboard chips.

It's possible your port is crippled in some way, but I'm guessing the bottleneck is in the Out32() function. It could be using some convoluted operating system port access method, instead of a simple OUT opcode. Try putting a simple loop around an Out32() to measure its speed. If that's the problem then try using PortTalk or some other port access method (these are for Windows):
**broken link removed**

USB1 is 12MHz, but that's bits per second. Parallel ports are roughly similar in speed - usually slightly slower, but some are faster. USB2 flies.

Please don't cross-post. It's against board rules.
 

OK thanks guys will look into this peculiar one.

regards,
gvanto
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top