I want to measure the time between two signals that are not in phase and i am using arduino Uno. I have converted the 2 sinusoidal signals into square waves and i am feeding them on INT0 and INT1 respectively. To measure the lag between the two signals i want to measure the time between the rising edges or falling edges of the signals using interrupts. On receiving the first rising edge i want to start a timer, say timer 3, upon receiving the second rising edge i want to stop the timer. my problem is i cant find a library that will allow me to start and stop timer the 3 and use the value it has in store.how can i do it?
0
votes
1 Answers
0
votes
Assuming you're talking about a whole number of microseconds between edges, you could create a global variable to store the time when the first interrupt is triggered INT0LastTime=micros(), and get the second interrupt to compare the 'time now' to the time of the first interrupt.Lag=micros()- INT0LastTime;