Author Topic: Charting and data logging values  (Read 5062 times)

pat@uow

  • Newbie
  • *
  • Posts: 12
    • View Profile
Charting and data logging values
« on: March 13, 2018, 06:58:03 PM »
Good morning,
I've been trying to set up both a chart (by sampling) and datalogging to csv/text file using AHMI Version 3.99x
There are 8 values I would like to display and log. Values all come through to a digital panel meter display just fine.
I added all 8 values to the collection for the chartbysampling, and the collection for the Basicdatalogger2.
The chart is intended to display the last 30mins of data , but when I run there is only 1 value (the first in the collection) displayed and the x axis timescale is not consistent.
The datalogger text file appears to be recording values, but the alignment of values is not the same as the collection and there is no header to define the values recorded. Over-writing may be an issue here....

My questions
Am I using the right tools for the job ? i.e. chartbysampling for the charting , and datalogger2 for the datalogging.
If so, is there a resource which consolidates the most up to date information on how to correctly configure all of the settings in each of the tools  - particularly charting and datalogging.
Alternately, is there a single thread or post which explains the key process steps for (1) getting a chart of multiple values , and (2) a daily or triggered log file so that new files are added rather than overwittten.

Thanks in advance for your assistance.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Charting and data logging values
« Reply #1 on: March 13, 2018, 08:55:34 PM »
Stock controls for charting are based on MS Chart so you can always Google on how to do something.
Also search this forum for topics that involve charting or specific control you might be using (make sure to be on the main forum page before you start the search).

Since you already added 8 values to the ChartBySampling's PLCAddressValueItems collection then you should also add 7 more series for a total of 8 series in the Series collection. Whatever settings you have changed for Series0 you should apply to all other series as well (an example could be setting the XValueType of Series0 to DateTime --> all newly added series have to have the same setting otherwise the chart will not be moving along the x axis).

For a specific DateTime format check this topic: https://www.advancedhmi.com/forum/index.php?topic=1922.0

Current code will not be doing any of this automatically for you (it is set to add series, if missing, and also set them to the FastLine chart type).

ChartBySampling is a live chart. If you need a static chart for logged values then look at the latest posts in the Additional Components category.
ZedGraph based chart controls, from this same category, might also be an option.

These are things that worked for me so give it a try.
« Last Edit: March 13, 2018, 10:21:46 PM by Godra »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Charting and data logging values
« Reply #2 on: March 13, 2018, 08:56:18 PM »
Currently the best method is to run the BasicDataLogger2 and then use a separate application to view the data from the file. There is a chart component in the works that will make the separate application a chart that can be added from the Toolbox to your same application's form.

https://www.advancedhmi.com/forum/index.php?topic=571.0

https://www.advancedhmi.com/forum/index.php?topic=2034.0

pat@uow

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Charting and data logging values
« Reply #3 on: March 15, 2018, 05:50:59 PM »
Thanks Godra and Archie,

I think the piece I'm missing is the link between the "collection" and the "series" in the chartbysampling. I do want a live chart (for 30 last minutes of data - by second). From your text, does this mean for each member of the "collection" the "series" needs to be set up 1 for 1 for both the Y and X axis?

The datalogger2 reporting to a text / csv file (for reading in Excel) is just fine. Only need to work out the column headers, common timestamp and creation of a new file daily. Any tips in this direction would be really appreciated.

Cheers

Pat

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Charting and data logging values
« Reply #4 on: March 15, 2018, 08:13:08 PM »
It should be just the X axis (XValueType property). Leave YValueType property on Auto.

A line from the log file looks like this:  14-Mar-18 18:22:56,14,31,12,29,13,27,16,23
The Date/Time stamp is common for all values and represents the X axis.

For a test, drop a new ChartBySampling control on the form and add your 8 addresses to PLCAddressValueItems collection.
Then go to Series and have it look like the attached picture - each series should only have the values circled in red changed from default.
You could possibly change the name of each series to reflect its PLC address.
Then run the program and see what you get.
« Last Edit: March 26, 2018, 03:54:08 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Charting and data logging values
« Reply #5 on: March 26, 2018, 03:56:17 PM »
For the creation of the daily log file, you might try using modified data loggers from this post:

