measurement of time in arduino

Thread Starter

neeladrinath

Joined Apr 5, 2017
37
Hii
The system is like this.
Arduino 1
using the start button the arduino 1 will transmit signal and also a timer will start.

Arduino 2
the arduino 2 will receive the transmitted signal by arduino 1 once the arduino 2 received the signal it will transmit another signal back to the arduino 1.

Arduino 1
the arduino 1 will received that signal then stop the timer. Then the arduino 1 will determine the time.
then using formula we can get the distance.

In this system only my doubt is how to know time. I don't know about arduino timers. So please say that how can I measure this tome.
 

LesJones

Joined Jan 8, 2017
4,511
As Arduinos are usualy programmed in "C" it is difficult to measure times in the order of microseconds as you don't know how long a line of code takes to execute. If you are measuring time in the order of days you will not have a problem as the time taken to run the code will not be significant in your results. You need to give an idea of the time you are trying to measure.

Les.
 

AlbertHall

Joined Jun 4, 2014
12,624
I am sure there are many other methods.
For instance, you have a timer external to the arduino and the arduino sends start and stop signals to the external counter.
 

AlbertHall

Joined Jun 4, 2014
12,624
As Arduinos are usualy programmed in "C" it is difficult to measure times in the order of microseconds as you don't know how long a line of code takes to execute. If you are measuring time in the order of days you will not have a problem as the time taken to run the code will not be significant in your results. You need to give an idea of the time you are trying to measure.

Les.
You can also program an arduino in assembler (though it is definitely more effort) and then you can do timing by knowing how many instruction cycles have elapsed.
 

djsfantasi

Joined Apr 11, 2010
9,237
It might be helpful if you shared why you are looking for another method. It could clarify the real world environment. Or it might provide some information on your skill set.

Just wondering...
 

R!f@@

Joined Apr 2, 2009
10,004
@djsfantasi is asking why you are not accepting the suggested method and asking for some other way ?
What is it exactly you are trying to do ?
What is your experience in building ckt's or what is your programing skills ?
 

R!f@@

Joined Apr 2, 2009
10,004
It might help if you show us what you did so we can show you where you went wrong.

Another way is to buy a measuring instrument.

And again you did not answer the questions.
If you want help answer the questions that we ask or we might just ignore you.
 

LesJones

Joined Jan 8, 2017
4,511
Hi Albert,
I mostly work with assembler (Mostly 8 bit PICs and Atmel chips.) I find it much easier to understand than programming in "C". If the TS wants another method he could use assembler which would give him direct access to the timer/counter modules.

Les.
 

DickCappels

Joined Aug 21, 2008
10,661
Just to give you a feel for the problem: 2 meters to 400 meters at about 1 foot per nanosecond amounts to about six nanoseconds to 1.2 microseconds time of flight. I suspect that if using on-chip timers the granularity of your time measurement is going to very large. Using an AVR clocked at 20 Mhz the timer's granularity will be about 15 meters. There will also be overhead in the transmitter and receiver circuitry which may be close enough to being constant that they can be subtracted out. I don't know about other processor families that work with Arduino.

An external timer, possibly an anlog circuit can give much finer granularity.
 

MrAl

Joined Jun 17, 2014
13,700
Hi,

Yes the usual method is to use the count usually called "millis()" or "microseconds()" or something like that.

If that doesnt work, then we need more detailed information about the project or at least hear about what did not work about it.
 
Top