Function Block or not

gajtguy

Member
Join Date
Nov 2023
Location
Philly-ish
Posts
3
Hi folks. New to the forum, but been working with PLCs for several years now. Would like some advice on whether you would keep this logic, or craft a function block. Which is something I can't seem to wrap my head around.

Net result = I need %MW0 to be either a 0, 1 or 2 value for a two door salleyport (real doors, interlocked). This is so that an HMI display can show a normal mode (0), or both doors being opened is a violation (1) or they can change the mode so the salleyport is bypassed (2).

Right now I'm using 3 rungs for just 1 Sallyport. The job has 5 total. So would a function block be cleaner/better? Or is this 3 rung logic just fine?

.

3RungMethod.PNG
 
I would keep as is for this software (Somachine basic or machine expert basic)
The user defined function blocks is not very user friendly in this software. This is also not a lot of coding thats going to save you time by just replicating it 5 times . I would just have each salleyports logic in in 5 different sections
 
The thing about creating your own function blocks is a good idea especially if you are going to re-use the code, however, there are things to consider like is it worth it, first of all, a call to a function block will require more memory, if the function is complex & re-usable then ideal, however, if only a few rungs not worth it, for example if you have 3 inputs & one output but only 3 rungs of code then actually using it in a function is not worth it, the in/out parameters have to be passed to the FB as well as rerturned, so in effect, if you noly have 3 rungs of code then to call the function first it has to copy the in variables to the Block then process the code & return any result of an output as this would take at least 4 instructions to pass the variables then proicess the 3 rungs of code can actually make your processing time increase, if the FB is called as seperate instances then it is the same as writing the code in long hand plus the extra processing of passing the variables which although quicker to code increases the number of instructions many times. so unless the FB code is quite substantial then creating a single instance to be called many times makes sense but if not then don't bother.
 
More Old Guy History

We've done a lot of jail and prison work over 30+ years. Initially I was told 'Get serious Dave, prison guards can't use computers!'. A county jail decided to risk it. Still got our software in there 30 years later after 3 generations of touchscreen, plc, and computer hardware.

The first generation for many customers was Square D Symax followed by GE 90-30. Paper templates ran through a copy machine so I could fill in the addresses for similar doors. Not uncommon to see 1000+ rung programs. All the code and label typing was leading me to a mid-life crisis concerning my choice of profession.

Modicon Momentum was the first family we used with user-defined function blocks followed by newer GE stuff. Typically only two or three were needed. One for a slider or gate, one for a 'pop' lock, maybe one for a full cycle lock. Maybe another for an intercom station. Program printout sizes abruptly dropped by a factor of 10. The highly repetitive nature of corrections work makes it ideal for function blocks. Having said that - I agree that you aren't describing enough to make it worth the effort.

Function blocks got me over the midlife crisis thing. Now I can just define the interface to the block and let somebody else figure out the instances. Had a lot of jobs where most of the programming was done by a non-programmer type.

The design of the data interface to the corrections version HMI has been stable for most of the 30 years. PM me if you are interested in how we do it.
 
Man I would love to see a example of prison/courthouse work. The plc controls would be one thing, but the HMI interface is really new to me. So seeing some real examples would be awesome..
 
I was using FB's in the early 80's mainly siemens they were far ahead of the competition, I also did my own FB's of a sort on SLC, just had some variables (N & F & B files ) reserved for passing data to/from routines just the same really except you had to manually move them. saved quite a bit of memory, had one where 50 + valves & motors where pass the in/out to a common program block certainly better than copy & paste each one.
 
Function blocks got me over the midlife crisis thing. Now I can just define the interface to the block and let somebody else figure out the instances. Had a lot of jobs where most of the programming was done by a non-programmer type.


I wish a certain person at work, who's now retired, had had this kind of midlife crisis a couple of decades ago. LOL


I've seen plants with thousands of rungs all doing the same thing to different variables (always Rockwell for some reason) and people fighting me all the way about encapsulating stuff.

One tiny project I did on an S7-1200 where effectively I had 50 Alarms with latching and muting, I left a small bug behind to show my colleague the power of it... he was speechless. LOL



I also did my own FB's of a sort on SLC, just had some variables (N & F & B files ) reserved for passing data to/from routines just the same really except you had to manually move them. saved quite a bit of memory, had one where 50 + valves & motors where pass the in/out to a common program block certainly better than copy & paste each one.


I sometimes get the feeling I've seen your code... Last place I worked had a plant designed this way. It was horrendous to work with because no one commented the code. I gave it a go a few times, had a CPU hang up and couldn't figure out why so worked around it thinking the next big change would be a replacement. Clever stuff, really, but unless it's been documented somewhere it's a right pain to live with. Also, it heavily relied on Access for the FTView graphics to match up which was a pain to get hold of.
 
I very much doubt it, the ones in question were at a plant where I worked as the systems engineer, all those PLC's are still in place but not used, the company went into liquidation & the ones I did (SLC) were scrapped with the exception of two, those were both for data capture on the lines, originally programmed by a-another but I took them over & as one was virtually full that's when I did the subroutine & passed the variables, the routine communicated with 20 message displays to display the production rate & speeds etc. they are still in place but not used just powered down as the place was taken over but nearly all plant scrapped & replaced, I worked there for another 4 years but they never took out the SLC's for the data capture they are still in the roof voids.
 

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
120
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
297
Hi! I am using a TM200CE40T PLC from Schneider to write data over Modbus. I have used Memory words (%MW) before using the Write variable...
Replies
1
Views
537
Hi Yes, I'm stuck again. Trying to define a Function Block. What I've put in there so far has been a straight copy/paste from the code (and that...
Replies
22
Views
2,891
Hello, We have a startup valve, that has to open on startup etc. We also want to know the flowrate throughe valve. They told me that in previous...
Replies
17
Views
2,749
Back
Top Bottom