Pi as a timer device

Hello all. I came across a potential niche application, where I would use the Pi as a timer device in a race situation. Specifically, the timer wuld be started from an external device. Then, people would use a button to mark lap completion for up to 10 lanes, and eventually mark the race completion time with the same button. Based on the documentation found this weekend, I should be able to to that with a momentary NO switch and a couple of resistors.

That said, I am unsure how to proceed. I was unable to find reasonably good answers to these two questions
1- Is it possible to manage up to 11 input channels with just the GPIO? (or do I need to resort to an ad-on card?)
2- Is is possible to run a loop to test the channels fast enough to get a precision beter than 0.01 second?

To be clear on the application, I want to create a semi-automatic timing device for short track speedskating. International, national and Qubec lite competition circuits (to name those that I know, there are certainly others) work with photo-finish equipment and in the case of international races, RFID devices. I am not aiming to compete with that! Regional circuits, on the other hand, most often resort to manual timing because of the cost of high end equipment. In addition to the loss of precision, the added paperwork often creates a bottleneck at the race secretary. I want to create an affordable semi automatic timer device suitable for regional and perhaps lower provincial levels. I can see that the Pi-based device would have advantages over some of the existing semi-automatic devices that I know, when coupled with the software that I envision.

Any insight in the type of device (timekeeping) would be welcome!

I count 26 I/O on a Pi so 11 O/I should be ok, even if making a small card to multiplex the inputs is not that complicated.
the problem if you multiplex is that if timing is in the loop, it can be difficult to demultiplex in a short period of time

Thank you Jean-Yves.

Your answer suggests that there is a better approach than read the input channels in a loop. Can you expand on that please?

nothing - your second question is more important than the first
and I know from other people ( I did not experiment myself) that doing a time measurement on a non-real-time os computer can be very difficult, especially if you have 10ms of max blind time.
so I will first let others answer to the second question, if it is ok, then the 1st question is not difficult.

Thank you Jean-Yves.

You are quite right that computers are bad timekeeping devices as a general rule. Since the device will be dedicated to this sole usage, and since I will simply record the time of specific events which I am going to process after-the-fact, I am hopeful that I can indeed reach 0.01 second (or better) accuracy.

I went ahead and ordered a Pi3 development kit from Canakit. I will a) get familiar with the environment and b) develop a proof of concept app and possibly a test bench to push very controlled event timings. Then test the POC against some real world situations. I suppose that the worst possible outcome is I wasted a hundred dollars or so…

even if it does not work, you will learn a lot programming a Pi, and a Pi is still usable elsewhere !

[quote=288688:@Louis Desjardins]That said, I am unsure how to proceed. I was unable to find reasonably good answers to these two questions
1- Is it possible to manage up to 11 input channels with just the GPIO? (or do I need to resort to an ad-on card?)
2- Is is possible to run a loop to test the channels fast enough to get a precision beter than 0.01 second?[/quote]

Hello Louis,

Sorry for being late to answer your question and Jean-Yves has done well. Here are some additional answers to your questions:

  1. Using the MCP23017 port expander, there can be up to a theoretical amount of 128 channels which can be connected to the GPIO. This is achieved with 8 of these chips to the Pi with 16 channels for each chip, which is all performed with Xojo (Example 23-2 in the Raspberry Pi book)
  2. Using interrupts, the Raspberry Pi and Xojo can easily detect 600 microseconds (0.0006 seconds). I am sure that the detection can be much less than this and this is by reading the digital signals of an IR remote control (Example 22-2 in the Raspberry Pi book).

I haven’t tried to use interrupts with the MCP23017, and there are two interrupt banks on this MCP23017 chip which makes it seem possible. :slight_smile:

There are some caveats with interrupts as they can be challenging at times.

The price of one MCP23017 chip is really reasonable MCP23017 at $2.95 on Adafruit (not including shipping and handling).