We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › reaction time
Page Index Toggle Pages: 1
reaction time (Read 446 times)
reaction time
May 17th, 2008, 10:12am
 
im trying to write a program that calculates the response time for subjects for a given set of dots around a focal point.I'm trying to loop the images in the draw() function and catch the subjects response with the keyPressed() function.  Though every time I get a time values that are too consistent,i.e., they are the multiples of certain values.  I think the problem is related to how I delay the images on screen. Ive tried to use for loops to slow the program down;if statements that allow the draw function to circulate repetitively; ive even tried to run a separate thread to watch the time, but none of these worked.  If anyone has any ideas, any help would be greatly appreciated.
Re: reaction time
Reply #1 - May 17th, 2008, 3:36pm
 
I made a little test program, and I got quite varied results, so I am not sure how you do your tests.
Code:
float time;

void draw()
{
if (frameCount % 120 == 0)
{
color c = 0xFF000000 + int(random(1, 0xFFFFFF));
fill(c);
ellipse(width / 2, height / 2, width / 3, height / 3);
time = millis();
}
}

void keyPressed()
{
float endTime = millis();
println("Time: " + (endTime - time));
}

The color change is quite regular, so I can get good low time when I anticipate the change. Although I can anticipate too much and have a big number instead...
Re: reaction time
Reply #2 - May 23rd, 2008, 9:06am
 
The numbers captured are not all varied.  They are all off-set from each other by about 15 to 16 milliseconds.  I tried to achieve as many different values as possible and all I got were numbers that, when arranged in order, demonstrated a pattern that leads me to believe that the timer is offset by the time it takes the processor to go through the code.  This proves difficult for me as my code has a large amount of code and thus the values are offset by larger values, thus i am not able to get as accurate a reading by this manner.  Thanks for the help though. If there are any other solutions I am open to suggestions.
Page Index Toggle Pages: 1