?
Solved

How would I go about using mulitple timer's efficiently?

Posted on 2007-11-23
6
Medium Priority
?
202 Views
Last Modified: 2010-04-23
I am planning on using a Timer to "poll" an PCI card that controls two different axis of a machine. I need to have at LEAST one Timer constantly getting information from the PCI card to display any fault that the servos might run into. There are also times where I am going to need to have 2-3 more timers polling the PCI card for Inputs/Outputs that are currently on and other information that needs to be updated relatively quickly (I am shooting for <1 sec). Is there any good way to go about this? Or is have 3 or 4 timers (ticks at 1 sec) executing simultaneously not a problem?


Not sure if this matters, but I would assume it would have some effect: The program will be running on a new AMD 4000+ X2 Proc, XP pro, and 1 gig or memory.
0
Comment
Question by:Gssc1414
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 20339990
would be more efficient a single timer with the proper granularity. But you have to notice that in this approach, will attend event sequentially, so if one event lasts more than 1 second, by example, another event can keep unattended for a while.
separate timers allows you to attend event virtually simultaneously, but this will depend also if your PCI card will not get confused with this.
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20340113
Would it be possible to use multi-threading? Maybe put each timer on it's own thread? Or even just the critical ones on a separate thread than that of the program? I don't know much about multi-threading, so im not sure if this is feasible, and if it is, if it would really help me out that much or not.



Jaime,

Thanks for your quick response!
I will have to check into the PCI card and make sure this won't be a problem.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340161
In fact you don't need to do multithreading explicity. Timers are multithreaded implicity.
Just create many timers and launch them. Each timer have it own Tick event that run in a separate thread.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:Gssc1414
ID: 20340179
Alright, good deal. One last one for ya! Can I explicitly set a priority to different timers?


P.S. I upped the point value because of your extremely fast and precise answers. I really appreciate the help!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20340196
What do you want to do with a "priority timer" ?
Do some tasks sequentialy when timer collide? or do them in parallel with a differnent speed?

For first, I suggest a priority queue, for second use a regular thread an simulate a timer with an infinite loop with delay.

BTW, you have to check also if the API you are using to interface the PCI card will accept concurrency
0
 
LVL 3

Author Comment

by:Gssc1414
ID: 20347101
Very well. It looks like I am a little confused. I once again apologize for my lack of knowledge. I will take your advice and go with it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question