Red Lion scripting

Nebul0us

Lifetime Supporting Member
Join Date
Dec 2015
Location
Spokane, WA
Posts
125
I need to make a navigation to 1 of 2 pages based on the value of a DINT in the PLC.


I need a statement in the script that basically says when the button is clicked it will navigate to page X when the tag value is equal to 4700 or 6000. If the tag value is not equal to those two values then it will navigate to page Y. Can anyone help me with this? I am a Red Lion noob...
 
Code:
 If (TagFromPLC == 4700 || TagFromPLC == 6000) GotoPage (X);
else GotoPage (Y);

You can put that right on the button "Action" tab under Action Details choose "On Released" and select "Complex" for type, then paste that code into the Complex Code window, edit the tag names and page names to match your system and it should validate.
 
OkiePC, thanks for your help. I am curious about another task with the Red Lion, if you don't mind helping me on the same thread?

Basically I want to have a popup when a DINT from the PLC equals a certain value. How can I accomplish this?
 
OkiePC, thanks for your help. I am curious about another task with the Red Lion, if you don't mind helping me on the same thread?

Basically I want to have a popup when a DINT from the PLC equals a certain value. How can I accomplish this?

On the Tag, click on the "Triggers" tab, set the mode to "Data Match" then for the Value: enter the constant, another tag, or an expression for the value you want to generate the trigger.
For the action:
ShowPopup(YourPageName)

You can also set a delay time in milliseconds if you might need to debounce or delay the trigger.
 
On the Tag, click on the "Triggers" tab, set the mode to "Data Match" then for the Value: enter the constant, another tag, or an expression for the value you want to generate the trigger.
For the action:
ShowPopup(YourPageName)

You can also set a delay time in milliseconds if you might need to debounce or delay the trigger.


I understand that part, but what calls the tag to begin with?
 
I understand that part, but what calls the tag to begin with?

If you have that tag value source assigned to a PLC address, each time its value is updated (by the PLC communication driver), the system will check its trigger settings and act according to how you set it up, so it is automatic just like alarms only without the same alarm list history and other overhead.
 
If you have that tag value source assigned to a PLC address, each time its value is updated (by the PLC communication driver), the system will check its trigger settings and act according to how you set it up, so it is automatic just like alarms only without the same alarm list history and other overhead.


But I only want the popup to show at a certain point within the sequence, or basically only on 1 screen. So how do I call the tag only when I get to that screen?
 
But I only want the popup to show at a certain point within the sequence, or basically only on 1 screen. So how do I call the tag only when I get to that screen?

Let's clearly define what you want a little better. When a value in a tag that is controlled by the PLC reaches a certain value AND the operator has navigated to a particular screen, you want this popup to appear, correct?

If so that leads to the question of order of those things happening and how do you want to respond. If the tag is already at the trigger value and then the specific screen is chosen, do you want the pop-up to happen? Or do you want to only check the value of the tag when the specific main page is chosen?

There are events that you can use for when a main page is first selected that could make the comparisons. There are cases where you may want to have the PLC "know" which page is being displayed as well.

Knowing the bigger picture of what you are doing would be helpful to give better advice.
 
Good morning OkiePC! I want to start off saying how much I appreciate you lending a hand to a Red Lion noob like myself.


So to be more clear, the operator will already be on the screen when they are asked to press two physical push buttons (to keep hands away from pinch points.) When those 2 buttons are activated, a DINT is moved to a PLC tag. That is the tag I want to trigger the popup, while still on that screen.


On another note, I would also like to hear best practices for passing screen numbers to the PLC so the PLC "knows" what screen the HMI is on as you mentioned.
 
Good morning OkiePC! I want to start off saying how much I appreciate you lending a hand to a Red Lion noob like myself.
You're welcome!

So to be more clear, the operator will already be on the screen when they are asked to press two physical push buttons (to keep hands away from pinch points.) When those 2 buttons are activated, a DINT is moved to a PLC tag. That is the tag I want to trigger the popup, while still on that screen.

Then simply use the trigger on the Crimson tag to call the pop-up. The pop-up will be called once each time the value in that tag changes to match the value you place in the trigger regardless of what page is presently displayed.


On another note, I would also like to hear best practices for passing screen numbers to the PLC so the PLC "knows" what screen the HMI is on as you mentioned.

To have the HMI keep track of what page is being displayed, I will create a tag with "internal" as the source, I will mark it as retentive.

