FPGA based Reaction Timer
In my first semester of Uni, we had a course called ‘Discovering Engineering‘, which was half an intro to Systems Engineering, and half giving us an insight to the opportunities available in the engineering field. As part of that course, there were numerous guest lectures where graduates talked us through their career path and the work they have done since finishing their Engineering degree. In three of those lectures, these things called Field Programmable Gate Arrays (FPGA’s) were brought up, and all of the speakers spoke about how powerful they were and that there were a huge variety of things that could be done on them. Being interested in electronics, I went home and watched a few videos on FPGA’s, however lots of it went over my head and I promptly forgot about it for over a year.
Then came the end of second year when we were all discussing the courses that we would be taking in the third semester of third year. ENGN3213 – Digital Systems and Microprocessors – came up, not only as it was compulsory, but I had been playing with Arduino’s for a while and wanted to learn the magic which I knew was under the abstractions of the Arduino ecosystem. This is also where FPGA’s come back into it, as half of the course was focused on digital logic, and in particular the implementation of logic through the use of Field Programmable Gate Arrays. I also noticed a familiar name on the course outline – Lyle Roberts – as he was one of the graduates who spoke to us in first year, where he mentioned the use of FPGA’s in his PhD thesis on ‘high-power optical phased arrays for space debris tracking and manoeuvring’ or as his talk put it, ‘Space Lasers’.
Lyle’s half of the course was easily the highlight of the semester, and has made me aware to a whole subset of engineering that I wasn’t privy to three months ago. Due to the short time period that was put aside for the course, there are numerous concepts and uses of FPGA’s that were brought up but never extended upon, and I intend on exploring as many of them as I can over the winter break and going forward into the future.
But enough with the backstory on how I came to learn about FPGA’s, let’s get into the details.
Firstly, the reaction timer was an assessment piece for ENGN3213 and was done with one of my mates Alex, and for the first time in my degree I can honestly say that we both equally contributed to the assignment. The task was to make a reaction timer which would measure your reaction time and display it on the inbuilt seven segment displays on the Basys3 development board were were using. There were other parts to it such as having the delay between starting the timer and the LED’s turning on randomly being between one and five seconds, and displaying FAIL on the seven segments if you pressed the button too early or left it way too late. We also had the opportunity to gain up to 2% extra on our overall mark if we went above and beyond the requirements that were laid out, and because the assignment was due at the end of the two week non teaching break, I decided to go all in and earn that 2% by adding an external RGB button, an electric shock pen that was triggered through the FPGA, drawing up and 3D printed enclosures for both, and designing a PCB which would join the Pmod connector on the Basys3 to the peripherals without any loose wires.
The below video shows the workings of the reaction timer, and then covers some of the interesting implementation details regarding the RGB LED control, the work required to modify the shock pen to allow it to be controlled by the FPGA, and the low latency debouncer that was written to ensure that the reaction time would not be influenced by the time taken to debounce the buttons.
As mentioned in the video, due to this being an assignment, I unfortunately won’t be releasing the source code as I don’t want to risk getting the book thrown at me for allowing plagiarism. In saying this, if there is part of the code that you would like to use for something other than an ENGN3213 assignment, send me an email and I’ll get back to you.
After completing this assignment, it has really sparked my interest in FPGA’s and the applications for them. Over the winter break (which starts in 16 days as of writing this!) I intend on getting the reaction time to display over the inbuilt VGA connector, and might even try and get some images to display at various times during the runtime of the reaction timer. I also have a Zybo Z7 development board on the way, which utilises a Xilinx Zynq SoC as the brains, and leaning how that works will be another interesting learning experience.