Eclipse Community Forums Forum Search:

Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Why "INF" value in composite fb?(addition of 2 small real and dividing the sum by 2 delivers INF)
Why "INF" value in composite fb? Sat, 24 December 2016 01:36
 Ernst MurnleitnerMessages: 19Registered: December 2016 Junior Member
I want to calculate the mean value of two real values. It works, if I use a simple fb with the following:

QO := QI1 AND QI2;
IF QO THEN
OUT := IN1/2.0+IN2/2.0;
END_IF

However, it does not work if I make it with a composite fb. See atached pictures.

• Attachment: mean1.png
• Attachment: mean2.png
Re: Why "INF" value in composite fb? [message #1750666 is a reply to message #1750656] Sat, 24 December 2016 10:46
 Alois ZoitlMessages: 672Registered: January 2014 Senior Member
I think the problem is that you are specifying only 2.0 at the second input of the F_DIV block. As the inputs are of type ANY_NUM the code does not know what to do with the 2.0 wand will ignore it. Therefore the second input stays at 0.0 and you will get a division by zero.
In order to do this correctly you would need to specify the type with your parameter (e.g., REAL#2.0). With that the runtime knows your intention.

I know this is not nice and already the tool should handle this. Generally I would say that the basic FB solution is for your problem the better and more clean solution. It uses less memory and will also be much faster.

In my personal opinion I would use the generic math blocks only when there is some simple adaption between some existing FBs needed. E.g., you need to combine two values to form a new one. For applicaiton components I would not recommend them. Most of the time the resulting FB networks are very complicated, hard to understand and maintain.

P.S.: While thinking about why you have this issue I came up with a workaround for the REAL2REAL FB: If you give also a parameter value with REAL#0 for the first input of F_DIV then the input should be correctly typed and a direct connection between F_ADD and F_DIV should be possible. As I'm currently in the train I haven't tested it. But you could give it a try. This should work in applications and CFBs alike.
 Previous Topic: MQTT Next Topic: Version Information on Splash Screen
Goto Forum:

Current Time: Tue Nov 20 13:45:55 GMT 2018