473,890 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3776
Take a look at the System.Threadin g.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*******@disc ussions.microso ft.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 "Introducti on 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*******@disc ussions.microso ft.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.Environm ent.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*******@disc ussions.microso ft.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.Threadin g.Timer and from within your
OnTick routine call the Win32 function QueryPerformanc eCounter 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*******@disc ussions.microso ft.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_multimed ia_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
1592
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 tried to compare the variables and they seem to be the same. The versions of MySQL are slightly different with the good one being 3.23.41 and the one timing out being 3.23.58 Any ideas on what I can check for that would be different or help...
10
2182
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 second. What would cause this? Is it some kind of postgresql.conf configuration failure? I have the same query running fine on a different machine. QUERY PLAN...
9
1762
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 to be processed in the next upcoming hour so my application has to to connect to data base right on (for example) 5:00:00 then check all the jobs that are due on 5:00:00 5:15:00 5:30:00
1
1431
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 placing timing code in all of the following: Page_Load OnInit LoadViewState(object savedState) object SaveViewState()
3
1705
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 times, its right away, some times after 10 seconds. I have included the setup of the process and the outline of the Call Back Method. As posted, the callback method can be mildly erratic (only doing a debug.writeline) I am guessing up to an 80%...
2
3317
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 to use from the command line, but it is less convenient for timing large pieces of code or when working in the interactive interpreter. E.g. variations on this *don't* work: $ python Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
2
1553
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 code. I'm working on a page for a travel company. There's way too much going on with it/on it, but I'm kind of stuck at this point - the client loves it, so I have to solve this problem.
3
1414
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 Frederick, VA A proxy through our company net via Houston, TX Remote controlling my own server from Houston, TX
0
1961
by: Daniel Fetchinson | last post by:
On 4/15/08, Daniel Fetchinson <fetchinson@googlemail.comwrote: BTW, using the following ###################################################################### # CODE TO TEST BOTH FUNCTIONS back = fill_matrix(generate_zero())
0
9814
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10903
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10449
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8006
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7158
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5834
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6034
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4257
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.