Check timing of various input pin

Hi all,

I intend to measure the response time of relay contacts. The equipment under test (EUT) is a 24V - 3 poles relay. I am using a 4 channels optocoupler to detect 1) when voltage is present at the coil 2) the making of the contacts. I am using an Arduino Nano with LCD (20x4) to display the results. The wiring is simply that input pin 2 will be detecting the output of the optocoupler that is link to coil voltage while pin 3 to 5 are link to the relays contact through the optocoupler respectively. Currently, my approach is that pin 2 will acquires the millis() and store in time0 while the relay contacts will do the same and store that in time1, time2 and time3. I am using the simple "if" statement to check the condition of these 4 inputs.
My question are 1) the EUT usually has a contact response time around 20ms and the time difference between them is probably 1ms. Can the Nano accurately do such computation? 2) Will the contact bouncing affect the acquisition time even i am using an optocoupler?

For your case, you probably want to use microseconds instead of milliseconds.
As for contact bounce, you can have it any way you want it. First contact or first contact, plus some time period. What do you want?
You don't want an if before you do the subtraction to determine the actual time between activation and time for contact. The difference is the reaction time for the relay.
Paul

Paul, thanks for your reply.
I will try subsequently to use micros() instead. As the response time between contact can be 1ms or lesser or greater, of course, the concern is the minimum differences. I am not sure by the time the first contact is registering its time and the next contact "if" statement is true will that cause a delay in time acquisition. Contact bouncing can be long for this application i think, so I built in a condition to only register the timing for once only. But I am not certain that will resolve the issue. As you can guess, there are 4 "if" statement altogether, I was wondering if that will affect the time acquisition to accurately reflect the actual relay response time. I was thinking to use 1 Nano for each contact to be precise but it sound so wasteful.

Once you have the time in microseconds for the time between activation and each of the contact closures, you can easily determine which contact is faster/slower, or identical. Why do you care about contact bounce? If that is a problem for the equipment, then you are not using the correct type of relay.
Paul

My concern is when the contact is bouncing which it will, at which point the input will register the change and trigger the time acquisition. Will it be the first rising/falling edge or the subsequent one or later. I will be happy to register it on the first rising/falling edge but are not sure will that be the case. I will try to set it up again and change it to micros the see if the difference is obvious.

Certainly depends on how you write the program.
Paul

Paul, I think it is quite alright now. I can see the difference in the response time now by changing it to micros(). Anyway will revert back to millis() when everything is working fine. Next step is to verify the accuracy with another professional equipment, probably using a scope. Cheers.