If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"Clocking" events in Excel
I’m writing a psychological test which will flash simple 4-choice multiple
choice questions and score how quickly you hit the 1, 2, 3 or 4 key. I need to CONSISTENTLY measure very small time differences in how long it takes a person to answer each question after it appears on the screen. My goal is to use Visual Basic and Excel to “clock” such events in a very standard way, across different instances of taking this test on the same PC each time. Four questions: 1) Can the Auto Save or Auto Recovery functions be shut off by a Visual Basic command? 2) On the same PC from one test-taking event to the next, will the clock slow down if there is a reduction in available memory or increase in the number of background apps that are running? 3) If the answer to (2) is YES, is there still a way to have the program automatically recalibrate itself? For example by picking some information about CPU usage or speed off of the Performance Tab of the Windows Task Manager? 4) If clock degradation exists, is it predictable or irregular? If the clock degradation is predictable, couldn’t the calibration to an internet clock still be done by taking two time snapshots, say a day apart, the day before the next test? By taking a long time interval for the two measurements, any issues with internet connection speed would be negligible. Thanks! Pete |
#2
|
|||
|
|||
What do you mean by "very small"? The built-in VBA Timer function returns the
number of seconds that have elapsed since midnight. The following shows a resolution of 0.015625 seconds (t - t0). Sub TestTimer() Dim t As Single Dim t0 As Single t = Timer Do t0 = Timer Loop While t0 = t Do t = Timer Loop While t = t0 Debug.Print t0, t, t - t0 End Sub Charles Williams developed the following code for a high resolution timer (millisecond resolution, AIR): 'CLASS MODULE CHighResTimer 'copy all of this code to a class module in 'the workbook that needs the timer Option Explicit 'How many times per second is the counter updated? Private Declare Function GetFreq Lib "kernel32" _ Alias "QueryPerformanceFrequency" ( _ lpFrequency As Currency) As Long 'Get counter's current value? Private Declare Function GetCount Lib "kernel32" _ Alias "QueryPerformanceCounter" ( _ lpPerformanceCount As Currency) As Long Private TimerFreq As Currency Private TimerOverHead As Currency Private TimerStarted As Currency Private TimerStopped As Currency Private Sub Class_Initialize() Dim Count1 As Currency, Count2 As Currency 'Get the counter frequency GetFreq TimerFreq 'Call the hi-res counter twice, to check how long it takes GetCount Count1 GetCount Count2 TimerOverHead = Count2 - Count1 End Sub Public Sub StartTimer() GetCount TimerStarted End Sub Public Sub StopTimer() GetCount TimerStopped End Sub Public Property Get Elapsed() As Double Dim Stopped As Currency If TimerStopped = 0 Then GetCount Stopped Else Stopped = TimerStopped End If If TimerFreq 0 Then Elapsed = (Stopped - TimerStarted - TimerOverHead) / TimerFreq End If End Property 1) Can the Auto Save or Auto Recovery functions be shut off by a Visual Basic command? The AutoRecover object has an Enabled property. It also has a time interval that can be set as high as 120 minutes. I don't know about AutoSave. 2) On the same PC from one test-taking event to the next, will the clock slow down if there is a reduction in available memory or increase in the number of background apps that are running? Yes. Windows controls the amount of time that is allocated to each running application. AFAIK, you have no control over the amount of time that's allocated to your app, and when. 3) If the answer to (2) is YES, is there still a way to have the program automatically recalibrate itself? For example by picking some information about CPU usage or speed off of the Performance Tab of the Windows Task Manager? Does Charles' code take care for this for you? If you want to time some other event as a control, what event would you use? 4) If clock degradation exists, is it predictable or irregular? If the clock degradation is predictable, couldnt the calibration to an internet clock still be done by taking two time snapshots, say a day apart, the day before the next test? By taking a long time interval for the two measurements, any issues with internet connection speed would be negligible. I'm sure the speed will vary with the number of other applications that are running. Do you have control over that? For reliable results, you might need to shut down almost all background tasks. A final comment: because of Windows' multitasking, a Windows app may not be suitable for your purpose. You may need an old DOS program, but, AIR, then your resolution is limited to 1 clock tick, ~ 0.05 seconds. Assuming you're at a university or college, what software do your colleagues use for this sort of thing? On Thu, 21 Oct 2004 09:23:55 -0700, "Pete" wrote: Im writing a psychological test which will flash simple 4-choice multiple choice questions and score how quickly you hit the 1, 2, 3 or 4 key. I need to CONSISTENTLY measure very small time differences in how long it takes a person to answer each question after it appears on the screen. My goal is to use Visual Basic and Excel to clock such events in a very standard way, across different instances of taking this test on the same PC each time. |
#3
|
|||
|
|||
Thanks Myrna! I am not associated with a university--I am just trying to
test human reflexes. Instead of wasting time with a video game I think it would be intersting to have a program that you could run for a minute and test yourself a few times a day--e.g. how are you doing when you are well-rested versus over-tired etc. APP wise I am just running a PC with Windows XP and Office 2003. I am not sure but I think the fifteen one-thousandths of a second you cite should be fine! Or even the .05 if I go with a Dos app. I'll look over what you have sent and test it out. In all likelihood it seems this could work if the other apps are shut down when running the test. Thanks very much! Regards, Peter "Myrna Larson" wrote: What do you mean by "very small"? The built-in VBA Timer function returns the number of seconds that have elapsed since midnight. The following shows a resolution of 0.015625 seconds (t - t0). Sub TestTimer() Dim t As Single Dim t0 As Single t = Timer Do t0 = Timer Loop While t0 = t Do t = Timer Loop While t = t0 Debug.Print t0, t, t - t0 End Sub Charles Williams developed the following code for a high resolution timer (millisecond resolution, AIR): 'CLASS MODULE CHighResTimer 'copy all of this code to a class module in 'the workbook that needs the timer Option Explicit 'How many times per second is the counter updated? Private Declare Function GetFreq Lib "kernel32" _ Alias "QueryPerformanceFrequency" ( _ lpFrequency As Currency) As Long 'Get counter's current value? Private Declare Function GetCount Lib "kernel32" _ Alias "QueryPerformanceCounter" ( _ lpPerformanceCount As Currency) As Long Private TimerFreq As Currency Private TimerOverHead As Currency Private TimerStarted As Currency Private TimerStopped As Currency Private Sub Class_Initialize() Dim Count1 As Currency, Count2 As Currency 'Get the counter frequency GetFreq TimerFreq 'Call the hi-res counter twice, to check how long it takes GetCount Count1 GetCount Count2 TimerOverHead = Count2 - Count1 End Sub Public Sub StartTimer() GetCount TimerStarted End Sub Public Sub StopTimer() GetCount TimerStopped End Sub Public Property Get Elapsed() As Double Dim Stopped As Currency If TimerStopped = 0 Then GetCount Stopped Else Stopped = TimerStopped End If If TimerFreq 0 Then Elapsed = (Stopped - TimerStarted - TimerOverHead) / TimerFreq End If End Property 1) Can the Auto Save or Auto Recovery functions be shut off by a Visual Basic command? The AutoRecover object has an Enabled property. It also has a time interval that can be set as high as 120 minutes. I don't know about AutoSave. 2) On the same PC from one test-taking event to the next, will the clock slow down if there is a reduction in available memory or increase in the number of background apps that are running? Yes. Windows controls the amount of time that is allocated to each running application. AFAIK, you have no control over the amount of time that's allocated to your app, and when. 3) If the answer to (2) is YES, is there still a way to have the program automatically recalibrate itself? For example by picking some information about CPU usage or speed off of the Performance Tab of the Windows Task Manager? Does Charles' code take care for this for you? If you want to time some other event as a control, what event would you use? 4) If clock degradation exists, is it predictable or irregular? If the clock degradation is predictable, couldn’t the calibration to an internet clock still be done by taking two time snapshots, say a day apart, the day before the next test? By taking a long time interval for the two measurements, any issues with internet connection speed would be negligible. I'm sure the speed will vary with the number of other applications that are running. Do you have control over that? For reliable results, you might need to shut down almost all background tasks. A final comment: because of Windows' multitasking, a Windows app may not be suitable for your purpose. You may need an old DOS program, but, AIR, then your resolution is limited to 1 clock tick, ~ 0.05 seconds. Assuming you're at a university or college, what software do your colleagues use for this sort of thing? On Thu, 21 Oct 2004 09:23:55 -0700, "Pete" wrote: I’m writing a psychological test which will flash simple 4-choice multiple choice questions and score how quickly you hit the 1, 2, 3 or 4 key. I need to CONSISTENTLY measure very small time differences in how long it takes a person to answer each question after it appears on the screen. My goal is to use Visual Basic and Excel to “clock” such events in a very standard way, across different instances of taking this test on the same PC each time. |
#4
|
|||
|
|||
I found this post by Jim Rech:
http://groups.google.com/groups?thre...%40cppssbbsa04 That toggles autosave. Pete wrote: I’m writing a psychological test which will flash simple 4-choice multiple choice questions and score how quickly you hit the 1, 2, 3 or 4 key. I need to CONSISTENTLY measure very small time differences in how long it takes a person to answer each question after it appears on the screen. My goal is to use Visual Basic and Excel to “clock” such events in a very standard way, across different instances of taking this test on the same PC each time. Four questions: 1) Can the Auto Save or Auto Recovery functions be shut off by a Visual Basic command? 2) On the same PC from one test-taking event to the next, will the clock slow down if there is a reduction in available memory or increase in the number of background apps that are running? 3) If the answer to (2) is YES, is there still a way to have the program automatically recalibrate itself? For example by picking some information about CPU usage or speed off of the Performance Tab of the Windows Task Manager? 4) If clock degradation exists, is it predictable or irregular? If the clock degradation is predictable, couldn’t the calibration to an internet clock still be done by taking two time snapshots, say a day apart, the day before the next test? By taking a long time interval for the two measurements, any issues with internet connection speed would be negligible. Thanks! Pete -- Dave Peterson |
#5
|
|||
|
|||
Thanks Dave - I will give it a try.
"Dave Peterson" wrote: I found this post by Jim Rech: http://groups.google.com/groups?thre...%40cppssbbsa04 That toggles autosave. Pete wrote: I’m writing a psychological test which will flash simple 4-choice multiple choice questions and score how quickly you hit the 1, 2, 3 or 4 key. I need to CONSISTENTLY measure very small time differences in how long it takes a person to answer each question after it appears on the screen. My goal is to use Visual Basic and Excel to “clock†such events in a very standard way, across different instances of taking this test on the same PC each time. Four questions: 1) Can the Auto Save or Auto Recovery functions be shut off by a Visual Basic command? 2) On the same PC from one test-taking event to the next, will the clock slow down if there is a reduction in available memory or increase in the number of background apps that are running? 3) If the answer to (2) is YES, is there still a way to have the program automatically recalibrate itself? For example by picking some information about CPU usage or speed off of the Performance Tab of the Windows Task Manager? 4) If clock degradation exists, is it predictable or irregular? If the clock degradation is predictable, couldn’t the calibration to an internet clock still be done by taking two time snapshots, say a day apart, the day before the next test? By taking a long time interval for the two measurements, any issues with internet connection speed would be negligible. Thanks! Pete -- Dave Peterson |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
After installing Windows XP SP2 , how do I open old Excel 2003 fil | Mike D | General Discussion | 2 | September 2nd, 2004 10:21 PM |
Automatically Updating Excel Data In Word Doc Inside Excel File | Business Design Architect | General Discussion | 0 | August 29th, 2004 10:55 PM |
EXCEL TO OUTLLOK | Woodsmith | General Discussion | 0 | July 6th, 2004 12:29 AM |
Excel 2000 crushed | Sue | General Discussion | 3 | June 30th, 2004 12:25 AM |
Cannot open large excel file | Niall Caslin | Worksheet Functions | 3 | October 29th, 2003 05:24 PM |