I'm trying to start a project as described:

When someone presses a button I need to start a stopwatch. Then, when someone presses another button (hardware button), I detect the elapsed time from the start with a millisecond's precision.

Is this possible using Windows 10 IOT and C#?


As mentioned in a previous answer, Windows IoT is not real time operating system. But what does that REALLY mean?

You only require a RISC OS like Arduino or PIC if:

  • You need to repeat specific actions in extremely accurate intervals. For example software oscillator, reading sensor values in exact (atomic) intercals or software bit banging (UART/SPI)
  • You need to measure interrupts from other devices in extremely precise times. Like a laser finish line with accuracy within micro seconds (<1ms)

    An event driven operating system like Raspbian or Windows IoT is perfectly suited for your application because:

  • The Raspberry Pi hardware handles inputs by using hardware interrupts and raising an event in the OS.

So what does that mean? Unless you need exactly precise (micro seconds!?), or atomic timing you can use any kind of Event Driven OS, like Windows IoT or Raspbian.

It means that the Pi actually measures the button click within several CPU cycles (thats faaaaast) and the OS will process it as soon as it can.

So unless your CPU/GPU is 100% overloaded with video encoding or something then you will not experience any thing more than 20~100ms added time after clicking a button. (Where 100ms is pretty excessive over estimation on even a 50% CPU usage) It doesn't take much to process an event in these OS's - It just is not micro second precise.

The same phenomena applies to all Personal Computers. I am sure you have played RPG game. The difference between you making a head shot or your opponent, is who can compensate better for the delay between human <> OS <> network lag.

  • Thanks for the complete answer, in fact i need cents of seconds precision, (10.68 ten seconds and 68 cents) but later i'll try to achieve the milisecond precision, the button was an example, but in real case an ahtlete will touch a pad and i need the exactly time he touched, the RPi will be exclusive for this, if possible ill make this the priority Code, thread everything and try to remove anything not needed. So in the maximum my precision will be 1ms, you think 1ms its possible without arduino/pic? Will be more secure with arduino/pic? – Eduardo Estevão Apr 18 '16 at 9:00
  • Yea I think if all the Pi is doing is waiting for that button you will get a great response time. But you could do a test. Wire one button the Arduino and Pi. Write software to show you elapsed on both. When you click one button you will see the difference. In ms. Do it like a hundred times and record each difference. You then get a mean avg. you decide if it's good enough or not. The thing is one one button is pressed after the other. The order will be the same. – Piotr Kula Apr 18 '16 at 9:03
  • 1
    Thanks ill do, ill split the cable so i get the same signal on both and which one handles better. – Eduardo Estevão Apr 18 '16 at 9:06

This project is going to require additional hardware. Windows 10 IOT is not a real time operating system; that makes millisecond precision rather tenuous at best. Your best bet will probably be to use something like an Arduino, and have it communicate with the RPi as necessary.

  • Thanks for the editing, this additional hardware, this hardware that will detect the touch? and send the time to the RPi? its possible also start that high precision stopwatch on the arduino? – Eduardo Estevão Apr 17 '16 at 23:47
  • @EduardoEstevão it should be able to, yes. – Jacobm001 Apr 18 '16 at 5:04
  • @ppumkin the original question asked for precision of "a millisecond". That's how I answered... – Jacobm001 Apr 18 '16 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.