I have a real problem to understand the difference between: FB & FC. HELPPPPPPPPPPPPPPPPPPPP:reup:I REALLY NEED URGENT HELP (YES/NO answers will help also).i'm a beginner in siemens 300/400 & i came from computer programming background and i made some simple applications on the S7-200.Now, what i know / & what i'm confused about????FC does not have memory / FB has memory - DB? Confusions:FC has inputs & outputs - why?what are the cases that it makes me use the FC's I/Ocan i assign 'Q's/PLC outputs' to the FC outputs?if YES then if the FC call is conditioned, that means if the conditon is not fulfilled the Q-output will turn to ZERO - Yes/No?FB has memory and i can assign different DB's to it, e.g. Motor control.
![]() ![]()
Fine that what i always read. FC does not have memory / FB has memory - DB? Confusions:When you call an FB it asks for a IDB to link with it, in this all IN/OUT/INOUT/STAT parameter values gets saved into the IDB. The IDB is just a DB at the end of the day, but its format is fixed to the FB data above. Here I'll try and make it simpleFC = Simple Subroutine.
USA/MFO/2002 datasheet, cross reference, circuit and application notes in pdf format.
Example I want the average of two numbers.Inputs Needed: Value1 and Value2Outputs Needed: ResultResult = (Value1+Value2)/2Once I work out the Function.do I need to see intermediate steps? Do I want to copy code over and over and replace Value1 & 2 with new variables? I simply want to use the FC like it was a internal instruction. Pass data in.get result out.FB = Like above but I need STORAGE MEMORY or I need the intermediate results from outside block.Motor Block.Inputs Needed: Start & Stop, On Delay PresetStorage Needed (STAT Area): RunStartFlag, OnDelayTimerOutputs: RunCoilWhat does it use for storage?
Do I need a DB for each FB call yes and no. Once you figure out how to use the power of multi-instance.you'll never go back to checkers once you play chess. It can hurt your head until you understand the concept. The beautiful thing about it is you don't have to generate reams of datapoints.
The FB's do it for you.Nick. Thanks peter, without u giving time, i would have been still 'lost in space, same like miss piggy' - LOLmy god, the main difference the specific STATIC variables attached with every FB call:bow:thank u nick, ur answer was clear. But it emerges some questions:multi instancing: i came from a programming bacground so i'm familiare with the concepts but not with the methodlogy.so if we consider multi instancing, (in a motor control example as usual)that would be done by defining 10 DBs for 10 motors and 1 FB for the functionality and then i will call the FB 10 times and i'll pass the 10 DBs each at a time.this is the methode of multi insatncing - YES/NO???there are other ways, YES/NO???u said it will save my time in defining of variables, but i'll repeat the DBs, YES/NO???thanks & less confused,Michael.
I suppose the easiest way to explain, they both can function similarly, except, if you want to save the status with the FC, you have to do it with the parameters you pass to the block on calling.A bit like the InputPar sends info in and the ReturnPar passes the information back when you call a routine in ControlLogix.The difference with an FB is it has additional internal parameters called STAT's, which is stored in a data area you specify when you first program the block call. You can still pass data in and out, but that data and the STAT's get stored. That way on the next scan the block 'remembers' the state from the last scan.If you call the same block a number of times in the code, you would normally specify individual data areas to store the memory for each call, like 20 calls for 20 different motors for example.To michael, I only have ControlLogix at the moment, to give you an example I would need step 7. Mico207 - As you have mentioned you come from a computer programming backgound, here's another description for you.In a Function Block - all accesses to IN, OUT, INOUT and STAT variables are performed by reading/writing data to/from the instance data block associated with the FB. The sequence of events for processing is as follows:1.
The calling block writes parameter values into the instance data block.2. The function block is called and acts upon the data in the instance data block and writes result data into the instance data block.3. SUM UP:-Hello, I’d like to put an objective sum up so everyone will benefit easily from this thread.Properties / Difference – FC vs FB, DBFC: variables are passed by REF. (Pointers) which means any change of the value the same variable along the program will have an effect on the FC functionality.FC: which also leads to – HAVE NO MEMORY – as it refers to variables whatever their valueFC uses: can be used in mathematical operations, organizing of the program ex. Call different FBs depend on some input values and return flags FB: where as FB is similar in nature but with additional options that give it its power.FB: variables are passed by VALUE, which means whatever changes that happen to that variable in your program the FB will not sense it.FB: ex.
Same as what Mr. L D said: if u made and FB to add 2 numbers & return the sum (selected mathematical operation for simplicity) and u call it 2 successive time.
1st u passed 5, 4 then the result is 9. 2nd time u passed only 1 value 6 (in the place of the 1st input) then the result will be 10.FB: also have the amazing STAT variables which are used as memory. Example the M+ button that u find on ur calculator.FB: DB, it is just an amazing concept – the DBs they have the inputs, outputs, In/Out, Stat variables stored in it and assigned to the FB. I was confused about it in the beginning why they have to do that???
The answer is simple it gives the programmer the power to know the values at any time along the code.FB: also it differentiate between the values/variables and the code to do the action. Finally what affects any system are the values, the logic is just a mean to reach the desired outputs/values.FB: multiple DB, i.e.
FB200 (for ex.) is assigned to it DB200, DB201, DB202 (Typical DBs, assigned each at a time on each call of FB200) another amazing concept. As long as the logic of FB200 will do the same job every time it is called, and what we need is on the values (bec.
That’s what really do the control) so it very clear to assign typical DBs on successive FB200 calls that will control identical instrument in the same manner (eg. Motor – as usual).FB: one more thing here, due to the property of the DB to retain data will lead to keep the output status stable if it depend on a DB value (ex. RunMotor)FB: finally we r left with 1 concept we didn’t discuss is MULTI-INSTANCING and as Mr. Peter said: u can define FB in the STAT of another FB which I check the simatic manger help n I found what he told exactly so I guess I’ll open another thread dedicated for this topic.FB uses:same operation on multiple machines.operations where machine status have to be saved (maybe breakdown/recover scenario, car move/stop on different stations).PLEASE CORRECT ME IF ANY INFORMATION IS WRONG, NOT QUITE CLEAR OR NOT COMPLETE.Regards,Michael. For the behaviour I am explaining the following are simple.
Each of these variables is uniquely defined by a 32 bit area pointer. At the lowest level, an area pointer is always passed to an FC.M0.0MW10I0.0Q10.5DBX10.0L10.0A fully defined DB reference cannot be stored in a 32 bit area pointer (it actually requires 48 bits) and so hence the following are complexDB1.DBX0.0DB10.DBW10As these variables cannot be uniquely defined by an area pointer, the editor produces code that copies the variable into an area that can be uniquely defined by an area pointer.
The area it uses for this purpose is the L area - the local temp area.If you want to bottom out what is happening here, you need access to a plc or PLCSim. Hellooooo,i come to u again guys seeking wisdom:)here is an FB that i'm including in my project and i want to clear my doubts once and for all.& DB201 are assigned to FB200, and is been called twice from within an FC.my question is: if the TEMP '#X2maskON' is disengaged 'ZERO' then the FB outputs:Q116.4, Q116.5, Q116.6, Q116.7 will be also turned off = YES/NO???but the DB200.DBX6.0 (where 6.0 is one of the BOOL Outputs) will also turn to ZERO = YES/NO???thankxxxx. SUM UP:-Hello, I’d like to put an objective sum up so everyone will benefit easily from this thread.Properties / Difference – FC vs FB, DBlistFC: variables are passed by REF. (Pointers) which means any change of the value the same variable along the program will have an effect on the FC functionality.This is not clear to me. What do you mean by along the program. Do you mean before the FC call? If a parameter is passed by address then what happens to that parameters value when it is changed within the FC?1.
Can input parameters be changed by the FC so the value is changed when the FC returns?FC: which also leads to – HAVE NO MEMORY – as it refers to variables whatever their valueIt would be best to say that FCs don't maintain a state or are stateless.Note, as pointed out, one can keep the state externally in a DB and pass a DB to the FC.listFB: where as FB is similar in nature but with additional options that give it its power.FB: variables are passed by VALUE, which means whatever changes that happen to that variable in your program the FB will not sense it.Are you sure about this? I don't think this is right. What would be the point of passing variables then.FB: ex. Same as what Mr. L D said: if u made and FB to add 2 numbers & return the sum (selected mathematical operation for simplicity) and u call it 2 successive time.
1st u passed 5, 4 then the result is 9. 2nd time u passed only 1 value 6 (in the place of the 1st input) then the result will be 10.Can you pass a variable number of parameters? I don't think so.FB: also have the amazing STAT variables which are used as memory.
Example the M+ button that u find on ur calculator.FB: DB, it is just an amazing concept – the DBs they have the inputs, outputs, In/Out, Stat variables stored in it and assigned to the FB.Stat variables are local to the FB. The IN and OUTs are not, they are global.font=ArialPLEASE CORRECT ME IF ANY INFORMATION IS WRONG, NOT QUITE CLEAR OR NOT COMPLETE.Think about my questions above.I have never used multiple instance FBs. I just create duplicate DB and pass the DB number. When I do this I don't really need STAT variables either and can do what I want in a DB but Siemens makes it awkward to load DBs.I prefer SCL now.
STL is painful. Too much mental energy is spent keeping track of all this. Where do you want to spend your mental energy? On using the tool or getting the job done? I'll have to some search Peter, i'm not really sure as i'm a beginner myself but i combined my programming background to what i have understand from along the thread and wrote it in the sum up, so the people can check an amend or complete what is not. That's it.anyway please guys don't forget my questions:that means the FB & FC once they were called & their outputs status have changed. They will always keep their current state except if they were called again and the state have been changed from within the same FB or FC.YES/NO????+ how to change the DB (variable within) after creation & linking???:(.
![]()
Once the program completes the FC all that is left is the output in a memory location.true, but part of the IO defined could be pointers where info is stored for later.Another tricky bit is when I look at an FC online I frequently get data from a previous FC in the online view. Somewhere I read that the inside of an FC can't be viewed online.
Just in case Peter hasn't worded his answer forcefully enough, if you get into the habit of programming with Symbolic Priority enabled (in Simatic Manager, 'Edit - Object Properties - Address Priority (rider)' then set Symbol has priority 'For all accesses (I,Q,M,T,C and DB)', the problem with adding STATs just disappears along with a whole load of other problems.Have a look at this Thread (in particular S7Guy's sample program in post #23, to see how much easier life is when you resolutely use Symbolic Priority. My first: Once the program completes the FC all that is left is the output in a memory location.Peter: true, but part of the IO defined could be pointers where info is stored for later.These 2 statements mean the same thing to me. 'IO defined' or 'outputs', 'in a memory location' or 'pointers to where info is stored'.
Same.My first:Another tricky bit is when I look at an FC online I frequently get data from a previous FC in the online view. Somewhere I read that the inside of an FC can't be viewed online.
I don't see why, but this is the case with so much.Peter: You may not see where the logic is jumped over (not scanned) or if the FC is called more than once you may not know which call you are seeing the data of.You can map the path to the call that you are monitoring which means you can isolate the particular call, but you would need the calls to be made from separate locations to view your code (in FB's you can map it to an IDB).This makes no sense at all. If I open a block and select online, how is it possible that S7 is somehow confused about which data I want to see? How can it be skipped over if it is being executed?
Why do we need to re-write something just to stop S7 from putting the wrong data in the online view? I am trying hard to like S7.' You can map the path to the call that you are monitoring.' So in order to see what is happening in a FC online, I have to put each one in an isolating FB and then use an IDB for each one?????????? Why not just use FBs to begin with?I accept that this is the case, I just stopped expecting to see anything usfull in FCs online and switched to using FBs for all but the simple things.My first: The down side to this is if you have to edit the FB and you have used the Stat locations elsewhere in your program, the stats will shift and be in different locations so everywhere in your program where you referenced these stats, you have to edit.Peter: The STATs are symbolic so you should not need to do this. (But not priority over absolute as we discover later.)I keep hearing things like this. Symbolic is on by default, even when I turn it off to change an address, it comes back on after I close the block.
So it is always on when I open a block and when I make a new block. However when I have to make a change, the symbol is not available in the DB drop down list to select as it does not display everything in the DB in the list.I still have not figured out the pattern to this.
All the stats have symbols, but not all show up. The DB is named, if its not named the whole DB doesn't show up in the list. So many times I have to use the actual address by turning symbolic off. Of course right after I enter the address it displays the symbol which is quite irritating.
I would prefer S7 not do so much automatic switching. It is as if it suddenly realizes the address has a symbol after I use the complete numerical address. The only reason I do it this way is because I have to.Peter: It depends if you want a fast program, STL is lower level code and makes the code more efficient. I would be interested to see some data on this. I imagine the difference is around 10% but that's just a WAG based on looking at STL and the STL generated by LAD.I would hope the ladder is compiled into a similar code as STL when downloaded into the PLC processor.
I guess you can make more direct comparisons and leave out some steps in STL that are needed in LAD.RMA:Just in case Peter hasn't worded his answer forcefully enough, if you get into the habit of programming with Symbolic Priority enabled (in Simatic Manager, 'Edit - Object Properties - Address Priority (rider)' then set Symbol has priority 'For all accesses (I,Q,M,T,C and DB)', the problem with adding STATs just disappears along with a whole load of other problems.See that is specific and very usefull advice right there. Mine was set to use the symbols but the Absolute had priority. (upper left selection)Without your specific advice I would have thought I was using symbolic addressing, and I was, it just wasn't set to take priority over the Absolute.Have a look at this Thread, in particular S7Guy's sample program in post #23, to see how much easier life is when you resolutely use Symbolic Priority.This will make several things easier,Thanks Peter and RMA. You have to forgive me if I'm not specific, I don't have access to S7 anymore, on this side of the pond I'm stuck with ControlLogix (trying hard to like it).I did not mean to imply that your advice was not valuable, (it is very much so),just that frequently veteran users make reference to methods which seem like a small pile of words.
And while they are decidedly correct in grammer and usage, seem to be completely foreign.With regard to the path to the FC, it can be done, someone else may have to point to the correct drop down and selection.There are two methods to isolate your multiple called blocks, one is to state which DB you want, this can be your IDB and makes FB's easier to monitor.I see no place to specify which DB I want. I call an FC and it has no DB to specify. 'Either make a copy of the FC which is called multiple times and substitute it in one call for the original FC or else create and open a dummy DB'After looking all the posted responses over I now understand the veiw part and using the test call and that only the first instance is displayed.However, I am unclear about the above statement.' Make a copy of the FC.' Does this mean to insert a copy of the one you want to watch as the first one and then it will be the one with veiwable data?'
Or else create and open a dummy DB'Not sure about this one. If these are FCs, why do we need a dummy DB? And what would go in this DB?Almost there.Thanks again. Attached screen shot shows you how to do it.If in doubt, press F1, the info is in there. (somewhere)Thanks,The issue I have with searching the 'help' is knowing what to ask. Before I read this, I would never have imagined such a thing was possible or necessary. I have never seen such layers of obscurity.And I tried asking 'What should I search for help on to answer my question' angle, but had a difficult time interpreting the help answer anyway.It is too easy to just ask in the forum and get lazy, and I am trying not to do that, but the system is just so cumbersome.I think I am on the verge of getting somewhere like 'the next level' or about to completely get lost.Fun place to be.Oh I am trying to use the info you included without success.
Not sure why yet, still working on it.Thanks again. 'Make a copy of the FC.' Does this mean to insert a copy of the one you want to watch as the first one and then it will be the one with veiwable data?Sort of, simply make a copy of the original FC with a new number, for example if the original FC is FC74, then you might call your copy FC1074. Then substitute this new FC for the call of the original FC that you want to view. Since the new FC by definition is the first (and only) instance of the FC then you can be sure that the data that you see when viewing it is correct.' Or else create and open a dummy DB'Not sure about this one. If these are FCs, why do we need a dummy DB?
And what would go in this DB?The dummy DB is purely used to define the path for viewing your multiply called FC as shown in the example Jeebs posted. You don't need to put anything in it (just leave the dummy placeholder in it) and then on the line before the FC call you want to view, insert the command OPN DBxyz - if you're working in Ladder, insert a new Network directly before the FC call you want to view and add the OPN DBxyz command there.The DB is purely used to assist with the trigger definition as shown above and can be deleted when you're satisfied everything is working correctly.The issue I have with searching the 'help' is knowing what to ask. Before I read this, I would never have imagined such a thing was possible or necessary. I have never seen such layers of obscurity.I know exactly what you mean here! I sometimes think my brain must work differently from the guys who write the help files - and that's not just the case with Siemens! You guys seem to be making this a bit more complicated than it really is, in my opinion.An FC is just a function, a re-usable set of code. You can use it over and over again, call it as many times as you need to.
You give it a set of inputs every time you call it, it operates on them, and gives you a set of outputs. Any information about what goes on inside the FC is lost after the programs operates on it.An FB is used in a similar way, but is much more powerful. It's a reuseable set of code with inputs and outputs just like an FC, but it also has its own memory area. Every time you create an FB, you create a DB, which is the memory area for that FB. What's nice about S7 is that every time you use that FB in your program, Step 7 creates a new version of its DB memory area for that particular instance of the FB.
This is called an Instance Data Block. In this way, you can use the same FB 100 different times, without having to manage 100 memory areas, one for each call of that FB. There are more powerful consequences of this when you do complicated things like indirect addressing, udts, or nested function blocks.You get to view information about what is happening inside each instance of an FB, unlike an FC, because the FB has its own memory area for each call, or each time its used in the program. If you looked online at an FC that was being called in several places, you wouldn't know which version of it you were looking at.
But for an FB, you could look at the Data Block for that specific instance of that FB, so you knew exactly what part of the code you were looking at.That's the main difference between an FC and an FB.$. You guys seem to be making this a bit more complicated than it really is, in my opinion.Yes we did detour into how to see 'live' data. Apart from that you over simplify it in an incorrect way.An FC is just a function, a re-usable set of code.So can be an FB, but neither is limited to that. For instance both can be a main block calling other blocks.You can use it over and over again, call it as many times as you need to. You give it a set of inputs every time you call it, it operates on them, and gives you a set of outputs. Any information about what goes on inside the FC is lost after the programs operates on it.Yes, you can also give it no inputs and no outputs, it can be simple it can be complicated, you may need to see the status in one instance of a call and disregard others, which is what the last few posts have been about, you may send data to different DB's from within (so data not lost).An FB is used in a similar way, but is much more powerful. It's a reuseable set of code with inputs and outputs just like an FC, but it also has its own memory area.
Every time you create an FB, you create a DB, which is the memory area for that FB. What's nice about S7 is that every time you use that FB in your program, Step 7 creates a new version of its DB memory area for that particular instance of the FB.Not if its a shared instance (called from within the block with the FB's embedded).This is called an Instance Data Block. In this way, you can use the same FB 100 different times, without having to manage 100 memory areas, one for each call of that FB. There are more powerful consequences of this when you do complicated things like indirect addressing, udts, or nested function blocks.You can do indirect addressing in FC's and use UDT's, I'll concede that you cannot embed a FB.You get to view information about what is happening inside each instance of an FB, unlike an FC, because the FB has its own memory area for each call, or each time its used in the program.erm.
No you can't. You'd have to look at the DB not the FB to see what's happening, looking at the FB status gives you the same problems as an FC UNLESS you specify the DB, which is what the last few posts have been describing.If you looked online at an FC that was being called in several places, you wouldn't know which version of it you were looking at. But for an FB, you could look at the Data Block for that specific instance of that FB, so you knew exactly what part of the code you were looking at.ONLY in debug mode and if you specified the DB. As has been explained similar can be done in an FC.That's the main difference between an FC and an FB.$Apart from one or two bloomers, spot on:beerchug. Old thread, but just found.;)I'm an old-school ladder logic guy born and bred on GE and AB. That said, I've been programming S7-300 full time since 1999. I don't use FB's in the way most people use them.
Simple reason: you don't get cross-references. I have had to follow many other programmers that used FB's and it is nearly impossible to track stuff down. The HMI can write to the Instance DB and affect the process. The programmer could have used the Instance DB addresses elsewhere in the program. When you are inside the FB and right-click and do 'Go To.'
There is no way that I have found to get a cross-reference to back track. It's true that you can execute a cross reference for the Instance DB but you have to know to do this - not intuitive.
If there is a workaround for this: educate me. Final thing: you are in an FB and you see the logic. All addresses are local data preceded with a pound sign.
What's the address? Contrast this with the way I do it, to be explained now.What I do in all my programs is use an FC as a subroutine, the same way we'd use a subroutine in GE or AB. Then when I need to do logic for a process or a machine within a program I will choose a group of FC numbers and one DB. I do all the logic in the group of FC's and use the one DB. I say a group of FC's because its a good idea to break code up that is larger than 2kb for online monitoring purposes, as well as downloading the FC for program changes. My code practice is very portable and cross-references are available for me and those that follow.
To explain, if I have 8 identical processes then I can simple copy my FC (s), copy my DB, and then search and replace within the FC. Boom Bam, code replicated. I don't see what the big deal is about FB's. I'd also much rather edit variables within a DB than deal with the editor in the top of the FB. And back to the last question of the preceeding paragraph.
In my FC that uses a DB, you see the address. Right-click and do Go To. And get a cross reference.I don't use FB for machine code. I do use FB for limited applications but always keep in mind the lack of global cross-reference and use that as my deciding factor. So I do use FB's, but not like most Siemens programmers seem to.Caveat: I did not read every post in the four pages of this thread before I posted. I did read most of them.:).
Paul,So I take it your using S5 timers and replacing the Timer numbers or passing them in? This is where the FB approach really wins outs. Need a timer.
Bingo go declare one and your good. Further to this TONs (SFB4) are far superior timers. Run for 28 days and you get 1 mSec res.Yep. If I have a machine called Tipper 1 then all tag names for this machine have 'Tip1' in them. The global Data Block DB21 for Tipper 1 is 'Tip1' and the timers for Tipper 1 are 'TMRTip1xxxx'. To create the logic for Tippers 2-8 I would copy and paste the original global DB21 and call it DB22 with symbol name 'Tip2'.
I'd copy the timers for Tipper 1 & rename Tip1 with Tip2 in Excel and then paste them into the Symbol table. Then copy the FC's for Tipper 1, renaming them with appropriate names. Then open in the ladder editor and search and replace Tip1 with Tip2 and it's done.I understand the IEC timers are awesome but what I don't like is having an instance DB associated with each timer. That makes too many DB's in Simatic Manager. Can you post example code of a timer declared in an FB?;356824'If you want to use SFB4 from a FC using Paul B's approach, declare the SFB4 interface in the global DB, set up AR2 to point to it and make the instance DB number the same as the global DB number. You have to call SFB4 using UC SFB4 and manipulate the timer data via the global DB.Simple example attached.Thank you very much for this! I am working with this now.
My question for you is what does this line mean:UC SFB 4The instruction UC does not appear in STL instruction help.Your global data block has timers declared with the UDT 'sfb4Interface'. I did not know this was possible and I am working on how to use this. Your example is very much appreciated. I have not used SFB4 because I did not like having to assign a DB every time I used a timer. I'd have 500 instance DB's in some programs. Your way is very interesting.
This post:be very easy to solve with my global data blocks and FC style of programming:1. Compare the offline DB to the online DB to ensure timestamps are the same.2. Backup your project in case something goes wrong.3.
Open your project offline, and then open online.4. Drag & drop the online DB to the offline project.
This will 'get' the current working values.5. Open the DB and add whatever you want to add to it, then download to PLC.I have used this method to add things to a DB while a process is running and never lost data or had any problems. How would you do this simple & fast with FB, DB method? This post:be very easy to solve with my global data blocks and FC style of programming:1. Compare the offline DB to the online DB to ensure timestamps are the same.2. Backup your project in case something goes wrong.3. Open your project offline, and then open online.4.
Drag & drop the online DB to the offline project. This will 'get' the current working values.5.
Open the DB and add whatever you want to add to it, then download to PLC.I have used this method to add things to a DB while a process is running and never lost data or had any problems. How would you do this simple & fast with FB, DB method?Say your DB contains a count value from the process, your method will lose the counts that take place whilst you edit and download the DB. Ah, that is different menu item than the F1 key.' When the CALL instruction is used for a function block (FB) or system function block (SFB) an instance data block (DB no.) is expressed explicitly in the instruction. For a call made with the UC instruction, you cannot associate a data block in the UC address'.Very interesting, I am learning so much!I have completed code where my main control functions are in FB's called from within the same master FB, all are called using UC.The main FB has only STAT's made up UDT's, the rest of the blocks have the same UDT's in the same order, up to the point where they need data.All data is available to all blocks only the first call has an IDB.IO is added in FC's externally where I transfer it in.
So no IO parameters to any blocks.Very neat. L DAR2,P#0.0 - true. I've not encountered an installation where it mattered. I have seen where if I upload with the line running and then download with the line stopped, motors start.
So I don't do that! I use S5timers so they wouldn't be affected. Now that I have played with your SFB4 timers with global DB I can sure see where it would matter for that! Had a nice couple of hours exploring that code you posted, much obliged.Repeat: How would you do this simple & fast with FB, DB method?PeterW - I would like to see your code, if you would be willing to share. Click my name and send a PM if you don't want to post publicly.With Siemens the level of complexity is a never-ending tower of stairs.
Each time I reach the next floor and feel accomplishment I see the next flight of stairs. The beauty of the complexity is the power. I found my comfort zone after a year of exclusive Siemens programming and am still exploring the edges. I have learned much from you guys in just two days with this thread. It really helps to be able to see how others do things.
Here's an example project that I've just made up that uses UC FBx from the main FB.By declaring the same UDT in the STAT area of the FB's, each FB called using UC acts as an extension of the original FB.If you change the UDT, you must edit each FB and update the interface.I've also used a UDT for SFB4's interface (as in the previous example project) to allow an array of SFB4 timers to be used.I've shown two methods of calling SFB4 via FC'sWith the first you have to generate the logic for the timer before calling the FC.With the second method you pass the timer logic in to the FC. LD, I eagerly downloaded this Sunday the 24th (big American Football day, the AFC and NFC Championships) from my home computer and emailed it to myself. I have now had a chance to open it in Step7 and I want to say another THANK YOU for your lesson. I continue to learn from you.
I am very much obliged!I don't know that I would program this way but I am intrigued by the ability to do so. I will say that I am starting a new project and exploring the use of UDT's for common structures. I have been using structures in DB's, so it seems very familiar to me.The one thing I can see is when I declare a STRUCT in a DB it is very easy to go back and modify it.
For example I might have ten identical motors and copy and paste the struct ten times. Then when I want to add a variable I have two options:1. Re-copy and re-paste the struct ten more times. (With the UDT this is all handled by the software - I need only compile.)2. Edit each structure's contents to include the new variable. With this method the data in each structure is retained.The difference is the ability to maintain the current data.
But I am sure enjoying learning, thank you for your contributions.:)Declaring with a UDT is so clean.
Features. Tested on Oracle, DB2, MySQL, SQLite, HSQLDB, H2, Apache Derby and SQL Server but should work with any database. Tested on Windows, Linux, Solaris and Mac OS X, but should run on any configuration. Syntax highlighting. SQL reformatting. Update records by directly editing the result grid.
Insert, edit, delete and duplicate records. Open, export and import BLOB's and CLOB's.
Export results to Excel, PDF or flat file. Copy and paste BLOB's and CLOB's. Export results to insert statements. Consult the database structure in the schema browser.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |