How to Make a Timer with Milliseconds

I am trying to create a timer that tracks milliseconds. The reason being is that I want to track key strokes, store them, and later repeat them. In order to repeat each key's input interval accurately, I need to
track amount of time each key is pressed between each other and to do so I plan to record by the millisecond. I won't be storing each millisecond but rather I want to make sure that the Controls.TextType and Timer event can be processed at any moment. From
my observation, I can't go any lower than one second because, realistically, multiple keys can be pressed in less than a second and also I can't recreate one second (accurately) out of milliseconds unless its ticking by one millisecond. As far as I know, I
can use the Timer object but I encountered a limitation. The Timer.Interval only goes as low as 10 milliseconds. I looked at other options and considered using Clock.Millsecond and subtracting two versions of Clock.Millisecond at a millisecond difference but
did not manage to make a working sample.
I also tried using using Program.Delay() but I don't understand how this doesn't measure one millisecond:
gw = 600
gh = 300
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.KeyDown = onKeyDown
GraphicsWindow.KeyUp = onKeyUp
GraphicsWindow.Left = 0
GraphicsWindow.Top = (Desktop.Height - gh)*0.20
TextWindow.Left = (Desktop.Width - gw)*0.90
TextWindow.Top = (Desktop.Height - gh)*0.20
txtSize = 20
tx = (gw - txtSize)*0.20
ty = (gh - txtSize)*0.50
GraphicsWindow.FontSize = txtSize
GraphicsWindow.DrawText(tx,ty,"CLICK GRAPHICS WINDOW SCREEN THEN")
GraphicsWindow.DrawText(tx,ty+txtSize,"PRESS ENTER TO USE KEY EVENT")
milliSec = 0
sec = 0
print = "True"
While "True"
milliSec = milliSec + 1
If (milliSec > 999) Then
milliSec = 0
sec = sec + 1
TextWindow.WriteLine(sec)
EndIf
If (keyDown["Return"] And print = "True") Then
TextWindow.WriteLine("You pressed at " + sec + ":" + milliSec)
print = "False"
ElseIf (keyDown["Return"] <> "True") Then
print = "True"
EndIf
Program.Delay(1)
EndWhile
Sub onKeyDown
lastKey = GraphicsWindow.LastKey
keyDown[lastKey] = "True"
EndSub
Sub onKeyUp
lastKey = GraphicsWindow.LastKey
keyDown[lastKey] = "False"
EndSub
Why do I suspect my timer isn't accurate? For one, when I count by one (like so one crocodile, two crocodile, etc) it doesn't match up. Also, I've compared it with many online stop watches and it's apparent they run seconds ahead.
My three options:
1) use the Timer object
2) use Clock.Millisecond
3) use Program.Delay
After constant failure and researching, I forgot to consider what is the default rate of a small basic program when its running as a whole and each line. Is it possible to go lower than it? Again the current goal
of my project at the moment is tracking a key stroke and returning the time the user inputted. That's why, I want my timer to move
by one millisecond so I am able to process every action. Any explanation, samples, or guidance would be helpful. Thank you.