Then on each page properties I will use the "on select" event to assign a value to that tag.

If I want to share that tag with the PLC, I just change the data source to point at the desired PLC tag.

You could also allow the PLC to dictate what page is displayed with another tag. Just use a trigger on data mismatch and run a program that uses a switch statement and a list of cases and breaks:

Code:
switch( HMI_Select_From_PLC ) {
case 1:
GotoPage(Page1);
break;		

case 2:
GotoPage(Page2);
break;		

case 3:
GotoPage(Page3);
break;		

case 4:
GotoPage(Page4);
break;		

case 5:
GotoPage(Page5);
break;
}



Side note: A habit I have developed with Crimson is any time I am doing anything with the "=" equals sign, I use two characters:

Code:
y := x   //assignment  The value in y is replaced with the value in x
y == x   //test for equality, returns 0 or 1 (true or false)
y != x   //test for inequality

I once wrote a lengthy program in Crimson and had a hell of a time finding a bug because I had inadvertently used "=" where I intended a test for equality and it was changing a tag I did not want changed. "=" is the same as ":=" and is the assignment operator.

Another sidenote: If you are going to write a long program or create a bunch of references to pages or tags, keep the names short and sweet...one or two characters if possible. When you get done with all the typing (which will be easier with short names) you can go back and make the tag/page names more meaningful and lengthy and Crimson will rename them throughout all your objects and programs automatically.
 
Last edited:
I simply don't understand why the PLC needs to know what screen the HMI is on? I know it was relevant way back due to communications bottlenecks, but don't understand why this would be relevant today?


Only thing I can think of is tracking operator screen adventures. IE: what did they do?
 
Then simply use the trigger on the Crimson tag to call the pop-up. The pop-up will be called once each time the value in that tag changes to match the value you place in the trigger regardless of what page is presently displayed.

This would result in the popup showing at times it's not wanted, like on the main screen when the part number is selected. I only want it to display from this specific screen.

Then on each page properties I will use the "on select" event to assign a value to that tag.


I'm terrible at scripting and it's very disappointing to me that I have to use it so heavily to accomplish things with Crimson. Anyways, how do I assign a value to that tag with scripting?
 
I simply don't understand why the PLC needs to know what screen the HMI is on? I know it was relevant way back due to communications bottlenecks, but don't understand why this would be relevant today?


Only thing I can think of is tracking operator screen adventures. IE: what did they do?

The only time I have ever done this is to maintain compatibility when upgrading systems that previously used Panelview Standards where that feature was used and operators were accustomed to the behavior of allowing conditions in the PLC trigger a page change (and let the HMI have control back once the page change occurred).

Nebul0us said:
This would result in the popup showing at times it's not wanted, like on the main screen when the part number is selected. I only want it to display from this specific screen.

This contradicts what you said earlier, so I didn't make it more complicated than necessary:

So to be more clear, the operator will already be on the screen when they are asked to press two physical push buttons (to keep hands away from pinch points.) When those 2 buttons are activated, a DINT is moved to a PLC tag. That is the tag I want to trigger the popup, while still on that screen.

If you only want the pop-up to be able to be called when a certain main page is displayed, then use a tag to track which page is visible as explained above, and on the tag value trigger script do something like:
If (PageDisplayed == 27) ShowPopup(MyPopup);

If there are a ton of pages and you don't want to have to modify the properties of all of them just to detect whether one single page is being viewed, then try using the Page Actions "On Select" and "On Remove" to set/reset an internal flag tag. I have never used the On Remove action, but I assume it will work as explained by the pop-up help.
 
Last edited:

Similar Topics

Hi All, As a precaution my company has been collecting copies all the HMI and PLC programs. I have recorded copies of most of our sites...
Replies
0
Views
58
While they came up quickly with a fix for the alarm date issue quickly I will have to drive around for a week or so, burning up a lot of fuel...
Replies
4
Views
273
From the Red Lion website, after some customer enquiries in the last week or so... Rev. March 25, 2024 [18:30] Just thought it might help a...
Replies
9
Views
283
How do you install update on Red Lion Crimson ver 3.1. Do I just need to run the exe file on the host server?
Replies
1
Views
118
Hello All, I need the ability to remotely reboot a Red Lion CR3000 HMI. Due to some graphics issues when the database is updated the HMI must be...
Replies
4
Views
238
Back
Top Bottom