473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Timing?

hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.
Nov 17 '05 #1
7 3748
Take a look at the System.Threading.Timer It has better resolution and isn't
reliant on the load in the message queue for it's processing.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"jamie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.

Nov 17 '05 #2
Hi,

I think that the best approach you can get is using System.Timer.

take a look at "Introduction to Server-Based Timers" :

http://msdn.microsoft.com/library/de...asedTimers.asp
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"jamie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.

Nov 17 '05 #3
Hi,

Use a timer but you control the timing using System.Environment.TickCount
that retrieves the ticks from the processor in milliseconds, this is the most
precise method.

You can compare your starting tickcount and comparing it with the final one
the control your timing. The loop can be interrupted by other threads and you
won't realize if it takes 10, 20 or 30 milliseconds to loop.

cheers
Salva
"jamie" wrote:
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.

Nov 17 '05 #4

"jamie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.


I'm not entirely clear what you want exactly, but if you need a timer that
fires exactly every 10 msec , you have choosen the wrong platform - both OS
and .NET, You need a Real Time Operating system for this and Windows is not
a RTOS.

Willy.
Nov 17 '05 #5
Jamie:

One can't do really precise motion control under windows, or any PC
operating system for that matter. You will need a real-time operating system
(RTOS). By definition an RTOS can say that an event will occur within a
certain amount of time with absolute certainty.

That being said, and hoping that your final project is not implementing a
pace maker, if you want to do this in windows and you want to do this from
C# you will probably want use a System.Threading.Timer and from within your
OnTick routine call the Win32 function QueryPerformanceCounter to calculate
the actual time elapsed with PInvoke.

Checkout

http://msdn.microsoft.com/library/de...nethowto09.asp

http://msdn.microsoft.com/library/de...ing/timers.asp

"jamie" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.

Nov 17 '05 #6
Jamie,

You'll have to use multimedia timers to achieve the best possible
resolution for the hardware. I'm not sure how the garbage collector
affects the resolution.

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_multimedia_timers.asp>

jamie wrote:
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.
Currently I am trying to use the timer
function block to do a 10ms loop, but
if I remember correctly.... that timing
wasnt the best. Any suggestions to improve
upon it? eg. A high priority thread, calculating
the thread sleep myself? ....????

Thankyou in advance,
jamie.


Nov 17 '05 #7
jamie wrote:
hey all,

I am attempting to do motion control for
a final project, but I have a concern....

For motion control, timing is everyting,
the better it is, the better it works.


C# and Windows aren't the best platforms for real time applications. If real
time is important for your application I would use a software PLC. Do the
real time stuff in the PLC and provide control access through a nice GUI
written in C#. :-)

Max

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jj | last post by:
I've got one database server that works fine when transferring large amounts of data, but a new one that has been setup seems to want to timeout or drop the connection after a period of time. I've...
10
by: Greg Stark | last post by:
This query is odd, it seems to be taking over a second according to my log_duration logs and according to psql's \timing numbers. However explain analyze says it's running in about a third of a...
9
by: Amir Ghezelbash | last post by:
Hey every body i had a question i am in process of writing an application, where this application needs to check the database on hourly bases to see if they are any information that are needed...
1
by: Novice | last post by:
Hi all, I'm at my wit's end on trying to insert some timing code into the server side code that parses the hashed data contained in the hidden field being submitted to the server I've tried...
3
by: gregory_may | last post by:
I have an application where I am using a System Thread to capture the screen & Broadcast it to clients. Its "working", but the timing on the background thread gets wildly erratic at times. Some...
2
by: Steven D'Aprano | last post by:
The timeit module is ideal for measuring small code snippets; I want to measure large function objects. Because the timeit module takes the code snippet argument as a string, it is quite handy...
2
by: julie.siebel | last post by:
Google apparently ate my original post to this (grr) so this'll be a bit more vague than the initial post, but...*sigh*. Javascript is not my forte, and I apologize for the acky-ness of the...
3
by: CSharpner | last post by:
Is it just me or is everyone having problems with the MSDN site today? It keeps timing out. http://msdn.microsoft.com I've tried from: Oak Ridge, TN A proxy through our company net via...
0
by: Daniel Fetchinson | last post by:
On 4/15/08, Daniel Fetchinson <fetchinson@googlemail.comwrote: BTW, using the following ###################################################################### # CODE TO TEST BOTH...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.