How to build your own LagBox

This guide will teach you how to build the hardware for your own LagBox, install all necessary software and conduct your own measurements on input devices of your choice.

More information on the project can be found here.

If you already have conducted measurements, you can share them with us here.


Hardware build guide


1
 What you will need
What you need:
  • Raspberry Pi computer (e.g. Raspberry Pi Model 3B)
  • optocoupler, model no. A817 (Link to datasheet)
  • 150 ohm resistor
  • perfboard
  • male pin headers
  • jumper wires
  • crocodile clips
  • An input device you want to use for your measurements (e.g. a mouse)
  • tools to open your input device (screwdriver, etc.)


2
Build a small circuit with the Optocoupler:
  • solder sockets for the Optocoupler IC to the perfboard.
  • connect one pin of the LED side of the Optocoupler to a protective resistor (150 Ohm).
  • add pin headers to both the LED side and the transistor side of the Optocoupler so both can be connected using jumper wires.

Make sure the Optocoupler is placed in the correct way in the socket (see datasheet).


3
 What you will need  What you will need
Connect the circuit to the Raspberry Pi as shown in the diagram. Our code uses GPIO pin 22 of the Raspberry Pi. You may use any other pin, but this would require a change of the corresponding constant in the source code.


4
 What you will need
Open the device you want to test.
 What you will need
Locate the contact points of the button you want to use.


5
 What you will need
Attach probes to the contacts of the button or permanently solder wires to them.


6
Optional: Use a multimeter set to Continuity Test Mode to check if the circuit over the attached wires will be closed if the button is pressed.


7
 What you will need  LagBox circuit
Final setup:
  1. connect the Raspberry Pi to a monitor
  2. attach a keyboard and a mouse to the Raspberry Pi (you will need a dedicated mouse for in order to control the software. Therefore you will need a second mouse if you want to measure the input latency of a mouse as shown in the image)
  3. connect the device you want to use for your measurements to the optocoupler as shown in the schematic
  4. start the LagBox software on your Raspberry Pi and you are ready to go! A guide on how to install the software can be found in the section below




How to install the Software


1. Install the latest version of Raspbian on your Raspberry Pi
2. Open a terminal
3. Install all dependencies available in Raspbian (PyQt5, Matplotlib, Seaborn):

sudo apt install python3-pyqt5 python3-matplotlib python3-seaborn

4. Install the evdev module for Python via pip (it's not available as a Raspbian package):

pip3 install evdev

5. Clone the code from the LagBox GitHub Repository to a folder of your choice:

git clone https://github.com/PDA-UR/LagBox.git

6. Navigate to the src/ folder inside the LagBox folder you downloaded (e.g. cd LagBox/src/). Run the following command:

make




How to use the software


  1. Open a terminal
  2. Navigate to the folder where you installed the software, e.g. …/LagBox/
  3. Navigate to the gui/ folder (e.g. cd LagBox/gui/)
  4. Start the software with the following command:


python3 latency_gui.py


1
Figure 1: LagBox circuit
  • Select the device you want to use for measurements from the dropdown. All devices connected via USB will be listed here.
  • The correct device type will be preselected, but can be changed manually.
  • Name the device to make the output log clearly attributable
  • (Optional) Provide the European Article Number (EAN)/ Universal Product Code of the device. This makes sure that the device can be easy identified by other people


2
Figure 1: LagBox circuit
Press the button on the device once. The software should automatically detect the correct ID.


3
Figure 1: LagBox circuit
Make sure the probes/wires are connected to the corresponding button. Press the button one more time and the measurement will start automatically.


4
Figure 1: LagBox circuit
After the measurement is finished, the results will be displayed. The output folder where all data including the diagram is saved will be displayed


5
Figure 1: LagBox circuit
You will be asked if you want to share your measurement results with us.


6
Figure 1: LagBox circuit
If you decide to upload your measurements, just fill out the form on this screen. Make sure that your Raspberry Pi is connected to the internet.




Anything unclear? Do you have suggestions how we could improve this guide? Drop us a message (English/German). You can also directly send an e-mail to raphael.wimmer@ur.de.