Codesys 3.5, FB, Input and Output

leon78

Member
Join Date
Jul 2004
Posts
65
Hello!
I have a FB with inputs, outputs and inputs-outputs.
The build finishes with error, if one of input-output isn't connected.
I need an extra warning, if one of inputs or outputs isn't connected.
How I can turn this warning on?
 
You have found the method to find missing connections. Do a build and it will complain.

Or maybe you want to know how to not have to put a value at some of the points on the function block. In that case, you right click on the function block call and select
Remove unused FB call parameters.

It will remove them from the screen and prevent the error from being generated. If they are required parameters then they will have to have default values or you will have to enter them elsewhere.

You can bring back the graphics for all FB parameters by right clicking on the function block again and selecting

Update Parameters.

All parameters will be shown again with question marks on the ones without connected tags.
 
Last edited:
Code:
{attribute 'reflection'}
FUNCTION_BLOCK POU
VAR_INPUT
	In1: BOOL;
END_VAR
VAR_OUTPUT
END_VAR
VAR
	{attribute 'is_connected' := 'In1'}
	in1ConnectionInfo: BOOL;
END_VAR

This may help. The attribute 'is_connected' recognises if 'In1' is assigned (and sets 'in1ConnectionInfo')

To create a user compile error, you can just:
{error 'this is an error'}

but I can't see how to make it conditional. I'd be keen to see if you get an answer.
 
I want to have the error in this case:
Compiler Error C0040
Message: Function ‘<function name>’ requires exactly ‘<number of inputs>’ input
 

Similar Topics

Hello, it is possible to rename d.input or output in order to this change apply to whole project? I can change name easily in HW config of inputs...
Replies
1
Views
1,461
Hi, I've never used codesys but now I'm converting a program from Codesys and Beijer Electronics. All the blocks is shown without input names for...
Replies
5
Views
1,420
I'm using a pressure sensor that outputs 4-20mA related to a range from 0-6 bar. i want to connect this to my WAGO 750-485 module. It's the...
Replies
3
Views
4,780
Hello to all, can you please provide an example of obtaining a current working directory as a string in CodeSys? For example, during starting the...
Replies
7
Views
166
Hello to all, I'm just starting with using CodeSys. Immediately, I have noticed that Codesys doesn't use data blocks like for example S7 does...
Replies
11
Views
208
Back
Top Bottom