- HMI Model: cmt3108xp
- EasyBuilder Pro Version: 6.10
Good morning,
Hello,
I would like to know if is it possible to dynamic assign the decimas to a filed number using a variable.
Example:
On the HMI I added the controls for an air regulator.
This by default works in bar with a range from 0 to 5 bars.
With this unit I need 2 decimals, so on EasyBuilder Pro I set2 integeres and 2 decimals.
Easy peasy
But what if the customer what to use example Pascal as um?
I can increase the integers to 6 (so 5 bars = 500000 Pa), but with this um I don’t need decimals.
With the Siemens panels (Unified) I created a javascript function to automatically set the value based on the um and decimals.
Something like this
export function aria_testa_valore_SET_OutputFormat_Trigger(item) {
var value;
// decimal2
// 0 - hidden
// 1 - 1
// 2 - 1.1
// 3 - 1.12
// 4 - 1.123
let decimali = Tags("Aria_testa_sgn_num_decimals").Read();
if(decimali == 1) {
value = "{I}";
} else if(decimali > 1 && decimali < 5) {
// sistemo la variabile
decimali = decimali - 1;
value = "{F" + decimali.toString() + "}";
} else {
value = "{F1}";
}
return value;
}
The function was triggered with the same frequency of the variable’s acquiring speed, every value got from the plc was automatically converted.
Is it possible to do something similar? If so, will it has some impact on performance etc?
Hello,
This looks like a great use case for implementing function blocks within our Macros. I did want to ask, could you clarify the data types you’re using for the item
parameter and the return value in your function?
Thank you!
Typically this task is done within a PLC program/POU rather than an HMI program. Can you advise why in your application it is necessary to perform scripts on Siemens panel HMI or Weintek HMI to accomplish this?
Thanks for the reply,
Intresting, could you be more specific?
item
on Siemens Unified is added automatically when you create a script.
I don’t use it on my function so I am not sure.
I had a very limited time to work on the project so I am not even sure if it can be removed or not.
What I read is Aria_testa_sgn_comuni_usint[1]
an usint from an array defined on plc where:
0 - is disabled (I use this value to hide the box on the visibility property)
1 - set 0 decimals
2 - set 1 decimals
and so on…
the value
, returned is the set for the property.
where {I} is integer and {Fx} are real (x is the number of decimals to show, default is 1).
With Siemens Unified I had to set many arrays since these panels for some things are very cool but for the most, are terrible (only 1000 tags, tons of parameters to set for eah field, etc).
It is like a wrong mix between a web page and wincc.
Something must be done with js, other with default wincc tools, styles and themes must been defined with an external tool… a mess very hard to maintain and develop specially in the early phases where the GUI is still not very defined.
Anyway, now I can stop praising these panels so I will back in topic 
This is how I set the script:
The ideal was to pass the usint from the plc as input value, but as said I had limited time to work on it, so I prefer to copy & paste and modify the plc parameter inside the function.
With the old Comfort panels instead, to solve the same thing I used faceplates. Basically I created a faceplate where I pass the value to show and decimals.
On the faceplate there are 3 input box and the rightone is shown based on the decimal field value. Not very elegant but it works…
What I would like to achieve is use 1 function to dynamically assign the right decimals, something reliable and easy to maintain, is it possible?
Hello and thanks for the reply.
you are right, I do this task on plc side, but with the default settings, on the panel I will see anyway the extra decimals I don’t need.
Thats why I want to do something custom - if possible -, to show only the “raw” value that comes from the plc.
example if in EB pro I define an input box with 6 integers and 4 decimals and the number to show is 0.25, on the hmi I will see 0.2500 and, if the user switches from Bar to Pascal the number to show is 25000 but will become 25000.0000 on the hmi.
This to me is a problem, because at first the numbers are not easy to read 25000.0000 => 25000 (see below), and also I will need huge fields (or set small fonts) to show the values.
The GUI, as well the user experince, will be bad.
This
versus this
With Siemens’ hmi (see above) I creted some tricks to bypass this behaviour and show the right value.
I would like to do something similar (or better/smater) even here…
My original idea was to send the value multiplied by 1, 100, 1000 (based on the decimals) and use the scaling function on EB pro to do the trick, but I will still need to specify the decimals… so I think that it will not work…
Or use macros but I don’t know how the panel will react if I will have 10 or more macros per page to update values
For this use case (below), usually our customers will create two separate Numeric objects to display parameters with different metrics and utilize the visibility control function to determine which Numeric object will show up at runtime.
"example if in EB pro I define an input box with 6 integers and 4 decimals and the number to show is 0.25, on the hmi I will see 0.2500 and, if the user switches from Bar to Pascal the number to show is 25000 but will become 25000.0000 on the hmi.
This to me is a problem, because at first the numbers are not easy to read 25000.0000 => 25000 (see below), and also I will need huge fields (or set small fonts) to show the values."
Running many “long” macro scripts per page/window to update values may cause an unwanted perfomance issue.
By the way, if you purchase Weintek products from your local distributor Tecono Bi Homepage - tecnobi.it, you can reach out to their technical support team for further consulting services.
1 Like