TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ray
NA
7
0
counting incoming pulses (parallel port)
Jan 21 2008 6:42 PM
I'm still beginner and trying to count incoming pulses (square wave) via pin 10 (S6) of parallel port. Frequency input is 1Hz-100Hz. No pulses are when the logic is HI, and I start counting as soon as its logic is LOW.
I did something like this:
int y = 126; // HI logic
do
{
y = PortAccess.Input(889);
textBox1.Text = Convert.ToString(y);
textBox1.Refresh();
} while ((y == 126) || (y == 62) ); //126 is HI level, 62 is LOW
and i detect and count the changes of HI and LOW in a textbox:
private void textBox1_TextChanged(object sender, EventArgs e)
{
count = count + 1;
textBox3.Text = Convert.ToString(count);
textBox3.Refresh();
}
with this code i count the pulses twice the input frequency
however the wait loop (do while) will make the application frozen if I switch to another application.
Any suggestion here? I'm trying to do a multithreading but cant figure out how and whether it's the correct solution.
I also tried to sample the incoming signal (square wave) with a timer (1ms -30ms interval), but it cant count correctly (count too slow most of the time). Am I coding it correctly?
private void timer1_Tick(object sender, EventArgs e)
{
y = PortAccess.Input(889);
if (y == 126)
{
textBox1.Text = Convert.ToString(y);
}
else if (y == 62)
{
textBox1.Text = Convert.ToString(y);
Can someone help me with better algorithm?
thx a lot
Reply
Answers (
4
)
Complex Number Arithmetic in C# Visual Studio 2005 - 8 Express Edition
error in showing the design of the form ( its urgent)