HalfwayDead wrote:I am of course aware that the camera is exposing for 1/1250th of a second and therefore if the LED turns on halfway into that exposure time it's going to be half as bright.
Correct, you figured that out.
HalfwayDead wrote:However, I'm getting a lot of situations where the LED is at (estimated) 20% brightness in 1 frame then 80% in the next one and 100% in the third etc.
That would likely be the mouse button's fault, there are many mouse buttons that have a more gradual resistance increase than others. Time when you see the first LED illumination. It may add a slight error margin as you say.
You can measure this by connecting an oscilloscope to the mouse, and you'll witness a "curve" instead of a "squarewave", this is just a characteristic of some kinds of buttons. It can be quite annoying, and possibly a problem with some of them. This happens very often with old mice, and a lot less often with newer mice.
Is your mouse old?
Old mice often have has button contacts that create a more gradual resistance increase (even over a few milliseconds) because of things like residue and fine metal dust (caused by grounded contacts), or other films of corrosion, or other poor contact. If you ever opened up a very old gamepad, and opened up the contacts, you can notice how dirty it gets inside the button contacts from wear-and-tear, even sealed ones, because of fine-metal-dust-grinding of repeated button-mashing (slamming two pieces of metal together millions of times).
This turns buttons into what behaves as fast-potentiometers sometimes, like a pressure sensitive button, where there's a gradual resistance-decrease (say, over 1ms) rather than a darn near-instantaneous resistance-decrease (say, microseconds). Connecting an old, super-worn clicker-dome button to an oscilloscope, shows more of a curve instead of a squarewave, upon the trigger. If you press slow enough, it may even exhibit pressure-sensitivity too. Or it might click from infinite-resistance to a non-zero-resistance that behaves pressure-sensitively after the click occurs.
In the real world -- once it becomes bad enough, button response becomes erratic (slight press before clicking can cause erratic mouse clicks). But even one year before that happens, your mouse button already is likely slowing down dozens of microseconds from the repeated grinding. The microcontroller within tries to react quickly (debounce filtering can make an old mouse last longer before it begins to malfunction...) but is always imperfect.
(If you're a paid championship player "milliseconds matter" type person -- then it is best to replace eSports computer mice long before the buttons begin malfunctioning, because it may be unwittingly adding a few hundred microseconds of input lag.... But for 99% of people, that insignificant lag of a slightly worn button, doesn't matter)
Anyway, weird behaviors can still happen to certain types of button mechanisms of new buttons too -- but such button mechanisms are kind of unwanted in eSports-quality mice. So I'm assuming -- I'm hoping -- your modified mouse was already at least a few months old (minimum).
For fastest mouse button response, it is better to use a fresher/newer mouse. But if you are testing a heavily-used, press the mouse button harder/faster to minimize this "1.5ms lag" effect you're seeing.
If you're testing a newer mouse, with a fresh mouse button, you are less likely to see this sort of behaviour, and the button click will be more in unity with the LED illumination, vastly reducing error margin to simply your high speed camera's shutter speed.
For even better accuracy, be familiar with rolling shutters.
Most of the time, an accuracy factor of 1 shutter cycle (e.g. 1/1250sec error margin) is plenty enough for input lag tests.
But if that's not enough accuracy, it's possible to work on the error margins:
(1) Fresh/new mouse with fast reacting button. That keeps LED timing with mouse microcontroller timing, as tight as possible.
See above for why old mouse buttons sometimes sort of behave "pressure sensitive" like fast potentiometers
(2) LED on same 'scanline' as screen response you're paying attention to (eliminates camera rolling scan error margin)
Rolling shutter during 1250fps means top edge of camera image is 1/1250sec less lag than bottom edge, so aligning the LED on the same scanline as the screen response you're trying to measure, can improve accuracy even further.
(3) LED brightness calculation (50% brightness = 0.5 frame) -- this is incredibly tough to do, but extrapolatable.
Works best with very squarewave mouse buttons, doublechecked with an oscillscope. You could also illuminate "reference LEDs" on a breadboard (10 LEDs at 10% brightness steps) along bottom edge, as a brightness compare. That can allow you to get 100 microsecond precision out of 1/1000sec (1ms) shutter. However, an LCD display's GtG generates MORE error margin than this, especially considering GtG of a specific color pair can be several milliseconds different than the GtG of a different color pair -- more input lag for specific LCD color transitions, for example.
If you're unsure how to trust it, connect oscilloscope to the mouse button too (which can simultaneously be done with the LED), see how the button looks under an oscilloscope (you want to measure resistance change at approximately 100KSPS (Kilo Samples Per Second) or 1MSPS (Million Samples Per Second) or so -- and scale the display graph to a scale over roughly ~5 milliseconds to show the button curve. Though sometimes you may need different range settings to see the curve more clearly -- depends on quality of your oscilloscope.
It's shocking how a lot of buttons don't behave like square wave!
What error margin are you trying to aim for? 1ms is often good enough error margin for lag benchmarking with 1ms GtG LCD's. 1.5ms button lag from a worn button is a tad high, but you should get far less than that by pressing the button quicker/harder -- and push it within the 1ms error margin typically targeted for in these types of high-speed-video lag tests.