Posts

piLagTesterPRO user's Guide/manual for measuring monitor Lag, response time

The piLagTesterPRO is a cheap addon to the Raspberry Pi for measuring monitor input lag and response time. Using it requires minimal Linux knowledge, most of which this page will teach you, such as: you hit enter after typing a command (most commands are just a single word). For instance to start the lag tester you type lt and then hit enter.

This is an owner's guide to using the software; this other page explains how to set up the hardware

In order to get good timing resolution the software needs to be run from the command line, which is how the provided OS image is configured to boot. Once powered up fully you will be automatically logged into root with no password required. The default password is the letter t. Yes, I'm not expecting you to run this on public a network. You won't break anything if you change the password, however, other than my heart.

The lag test is started by typing lt at the prompt. If you want to save the results of your test to disk, try giving a filename (no spaces allowed) like this: lt sonyxbr4  

This is what you should see:




(If you need a reminder of what the graph shows read this). From this screen you have two main options: press escape to quit, or space to start recording and averaging the currently measured lag. Press escape when you have recorded enough measurements (I recommend at least 7).

Sensor placement

Before you start recording position the light sensor over the target rectangle (top, middle, or bottom) and make sure you are getting enough light for a consistent measurement, but not so much that you are getting clipping (the yellow part of the graph should show some variation, not just a flat rectangle). 

The light sensor is somewhat directional so changing the angle between it and the display will give you some control over the light levels. The sensor works over a wide range of intensities, however, so that shouldn't be necessary. I've found TVs don't vary enough that I need to mess with adjusting anything unless I'm trying a new mounting method. Keep in mind the wires can't be bent an infinite number of times, so adjust the angle with the tape. 

If you are testing a TN display keep in mind that the angle to the screen can impact the response time (pointing the sensor up at a significant angle gives the same input lag, but a slower response time). This a real property of TN displays but you don't notice it with the naked eye because we are talking about 10-15ms slower response time. 

If testing a CRT: there are two things to keep in mind. First, CRTs produce an incredible amount of electronic and magnetic noise, and can make the sensor malfunction for some period of time if it physically touches the tube. Best to hold it with your hand at least an inch away from the screen to avoid this problem. Consider sliding the sensor into a plastic hose/black straw/etc. so you can limit its field of view while maintaining your distance from the surface of the screen. Second, because many/most CRTs have significant overscan it's best to measure the center of the middle bar on the screen. You can calculate the lag at the top of the screen from this measurement by subtracting half a refresh cycle (eg at 60hz you would subtract 8.3ms). On most CRTs you should find the estimated lag  at the top of the screen is no more than 1ms, which includes some time for your HDMI to VGA adapter and also a little time for the phosphor to get bright after being struck by the electron beam. However a couple late model CRT HDTVs actually deinterlace 480i content before displaying it, adding significant lag.

Advanced options

By default the target rectangles are wide enough that you can find a single position to measure both 480p/i (4:3) and wide screen modes (720p, etc). The bars blink on and off completely, changing the local light levels, so TVs with dynamic contrast may adjust the backlighting level between frames. This can confuse  response time measurements. The alternative is to use smaller target rectangles which shift back and forth, keeping the local light levels constant. While the lag tester is running type D to toggle this alternative mode on. In this mode place the sensor over the target when it is in the left-most position.

There are a few other options you can adjust from this screen. You can increase and decrease the scale of the graph with the 1 and 2 keys. P takes a screenshot. Q and W adjust the brightness threshold used for detecting input lag (aka 1st response). A and S do the same thing but for measuring the full response. 

Interpreting measurements 

