Check FB input - Beckhoff(TwinCAT 2)

Join Date
Feb 2012
Location
São Paulo
Posts
53
Good afternoon sirs,

I'm developing a library for Beckhoff PLCs using TwinCAT 2. What I need is to check if the input of the FB (declared in VAR_INPUT inside de FB) has any variable.

For a better explanation: I have some fault monitoring that can only occur if it's enabled. In some old FBs there was an input on the FB to enable the monitoring and another for the sensor that trigger the fault.
I want to eliminate the enable input from my FB and check the sensor input, if there's something on that field, then I'd monitore that fault.

Thanks in advance.
 
Set the input to a INT.
Initialize that input to -1.
Each time you call the FB pass the real input value (1 or 0).
Inside your FB check what you are receiving, if something is being passed then you'll get something different than -1.
If you want to check that along all the life cycle of the program once finished inside the FB rewrite that variable and assign -1 again.

Good luck.
 
But if the Input has nothing it'll return FALSE(0), then when I read the input and pass its value to the INT variable it'll be set to 0, cause outside the block it's FALSE, and will ever execute.

I have to check if the VAR_INPUT has some external variable attached to it, outside the FB, and then set any value to my fault check variables (TRUE or FALSE).
 
You could use pointers, if the pointer is not initialized it's value is 0, if the pointer is initialized it's value is a memory address...
 
Correct a BOOL is either FALSE or TRUE, so no error check is possible here.
some answers: use a structure with a BOOL and BYTE
if the BYTE <> 0 there is a connection
another one is to use structure with BOOL+ and BOOL-
it is used in a safety relais so when BOOL+=BOOL- error is TRUE.
You must use a structure for this to avoid forgetting a connection.
 

Similar Topics

Hi, I have 2 safety devices (Banner EZ LS light curtains and a Keyence GS-71 Interlock) that are giving me some difficulties. The plc is a Compact...
Replies
6
Views
1,964
Hello all, I have a Controllogix 1756-L61 with some RIO. There are a couple of 1734-OB4E's that have gone bad. (no output voltage) My boss found...
Replies
10
Views
1,056
Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
0
Views
401
Hello I am new here and new to PLC's, I wrote this program for a class that I am taking and my local tech school. The description is switch 7 will...
Replies
10
Views
1,955
I'm trying to save a project as an L5X and I need to uncheck the "Encode Source Protected Content" checkbox, but it's grayed out. How do I get...
Replies
1
Views
935
Back
Top Bottom