Lag Test Your Controller – MiSTer FPGA Input Latency Tester

This is the MiSTer FPGA input latency tester, basically its a lag test for your controller. It’s a homebrew device you can build yourself from an Arduino Pro Micro and a few cables. The test results are extremely accurate, down to fractions of a millisecond. If you have ever used the MiSTer Input Latency controller lag time database, those results were produced by this device.

I made a video about this project and below you can find the same instructions in written form.

The downside to this project is you will need to solder onto each controller you want to test. The Arduino needs a way to fire the button presses and we do that by connecting two wires onto the controllers PCB. If you can overcome this, by finding a solder pad, exposed pin, or as I did, screw a small hole through the PCB.

The project was a combination of work. User Jorge from the classic gaming discord wrote the original Arduino code. It was then updated by Lemonici and Porkchop Express from MisterAddons.

You can find the projects GitHub page here and you will need to grab the files there and open the Arduino code file in the Arduino IDE. Here is a list of parts for the project. I live in Estonia and its hard to source parts from Amazon so I just order from AliExpress and wait it out.

The Arduino is the brains of the project

A simple page of Arduino code drives the project.

  • The Arduino fires off a button press down one pin
  • This prompts the controller to register a press.
  • A special NES core registers the button press and sends another signal out the GIO port on the side of the IO board.
  • Cut up an old USB 2.0 cable and wire the other end into the arduino. Plug it into the GIO port and this is how the return signal comes back to the Arudino
  • The code then calculates the roundtrip time
  • Repeat this several thousand times.

BUILDING A UNIT

First you need to wire the Arduino into the controller to fire button presses. You do this with two wires connected to pin 5 and a ground pin of the Arduino. You need to find the buttons PCB traces and solder the wire onto it. Pin 5 gets connected to a button’s active trace and connect a ground on the Arduino to a ground trace on the PCB. I also got these green terminal rails for the Arduino. They are easier to use than soldering and resoldering each time

If you want to connect to Arcade sticks, find these small metal lugs which are the same size as the lugs on the button of an arcade button.

Next up you need to make the the return signal cable. Get any old USB 2.0 cable and cut the small end off it. The USB-A will go into the USB-looking port on the side of the IO board. Solder the green wire into Pin 2 of the Arduino and the black wire into another ground pin.

You can also use a USB breakout board, connect ground to ground and D+ to Pin 2

PROGRAM THE ARDUINO

Download the Github package and load the file inputlatency/arduino/MiSTer_USB_Latency_Test_Lemonici in the Arduino IDE. Connect your Arduino to your PC via its onboard USB. Select your board type and com port. Then compile and then upload. Once the code is uploaded, unplug and plug the Arudino back into your PC. Now the lag test is ready to go, but it wont start until you make a serial connection on the com port.

Install the custom NES core to your MiSTer from the Github page. Take Create NES_Lag_Tester.rbf and place it in the _Console directory on your MiSTer’s SD card.

Enter the scripts menu and run “fast_USB_polling_on”. Enter the Lag Tester Core and don’t forget the button which will be fired needs to be mapped the NES core’s menu. After you are done, close the OSD.

Run the tests and get results

Open Putty and choose serial connection and type in the COM port you checked in the Arduino IDE. Make sure the port speed is 115200. The results come out in a comma separated format from the terminal. If you set Putty to record the log file, then you have CSV file of the results. Load that CSV onto Excel or your favorite spreadsheet and do all the maths and statistics you want on it.

Looking at the results

In the image below you can see the results I was most interested in. The formula I used to get that number is on the right. 5.3ms is very low, that’s about a third of frame (16ms) and I would say very acceptable for this cheap controller. The Standard Deviation is also quite small. That means we didnt get many wild, large and small results, that results were quite consistent.

Leave a Comment