Weintek function block call

Hello, I'm trying to call a function block in Weintek which returns 'a'. The code is pretty simple, I return 'a' as 1, 2 or 3. All I'm doing is changing the background of many values - if 'a' is 1 the color is gray, 2 is yellow and 3 is red ( see ss1 and ss2). I want to test this out since I have many points from which I need to get data but I get the syntax error in row 6 in ss1. I'm trying to figure out where the problem is, unfortunately with no success yet. Will gladly hear you guys if you have solution or better ideas for the code. I'm not sure this is the right way to write a function block - it's my first time.
 

Attachments

  • ss1.png
    ss1.png
    133.3 KB · Views: 18
  • ss2.png
    ss2.png
    111.6 KB · Views: 19
On line 6 in ss1.png, where you call the Status function you cannot use the datatype declarations (short, float). Nor do you need those declarations: the main routine already knows the datatypes of the arguments passed to Status.
 
Whoops, sorry, I think it is the equals sign (=) that is the problem, because line 6 is not calling Status, it is declaring the datatypes of Status.
 
Whoops, sorry, I think it is the equals sign (=) that is the problem, because line 6 is not calling Status, it is declaring the datatypes of Status.
I've tried multiple variations but nothing worked - maybe I just can't call the function the right way. I'm not 100% sure if the logic is right but in my opinion it should be since all parameters are different. I'll save a lot of time and effort - I would have to use only GetData() for all of the 60-70 points, which are all with different addresses. Removing the equals sign doesn't fix the error.
 
Also, this might be a bit simpler for the definition of Status:
Code:
    if Value >= HH or LL >= Value then
        return 3
    end if
    
    if Value > H or L >= Value then
        return 2
    end if
    
    return 1
 
I've tried multiple variations but nothing worked - maybe I just can't call the function the right way. I'm not 100% sure if the logic is right but in my opinion it should be since all parameters are different. I'll save a lot of time and effort - I would have to use only GetData() for all of the 60-70 points, which are all with different addresses. Removing the equals sign doesn't fix the error.
how about this:
Code:
short a = Status(Value, HH, H, L, LL) /* no argument a; no datatypes */
?

Although I don't see where Value, HH, H, L, LL are declared in main(), so there may still be problems.
 
Oh, and that call to Status should be after the calls to GetData, so
Code:
short a
float Value
float HH
float H
float L
float LL

GetData(Value,...)
Getdata(HH,...)
...

a = Status(Value, HH, H, L, HH)
 
Oh, and that call to Status should be after the calls to GetData, so
Code:
short a
float Value
float HH
float H
float L
float LL

GetData(Value,...)
Getdata(HH,...)
...

a = Status(Value, HH, H, L, HH)
float a, Value, HH, H, L, LL
a = Status(Value, HH, H, L, LL)

GetData(Value, "PLC1", "Klon3.3TP90_TT", 1)
GetData(HH, "PLC1", "300.305TP90_TT_HH", 1)
GetData(H, "PLC1", "300.305TP90_TT_H", 1)
GetData(L, "PLC1", "300.305TP90_TT_L", 1)
GetData(LL, "PLC1", "300.305TP90_TT_LL", 1)

That's how I wrote it and didn't get error. Hmmm... you are right. I also changed 'a' to float just in case. Thank you very much, this week I'm going to practice those functions since they are very useful for repetitive code.
 

Similar Topics

Hi all, I'm working on a Modbus TCP integration on a Weintek HMI (EasyBuilder Pro, running under Online Simulation, not Off-line — since Off-line...
0
Replies
258
Views
Hi everyone, I am trying to establish communication between a WAGO 750-8112 PLC and a Weintek cMT2108X2 HMI, but I am unable to get stable...
1
Replies
297
Views
The older HMIs in the EMT series didn't have a problem. The CMT series seems to have this problem. Trend charts that are set to view a 24 hour...
0
Replies
262
Views
Hello, I need to connect 6 digital gauges with 5-pin SPC/Digimatic output (clock + data) directly to a Weintek HMI using Modbus RS485 (no PLC in...
0
Replies
297
Views
i have an issue that my hmi not connected to my plc, i dont know why it happen, im new with machine expert advance, because i usually using...
1
Replies
461
Views
Top