Reading parallel port with constant sample rate

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm interested to know what ideas are out there for reading a parallel port at a constant sample rate while still allowing the user to interact with the GUI. That is, reading it every 10ms for example without exception. Is this at all possible?

Current tests done show that if the sample rate is 10ms then this is acheived in general, but when another program loads or terminates this 10ms jumps up to 100ms or more. In these tests the code is placed in a Do Loop with Application.DoEvents and when the code is placed in a seperate thread in a Do Loop with Thread.Sleep(10). During this temporary 100ms there will be significant data loss.

Is it possible to acheive this real-time goal on a Windows OS with VB.Net?
 
Its possible under windows but I dont think its a possibility under vb .net
or for that matter in .net altogether. I just dont think the .net runtime is
deterministic enough to allow development of real-time applications
especially now that it has the non-deterministic garbage collector. You
might want to look at developing such applications in C/C++ or some
third-party real-time module for windows depending on how much of a need
this is to you. Here are some links:
http://www.merl.com/reports/docs/TR98-02.pdf
http://sys-con.com/story/?storyid=45500&DE=1
http://www.tenasys.com/intime.html
http://www.engineeringtalk.com/news/nem/nem108.html

hope this helps..

Peter said:
I'm interested to know what ideas are out there for reading a parallel
port at a constant sample rate while still allowing the user to interact
with the GUI. That is, reading it every 10ms for example without exception.
Is this at all possible?
Current tests done show that if the sample rate is 10ms then this is
acheived in general, but when another program loads or terminates this 10ms
jumps up to 100ms or more. In these tests the code is placed in a Do Loop
with Application.DoEvents and when the code is placed in a seperate thread
in a Do Loop with Thread.Sleep(10). During this temporary 100ms there will
be significant data loss.
 
Thanks for your feedback. Do you think it is possible to write a module (in a real-time 3rd party product) for scanning the parallel port at a specified sample rate and raising an event within a .NET application when a certain condition is met?
 
Parallel ports are synchronous, therefore you should not be able to 'loose'
data. For example, when you scan a document in using a paralell port, and
start other applications, do you loose data ? No!

It is a case of writing a driver to interact with the port, not an
insignificant task, but do-able.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Peter said:
I'm interested to know what ideas are out there for reading a parallel
port at a constant sample rate while still allowing the user to interact
with the GUI. That is, reading it every 10ms for example without exception.
Is this at all possible?
Current tests done show that if the sample rate is 10ms then this is
acheived in general, but when another program loads or terminates this 10ms
jumps up to 100ms or more. In these tests the code is placed in a Do Loop
with Application.DoEvents and when the code is placed in a seperate thread
in a Do Loop with Thread.Sleep(10). During this temporary 100ms there will
be significant data loss.
 
What if the parallel port was being written to (by an external device) every couple of milliseconds? Not sampling the data at a constant rate will miss data.

Any suggestions?
 
Hi,
Is it possible to acheive this real-time goal on a Windows OS with VB.Net?
<<

In general, no. Windows is not a real-time OS, and .NET is far from a
real-time programming environment, even if Windows were RT.

However, depending on what your "real" goals are, it often is possible it
approach RT in an application. Certainly, 10 mS for accessing a parallel
port is reasonable. However, at the boundaries of operation you may see
results that lie outside this "window." For more information you may want
to look a the PC Data Acquisition link on my homepage. It has some
discussion of RT issues.

BTW, thread.sleep put your thread to sleep for AT LEAST 10 mS, not for
EXACTLY 10 mS. A more reasonable approach (IMO) would be to use a threading
timer, and to provide some sort of internal correction mechanism that checks
on elapsed time.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 
If you absolutely cannot afford to miss ANY data, then you cannot use
Windows or .NET. You must use a RT OS and compatible language.

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
 
Back
Top