You'll notice that the lag fluctuates. The pi lag tester itself is consistent to 0.2 milliseconds or better, but the signal it measures varies by much more than that, due to the flickering backlight used on most displays. Rather than leaving the backlight on all the time, TV's pulse it on and off, perhaps to reduce motion blur, or as a way to change the brightness level. Either way, you can't see pixels changing when there's no backlight, and backlight flicker never seems to be synchronized with the frame rate (this may be done to reduce perceived flicker, I'm not sure).

Occasionally you will find a TV where the lag doesn't just fluctuate, but drifts by a millisecond or more with each measurement, and wraps around after drifting consistently for 16ms. This is the sign of a TV that has uses a fixed refresh rate of 59.94HZ even when the Pi is outputting 60HZ (or vs versa). On such a TV it's possible that even when you set the refresh rate on the pi to match the TV, the TV still won't sync with the input signal, and will maintain fixed extra lag of  up to 16ms. Each time you turn the TV back on the lag should change in this scenario. This is not a bug with the piLagTester(pro). Other lag testers will show the same thing. I include software to test for this, called vsyncTest. You can also test if the drift is permanent or if the display eventually settles on the lowest value using the command drift. You will also see drifting lag on TVs that advertise refresh rates that are significantly higher than they actually support, such as 75hz on a 60hz display  .

Summarizing results 

After running several tests you might want to see a summary of the results so far. try

cat log.txt

If you start the lag tester with the optional <name> argument (e.g. lt sonya7) it will be listed in the summary, along with the average lag and response time for that session. Furthermore, the raw brightness values for each recording trial are saved in the <name>.datr file, and the calculated input lag and response times for each trial in the <name>.datx file.  These files are stored in the current directory, which is /root when you first turn on the pi. You can type ls to see all the files there, and you can move them to your desktop using SSH (I use winSCP for this). Alternatively, you can save the files to the FAT32 partition of the SD Card, which is readable on windows etc. with no extra drivers. To do this just type "cd /boot" once when you first power on the pi. But be aware, the raw recordings take up a lot of space and the FAT32 partition doesn't have a lot of extra space so I prefer the SSH option.

To get rid of all recordings safely (important as root) don't use rm but instead use del:

del *.dat*
emptyTrash

emptyTrash is required to actually free up space, del just moves the files to a "trash can". 

Measuring input lag for interlaced modes or different resolutions and refresh rates

The easiest option: tvmenu lets you interactively select the resolution and refresh rates from among the set of modes that the monitor has told the Pi it supports. Note there are often other modes that the monitor can display properly but which it doesn't advertise. There are some additional scripts that force modes even if the monitor does not report supporting them. Retro gamers will be particularly interested in input lag for 480i and 480p signals. I've included several mode settings scripts which include these and other popular resolutions:

tv1080p  
tv1080i
tv480i  
tv480p 
tv720p  
tv4k

Here's an example of testing 480i:

tv480i
lt

By default these scripts run at 60hz, but you can switch to NTSC (59.94hz) by adding -t, like this: tv480p -t . The pi is happy to do 240p over HDMI as well, but most TVs don't like 240p over HDMI; you'll probably need to plug the pi into a cheap HDMI->component/composite adapter first.

If you want to test modes outside of that list, that's also possible, although the pi0 and pi4 versions use different methods for selecting them.  With the pi4 it's even possible to create modes from scratch, using either modeline which allow very precise control, or using the "CVT" algorithm which only requires the width, height, and refresh rate. The details to these commands are explained each time you turn on the pi0/pi4.

Testing multiple resolutions / automation

If you are testing more than one display you might be interested in some scripts that automate switching resolutions and generate intuitive file names too. There are several to choose among:

testAll 

will load each of the popular modes and wait for you to press spacebar to start recording. Once you have taken enough samples (7 or more!) press escape and it will advance to the next mode. Halfway though you are expected to move the sensor from the top to the bottom of the screen. You can also do testAllByRes that has you moving the sensor more often.

The syntax is testAll tvNameOrSomething (no spaces!).

If you want truly hands free testing, you can also use the autoTest script, which runs through a range of resolutions with zero keyboard interaction from you. Of course if your sensor is in the wrong place you'll get junk data. The syntax is autoTest tvname locationOrNote <samples>. For instance:

autoTest LG top 15
autoTest LG mid 15

This pair of commands would save 15 samples each, starting the moment you press enter at the command line. 

If you want to edit the list of resolutions tested, type nano /x/autoTest but I'll leave the full details to advanced users who can extrapolate from examples.

Real pros will also want to try out the responseTime and vsyncTest scripts both of which print a short summary of their syntax if you execute them with no arguments. 

Advanced command line options


lt -h lists the options, but here they are in detail:

-a<number> causes the program to start recording automatically. It  skips the first 3 measurements firsts, so that the screen is in a steady state. when <number> is reached it will quit automatically as well.

-x turns off recording to the .datx file. 
-r turns off recording  to the .datr file
-l sets the name of the log file (normally log.txt).
-p <0..255>: brightness of test probe (255=default)
-b <0...255>: brightness before/after test probe (0=default)
 -u ultra-wide bars (good for testing cracked screens)

You can set defaults by editing the lt script in /x, like this: nano /x/lt

Here's an example invocation, which automatically records 5 trials, doesn't save the raw brightness data, writes the trial by trial input lag and response time to xbr_resolution_top.datx, and appends the average input lag and response time to sonysummary.txt

lt -a5 -r -lsonysummary.txt xbr4 top

Publication quality figures

If you want to make figures for web/print you have two options. You can export individual trials into a simple text file that Excel or any other plot package or website can read. Then you can design any kind of plot you want given enough clicking around. Or there's the option of using the custom plot code I've written that auto-generates pretty nice figures but without the ease of modification that Excel would offer. 

For those autogenerated figures you'll need to roll up your sleeves and install some software on your desktop (Windows, Mac, or Linux) called octave. It's a full programing environment, but the sample script I wrote for it does not require any programming experience, you just double click my script and press F5 to run it; it will ask for the location of the  .datr file you transferred from the pi, and then will plot each trial, one after another. Full instructions are given at the top of my script so I won't duplicate them here. The script is downloadable the same place as the SD card image are stored:

https://1drv.ms/f/s!Ahb4rgU6L_z9gxV287CTdwmz8mvh (link not clickable to avoid extra traffic).

Either way you'll need to copy your data off the pi and onto your desktop. Use a SCP client to connect to the pi if it's on a network; by default all the raw .datr files are in the folder called /root. I use winscp for this. Or if it's not on a network you can copy the files from the SD card directly. Unless you have a linux desktop you'll need to move the files to where they can be accessed by windows or the mac first.  One way to do this would be to log in to the pi and type mv *.datr  /boot which will move the files to the easily readable fat32 boot partition on the SD card. Be sure to turn off the pi (halt) before removing the SD card.

Display characterization

To tell how pixel perfect your TV is, try out these programs that provide useful test images: 

dots
lines
bouncing
pixelart






piLagTesterPRO getting started guide

First, you'll need a microSD card (or use the one you ordered from me). It needs to be 4GB or larger for pi0 or at least 16GB for the pi4. 

You can download the OS image using the link I'll email you when you place your order. It's less than 1GB when compressed, though it is significantly larger when decompressed.

I use 7zip file for maximum compression. Uncompress the .7z file and write the image like you would any raspberry pi disk image (I use win32diskimager). No further configuration is needed, just insert the SD card into your Pi.

Next, while the pi is still off, connect the sensor. 

This is what your light sensor will look like when you get it:


The black tape is to block outside light if you choose the recommended sideways mount with a bit of removable tape. Here's what that looks like: (note, provide your own tape, don't unwrap the sensor). 




