Sorry if the question is trivial, but I am new to codesys :)
I am currently working on retrieving some JSON-formatted sample-points through a http GET request.
I can successfully retrieve and split the sample points, but the sample-points for the X-axis is a timestamp (epoch time).
I am trying to plot the sample points by using the XYchart visual element, but as the used variables for the XYChart is basic integer types, the visualization of a DT by using a interger-type is not optimal.
My question is then: is it possible to "hack" and then be able to plot strings in a graph?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to do the same thing, basically, I am storing a variable REAL and a timestamp in DT format to a CSV file on the PLC flash memory, and at the same time I would like to read the CSV file and display it on XY chart (it is like a custom made trend recording, since Schneider M241 dosen't support codesys trend recording manager). Anyways, I read the CSV file succesfully and store the timestamp and value in seperate arrays, however, XY chart dosent support neither DT variables nor string variables. Hopefully, someone has got a solution for this :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have not seen someone post a solution yet. That doesn't mean it doesn't exist though. I had seen someone do this but they did the work external to Codesys using Grafana I think and the graph was accessed on the PLC with the browser.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm doing this by creating a separate X axis array in the visualization that's nothing more than an array of numbers counting up
within the visu that's displaying the XY Chart:
VAR
XAxisData: ARRAY[1..1440] OF REAL:= INIT_XAXIS();
END_VAR
where the INIT_XAXIS function is simply:
FOR i:= 1 TO 1440 DO
//initialize X Axis: 1 to 1440
INIT_XAXIS[i]:= INT_TO_REAL(i);
END_FOR
the XY chart curve Data X variable points to XAxisData
then I hide all the X axis numbers, ruler, ets, and create the timestamps manually using text fields and some functions to get the correct timestamp from the array
FUNCTION TIMESTAMP : DT
VAR_INPUT
Index: REAL; //percent of full scale
XAxisControl: VisuStructXYChartAxis;
END_VAR
VAR
timestampindex: UINT;
END_VAR
Hi,
Sorry if the question is trivial, but I am new to codesys :)
I am currently working on retrieving some JSON-formatted sample-points through a http GET request.
I can successfully retrieve and split the sample points, but the sample-points for the X-axis is a timestamp (epoch time).
I am trying to plot the sample points by using the XYchart visual element, but as the used variables for the XYChart is basic integer types, the visualization of a DT by using a interger-type is not optimal.
My question is then: is it possible to "hack" and then be able to plot strings in a graph?
more posts ...
Hey,
I'm trying to do the same thing, basically, I am storing a variable REAL and a timestamp in DT format to a CSV file on the PLC flash memory, and at the same time I would like to read the CSV file and display it on XY chart (it is like a custom made trend recording, since Schneider M241 dosen't support codesys trend recording manager). Anyways, I read the CSV file succesfully and store the timestamp and value in seperate arrays, however, XY chart dosent support neither DT variables nor string variables. Hopefully, someone has got a solution for this :)
I have not seen someone post a solution yet. That doesn't mean it doesn't exist though. I had seen someone do this but they did the work external to Codesys using Grafana I think and the graph was accessed on the PLC with the browser.
I'm doing this by creating a separate X axis array in the visualization that's nothing more than an array of numbers counting up
within the visu that's displaying the XY Chart:
VAR
XAxisData: ARRAY[1..1440] OF REAL:= INIT_XAXIS();
END_VAR
where the INIT_XAXIS function is simply:
FOR i:= 1 TO 1440 DO
//initialize X Axis: 1 to 1440
INIT_XAXIS[i]:= INT_TO_REAL(i);
END_FOR
the XY chart curve Data X variable points to XAxisData
then I hide all the X axis numbers, ruler, ets, and create the timestamps manually using text fields and some functions to get the correct timestamp from the array
FUNCTION TIMESTAMP : DT
VAR_INPUT
Index: REAL; //percent of full scale
XAxisControl: VisuStructXYChartAxis;
END_VAR
VAR
timestampindex: UINT;
END_VAR
timestampindex:= TO_UINT(((XAxisControl.rMax - XAxisControl.rMin) * (Index/100)) + XAxisControl.rMin);
timestampindex:= MAX(timestampindex, 1);
timestampindex:= MIN(timestampindex, 1440);
TIMESTAMP:= Data[timestampindex].TimeStamp;
These functions both assume data and timestamp arrays of 1..1440
And I'm using the XAxisControl variable to allow for zooming and panning of the displayed data, which then also updates the timestamps
Last edit: tvm 2021-03-16