Input Lag Tester

Brainlet

New member
Hello, I've never owned a microcontroller and have no background in EE, so I have a lot of questions. The project will consist of a Teensy 4.0 / 4.1, the ILI9341 touch display (https://www.pjrc.com/store/display_ili9341_touch.html), a phototransistor and a white LED. The goal is an automated mouse movement to photon input lag tester without any software and driver dependencies on the PC side. The white LED is meant for self-testing the measurement overhead.

1. Does the Teensyduino 'Mouse.h' module work without special drivers? If I were to plug in the device to a computer without the Arduino IDE and Teensyduino installed, would it be recognized as HID-compliant mouse without prompting any driver installation?

2. Does the Teensy 4.0 / 4.1 support 8000 Hz USB communication with the 'Mouse.h' module or is Raw HID code required?

3. Do I need the special Micro-B USB cable (https://www.pjrc.com/store/cable_usb_micro_b.html) for this or will a generic one do the job?

4. I've seen plenty of people who use resistors with the ILI9341 display but also plenty of people who don't. Does the "Connections" section still apply to the Teensy 4.0 / 4.1 (only resistor being 100 Ohm for the LED)?

5. Does the display come with pre-soldered pin headers?

6. I plan to use the phototransistor with a probe to an analog pin. How do I determine what resistor I need between the transistor and ground? Are there any specifications (both on the Teensy and phototransistor side) I need to account for (e.g. max photocurrent)?

7. Are there any ADC noise / signal integrity considerations with very long (~ 1 meter) cables for the phototransistor?
 
Many questions. Here's quick answers and some comments about phototransistors in general...

On Teensy, you use the Tools > USB Type menu in Arduino rather than "Mouse.h". It is detected by Windows, Mac and Linux as a normal USB mouse. All features work, with the exception of the moveTo() function doesn't work on some (most) Linux systems due to a limitation in the X11 event handling on Linux. Basic mouse movement (relative coordinates) and button clicks work on all systems using only the built in drivers.

The USB micro B cable isn't special, any generic cable will work. Well, except for charge-only cables, which are incredibly common in drawers of leftover USB cables. Make sure your USB cable actually has data wires. Charge-only cables are the most common tech issue.

Most ILI9341 displays have resistors built into their LED backlights. The 100 ohm resistor recommendation is on the conservative side, for the rare / old ones that have the backlight pin wired directly to LEDs.

Teensy can be purchased either with pins soldered, or without.

I hope you can understand how impossible it is to say exactly which resistor or other circuitry may be needed for an unknown phototransistor, and without a clear description of your intended use.

Long wires, analog signals, and (maybe) high impedance sensors are sort of a perfect storm for signal quality issues.

But in typical usage, phototransistors usually aren't used as analog sensors. The common way to use phototransistors is as a basic on/off type detection.

The nature of a phototransistor is basically that it acts like a transistor switch that goes from not conducting to fully conducting (also called "saturation" for bipolar transistors) with the change from darkness to light. Of course there will be some particular dim illumination which causes the transistor to operate in its linear region, but that light level will be difficult to predict. It's likely to be temperature sensitive and could vary quite a lot between phototransistors, even from the same manufacturing lot. They're usually not suitable for use as an analog sensor, because the current amplification behavior of the transistor is so unpredictable.

A typical connection would be to wire the emitter to ground and collector to a digital pin. The pin's internal pullup might be enough, using pinMode INPUT_PULLUP. Or you might connect a real resistor between the pin and 3.3V. Resistors in the range of 1K to 100K are probably worth trying. Lower resistance will give a threshold where the pin changes at a brighter light level. The pin will be logic low when light is present, and logic high in darkness.
 
Thanks for the reply.

On Teensy, you use the Tools > USB Type menu in Arduino rather than "Mouse.h". It is detected by Windows, Mac and Linux as a normal USB mouse. All features work, with the exception of the moveTo() function doesn't work on some (most) Linux systems due to a limitation in the X11 event handling on Linux. Basic mouse movement (relative coordinates) and button clicks work on all systems using only the built in drivers.
I found the USB library (https://github.com/PaulStoffregen/cores/blob/master/teensy4/usb_mouse.h#L46). I assume
Code:
usb_mouse_move(int8_t x, int8_t y, int8_t wheel, int8_t horiz)
is the function I'm looking for to simulate mouse move events.

Most ILI9341 displays have resistors built into their LED backlights. The 100 ohm resistor recommendation is on the conservative side, for the rare / old ones that have the backlight pin wired directly to LEDs.

Teensy can be purchased either with pins soldered, or without.
I'm referring specifically to the PJRC one in the store (https://www.pjrc.com/store/display_ili9341_touch.html). Does that one come with pre-soldered headers? Considering you mentioned "rare / old", is it safe to assume these have built-in resistors and I don't have to use any (neither for the LED connection)?

They're usually not suitable for use as an analog sensor, because the current amplification behavior of the transistor is so unpredictable.
Seems like what I'm actually looking for is a light to voltage converter (https://www.youtube.com/watch?v=MbZUgKpzTA0&t=82s). I definitely need the granularity since I'll have to account for monitor response times and adjust the sensitivity depending on the tested scenario.
 
Back
Top