The sensor should be bent a little towards the screen to increase the signal. Don't bend and re-bend on every single TV you test to avoid fatiguing the wires. I've found a single 45 degree angle is good for all the TV's I've tested. If anything the sensor is too sensitive; you could always reduce sensitivity by adjusting where you place the sensor; if it's only partially on top of the target rectangle it won't pick up as much light. 



Finally, plug the sensor into pins 1-6 on the PI's GPIO header. Reminder: The Pi should be off when you do this. Here's a photo of what it should look like if you are using a Pi 0. 



The #1 mark on the plug should be lined up with Pin 1 on the GPIO header. Pin 1 is the pin closest to the SD card (this is true for all pi from 0 to 4). I've written "SD" + the arrow to remind you where pin 1 is in case you forget! 

Technical note: The eagle eyed of you might notice that there's no wire going to pin 1 in the plug. The lag tester only uses 4 pins, but I use a 2x3 plug to remove any ambiguity about which way to plug it in, since plugging it in backwards or sideways could damage the lag sensor. 

Mitsubishi LT-46144: input lag, deinterlacing and upscaling using the piLagTesterPRO

This 120hz 1080p TV from 2007 is a mixed bag, with variable and relatively high input lag, but fast deinterlacing and decently good upscaling While the marketing says LCD, the weight says plasma (72lbs!) as does the power consumption, of ~300 watts, and the infinite viewing angles.  Given that plasma was a selling point at the time, I doubt it's really an unadvertised plasma, but it's definitely an odd duck of an LCD.

Image quality

Good upscaling is critical for retro gaming. Ideally, all pixels should appear equally sharp and bright (no aliasing), and angled lines should appear smooth, with no jagged, irregular steps. Also important is that the display shows most or all of the pixels it is sent. Often, this is not the case, with some number of pixels cropped from the bottom or top edges. Shockingly, these tests are relevant for modern gaming as well, because even at their native resolution many TVs have aliasing and cropping.

