Siemens S5-115U Function block problem.

R

Thread Starter

RENE VENTER

Dear List.

I replaced an Festo PLC system with a Siemens S5-115U, with a 941CPU. I added a new function for the machine whereby it will display a fault
number as soon as a fault occurs. I did this by using a FB, which looks as follows:

NAME: FAULTS
DECL:

A I 0.0 Automatic
A N I 0.1 Loader not at top position
J C =3D M000

I listed about 25 faults this way, and then it concludes like this:

M000: L KH 0001
T QB 25
BEU
It ends at M025 with a BE as the last part of the function block.

Now this works really fine. If a fault comes up, it gets transferred to the display (QB25), and everything is ok. The problem that I have is
that the PLC does not allow me to put too many lines in one function block, so I wanted to put in another FB in order to be able to put in
more possible faults. As soon as I did that, the program totally ignored the first FB, and jumped directly to the next one and displays the first
fault number in the FB, even if the conditions for the first scan is not even met. For example, the second FB looks something like this:

NAME : FAULTS2
DECL:

A I 0.0
AN I 2.0
JC=3DM000

and then later on:
M000 : L KH 0026
T QB 25
BEU
and so forth.

As soon as I put the PLC in run mode, it immediately displays a 26 on the display, even if the conditions is not true.

Can anyone help me to overcome this problem, so that I can use more than one FB to list and display the faults?
Thank you very much.
 
M

Michael Griffin

At 13:20 31/01/00 -0500, RENE VENTER wrote:
>I did this by using a FB, which looks as follows:
>
>NAME: FAULTS
>DECL:
>
>A I 0.0 Automatic
>A N I 0.1 Loader not at top position
>J C =3D M000
>
>I listed about 25 faults this way, and then it concludes like this:
>
>M000: L KH 0001
> T QB 25
> BEU
>It ends at M025 with a BE as the last part of the function block.
<clip>

If I understand what it is you want to do, then I would suggest re-writing it to something like this:
---------------------------------------------
L KH0001 ;First fault code
A I0.0 ;Fault code conditions
AN I0.1
JC =M0 ;Jump to end of block if fault conditions true.

L KH0002 ;Second fault code.
A Ix.x
AN I x.y
JC =M0
...more code...
...then finally...
L KH000 ;Default message (may be something other than 0)
M0: T QB25 ;Faults jump to here - this is the *only* spot where
;you transfer to your output byte.
BE ;This is the end of the function block.
---------------------------------------------
Note that the difference between your logic and what I have outlined is that each fault logic section operates by 1) load the fault code, then 2) test if the fault condition is true.
If the fault condition was not true, then the next fault condition gets loaded, replacing the previous one in ACC0. You end up doing extra
LOADS this way, but this instruction has a fairly low overhead and so won't be much of a burden. All the jumps point to the *end* of the block, where the final instruction transfers the result to the output byte. Also note that just before the jump label you need to load a default value to ensure that something predictable will get loaded into the output byte if there is no fault.

The limit you are seeing with your logic is not one of how many lines in a function block, rather it is how far you are allowed to jump. The
limit on a normal jump (e.g. JC) is if I remember correctly +/- 127 bytes. This is why you have a problem. The logic I have suggested should be shorter than what you are attempting, and may in itself solve your problem. If not, then you could quite easily introduce an intermediate jump in the middle of your logic structure. i.e.

---------------------------------------------
L KH0001 ;First fault code
A I0.0 ;Fault code conditions
AN I0.1
JC =M0 ;Jump to intermediate position if fault conditions true.

L KH0002 ;Second fault code.
A Ix.x
AN I x.y
JC =M0
...more code...
JU =M1 ;If there was no fault, then jump around next instruction.
M0: JU =M2 ;else, jump from this point to the end.
M1: NOP 0 ;This is just a dummy location.
...continue with more conditions, but these ones jump to M2
...then finally...
L KH000 ;Default message (may be something other than 0)
M2: T QB25 ;Faults jump to here - this is the *only* spot where
;you transfer to your output byte.
BE ;This is the end of the function block.
--------------------------------------------

You said you have 25 fault conditions. A good program size estimate would be 2 bytes per A or AN, 4 bytes for the L, and 2 bytes for the JC.
This would give about 10 bytes per fault condition, or about 250 bytes or more total (25 faults x 10 bytes). This means you will probably need at least one intermediate jump position, and possibly more.
Another possibility is to break the logic up into smaller sections (with each less than the maximum for a jump). Instead of intermediate jumps, you could terminate the logic right there if a fault occurs.

