DIY Arduino Latency Tool

Everything about latency. Tips, testing methods, mouse lag, display lag, game engine lag, network lag, whole input lag chain, VSYNC OFF vs VSYNC ON, and more! Input Lag Articles on Blur Busters.
CrazyCookie
Posts: 8
Joined: 04 Jun 2023, 05:30

Re: DIY Arduino Latency Tool

Post by CrazyCookie » 13 Jul 2023, 12:53

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!

delve
Posts: 146
Joined: 15 Aug 2020, 05:24

Re: DIY Arduino Latency Tool

Post by delve » 13 Jul 2023, 14:07

can you name some of these "other latency tools" that i can purchase?

CrazyCookie
Posts: 8
Joined: 04 Jun 2023, 05:30

Re: DIY Arduino Latency Tool

Post by CrazyCookie » 13 Jul 2023, 14:15

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.

delve
Posts: 146
Joined: 15 Aug 2020, 05:24

Re: DIY Arduino Latency Tool

Post by delve » 13 Jul 2023, 18:45

nice, thank you.

0ka
Posts: 19
Joined: 25 Jun 2023, 02:17

Re: DIY Arduino Latency Tool

Post by 0ka » 13 Jul 2023, 21:06

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.

0ka
Posts: 19
Joined: 25 Jun 2023, 02:17

Re: DIY Arduino Latency Tool

Post by 0ka » 13 Jul 2023, 21:25

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.

Wire77
Posts: 2
Joined: 15 Jul 2023, 16:45

Re: DIY Arduino Latency Tool

Post by Wire77 » 15 Jul 2023, 16:49

Added a LCD Screen :)
Attachments
IMG_0254.jpg
IMG_0254.jpg (3.22 MiB) Viewed 2030 times
IMG_0252.jpg
IMG_0252.jpg (3.21 MiB) Viewed 2030 times

Wire77
Posts: 2
Joined: 15 Jul 2023, 16:45

Re: DIY Arduino Latency Tool

Post by Wire77 » 16 Jul 2023, 10:07

Love this DIY Arduino Tool, I added a lcd screen so I don't have to use serial monitor :)

User avatar
Chief Blur Buster
Site Admin
Posts: 11653
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Re: DIY Arduino Latency Tool

Post by Chief Blur Buster » 16 Jul 2023, 22:11

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!
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

FPSMaster
Posts: 189
Joined: 04 Jun 2021, 20:39

Re: DIY Arduino Latency Tool

Post by FPSMaster » 25 Mar 2024, 16:27

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);
}
}

Post Reply