How to use CODESYS variables within the "Dynamic limits" of a trend display

How to use CODESYS variables within the "Dynamic limits" of a trend display https://forum.weintekusa.com/uploads/db0776/original/2X/4/494119386705e83bffb7e5f710e0bfe147e996f4.png
none 0.0 0
  • HMI Model: cMT-3108XP using Codesys as the PLC
  • EasyBuilder Pro Version: V6.09.02.338

I’m building a popup to be used for PID control as seen below and want it to include a trend that dynamically updates with the data for the PID loop popup that was requested. This is working correctly for the most part, just a couple things to iron out.

My issue is that while testing I notice that the sampling seems to not stop after I close the popup window. The issue this causes is that if I opened a level control that has a setpoint of 2000 gallons, close it, then open a flow control that has a setpoint of 150 gpm, it shows a line coming from way off the trend screen. See below.

Is there a way I can get the Data Sampling that I’ve configured to start fresh every time I open a new PID popup rather than showing past data? I have a Codesys function block created to handle all the popup data/control. There is a PopupRequested (true when popup is requested and false as soon as the popup is closed) variable within. Perhaps that can be used for this?

Also, I am not quite understanding how to get dynamic values for the Y-axis. When selecting a channel there is a Min and Max value for the axis. If I click the Dynamic Limits box, it gives me an option to choose a local HMI register or a REAL value from the PLC. But why only one? I would expect one for max and one for minimum.

Hi @JDControlsLLC,

To start a fresh sample each time you open and close your popup window, I would recommend that you enable and use the “clear” command within your data sampling object:

You can use an “Action Trigger (Per-page)” object to trigger the “clear” command each time the window is closed:
Note: This object is located within the “Action-related” drop-down list in the “Object” tab.

Also, regarding the dynamic limits, if you select the usage button it will indicate that the “Min” and “Max” limit should be part of an array as in the example image below:

Ok the clearing of previous trend data works perfectly.

I’m confused on the min/max limits though. I was hoping to use PID.Y_MAX and PID.Y_MIN. Those are from the Codesys libary PID function block.

How do I map .Y_MAX into LW-1 and .Y_MIN into LW-0? Could I handle this inside of the function block I created with something like below:

LimitArray[0] := Y_Min;
LimitArray[1] := Y_Max;

Then in EBP I set the dynamic limit to LimitArray[0], so that would be the min value and it would follow that the max value would equal LimitArray[1]?

Mine just says SINT-0 and SINT-0, not LW-0/1 like yours does

@JDControlsLLC,

To map a CODESYS numeric variable to an HMI register I would recommend that you use the data transfer object as shown in this post: Link

Then, you can set the appropriate LW register within the “Dynamic limits” section to map these limits to the trend display. I hope this helps!!

I realize I mistyped with the Y_MAX and Y_MIN tags, those are limits for the output of the PID. But the concept is the same of what I wanted to do, I want dynamic axis min/max for the trends based on the min/max of the PV and SP values (usually these would be the same values) for the PID controller. The limits for the SP of the loop is something I’m creating internal to the function block I’m writing.

I’ll give this data transfer method a shot tomorrow and let you know if it works.

Just got a chance to try and it works. Thanks again for the help, yall are always great.

To summarize what I did in case this post can help someone else out:

I created a MaxSP and MinSP within the function block I am developing to control a PID and write the values to them. That information is then written to my function block for handling PID popup data, which includes the trend displaying.

Within EBP I had to create two Data Transfers (Bit Trigger) and set it up as below. Use LW0 for the min, and LW2 for the max.

Mine was LW0/2 instead of LW0/1 like your screenshot because the values I am trending are 32 bit float

And below is a popup for two different PID loops. First one being a pressure from 0-150 PSI, the next being a level from 0-2500 gallons. The setpoints change dynamically like I wanted.


1 Like

@JDControlsLLC,

Thank you for sharing your solution! I really appreciate it!
Have a great day!

Brendon,

I’m noticing an issue with the clearing of trend data that it seems to not always work properly when switching between the two PID instances I’ve created.

Troubleshooting this led me to notice that the Codesys variable I’m using, ClearTrendData, as the tag read by EBP as the Control for the Data Sampling, is flickering between a value of 0 and 1.

This variable is only used in one location and extremely simple code of an IF/THEN loop to set it to a 1 or 0 based on if a PID popup is requested to open. It is not written to anywhere in Codesys and I’ve even removed that code from my Function Block to troubleshoot.

The tag stays at a value of zero. When I try to write a 1 to it, it is overwritten to 0.

It seems like EBP is writing the zero to it, but why?

EDIT: Sorry, I missed above where you said to use a Action Trigger. I set one up to set ClearTrendData to 0 when opening the PID popup window, and set it to 1 when closing. Both are added to the PID popup window.

It still shows old trend data from the previous PID window I had open, which is a level controller with a setpoint of 2500 Gallons. So that’s where the trend line came from off the screen.

Good morning @JDControlsLLC,

When a “clear” command is written into the command address, the HMI will accept the command code value of 1 and then overwrite it with a 0 as part of its procedure. The developers may have implemented this to prevent the HMI from continuously clearing the data sampling memory.

The HMI’s software will do this with other object control addresses and address values as well. Can you please put a numeric object addressed to the ClearTrendData tag on the PID popup and while this window is open, enter a value of 1 manually and advise if the previous trend data clears?

Also, can you please remove the other Action Trigger (Per-page) object that sets the control address to 0? Per my suggestion, I think that only one action trigger object set to function on window close is necessary to accomplish to this goal, meaning that no additional PLC code or other objects should be necessary.

I tried that and as you expected, the HMI will force it to a zero immediately after I change it to 1. What that gets me is a quick clearing of trend data and then as soon as it is written back to 0, the trend starts.

So what I need is actually to write that to a 1 when the popup opens and no other action is necessary.

Now I removed the numeric input and replaced it with an Action Trigger (Per-Page) to write a 1 to ClearTrendData upon opening the PID popup and it works perfectly.

1 Like

@JDControlsLLC,

Wonderful news!! Thank you for the update, I’m happy to hear that everything is working as expected!