Deinitialize a Function(); in TWINCAT 3

Sohaib28

Member
Join Date
Aug 2015
Location
Cottbus
Posts
31
Hello:
I am working on TwinCAT 3. I have a variable 'Allow_Control'. Whenever this variable is 'TRUE' I want the Function FCN_ON_ACSwitch(); to run otherwise when it is FALSE I don't want the function to run. It looks like this statement is not working.

If Allow_Control=TRUE THEN FCN_ON_ACSwitch();
ELSE NOT FCN_ON_ACSwitch();
END_IF.

And what happens when I am using a program instead of a function. As Operational(); is my another program and COM(); is my MAIN program. I am running Operational(); in COM(). If Allow_Control is 'TRUE' I also want Operational(); to run otherwise it should not run from COM. Please have a look at the attachments.

Any help will be highly appreciated. Thanks in advance.

Unbenannt1.PNG Unbenannt2.PNG Unbenannt21.PNG
 
Is anything else working? Are you sure it is in run mode? Declare a new variable MyDint as dint and add this to your Com routine:

MyDint = MyDint + 1

You should see the value changing every scan.
 
Yes Everything else is working fine. But the main problem is this statement

If Allow_Control=TRUE THEN FCN_ON_ACSwitch();
ELSE NOT FCN_ON_ACSwitch();
END_IF.

This is not running. I only want this function to run when my variable Allow_Control is TRUE else the function should not run.
 
Delete the second line and see if that helps.
You can't "NOT" a function.
If your variable is true, it will call the function, if it's false it will not.
 
Last edited:

Similar Topics

Hi, I have attached herewith one image which our programmer has been used in S7 1500 PLC. Now we need to use the same instructions in S7 1200 PLC...
Replies
4
Views
134
Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
33
Views
1,103
Good morning crew! Ok my logic works but I am missing something. When the start button is pushed it should like the red light for 4sec then shut...
Replies
13
Views
443
Please see attached file. I need this program in Function Block form but I am totally lost on this. Any help would be appreciated. Thanks!
Replies
8
Views
308
The idea here is to provide for a brief rapid influx of message codes while preventing sequentially repeating the same message. i.e. if two...
Replies
23
Views
706
Back
Top Bottom