3/24/2025 11:03 PM | |
Joined: 7/10/2016 Last visit: 8/20/2025 Posts: 15 Rating:
|
I will not continue a separate topic. Then I have such a situation, TANK x4, perfect for UDT. But.. I will also definitely need N_TRIG for each stop, I will need BLINK 1Hz for each lamp. If I make UDT TANK, then I will use the same functions for buttons or lamps in FB, but also in other places in the code. I will duplicate the same. If I insert all I/O into FB and perform operations on them that return useful options (--NOT--, P_ N_, timer etc.) then I will not insert them in UDT, but UDT will be very unreadable. It seems to me..., that for me (but I don't quite know how) would be to create a function that duplicates what is often used in the code. So pass all input from PLC_TAG to FC_Input. In this FC make N_, P_, NOT etc. And next make UDT TANK with START, but in FB_TANK use a FC_Input.%I0.0_N_Trig. Or maybe I'm thinking too much :D But I would like to create a general template that will speed up the process of creating new simple project designs. ------------------------------------------------------------------------------------------ |
Last edited by: Moderator_Lan at: 03/25/2025 08:59:11New subject after splitting |
|
3/26/2025 2:44 PM | |
Joined: 7/7/2010 Last visit: 9/8/2025 Posts: 16067 Rating:
|
There are many approaches to building FBs and UDTs. I tend to go along the following process: Build an OB (since in S7-1200/1500 we can have _many_ cyclic OBs). In that OB, I start with controlling just 1 of the things I might have many of (4 in your Tank example). I get the logic working flawlessly with 1 thing using global tags (for I/O) and DB tags for everything else. Once it is working, I then put all the logic for 1 of the things into an FB - including all the global tags and IO tags. Then I slowly replace one global tag as a time an FB interface parameter. When it is finished, I potentially have a single huge FB interface filled with parameters. If a see opportunity for a group of UDTs, like input parameters, output parameters, InOut Parameters, I will group them, build the UDTs, and start swapping out parameters - so long as it does not make it harder. I say the last part because sometimes UDTs make it more difficult to pass parameters in a smooth natural way that is easy to understand, repeat, explain, maintain, and expand. The UDT for me is the last thing I do rather than the first thing. For me, the first thing is to get it working. Then replicate it. Then see if something will help simplify it - like UDTs, or other data structure(s), or other I.T. type structures / architectures.
|
science guy |
|
Follow us on