Page 2 of 2

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 12:53
by CrazyCookie
0ka wrote:
13 Jul 2023, 12:47
CrazyCookie wrote:
13 Jul 2023, 12:33
I get screentearing regardless of borderless, because I dont use V-sync or Freesync etc.
now check with any other game that doesn't use dx12
I will definitely test it when I'm back home again. Now you got me interested if its DX12 that causes this. This would save me so much time for testing!

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 14:07
by delve
can you name some of these "other latency tools" that i can purchase?

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 14:15
by CrazyCookie
delve wrote:
13 Jul 2023, 14:07
can you name some of these "other latency tools" that i can purchase?
Best Tool is the OSRTT https://www.osrtt.com/ ,which is actually build by a known Tech Youtuber named TechteamGB, price: 260 Dollar (there will be a cheaper version soon, named OSLTT). Second is the SysLat https://syslat.com/ ,which costs around 130 Dollar (idk if this one still getting sold) which uses RTSS to measure lag.

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 18:45
by delve
nice, thank you.

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 21:06
by 0ka
CrazyCookie wrote:
13 Jul 2023, 12:12
Did you test using Muzzle Flash vs using the RTSS Latency Marker for measurments?
the brightness and color of the muzzle flash is different from the white flash from rtss latency marker, the light sensor may respond to them at different speeds. also game engine and rtss can read input differently. rtss is usually faster than the game engine.

Re: DIY Arduino Latency Tool

Posted: 13 Jul 2023, 21:25
by 0ka
i tested some things with gpu test triangle (cpu bound rendering):
usb 2.0 vs usb 3.0 controller: no difference
windowed mode adds ~25ms of latency
switching MSI mode on USB, GPU, changing driver affinity: no difference
VGA out vs DVI out vs HDMI-VGA adapter out: no difference

btw my arduino sends input at 62.5hz report rate (checked with keyboard inspector) which is not very good, the difference in measurements is large, i have to take 100 result values ​​and average them to get accurate results. also i can't use your code because my light sensor is analog.

Re: DIY Arduino Latency Tool

Posted: 15 Jul 2023, 16:49
by Wire77
Added a LCD Screen :)

Re: DIY Arduino Latency Tool

Posted: 16 Jul 2023, 10:07
by Wire77
Love this DIY Arduino Tool, I added a lcd screen so I don't have to use serial monitor :)

Re: DIY Arduino Latency Tool

Posted: 16 Jul 2023, 22:11
by Chief Blur Buster
Remember to measure multiple sync technologies (VSYNC ON vs VSYNC OFF) and strobe tech (ULMB ON vs ULMB OFF) and measure top/center/bottom. Run at least 100 or 1000 passes for VSYNC OFF at varying/random frame rates (or just brute it far beyond Hz, e.g. 1000fps).

So that's about 12 lag averages per sync setting, times per strobe setting, times screen position of photodiode.

Sometimes you will get TOP<CENTER<BOTTOM and sometimes you will get TOP=CENTER=BOTTOM, and sometimes you will get TOP>CENTER>BOTTOM.

Big rabbit hole, you've been warned!

Re: DIY Arduino Latency Tool

Posted: 25 Mar 2024, 16:27
by FPSMaster
Hey, I just randomly stumbled over this post. I build the same tool myself. There are only 3 concerns with your setup.

1. You're using a photo resistor. There is a second variant of this LM393 light sensor, which has analog output and a photo transistor, instead of a photo resistor. Using a light transistor should give slightly more accurate results.

2. You're not fully shielding the sensor from ambient light. You could use tin foil to shield the sensor.

3. Your code doesn't have a dynamic light calibration. That means you always have to re-adjust the potentiometer, depending on the ambient light, monitor brightness etc.

I actually used your code and modified it to include a calibration method, so ambient light won't disturb the tests. Also, I switched from digital signals to analog signals, which made this even possible.

Here is the optimized code (only works with the Analog LM393 Light Transistor):

// Mouse - Version: Latest
#include <Mouse.h>

// Light sensor pin
const byte lightSensorPin = A0; // Assuming light sensor is connected to analog pin A0

// Pushbutton pin
const byte buttonPin = 2;

// Variables for reading the pushbutton state
bool buttonState = 0;

// Variables for reading the light sensor state
int newLightSensorValue = 0;
int oldLightSensorValue = 0;

// Light sensor threshold variables
float lightChangeThreshold = 0.10; // 10% change
int lowerThreshold = 0;
int upperThreshold = 0;

void setup() {
// Initialize serial communication at 9600 bits per second
Serial.begin(9600);

// Initialize mouse
Mouse.begin();

// Initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT_PULLUP);

// Initialize light sensor pin as an input
pinMode(lightSensorPin, INPUT);

// Initialize the LED pin as an output
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
// Read the state of the pushbutton value
int buttonState = digitalRead(buttonPin);

// Check if the button is pressed. If it is, the buttonState is LOW
if (buttonState == LOW) {
// Turn LED on
digitalWrite(LED_BUILTIN, HIGH);

// Store the previous state of the light sensor
oldLightSensorValue = newLightSensorValue;

// Get the new state of the light sensor
newLightSensorValue = analogRead(lightSensorPin);

// Calculate the dynamic threshold values
lowerThreshold = int(oldLightSensorValue * (1.0 - lightChangeThreshold));
upperThreshold = int(oldLightSensorValue * (1.0 + lightChangeThreshold));

// Check if the light sensor reading is within the dynamic threshold range
if (newLightSensorValue > lowerThreshold && newLightSensorValue < upperThreshold) {
// If within the threshold, initiate the latency measurement
Mouse.press();
unsigned long startTime = micros();
delayMicroseconds(1);

// Wait until the sensor's state is changed
while (newLightSensorValue > lowerThreshold && newLightSensorValue < upperThreshold && buttonState == LOW) {
newLightSensorValue = analogRead(lightSensorPin);
buttonState = digitalRead(buttonPin);
delay(0);
}

unsigned long endTime = micros();
Mouse.release();

// Calculate and print the response time
float responseTime = (endTime - startTime) / 1000.0;
Serial.println(responseTime);

// Add a random delay
delay(random(400, 600));
}
} else {
// Turn LED off
digitalWrite(LED_BUILTIN, LOW);
}
}