Program Code: FRT619
Removing the comments tags (from the last three lines at the bottom of the mainTimer subroutine) will show that I can store time values and rely on the fact that they can be compared. It's no where near completion
but, hypothetically, this will allow me to achieve my main goal: storing time intervals from any key and repeat them at the user's command accurately when the timer restarts. I'm sure I've compromised the timer's accuracy though. What are your thoughts? Do
you see a better way to approach this problem? Also, I wasn't able to display the milliseconds but realized that it may not be necessary since I only need it to process events and store variable accurately. Not to display the precise time. Although, I am open
to any solutions to this minor problem. One more note: I nested the main loop with a small loop that changes run to true when milliseconds is zero. This is used to assure that milliSec has an initial value of zero, which is crucial to store time accurately.
Bug: Timer stops if user holds enter key. Solution: remove program delay in sub routine control, however, user can't hold key and record same key multiple times.
New Solution to bug: implement button and textbox events (allows user input while recording time through PC's clock--in milliseconds).
On a side note, the clock object communicates with the PC's clock, which would mean it's asynchronous from the program and isn't affected by program delay. However, if the PC's clock is ticking by the millisecond(s) and the program stores the time from the
PC's clock and display it with a delay of 1000 milliseconds. The clock object may not be affect but displaying the time will be?

Similar Messages

  • How to make text columns with adobe muse

    Hi,How to make text columns with adobe muse (like InDesign)?

    Multiple columns can be acheived with CSS - http://www.w3schools.com/css/css3_multiple_columns.asp
    div
    -moz-column-count:3; /* Firefox */
    -webkit-column-count:3; /* Safari and Chrome */
    column-count:3;
    I'm surprised that Muse does not support text columns yet, but perhaps the custom CSS can be added in style tags on page properties. Haven't tried it, but don't see why it wouldn't work.

  • How to make turning page with ibooks author?

    How to make turning page with ibooks author?

    This question has been answered on this thread
    https://discussions.apple.com/message/17981772#17981772#17981772
    Best regards.
    Alex

  • How to make visible Time Sheet link

    Hi,
    I want to know how to make visible Time Sheet link on portal for a particular Personnel Area so that employees of this PA can fill their Time Sheet from the portal.

    HI,
    Use Tcode - CAT 2
    Regards,
    Shadeesh.G

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to make email link with a button with AC2 in flash cs3?

    How to make email link with a button with AC2 in flash cs3?
    I wrote this, but it does not work:
    btn_emailinfo.on (release) {
    getURL("mailto:"[email protected]");
    }

    I am guessing you put that on a frame?
    If so, the syntax is as follows:
    btn_emailinfo.onRelease = function(){
    getURL("mailto:[email protected]");
    Though, if you are placing it directly on the button itself,
    the syntax is:
    on(release){
    getURL("mailto:[email protected]");
    }

  • How can I count time with labview7?

    Hi
    How can I count time with labview 7 and NI-DAQmx like I did with labview 6.1 and "count time-easy.vi" (count event or Time.vi).
    I have a 6025E and labview 7.0
    Thanks

    I am not sure what you want to do or why..
    ... but here goes (some suggestions)
    If you want to count the time between two events, you have a choice, you may use the Tick Count. Inisitalize it first by getting a timestamp and then do a difference within a loop. The difference will give you the time elapsed in ms.
    You can also use the Get Date/Time String or Get Date / Time in seconds and once again take a snapshot when a first even occurs and another snapshot at the next even (at a point where you want to measure elasped time). This method is particularly useful if you want to timestamp an event.
    If I didn't answer your question, can you elaborate what you mean by "How can I count time".
    Best of luck..
    JLV

  • I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    It may be due to Continuity
    The following quote is from  Connect your iPhone, iPad, and iPod touch using Continuity
    Turn off iPhone cellular calls
    To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls.

  • In JSF, how to make a menu with access control?

    In JSF, how to make a menu with access control?
    The access control can be guided by programming, database or other means if possible?
    Thanks

    I want to make a dvd menu in iMovie because i don't have IDVD and can't find anywhere to download it?
    For making DVDs I would recommend iMovie 06 and iDVD 09 both readily available on Amazon or eBay.  Shop for iLife 06 and iLife 09.
    You can make menus and chapters with any version of iMovie except the latest one. There's nothing wrong with iMovie 11 either but I prefer iMovie 06.
    By using iMovie 06 and iDVD 09 I make DVDs with professional moving menus with very little effort. They look almost as good as Hollywood.

  • How to make slide images with Dreamweaver CS6?

    How to make slide images with Dreamweaver CS6? Please teach me.

    Hello
    in addition to Jon's hint, I'll send you some links to nice sliders (have fun with the different representations ):
    http://sandbox.scriptiny.com/javascript-slideshow/
    http://jquery.malsup.com/cycle/
    http://wowslider.com/best-jquery-slider-crystal-linear-demo.html
    http://www.jcoverflip.com/demo
    http://www.jacksasylum.eu/ContentFlow/
    http://addyosmani.com/blog/jqueryuicoverflow/
    You only need to use the source code to implant these shows there where you want. In my eyes it would be the best that you use first a very new and blank DW file to perform (maybe in LiveView) the one or the other.
    Hans-Günter

  • How do you create a swimming timer with milliseconds

    Does anyone know how to create a swim timer in milliseconds in Adobe Premiere Pro?
    If you've watched olympic swimming, you've seen the swim timers on the bottom right. I'd like to recreate this in Premiere Pro, showing MM:SS:Milliseconds. (1:25.78).
    I've tried several techniques, but I can't get the milliseconds correct!!
    Here's what I've tried.My media is 29fps.
    1. Create a blank Transparent Video
    2. Add a the "timecode" effect ot the video.
    3. Select the preferences -> show audio time units in the display.
    4. for the Time Display in the time code I used 30 Non-Drop Frame.
    (see a youtube tutorial I followed: http://www.youtube.com/watch?v=Xt3V8JL4LnA)
    This will show correct up to the seconds, but the format for the last is the frame # (up to 30).
    While I've tried changing it to 60 Non-Drop Frames, it only goes up to 60 (again # of frames). How do you get milliseconds?
    The difference between first and second in swim races is milliseconds.
    Thanks for your help.

    Yes. The finish is measured in milliseconds. But there are only 29.97, or maybe 59.94 frames per second in video. So getting to the correct millisecond will be impossible except with great luck.
    In fact, you have probably noticed that you can see the hand about to touch, and see it touching, but not all that often will you see the exact moment it touches.
    So, if you want to create a timer yourself, you can do that, and cheat by using titles to create your numbers. You can make it look like your timer is correct. But it won't be.
    If you want to create 60 different  titles to use to cover up the frames portion of the timecode, the first is 00, then 17, then 33, 50, 67, and keep going... As you can see when you divide 1000 by 60, the real numbers are 16.6667 and 33.33333 but that is just not worth worrying about, I suppose.

  • Is it possible to make a timer with AS3 which is accurate upto one millisecond.

    I am new to AS3. I have somehow developed a auditory and visual reaction timer by taking script from here and there. I know its not accurate and I also know that I will write it correctly when I have learned the script thoroughly,
    But I was checking the net about the timer class and various posts on it and  I am vexed with a question "if its possible to make an accurate timer with AS3?" can somebody please tell me for sure. and I will be grateful if I know how to make it correctly. I can post the code which I have written ( assembled ).

    the answer is, maybe. but for, for most coders, the answer is, no.
    getTimer() is accurate to within 1 ms.  but that allows you to determine time/elapsed time and does not call or execute code on a regular timed schedule. it can be used with the timer class or enterframe events to do some things accurately.
    however, the timer class is not accurate in the way beginning coders think.  it will, on average, allow calling a function at close to the designated interval if there are no performance issues with your swf.  it does not allow each function call to occur at a regular interval.

  • How to get/display  time with minutes in a test item

    Dear experts,
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Oracle Toolkit Version 10.1.2.0.2 (Production)
    PL/SQL Version 10.1.0.4.2 (Production)I've the following requirements.
    In my form, there are three text items and one save button.
    Text items named as
    No_of_days --> Number data type
    (user will enter number of days)
    hours_limit --> Char data type with format mask (HH:MI);
    (user will enter hours with minutes)
    Upto_date_time --> date data type;
    this field calculated as (No_of_days+hours_limit+sysdate)
    User will enter No_of_days or hours_limit:
    Based on the values I've to calculate Upto_date_time
    Here is the problem:
    1) If user doesn't enter hours_limit I want to show default time as " 04:00 PM"
    2) If user enter hours_limit field we should allow them to enter in the following format
    "HH24:MI" format;
    what whould be suitable data type for hours_limit field..
    I tried with char and i've set the format mask as ,
    set_item_property('BLOCK3.hours_limit',format_mask,'HH:MI');
    But I'm geeting the error
    "FRM-50027:Invalid format mask for given datatype"
    Please help to solve this problem,
    Regards,
    Karthi

    Hi vansul ,
    set_item_property('BLOCK3.hours_limit',format_mask,'HH:MI');
    Format mast is only allowed to date data type fields.If i set the hours_limit item's data type as date , I'm getting the error message "ORA-01843:Not a valid month"..
    How could i make this field only getting or display time with minutes?
    Regards,
    Karthi

  • How to make Macbook work with closed display?

    I need to make MacBook to be closed (display) most of the time and work with external monitor, keyboard and mouse (actually trackball as I have been hating any type of mice since 1998 and not using it even at work).
    Now I do not like mediocre resolution of small MacBook display and I prefer my 20 inch wide monitor. Also the keyboard is rather for quick work in small areas like restroom rather than comfortable work on big desk (I hate notebook keyboards either as they make me feel claustrophobic and crunching my fingers).
    Considering recent buzz on Mac Mini not living for too long into future I would love to find alternative solution (meaning I do not want computer with display and keyboard in one and I do not have needs of spending few thousand of dollars for big metal case good for feeding and breeding birds I have ergonomics demands, but not higg performnce processing needs.
    So can you tell me how I make Apple notebook being closed (and perhaps squashed by monitor stand) behave like a CPU box?
    Thanks,
    Maciek

    Thnaks, but I am not interested in bluethooth/wireless solution. That minimum of cable to reach CPU does not bother me and I do not buy big monitor to work on my computer from adjacent room. I just need space for more windows and I think Apple did great job having USB Hub on keyboard that allows stringing mouse and keayoboard with one cable to CPU.
    Also I haven't heard of wireless KVM and I use such solution. This is not my only computer as I run home network and two of them in my room are supposed to share keyboard, mouse and monitor. So far I was successful to run this setup, but I need inexpensive plain CPU from Apple to be able to find comfortable solution to work.
    Well I could drop the other computer if Apple managed to provide everything that I need (how about Safari properly working with Citrix client and Remote Desktop to Windows as I do not want Firefox on Apple computer? Only Firefox fixes the problems with this software).

  • Filter Express VI - How to make it work with single samples? (LabVIEW 8)

    Hi there,
    I'm trying to update some older code by implementing some sort of FFT.  Currently, my program acquires X data points, averages them, and spits out the Mean value into a graph (Signal as a function of wavelength) (Spectrofluorimeter).  This is done a number of times with the instrument moving to a different wavelength between each sample scan. I've tried to incorporate the Filter Express VI but it does not seem to be doing what I'd like it to.  I have it wired to my Signal Acquisition Express VI with the Filter set to Low-pass 100 Hz with the result being passed through the "Mean" VI and then graphed with the Build XY Graph Express VI.
    When I graph the Power Spectrum, I am seeing that the maximum observable frequency is always 1/50th my sampling rate (regardless of my low/high/bandpass settings).  For example: my # of samples is set to 100, and my sampling rate is 8000 and I observe a maximum frequency of 160 Hz.  If my # of samples is set to 100 and my sampling rate to 6000, the maximum frequency is 120 Hz.  If I try the Filter Express VI with very basic wiring and just hook up a battery to it, I see all sorts of frequencies all the way up to my sampling rate divided by 2 (i.e. 8000 -> 4000 Hz) so this seems very strange to me.
    I'm not sure what is causing this and perhaps its a limitation of the Filter Express VI and I'm supposed to filter using a different method?  I was thinking that perhaps I would need to store all of the dynamic data and then wire it to the Filter Express VI once the entire scan was completed and filter that way but I'm not sure how to save or buffer this dynamic data.
    I'm hoping this is a common problem and someone would be so kind as to offer me any suggestions!
    Thank you for your help!

    I think I should clarify that these aren't necessarily "Single Samples".  I take X number of samples at a specific wavelength, filter that, then take X number of samples at a different wavelength, filter that, and the goal is to have a frequency filtered data set at the end.

Maybe you are looking for

  • HELP. How to escalate in a genuine emergency?

    Background (rather long, sorry): We live in England but have a 2nd home in rural Wales (family history).  Both homes have phone and broadband via BT.  Both homes are in areas with near-zero mobile coverage but we route the mobile signal through the b

  • Problem in ESS Build when creating the project "Import can't be resolved"

    Hi All, we are using ESS and MSS 600 for ERP 2005 and EP 7.0. Once the cms INBOX components are imported to Development, I have started my development. In the Build process, when I am trying to create the Project for ess/us/bank inactive DC, It says:

  • Purchase Order Output Types

    Hi, My requirement is that clients needs different header in Purchase Order Printout based on Plant. Means for each Plant we need a particular Header in Purchase Order. I have found that for Purchase Order, Standard Output Type NEU is there and we at

  • No more songs in playlists?...

    all my playlists are stilled listed in itunes BUT theres no tracks in them? I recently moved tracks out of 'unknown folder' in my itunes libary but when i put them back in unknown, there was still nothing in my playlists. how can i have my playlists

  • Alternative to login.jsp

    Hi Is there an alternative method for accessing Portal/Instant Portal other than by using the default login.jsp. Could for example one of the API packages that are available with OracleAS Portal Developer Kit (PDK) be used as an alternative. If so an