I spent some more time today exploring the VSYNC.
It seems that it is possible to charge the sensor before it actually starts integrating/exposing. It is significantly less sensitive in this state, but it can still cause residue on “dark” frames if you are alternating some LEDs. If anyone is more familiar with imaging sensors… I’d be curious to hear an explanation for this.
Here is my understanding of VSYNC in relation to the PS3Eye timing:
Assuming the exposure is set to 0, the first row of the sensor is exposed. Then the VSYNC is pulsed and the first row is read off the sensor. While the first row is being read, the second row is exposed and then read off the sensor, etc.
When the exposure is higher than 0, multiple rows are exposed simultaneously. This allows for the same row clock, but longer exposure times. When the exposure is complete, at 511, about half the sensor is exposed simultaneously.
As I mentioned, there is a strange effect where enough light can start charging the sensor before it is actually exposing. The two ways to avoid this are by using the lowest possible exposure setting for your application, or by only pulsing LEDs for half the frame with the sensor fully exposing. This second solution means the image will be brightest in the center and darkest on the top and bottom.
The attached Arduino code will pulse a pin for you in sync with the VSYNC of your PS3Eye, and has a single variable corresponding to the exposure that can be set.