Serial Plotter: Getting (somewhat) accurate time reading on x-axis?

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 attached image 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:

    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. So every 100 steps is approximately 4 seconds. Is this reasoning correct? This is still not accurate enough since the serial plotter only shows every 100th marking on the x-axis.

Is there a better way to read the time elapsed in the serial plotter?

Is there a better way to read the time elapsed in the serial plotter?

There is no way to read the time elapsed on the serial plotter, because it outputs a new point every time you write one so it is not related to time in any way.

If you know your loop time you must me measuring it somehow, so that implies you have an oscilloscope. Looking at your output on an oscilloscope is the only way to measure when events occur unless you time stamp them.

That just means sending a few bytes which include the time as well as the data.

You could send a third data stream to the serial plotter that creates a time axis with tick marks of your own spacing.

Do that with the built in millis() timer to set up the axis and marks, for example send one value to form the axis, except at 1000 millisecond intervals, send a slightly different value.

It could be a challenge to work out the timing for the axis, along with your other data, so make sure that you understand the Blink Without Delay example.

Alternatively, use the Excel macro on a PC (PLXDAQ) to collect accurate time stamps for the arrival of each data packet, and plot the data using Excel.

What does the x-axis on the serial plotter represent? It is really important for me to get an exact time based on the x-axis of the plotter.

I had always thought that every 100th iteration(?) was marked on the x-axis, but recently changed something in my code which changed the x-axis to multiples of 83. Changing the baud rate does not seem to be the cause.

The smaller the sampling number, the better.

Sometimes it is in multiples of 100 and sometimes of 83 as in the images provided. What is causing this change? How can I alter this?

Many thanks.

Do not double post.

Two solutions to your problem were presented in your other post on this topic.

Tried answering in other post, thanking the people who answered, but since I am a new member, site did not permit.

The question is totally different.

Question 1: How to extract time information from serial plotter.

This Question: Why does the x-axis value change? How to manipulate this value?

"Setting up axis and marks" answers question 1, but does in no way answer this question.

What's so hard to understand with the x axis? A new point occurs whenever you output a value to the serial plotter.

If you want equal time intervals on the graph, write at equal time intervals to the serial plotter.

If you want time information for every point, write your own serial plotter.

I do not want equal time intervals on the graph or time information for every point.

I want to know why the Plotter sometimes samples the data with a grid size of '100' and sometimes less as per the images provided. I would also like to understand how to change this.

There is no grid size. You cannot change something that is not there.

but since I am a new member, site did not permit.

Don’t talk rubbish. There is just a 5 minuet limit for posting frequency for new members to combat spam.

Would referring to these values as the 83rd and 100th data points, be more correct? If so, this is what I have been trying to modify.

Threads merged.

From your other thread…

The question is totally different.

Question 1: How to extract time information from serial plotter.

The plotter doesn’t know anything about time. Assuming the X-axis is time, it could be milliseconds or days… It depends on what you’re plotting on the X-axis, or how fast you’re reading/sending the data.

Do you need to go back and get the time from the old data, or do you want to modify your code to time-stamp or time-control it in the future?

You didn’t show any timing at all so I’d guess your loop is running as fast as it an “print”. If that’s the case, you’ll need to add a time-stamp or slow-down your loop to a known loop-time, with a delay, but without the delay() function which will muck-up the timing even worse.

I would like to time-stamp the data in the future, without adding extra sampling marks using millis() but simply by reducing the X-axis values displayed (100 or 83) down to 10.

Since I know my loop time, I would then proceed by multiplying loop time by 10 to get time information.

Yes, my loop is running as fast as it can print. Unfortunately I cannot slow down my loop further by adding delays since I am running a PID controller. This is quite sensitive to loop execution time.

rizzo:
Yes, my loop is running as fast as it can print. Unfortunately I cannot slow down my loop further by adding delays since I am running a PID controller. This is quite sensitive to loop execution time.

Look at BlinkWithoutDelay, how to implement multiple "loops" of different timing. Start trying to understand the answers, instead of refraining wrong assumptions and bad coding. Most things don't work as you seem to assume :frowning:

Thanks for the answer.

Managed to modify x-axis scaling from showing every 100th data point to every 10th data point.