For example, instead of:
...more code...
JU =M1 ;If there was no fault, then jump around next instruction.
M0: JU =M2 ;Jump from this point to the end.
M1: NOP 0 ;This is just a dummy location.
...continue with more conditions, but these ones jump to M2

You could do this:
...more code...
JU =M1 ;If there was no fault, then jump around next instruction.
M0: T QB25 ;Write out the fault code
BEU ;and exit immediately.
M1: NOP 0 ;This is just a dummy location.
...continue with more conditions, and repeat the above as necessary.

Don't forget to make sure the last "T QB25" loads a default value if there are no faults present.
There are a lot of other ways to do this, but the above should work without requiring you to change your existing program too drastically or to use inverted logic.

When you attempted to create two function blocks, and if they both wrote to the same output byte without some sort of interlock, the second one will of course always over-ride the first. Your logic should be all in one function block, and it should keep the previous point in mind.

It would be possible to write a general solution which would be a function block which takes a word as a parameter and returns an integer
representing the number of the highest bit set (plus an offset to let you chain these blocks together). Your logic equations would then just use 'A', 'AN', etc. to set bits in the input word and get integers out. But that as they say is an exercise which can be left to the student (i.e. I can't remember what I did with it).

**********************
Michael Griffin
London, Ont. Canada
[email protected]
**********************
 
S

Slawomir Telman

Dear RENE VENTER,

I think you have one address (QB25) for display messages and you can display one massage at the same time (?). But if you make manager for
messages you will be able to display all messages, but one message at the same time only.
Furthermore you must have BEU after last condition.

For example:

Menage displays message
F 0.0 - pulse (blink) 1Hz
F 0.1 -auxiliary flag
F 0.2 - change display message

AN F 0.1
A F 0.0
= F 0.2
A F 0.2
S F 0.1
AN F0.0
R F 0.1

L FW 100
L KF 0
><F
JC =M000
L KH 0001
T FW 100
M000:

AN F 0.2
JC =M003
L FW 100
SLW
T FW 100 FY 101 & FY 100 (HB & LB) allows you manage 16 messages
JC =M002 ; 16th bits
JU =M003
M002: L KH 0001
T FW 100
M003;

alarm conditions
A I 2.0
AN I 2.1
A F 100.0 ; enable for display message 1
JC =M004 ; jump condition

Another conditions

Last condition
BEU;

M004 : L KH 0001
T QB 25
BEU
M005 L KH 0002
T QB 25
BEU
Another actions
Last action
BE

I hope my informations were helpfull for You.
Slav
 
P
You didn't tell us how you call the FBs. I don't think the first FB is ignored, but rather the output is overwritten by the second. The solution
that first comes to mind is to call the second FB only if the first FB returns no error (QB25=0). Why 26 is output? You probably did not include a
BEU or jump to end before the M000 label.

Regards,
Peter Kosin

Process control engineer
INEA d.o.o.
www.inea.si
 
W
Hello,

A FB does allow plenty of statements. Your original problem could be:
a.) jump instruction exceeds it's limits. You can only jump a certain words forward/backwards (I believe 128 words).
b.) The network gets too big for the editor.

In both cases split the FB in several networks, and you might have to use sublabels too continu the jump too extend the range of the jump.

Example:

A -CertainConditions
=3D -HelpFlag
JC =3DM001
some instructions here

M001: A -Helpflag=20
JC =3DM000


M000: the original label you want to jump to.
------------
The second problem is probably something with the way you call the your second FB. I suppose you did a JC (jump Conditional) instead of a JU
(jump unconditional).

For more questions, please mail to: listmana[email protected]


With kind regards, Mit freundlichem Gru=DF,
Met vriendelijke groeten, Bonne Salutions,

Wim Vrinds,
Software & commissioning engineer,
System Controls Division,
Stork

**************************************************
* +31 (0)162 575351
Fax mailbox: +31 (0) 20.8826.576 (preferred for unofficial documents)
Fax: +31 (0)162 575596
E-mail: [email protected]
Post address: Stork
Lissenveld 41
4940 VL Raamsdonksveer
The Netherlands
 
Top