measuring refreshing rate of a screen

Hello.
For a perceptual experiment in a research lab we would like to monitor the refreshing rate of a monitor with high precision (tenth of msec). Ideally I would transmit information from the sensor to matlab, which is running the experiment, through a serial or usb port. An Arduino look like an ideal candidate for the interface. However since I forgot most of my electronics classes I would like to have a positive feedback before starting this project. So here are my questions:
(1) Photocells have a too slow response time so what I am looking for is rather a photodiode or a phototransistor, is it correct?
(2) Recording from 2 photodiodes in parallel works exactly the same?
(3) Does the atmega chip have enough memory to store information during 1-2 sec before to send them to the computer?
Thanks for your answer.
Regards,
Baptiste

Why measure the refresh rate of the monitor with photo detectors, just look at the sync pulses with an oscilloscope and time the frame sync pulse?

  1. Yes
  2. Recording from 2 photodiodes in parallel works exactly the same? the same as what?
  3. How much information do you want to store? This is only a few bytes isn't it? You only have to measure the refresh rate once it doesn't change.

Thanks Grumpy_Mike.
(2) The same as for 1 photodiode only. That is connecting the photodiode anode to an entry of the chip, the cathode to Vcc and put a resistor between the anode and the ground. The arduino should have no problem acquiring the signal from two different photodiodes on two different pins. Is it correct?
(3) I should provide more details: we are running a perceptual experiment composed of hundreds of trials. A trial consist of a visual stimulus displayed for a very short time on a stereo screen (a screen at 120Hz where we alternate left eye/right eye), then the participant has to give an answer by pressing a key. We don't simply want to know the average refreshing rate, but rather to check if the monitor has been refreshed correctly and at the proper time during the whole experiment. Moreover to have a better control on the monitor matlab send information to the graphic card in synchronous mode and ask for a refresh only when needed (in other words the computer will be able to communicate with the arduino only after a refresh). This is the reason why I want to use 2 photodiodes (one to check the right eye and one for the left eye), and why I would prefer to store the photodiodes information in the chip and transmit a package to matlab at the end of the trial. As for the quantity of information, it is indeed only bits (0s and 1s from the photodiodes), and their number depends of the arduino's sampling rate which I don't know.

I think you are misunderstanding how a monitor works.
It can't fail to refresh at the rate it is set at. Are we talking about a CRT or LCD monitor here?
If it is a CRT then it is impossible for it not to refresh at the set rate. There is a lot of electronics that would fall apart if you attempted to do this.

send information to the graphic card in synchronous mode and ask for a refresh only when needed

That refresh is where the graphics bit map you are writing into gets switched to the graphics bit map that is being output. The monitor however will keep refreshing at it's set rate. The synchronous mode is where the switching between the displayed banks is synchronised to the frame flyback, in the non synchronous mode this switch can happen anytime during the scan and so the picture can change half way down the scan. So if you use this mode any image will be on the screen for an integer number of frames. Are you set up for interlaced mode on the monitors?

The arduino should have no problem acquiring the signal from two different photodiodes on two different pins. Is it correct?

The A/D converter takes about 100us to acquire a sample so it is not the way to time things very accurately. What do you intend to actually measure here? Any photo diode placed against the screen will show a burst of signals every frame. This is because the physical size of the diode means it triggers on about 5 to 10 lines either side of it's position. You can get a photo diode with a schimit trigger output that is suitable for light pens, this is probably what you would need but only if you have a white background, and I bet that messes up the experiment.

For you information I used to be a University Lecturer (Physics) and my wife has a Physiology degree so I know all about these sorts of experiments. One of my first publications was a computer tachistoscope way back in the 70s.