https://www.advancedhmi.com/forum/index.php?topic=2027.msg11388#msg11388

pat@uow

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Charting and data logging values
« Reply #6 on: March 27, 2018, 06:06:27 PM »
Thanks for that info.

I have a few issues with running a dual Y axis trend per the attached screen shot.

I have allocated each of Flow 1, Flow 2, and Flow 3 to the collection of the "Series"

Each member of the series has a setting for "axes" Y Axistype - Flow 1 is set to primary , the Flow 2 and 3 set to secondary. All X axistype set to primary.

In the chartAreas dialog -> axes -> collection -> X axis all auto , Y axis primary 0-100 , secondary Y axis 0-500.

I cannot get the Flow 2 and Flow 3 values to display on the trend.

I'm also having trouble setting the length of time on the x axis, after some time, the chart will just display the chart box with a bid red cross.

Any suggestions of what's wrong really appreciated !

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Charting and data logging values
« Reply #7 on: March 27, 2018, 06:45:18 PM »
A few questions:

1) Have you set the XValueType of each series to DateTime?
2) What is the current setting for MaximumActivePoints of the ChartBySampling (which pretty much defines the length of time)?
3) Can you upload the log file?

The attached chart picture has the settings you described (series1 bound to primary Y axis, Series2 and Series3 bound to secondary).
« Last Edit: March 27, 2018, 07:33:19 PM by Godra »

pat@uow

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Charting and data logging values
« Reply #8 on: March 28, 2018, 05:33:01 PM »
Thanks Godra,

The XvalueType had defaulted to Auto - so setting this to time (as per Flow 1) for Flow 2 and 3 appears to have worked.

The max points needs to be checked next - is time axis then purely max points / sample rate ? (Sampling is one per second) or is it also a function of the number of series / pens on the chart ?

When you say "upload the log file" - do you mean the datalogger "PLCDataLog.log", as I don't think this has anything to do with the "Chart by Sampling"

Also, with the links to the newer forms of the datalogger2, is there a procedure for how to incorporate these downloads into the project file correctly ? (Please forgive my level of VB is not great)

Cheers

Pat

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Charting and data logging values
« Reply #9 on: March 28, 2018, 06:30:14 PM »
Time axis is purely max points / sample rate.

Since it works for you now, I don't need to see the log file (which by the way was the datalogger "PLCDataLog.log").
If your data logger is logging exactly what the chart is showing then I was just curious to see what was being logged for Flow 2 and 3 since you couldn't see them in the chart.

These new data loggers are also a part of beta version posted here: https://www.advancedhmi.com/forum/index.php?topic=2058.msg11600#msg11600
So, if you wish then you can try the whole new version of AHMI.

With any new version of specific files, like data loggers, in order to add them to your existing project then normally you would just right-click their respective folder (in this case it would be the "Components" folder) and select Add/Existing Item and browse to the location where you downloaded the new files. Once these files are selected then you will be prompted to confirm that you want to replace the old files.

« Last Edit: March 28, 2018, 06:34:38 PM by Godra »

pat@uow

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Charting and data logging values
« Reply #10 on: March 28, 2018, 06:54:56 PM »
Thats awesome - thanks.
Yes- the values for Flow 2 and Flow 3 do appear in the datalog for the period where they do not appear on the chart.

PetrTecilla

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Charting and data logging values
« Reply #11 on: July 17, 2020, 12:37:40 PM »
Hello....my question is how many data you would want to display and how fast you want to refresh ect.
You could build a shift register for data + timestamps and add fixed amount of registers to a symbolist of some bargraph symobl you design.
Or you create a HTML5 page and use JavaScript to implement a dynamic chart.There you could also embedd a eHMI page to add some buttons or something similar.

https://www.7pcb.com/
« Last Edit: September 09, 2021, 06:07:24 PM by PetrTecilla »