Better Plotting Tool for CoDeSys 3.5?

2015-07-14
2016-10-19
  • Julian Henkel - 2015-07-14

    Hello,

    I'm working with CoDeSys 3.5 SP4 Patch 2 for a few weeks now. At the moment I'm trying to get a few x-y Graph done and I'm quite surprised that CoDeSys only comes with a histogram tool, that has absolutely no options of editing the x-Axis whatsoever. I'm looking for a plot tool/function like in MATLAB, where you can edit the x-Axis and have more overall opions, like logarithmic axes, etc. Is there maybe a better tool available that I can import into CoDeSys?

    Thanks for your answers!

    Julian

     
  • PJE - 2015-07-14

    I bypassed the standard functions and wrote my own... It's pretty easy. Each graph trace is a polyline whose x,y point coordinates can be set via codesys code.

    Doing this I have implemented multiple overlapping graphs with different scales and a multi-channel logic analyzer which uses the shortest polyline to draw the trace.

    The information for doing this was found on this forum. I can probably put a example together.

     
  • Julian Henkel - 2015-07-15

    That sounds very interesting and seems to be exactly what I need. It would be awesome if you could post an example, but if you don't have the time, I would also be happy if you'd post the link to the thread where you found the information.

    Thank you very much!

     
  • PJE - 2015-07-15

    Here's a template taken from my test code.

    You embed a polyline in the visualizaiton and set the Dynamic Point settings to:

    Array of points: _MAIN.apPoints[Trace#]
    Number of points: 256 (or as many as you need)

    Hope this helps.

    PJE

    PROGRAM _MAIN
    VAR                                                                                        
        (* History Graphs ---------------------------------------------------------------------------------------------- *)
        atGraphPoints : ARRAY[0..5] OF ARRAY[0..255] OF VisuElems.VisuStructPoint;       (* Graph Storage                *)
        apPoints      : ARRAY[0..5] OF POINTER TO VisuElems.VisuStructPoint;             (* Pointers to Graph Data       *)
        iWidth        : INT := 670;                                                      (* Graph Box Width              *)
        iHeight       : INT := 400;                                                      (* Graph Box Height             *)
        iOffY         : INT := 240;                                                      (* Graph Box Y Offset           *)
        iOffX         : INT := 12;                                                       (* Graph Box X Offset           *)
        iPX           : INT;                                                             (* Calculated X Coordinate      *)
        iPY           : INT;                                                             (* Calculated Y Coordinate      *)
        bUpdate       : BOOL := TRUE;                                                    (* Request To Update Graphs     *)
        siTrace       : BYTE;                                                            (* Trace Number                 *)
        siPoint       : BYTE;                                                            (* Point Number within Trace    *)
    END_VAR    (* ------------------------------------------------------------------------------------------------------ *)
    IF (bUpdate) THEN    (* Generate Graphs ============================================================================ *)
        FOR siTrace := 0 TO 5 DO                                                         (* Draw 6 Graphs                *)
            FOR siPoint := 0 TO 255 DO                                                   (*  Each With 256 Points        *)
                iPX := (* Calculate X coordinate for point - 0..iWidth *);               (*   Calculate X Coordinate     *)
                iPY := (* Calculate Y coordinate for point - 0..iHeight *);              (*   Calculate Y Coordinate     *)
                atGraphPoints[siTrace][siPoint].iX := LIMIT(0, iPX, iWidth)  + iOffX;    (*   Range Check & Add X offset *)
                atGraphPoints[siTrace][siPoint].iY := LIMIT(0, iPY, iHeight) + iOffY;    (*   Range Check & Add Y offset *)
            END_FOR                                                                      (*                              *)
            apPoints[siTrace] := ADR(atGraphPoints[siTrace]);                            (*  Assign Pointer to Data      *)
        END_FOR                                                                          (*                              *)
        bUpdate := FALSE;                                                                (* Prevent Constant Update      *)
    END_IF    (* ======================================================================================================= *)
    
     
  • Julian Henkel - 2015-07-21

    It has indeed helped me a lot.

    Thanks again!

     
  • galexis - 2016-10-19

    Could you post example please ?
    Best regards

     

Log in to post a comment.