I attempted to adjust the set to minimize cropping and aliasing. You get pixel perfect, non-zoomed images if you set the HDMI input name to PC. That means that 720p only fills 2/3rds of the screen. In this "mode" 480i is not supported. If you set the input to game 480i works, and that's what's reported below. Note that this has game as an input name and game as a color correction mode, but the "input name" seems to be the decider for upscaling etc.

resolution aliasing cropping (side, top)
480p/i some (game) 35,25
720p some (game)  40,30
1080p none (game/pc) 0,0

480i, sharpening =0



The TV defaults to over sharpening in all modes, causing ugly halos. For best 480i, you need to turn sharpening down to zero, which honestly doesn't look too soft, see photo. The diagonal lines are quite jagged, I think this may be a deinterlacing artifact as it flickers a bit like it's using some kind of modified bob deinterlacing. Similarly, notice the checkerboard becomes vertical lines, another hallmark of bob deinterlacing. But I don't think it's only bob as the horizontal lines are flicker free. I suspect the deinterlacing engine is the same that Panasonic uses in their plasma TVs of the 2000s, where regions of high motion get "bob" and everywhere else gets "lace". This is about as good as you can get if you want high speed deinterlacing without constant flicker.

In higher resolution modes turn down sharpening by about half to get the best image quality.

The display has 3 HDMI, and 3 yPbPr input. I only tested HDMI.

Input Lag

I used a piLagTesterPRO to measure input lag. This device sends a frame of video over HDMI and measures how long it takes to display it. This display has a game mode, and perhaps more significantly, an option to label the HDMI input as "game". With these off input lag was higher for sure. For instance 480i was almost half as fast without game settings.  I toggled all the other display quality settings as well, but did not see any further improvements, however the tests reported below with every "enhancement" set to off.

Complicating things significantly, this is yet another display that does not actually sync refresh to the input signal - instead it fills its own internal frame buffer from the video input and then draws that with a fixed additional delay that is randomly determined each time you turn on the set or switch inputs.  To take one example, input lag for 1080p can vary from 43ms to 59ms. What you get seems to be entirely up to chance. It can't even properly synchronize the display of this buffer with the refresh rate, at least for 60hz signals. It rapidly drifts out of sync every 10 seconds or so and has to drop a frame. For 59.94 (aka NTSC) refresh rates it is able to keep up, however, with no drifting lag (but still random changes in lag each time you change video mode or switch inputs, or do a power reset).

I've elected to report the average lag values here, since that seems fairest, but there's no right answer; for more discussion of this issue see the above link. It's worth noting that this kind of changing lag is the hardest for your brain/hands to adapt to. I'd much rather have an extra 16ms of fixed lag added to the display than one like this where sometimes the extra lag is 0, and sometimes it's 16ms.

And there's an additional complication: this TV occasionally gets mad at your input source and declares that it's a DVR (as in setting the name of the input to DVR) and disabling game mode. If you think you know better, too bad. Once it's made this choice the only way to get back to game mode is to physically unplug the console, disable the input port, and then plug the HDMI cord back in, at which point the TV will detect the new source and ask what type of input it is. This happens pretty easily, just in an hour of testing I saw it happen a couple times. Maybe it is something about the PI video signal, but I suspect not since no other TV has behaved this way.

Input Lag Test Results

I report two kinds of values. 1st response measures how long it takes for the TV to start responding (I use a 5% change in display brightness). This overly optimistic value doesn't tell how long it takes to see anything useful, but matches what other reviewers call input lag. full response is a more realistic measure of lag, and requires the display to reach 80% of full brightness. This combines both input lag and response time, and is closer to what you would actually experience in a game.

Interestingly, this TV appears to have roughly the same lag in all modes except possibly 480i. The 1st response averages 51ms at the top of the screen, and the full response adds just 9ms to that. At the bottom of the screen everything is just 8ms slower. You'd expect it to be 16ms slower, but this is a 120hz TV and once it starts drawing it goes twice as fast as a 60hz screen. Unfortunately, you can't feed it a 120hz signal, but at least you get rid of 8ms of lag this way.

Now, what about 480i? Shouldn't I be able to say with confidence if it's the same speed as every other mode? There are several factors that make that conclusion hard to make; first is that lag varies by up to 16ms each time you change video modes, and then there is the issue that the TV randomly decides to boot you out of game mode, as described above. I had this happen to me too many times and gave up on getting enough measurements for 480i in particular. It looked like 480i might be a few ms slower than 480p based on the samples I took, but if so it's not much, at absolute worst it's 8ms slower.  That's a great result, but since the TV is pretty high in lag overall there must have been time in the processing pipeline to do deinterlacing with no extra delay. Note that the Panasonic plasma's also do this, but have a much preferable 34ms of total lag (top and bottom). Again, it seems like this TV has some plasma like features....

