Step 7 FC help

Ranjith

Member
Join Date
May 2007
Location
Melbourne
Posts
316
I would like to thank this forum for helping me in previous occasions. I have attached the Source code of FC12. #ReadCounts is not connected to anything outside FC12. And I have called up FC 12 many times in the code. Problem is #ReadCounts increments many times in one scan. I expect #ReadCounts value to be from 1-4. Please guide me in the right direction.
 
You are using the temp local area for FP variables. The temp area for FC's should not be used for storing variables in between calls.
Either convert to a function block and use stats, or change the variables to IN_OUTs and pass in non-temp bits from the calling block.
 
FC help

Hi L D[AR2,P#0.0]

I have changed the #Readcounts to a VAR_In_Out and it works OK inside the FC12. Now I can see the correct values in #Runtime , #Fault_t0, #Fault_t1 and #Fault_t2 inside the FC12. But the values coming out of the FC12 "24M3".RunTime, "24M3".FaultT0,"24M3".FaultT1 and "24M3".FaultT2 are not the same as the ones' inside the FC12.
I have attached the source code of FC4 and FC12 and DB52.
Thanks for the help.
VATA.GIF


FC12A.GIF
 
Last edited:
It appears you are doing the same thing again.

#DriveStatus.ParaValue is a DINT in a STRUCT you have created in a TEMP area. You don't preset it within the block, at least I can only find it where you load it into the accumalator.

TEMP parameters MUST be conditioned inside the block before you use them, otherwise you don't know what its value is.


EDIT: just had a thought and looked for indirect addressing, I see you are transferring into the temp area.


2nd edit. How do you know which call you are seeing when you status the block, you call it multiple times.
 
Last edited:
To be honest I would program the block as a FB and the vast majority of the parameters you are sending in and out could be part of the Instance DB.
 
Ranjith - if you post source code:

(1) Please use text files as not everyone has word.
(2) Please use absolute addressing for the source. Put yourself in the position of someone importing your source code and trying to compile it. (i.e. create you own empty project, import your source and try to compile it)
 
new FC4

Pl pardon my ignorance. I do not have much experience with siemens and it works different to most of the other PLC's that I have worked with. I have removed some logic from FC4 source code. If you compile DB52,FC4[1] and FC12 should give you a complete picture of what i am trying to do in this application.FC12 is developed to control a SEW positioning drive using 8 words in and 8 words out.
I have used word number 8 to send parameter index number to the drive and read four different parameters (one at a time)and store the result in relevant tag(Dint) in db52. I can see that FC12 is getting the correct value #FaultT0=46 , #FaultT1=42 and #FaultT2=42. I would expect to see the same values stored in the DB52. Such as "24M3".FaultT0=46 , "24M3".FaultT1=42 and "24M3".FaultT2=42 .
But the values in Db52 are totally different. Pl help me to solve this. Thanking both of you for the help and your time.
 
You call the block twice, using DB's "24M3" and "25M3", what values do you have in DB "25M3", I suspect that DB holds the values you see on-line.

You are calling the FC twice and probably what you see when you status it is the second FC call, which is the one where "25M3" is the DB. I would imagine you would see #FaultT0=46 , #FaultT1=42 and #FaultT2=42 in that DB.

Inhibit the second call then status the block.
 
Last edited:
FC help

Thanks Peter and LD
When i was scrolling thru new posts noticed the following posted by LD.

"For a fully qualified DB reference, which DB1.DBX0.4 is, you have to use an IN_OUT parameter if you want to use SET RESET type instructions inside your FC".

Then I changed the four tags(#RunTime #FaultT0 #FaultT1 #FaultT2) in question to IN_OUT and now all works fine.

Thanks for your help
 

Similar Topics

I really struggle with STL in Siemens Step 7 Classic. I'll learn chunks, but then I don't use it enough to retain and build on the knowledge. When...
Replies
17
Views
3,218
Hi, Can someone translate this for me please, or at least help to explain what the instructions mean? SET SAVE =...
Replies
17
Views
4,622
Hello everyone I am new to Siemens Step 7 and having some issues I was going to add the a FC to OB1 (Network 28 In Image 1) But it was asking...
Replies
9
Views
2,395
Hello everyone I'm new here and was hoping someone can help me out. I have a pneumatic punching/ bending machine that broke down running on a...
Replies
39
Views
5,177
If I go online via the PC Adapter, all the blocks are there and all is good. If I go online via the CP-443 via IE, all the blocks then disappear...
Replies
6
Views
1,478
Back
Top Bottom