user43708: How do I find out the elapsed time from the serial Plotter graph? I am plotting sensor values from the Arduino Nano and would like to know the time scale on the x-axis in order to calculate settling time of oscillations.
I have tried the suggestions here but they do not seem to work in my case.
For example, in the graph below I would like to find out the time it took for the sensors to record their first movement at around point 190.

I am doing the following to print two values:
   //printData1();
   Serial.print(roll_err);
   Serial.print(" ");
   Serial.println(pitch_err);
   Serial.print(" ");

Baud Rate: 9600
Loop Time: 40ms
If my loop time is 40ms then I was thinking that the total time would be 180*40ms. Is this reasoning correct? 
Is there a better way to read the time elapsed in the serial plotter?
EDIT: Trying to get a 10ms 'grid'
As per the suggestion in the answer below I have tried running something similar to the following but the loop does not run at a constant time.

I tried to add Serial.print(((millis()/10)%2)*50); but as can be seen, the loop time is not constant.


user313: It depends on how precise you want your time-base to be. The plotter's x-axis is in sample-count, not time, so you have to emit samples at a fixed rate for it to have time-significance.
Your
loop(){
   yadda();
   zadda();
}

may or may not run at a constant rate, depending on what takes place in each iteration of the loop, as well as on your definition of "constant" (I don't believe I just said that...) 
Even if none of your code is conditional, binary to ASCII conversion, clock and Serial interrupts, and other low-level code we don't see, may run slightly differently from iteration to iteration; e.g. the number of interrupts during any given iteration may well vary.
If you need to hold a tighter timebase, stalling at the bottom of the loop until millis() reaches (the previous millis() + an interval constant) will at least get you to within a millisecond of a fixed loop-rate. You could, of course, do the same thing with micros(), as long as you know for a fact that the loop can never take longer to execute than 1/frequency you need it to run at, and even then, it should take a fair slop-factor (that's a technical term! :) less than that, "just in case".
Update:
Though I wrote "stalling" at the end of the loop, a better technique is to call every job (in your case, 1 of them - for now ? ) as frequently as possible and let each job decide whether it needs to execute. So in your case:
loop {
  maybeSampleAndPlot();
  // maybeDoSomeOtherThing();  // not implemented yet...
}

maybeSampleAndPlot(){
  time = millis();
  if time - previousSampleTime >= MSEC_040
    save (time + MSEC_040) as nextSampleTime;
    sample the data;
    plot the data;
  endif
}


43708: <p>How do I find out the elapsed time from the serial Plotter graph? I am plotting sensor values from the Arduino Nano and would like to know the time scale on the x-axis in order to calculate settling time of oscillations.
I have tried the suggestions <a href="https://arduino.stackexchange.com/questions/34854/x-and-y-axis-on-arduino-serial-plotter">here</a> but they do not seem to work in my case.</p>

<p>For example, in the graph below I would like to find out the time it took for the sensors to record their first movement at around point 190.</p>

<p><a href="https://i.stack.imgur.com/hEg7F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hEg7F.jpg" alt="enter image description here"></a></p>

<p>I am doing the following to print two values:</p>

<pre><code>   //printData1();
   Serial.print(roll_err);
   Serial.print(" ");
   Serial.println(pitch_err);
   Serial.print(" ");
</code></pre>

<p>Baud Rate: 9600
Loop Time: 40ms</p>

<p>If my loop time is 40ms then I was thinking that the total time would be 180*40ms. Is this reasoning correct? </p>

<p>Is there a better way to read the time elapsed in the serial plotter?</p>

<p><strong>EDIT: Trying to get a 10ms 'grid'</strong></p>

<p>As per the suggestion in the answer below I have tried running something similar to the following but the loop does not run at a constant time.</p>

<p><a href="https://i.stack.imgur.com/7pj4E.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7pj4E.jpg" alt="enter image description here"></a></p>

<p>I tried to add <code>Serial.print(((millis()/10)%2)*50);</code> but as can be seen, the loop time is not constant.
<a href="https://i.stack.imgur.com/Ey2Nc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ey2Nc.jpg" alt="enter image description here"></a></p>
 313: <p>It depends on how precise you want your time-base to be. The plotter's x-axis is in sample-count, not time, so you have to emit samples at a fixed rate for it to have time-significance.</p>

<p>Your</p>

<pre><code>loop(){
   yadda();
   zadda();
}
</code></pre>

<p>may or may not run at a constant rate, depending on what takes place in each iteration of the loop, as well as on your definition of "constant" (I don't believe I just said that...) </p>

<p>Even if none of your code is conditional, binary to ASCII conversion, clock and Serial interrupts, and other low-level code we don't see, may run slightly differently from iteration to iteration; e.g. the number of interrupts during any given iteration may well vary.</p>

<p>If you need to hold a tighter timebase, stalling at the bottom of the loop until millis() reaches (the previous millis() + an interval constant) will at least get you to within a millisecond of a fixed loop-rate. You could, of course, do the same thing with micros(), as long as you know for a fact that the loop can never take longer to execute than 1/frequency you need it to run at, and even then, it should take a fair slop-factor (that's a technical term! :) less than that, "just in case".</p>

<p>Update:</p>

<p>Though I wrote "stalling" at the end of the loop, a better technique is to call every job (in your case, 1 of them - for now ? ) as frequently as possible and let each job decide whether it needs to execute. So in your case:</p>

<pre><code>loop {
  maybeSampleAndPlot();
  // maybeDoSomeOtherThing();  // not implemented yet...
}

maybeSampleAndPlot(){
  time = millis();
  if time - previousSampleTime &gt;= MSEC_040
    save (time + MSEC_040) as nextSampleTime;
    sample the data;
    plot the data;
  endif
}
</code></pre>