I might use the wrong word: to me synchronous means that my code stops until the screen is refreshed. So I can't read from the serial port until the refresh. I mentioned that only to explain why I want to send data at the end of the trial only.
I will be more explicit: I'm currently using matlab with material I did not choose and do not trust. Moreover the computer is under windows which is known (many psychophysicists checked that and they all agree) to lack control and sometimes miss refreshes. In our experiment a trial start with a fixation of 500 msec, then a stimulus is displayed between 1 to 4 frames sequentially for each eye. So what I want to do is to tape 2 photodiodes in the upper corners of the monitor and display a small white rectangle under the tape (the subject will not see it) for one frame at the beginning of fixation and then when the stimulus is displayed so that I will know exactly if the stimulus has been displayed when I asked for. Here is roughly what I should record for a trial where the stimulus is displayed for 1 frames (1 means that the rectangle is displayed, the arduino will actually record the opposite):

| time (msec) | |0-8.3 | |8.3-16.6 | |16.6-500 | |500-508.3 | |508.3-516.6 | |516.6-response |
| - | - | - | - | - | - | - |
| left eye rectangle | |1 | |0 | |0 | |1 | |0 | |0 |
| right eye rectangle | |0 | |1 | |0 | |0 | |1 | |0 |

I don't know if it is more clear. I could draw a picture.
I don't know what is a schimit trigger. Do I really need it?
Thanks.
Baptiste

I might use the wrong word

Yes well there are a lot of wrong words being used here, the title for one is totally wrong, now I know what you actually want to do.

I would recommend that you use the SD4324 or SD5620 detector these are going to be fast enough others may not be.
You still have the problem of clusters of pulses. If you are just having one frame of your target followed by a frame some time later you could use the first pulse you see, followed by a blank period when you don't look at the sensor. Then start looking at the sensor again and stop your timing when you see the first one.

You said:-

with high precision (tenth of msec).

This is not what will happen, you can only hope to get meaningful measurements down to the resolution of one frame refresh time which for 120 Hz refresh rate will be 8.3 mS, any greater accuracy is an illusion and doesn't tell you anything. It is like a student measuring an angle with a plastic protractor and then working the COS of the angle to 6 decimal places because that is what his calculator said. So you should be able to use the millis() timer in the arduino.
I would use direct port addressing to read the two sensors in sanctimoniously and then have your code separate them.

Remember the actual real refresh rate of the monitor is fixed an will not change. Even windows is not crappy enough to make that happen because it is a function of the monitor itself not the operating system driving it.

You are right, I realize the title of this post is not very accurate.
The photodiode looks good. If I understand correctly there already is a pull-up resistor and an amplifier so I just have to connect it to one of the atmega pin?

You still have the problem of clusters of pulses.

Could you please detail that?

Thanks for your help, it already saved me much time.

so I just have to connect it to one of the atmega pin?

Yes.

You still have the problem of clusters of pulses.

The angle of view of the sensor is such that on any one frame it will pick up the raster over a few lines. Therefore you will get a pulse out of the diode for every line the sensor sees. When looking at this on an oscilloscope you get one pulse as the spot crosses the diode on the first line, and again another pulse on each subsequent line that is in its angle of view. These pulses will be separated by the time for a line scan. So it will appear as not one pulse per frame but several pulses per frame over the course of a frame.

However it should not matter on your system if you have a delay of half a frame after you see a pulse.

Are you talking more about the actual data on the screen refreshing? The screen refreshes regardles of if the data sent to the display is refreshed,
the sensor will tell you that the display is being refreshed 120hz, it wont tell you tho if that line is new or old data that windows failed to refresh on time

It will if the data is only being displayed for one frame followed by a number of blank frames and ending up with one frame of data. This is basically what the OP is trying to do. We went through the incorrect wording of the title earlier on in this thread.

Are you talking more about the actual data on the screen refreshing?

Yes, I actually want to monitor what is displayed on the screen, not the refreshing rate.

Therefore you will get a pulse out of the diode for every line the sensor sees

Ok, I think I understand. There is many ways to solve this problem, I could set a single pixel to max illuminance and the others to 0 if the diode is sensitive enough, or filter the signal.
I bought what I need for this project. I'll let you know how it works.
Thanks a lot for the help.