Help Trying to use TimePlot to compare data samples

Support forum for MegunoLink
Post Reply
ToolAA
Posts: 5
Joined: Sun Sep 18, 2022 1:14 am

Sun Sep 18, 2022 1:46 am

Hello,

I'm new here, and a fairly novice Arduino programmer. However, using the guides, forums and help resources has gotten me pretty far over the past few days. However, I'm at the limit of my experience while trying to solve a problem. I have built a machine use to test part stress failures of 3D printed samples. I typically print 5 or 10 samples of each beam design, then load test them for their failure points. I've been able to successfully collect real time data using the TimePlot function, however I am trying to find a way to record data so that each collected sample, is drawn over top of the existing data. Ideally, each collected sample would be a different color.

Here is an example of what I'm trying to achieve.
Data Plot Example.jpg
Data Plot Example.jpg (30.97 KiB) Viewed 236 times

is it possible to record data on the chart using the Fixed Time method, however at each sample, the time would revert to Zero and redraw then next sample data over the previous data sets.

Thank you in advance for your assistance. I'm looking forward to learning more.
philr
Posts: 407
Joined: Mon May 26, 2014 10:58 am

Sun Sep 18, 2022 2:00 am

Hi, I think you could do this by using the XY Plot (so send your own x values). And you would set it up so that for each plot you use a separate series name. An example for this on the timeplot can be found here
https://github.com/Megunolink/MLP/blob/ ... newave.ino

Note there is a cosine and a sine wave shown independently. XYPlot works the same. So you would need to generate a separate series name for each run you do and then use the same timebase (i.e seconds). Then they should plot on top of each other.
ToolAA
Posts: 5
Joined: Sun Sep 18, 2022 1:14 am

Sun Sep 18, 2022 2:57 am

philr wrote: Sun Sep 18, 2022 2:00 am Hi, I think you could do this by using the XY Plot (so send your own x values). And you would set it up so that for each plot you use a separate series name. An example for this on the timeplot can be found here
https://github.com/Megunolink/MLP/blob/ ... newave.ino

Note there is a cosine and a sine wave shown independently. XYPlot works the same. So you would need to generate a separate series name for each run you do and then use the same timebase (i.e seconds). Then they should plot on top of each other.
Thank you. I was playing around with XY Plot just now and decided to do a test with the X axis reading the number of steps counted from my stepper pulse routine. It sort of works. At least I understand how I could use Timebase to achieve a similar result.
XY Plot Example.jpg
XY Plot Example.jpg (176.22 KiB) Viewed 229 times
It seems like I'll have to create some sort of "For" statement to count each cycle press and then use that counter to create a series name and possibly alter the individual plotted series colors.

Any idea how I can eliminate that long diagonal line within the plot as it jumps from the high point back to the "Zero" point?
ToolAA
Posts: 5
Joined: Sun Sep 18, 2022 1:14 am

Sun Sep 18, 2022 7:52 pm

Well, I'm making steady progress. I've been able to plot multiple readings onto one chart.
Multi Series Plot.jpg
Multi Series Plot.jpg (141.03 KiB) Viewed 221 times
However, I'm hitting a brick wall with respect to finding a way to create some sort of method to create some sort of incremental series name, and change the plotted line color, during my program loop.

I thought I could create a simple array to input the color variable and increment the series name as just as a simple integer.

int plColor[7]={"Red","Green","Blue","Yellow","Black","Magenta","Cyan"}

for(int s=0; s<7; s++)
plColor[s]
psiPlot.SendData(S, plColor, x/64, pressureValue);


I appreciate any suggestions or hints to point me in the right direction to achieve this chart format output.
philr
Posts: 407
Joined: Mon May 26, 2014 10:58 am

Tue Sep 20, 2022 9:12 am

You might be able to use the pstring library to assembly a string in a char array
http://arduiniana.org/libraries/pstring/

Then use the char array as the series name. I havent tried myself but I think I have done something similar in the past.
ToolAA
Posts: 5
Joined: Sun Sep 18, 2022 1:14 am

Tue Sep 20, 2022 7:55 pm

philr wrote: Tue Sep 20, 2022 9:12 am You might be able to use the pstring library to assembly a string in a char array
http://arduiniana.org/libraries/pstring/

Then use the char array as the series name. I haven't tried myself, but I think I have done something similar in the past.
Thank you, Phil. I had seen some of your previous references to the pstring library, and I did start looking closer at how it works. My novicness is of course my biggest limiting factor. Well, I guess we all have to start somewhere.

If you do have an example of using a char array as the series name, I'd love to see it. I'll try to dissect it and see how I can apply the concept to my code. If not, I'll keep plugging along as best that I can. The developers of MegunoLink should know that if someone with such limited experience as me, can get as far as I've already gotten using just the online resources, they must be doing something right.
ToolAA
Posts: 5
Joined: Sun Sep 18, 2022 1:14 am

Wed Oct 05, 2022 1:28 am

philr wrote: Tue Sep 20, 2022 9:12 am You might be able to use the pstring library to assembly a string in a char array
http://arduiniana.org/libraries/pstring/

Then use the char array as the series name. I havent tried myself but I think I have done something similar in the past.
Phil,

I wanted to circle back and say thanks. It took me a week to teach myself what I needed to do, but Pstring worked perfectly.
Series Data.jpg
Series Data.jpg (145.41 KiB) Viewed 172 times
I figured I would share the function here for others to learn from.

// Pressure value function
void pressureData()
{ char buffer[10];
PString series(buffer, sizeof(buffer));
series.print("Test-");
series.print(cycleCount);
currentMillis = millis();
{ pressVal = analogRead(pressureInput);
pressVal = ((pressVal - pressZero) * transMax) / (pressMax - pressZero);
XYPlot psiPlot;
psiPlot.SendData(buffer, plotX/32, pressVal)
MyPanel.SetNumber(F("Seating Force"),pressVal)
}
startMillis = currentMillis; //IMPORTANT to save the start time of the current state.
}
}
philr
Posts: 407
Joined: Mon May 26, 2014 10:58 am

Tue Oct 18, 2022 7:14 am

Great work!
Post Reply