Problem with "Temp Variable” in FC blocks

wordless

Member
Join Date
May 2009
Location
Tehran
Posts
4
Hi everyone

First of all I’m beginner and it’s my first program with PLC and OP touch panel. This forum helps me a lot. Hope this time you can solve my problem.

I make a FC block (FC5) that control filling a tank. There are 9 tanks in the project. So I create 9 instances from FC5 and assign different input-output to the every function. Just one of the tanks should be filled at a time. So just one of the functions is running at the time.

vvkf4cmdl92vs9yqrwtc.gif



I have a problem with “Temp Variable” in FC blocks. The problem is when instance#1 runs(instance#1 of FC5), after filling the tank, when system switches to the next tank (actually next instance of FC5), all temporary variable that defined in the FC, remains and they are not reset for new instance of FC. For example when tank #1 reaches to its full limit level, a temporary Boolean variable will set. Then, When system switches to tank #2 its temporary variable is set at beginning of FC!


I don’t know what to do. I tried my best! After all I decide to convert FC to FB and assign different DB to each instance. But I decide to hear from you experts.

 
When using TEMPs you absolutely must initialise them in code. Write to the TEMPs before you read from them. And the writes must not be conditional.
You are assuming that the TEMPs are initially zero, but that is incorrect. The TEMPs contain arbitrary values depending on the code that executed previously.

Maybe what you are really after is to use FBs and define STATs in stead of TEMPs. Beware that TEMPs in FBs behave the same as TEMPs in FCs.
 
You must condition/intialise/write to all your Temp variables before reading them otherwise what you are seeing will happen.

If you need to store Data between scans for each instance then i suggest using a multiple instance FB and static variables.

Edit: too slow
 
Thanks

I think it's very simple for CPU to reset all temp variables in the block when function exit. I don't know but I think it's far from definition of function!

by the way, thanks for your reply. I'll work on FC to initiate temp variable. I'll test it and then if system worked, I'll switch to FB implementation.
 

Similar Topics

Good day all. I have a SLC-5/03 that has in its chassis an RTD Module (1746-NR4). The system was running fine but we had to move the cabinet from...
Replies
21
Views
5,667
Hello, I met last week a problem with a temp variable in a FC. I changed the program since but i want to understand because other FC/FB uses temp...
Replies
3
Views
1,952
I have GE fanuc Versa max PLC. But in Versamax plc have only Analog PID controller & my heater is a digital output. so how I can integrate with...
Replies
1
Views
3,289
Hi, I have had problem with upgrading some projects from v16 to v18. I tried it on 3 diffrent computers. I want to post this so that anyone that...
Replies
3
Views
143
Hi, I am having a challenge installing a new drive ACS355-03E-44A0-4 as it keeps on displaying Fault code F00018 even when the load is not...
Replies
3
Views
132
Back
Top Bottom