Crimson 3, databox showing (Changing) Tag info

M0Dark

Member
Join Date
Dec 2020
Location
Manchester
Posts
18
I have a databox on a display sheet which I want to populate with the label and data from a Tag.
The problem is that the tag changes based on some "complex" code.
eg. If Tag_X==1 then
Databox_1 should show Tag_A data and label text
or if Tag_X==2 then is should be Tag_B
etc etc.
How do I accomplish this? Noting that my actual code is much more complex and there are many tags and data boxes to fill.
Thanks
 
You answered one way yourself. Create a tag that will go on screen, from the drop down box make the Data Source 'Complex' and write your definition there.

That method hides some complexity in the tag source, you could equally write a 'Program' that calculates what need to be in the all the screen tags. That way all of your programming is in one place. Call the program on Tick to update the tags every second.

Another way would be to add an extra tag to the PLC and let the PLC decide what data should be copied to the extra tag.
 
Thanks Bryan,
The bit I am having trouble with is passing the label from the Tag being referenced to the databox.
As there are 35+ variants I was hoping to avoid creating extra tags as well as the databoxes for them.
 
A tag's label text can be accessed by putting ".label" after the tag name. So, to accomplish what you want I think you'd have to create a string tag to hold the selected label text. In my example: LabelText

Then the complex code for the display field data would be something like this:

Code:
If (Tag_X==1){
  LabelText := Tag_A.label;
  return Tag_A; }
else if (Tag_X==2) {
  LabelText := Tag_B.label;
  return Tag_B; }
For the display field's label, you would just need to set it to =LabelText.
 
Last edited:
So I basically have to create a new tag for each databox I have so it can pull the label into somewhere static for the label field to reference?
 
So I basically have to create a new tag for each databox I have so it can pull the label into somewhere static for the label field to reference?
Not necessarily. You could create a Program that returns the label text, and put a reference to that in the display field properties, i.e. "=MakeLabelText()". If you were intent on not having to create individual tags or programs for each display box, you could make one program (or two--one for data and one for labels) that takes an integer as an argument and uses a big case statement to sort everything out. So each of the display fields would call =MakeLabelText(1), =MakeLabelText(2), etc.
 
Ok Thanks,

Can I use both and and or operators in an if statement?
e.g.
if (X==2&&(Y==1orZ==3)

Yep as long as you use the correct number of parentheses and the correct logic representations for the logical AND (&&) and logical OR (||).

Example:
if (X == 2 && (Y == 1 || Z == 3))
 
Right I can't seem to get this to work. I have the following code in a string tag.

int X1:=0;
if (Test_Data.Complex_Test_Specific.Flow.F50_Meter_Select==1){
X1+=1;
if (X1 ==1)
return Analogue_Inputs.FT1.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.F150_Meter_Select==1){
X1+=1;
if (X1 ==1)
return Analogue_Inputs.FT2.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.F300_Meter_Select==1){
X1+=1;
if (X1 ==1)
return Analogue_Inputs.FT3.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.F600_Meter_Select==1){
X1+=1;
if (X1==1)
return Analogue_Inputs.FT4.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.FX4_Meter_Select==1){
X1+=1;
if (X1==1)
return Analogue_Inputs.Aux_4.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.FX2_Meter_Select==1){
X1+=1;
if (X1==1)
return Analogue_Inputs.Aux_2.Label;
}
if (Test_Data.Complex_Test_Specific.Flow.FAir_Meter_Select==1){
X1+=1;
if (X1==1)
return Analogue_Inputs.Air_Flow.Label;
}

But it will not seem to pull the label out of any tag.
 
Also I'm not sure how often it is going to query that code and look up the value. I only need it to do so when a certain page is opened, not once every second, is there a better place for me to put it so it doesn't keep running all the time?
 
There is probably a better way to accomplish your needs. Can you give us the bigger picture of what you are doing?

I have 7 different flow meters, and a program which allocates them to either;

off
Flowtotal1
Flowtotal2
Flowtotal3
Flowtotal4

I am trying to make a page which shows the meters which are allocated to each total along with the raw values of each and the total.
To make matters complicated I'm trying not to have them listed with gaps in the list.

e.g.

FlowTotal1 10
Flow1 2

Flow3 2
Flow4 6

would be easy with just the visibility function. but getting;

FlowTotal1 10
Flow1 2
Flow3 2
Flow4 6

is proving much more tricky than I imagined.
 
Also I'm not sure how often it is going to query that code and look up the value. I only need it to do so when a certain page is opened, not once every second, is there a better place for me to put it so it doesn't keep running all the time?

Each page has a field called On Select (page > properties, Actions Tab) that you can fill in to run once when the page is selected.

What is the bigger picture of what you are doing? It might make more sense to duplicate the page ten times, edit the data box to display the proper tag directly for each of the ten choices, and then use the value of the selector tag to control navigation to the right page.

I need a clearer understanding of your overall goal to advise.
 
I have 7 different flow meters, and a program which allocates them to either;

off
Flowtotal1
Flowtotal2
Flowtotal3
Flowtotal4

I am trying to make a page which shows the meters which are allocated to each total along with the raw values of each and the total.
To make matters complicated I'm trying not to have them listed with gaps in the list.

e.g.

FlowTotal1 10
Flow1 2

Flow3 2
Flow4 6

would be easy with just the visibility function. but getting;

FlowTotal1 10
Flow1 2
Flow3 2
Flow4 6

is proving much more tricky than I imagined.

Okay, it sounds like it would make more sense to have 4 pages, one for each flow total and on each of those pages list (or use conditional visibility) the flow meters that are assigned to that totalizer. I did something a while back to create a list (without gaps) for sequencer conditions...Let me see if I can dig it up and figure out how it might apply here.
 
What HMI and what version of Crimson are you using? I am working up an example in 3.0 for a 10" screen so I can emulate it. I think it will kickstart your work once you edit it to match your real tag data...
 

Similar Topics

I frequently create simple indicators on screen by copying the tag directly on screen and then altering the text states and background color...
Replies
3
Views
2,713
Hey guys, hoping someone here could give me a little advice. I'm working with a CR1000-04000 in Crimson 3.1 and I was interested in adding the...
Replies
4
Views
93
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
1
Views
81
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
102
Has anyone found a way to convert/replace/update the firmware on old Parker TS80xx series HMIs (i.e. TS8010, TS8006, etc) to accept Crimson...
Replies
0
Views
87
Back
Top Bottom