Results compared to other displays

To allow quick comparison between many displays I've summarized the results across all the displays I've personally tested with the piLagTester Pro. Min lag is the time to the first response, measured where the screen starts drawing (typically, the top); real lag is the time to the full response, measured where drawing finishes (usually the screen bottom), i.e. input lag + scan out + response time. Numbers in red denote average values that can vary by up to 8ms between power cycles.

This list is sorted by 480i performance, since that's the only place this set is competitive.

DisplayYear made (TV?)Native Resnative min lagnative real lag480i real lag480p real lag720p real lag1080p real lagnative response timenative scan out
Panasonic TH-58PE75U2008720p28.034.034.034.034.034.06.000.00
Panasonic TH-42PX75U2008720p28.034.034.034.034.034.06.000.00
Dell E2211H20141080p3.033.634.734.534.133.815.0015.57
Corprit D157 (hdmi)20211080p3.134.534.934.834.633.916.2515.13
AOC/Envision G19LWK2010900p3.131.239.538.738.437.815.5012.60
sony XBR 43X800D20174k24.544.346.546.044.644.75.0014.83
LG 42LC2D2006720p28.350.654.650.850.46.3015.95
TCL 40S32520211080p6.527.360.629.027.927.76.0014.83
Vizio E261VA2012720p19.359.061.160.459.258.925.0014.67
Samsung LN32B3602010720p37.660.062.161.860.560.18.0014.40
Dell U2410 (game)20101080p4.026.262.228.326.526.56.0016.20
Dell U2410 (sRGB)20101080p20.542.862.445.043.143.16.1316.13
ACER AT326520121080p19.543.862.745.343.843.88.0016.27
RCA L40FHD4120101080p20.346.665.048.047.046.09.6816.63
Sony 40VL130 (game)20081080p22.847.366.349.047.347.39.0815.43
Toshiba 40L2200U20141080p30.056.074.056.056.056.010.0016.00
Mitsubishi LT-4614420081080p51.068.075.068.068.068.09.008.00
Polaroid FLM-373B2007720p28.049.082.049.049.049.07.0014.00
Samsung LN46B61020121080p53.066.082.066.066.066.05.008.00
Vizio VO370M20101080p2.523.683.049.047.024.35.4715.67
Sharp LC-C3234U2009720p33.064.683.666.664.615.0016.60
Philips 42PFL3603D/F720091080p29.050.084.050.050.050.05.0016.00
Sony KDL-46EX40020101080p28.052.087.052.052.052.08.0016.00
Toshiba 46L5200U20131080p55.071.089.076.071.074.08.008.00
Sony 40S20L12007720p48.472.090.172.973.49.6014.00
Samsung LN46C63020121080p54.572.190.790.388.572.310.007.63
Vizio VO22L FHDTV10A2008720p28.061.094.061.061.061.018.0015.00
Samsung HP-T425420111080p69.775.794.176.075.75.001.00
Vizio E261VA2007720p28.062.095.062.062.062.018.0016.00
GPX TDE3245W2016720p28.051.0102.051.051.051.08.0015.00
SANYO DP507492010720p67.075.0103.094.079.075.07.001.00
Emprex HD 32022007720p27.050.5126.051.050.08.5015.00
Vizio E470VL (hdmi)20111080p69.086.0128.095.095.086.09.008.00
LG 47LW6500-UA20121080p66.680.7149.7149.081.780.92.2711.83


This TV is only average for 480i, but it's usable, which means half of the TVs I've tested aren't, when it comes to 480i content.  Combine that with the better than average upscaling, and this is a decent choice for retro gaming, if your tastes tend toward less twitchy games. 

Other models (to avoid?)

I tested the LT-46144, which is the 46" version. There appears to be two versions: Based similarities in their names, I suspect that the LT-52144  would perform similarly, just with bigger pixels. However, I've made no efforts to check if their specs exactly match. Interestingly, all of the following model numbers have the same schematic layout for their motherboard:  LT-40133 / LT-46133 / LT-52133 / LT-40134 / LT-46144 / LT-52144 / LT-46244 / LT-52244. Only the x144 and x244 are 120hz so those are your best bet for identical performance.

Email me

Name

Email *

Message *