S7-300/400:How do you return failure from Logic Blocks?

Genchan

Member
Join Date
Sep 2011
Location
Japan
Posts
18
You know, Step 7 has several ways to return results to caller block.

As I know,

1. RET_VAL
This can return value, but caller block must check it by comparator to confirm "success". I feel this is for returning error code.

2. OUT parameter
This can return value and UDT, but caller block must check it, too. I feel this is not for returning error code but for result of calculation.

3. ENO
This can return only Boolean. If the caller is written in LAD, Logic Blocks depending on the block will not be called on error, by putting depending Logic Blocks in the network sequentially.

I can not find out which is the best. And I think all of them can be ignored by caller Logic Block.

Please tell me, which do you use in your work?
 
return value and UDT?

your over complicating a PLC, as with your other thread, where you had the misconception that a PLC should be treated like a C++ program. It isn't a C++ program its a simple PLC.

A UDT is a mixture of data so you your reference above makes no sense.

A FC or FB can return the data as you wish as the programmer.

I never use the RET value (although some do), the ENO is only used if you plan to program in ladder and want to continue the rung after the block conditionally.
 
Use ENO via SAFE instruction. Put at bottom of called block and execute SAFE command on good condition. Otherwise it will be Off.
 
return value and UDT?

your over complicating a PLC, as with your other thread, where you had the misconception that a PLC should be treated like a C++ program. It isn't a C++ program its a simple PLC.

PeterW, I do not intend it here. I would like to know how seniors treat errors in Logic Blocks. If I have made you unpleasant, I apologize here.

Nick B, thank you for your opinion. I hope you to give me examples of "SAFE instructions", please.
 
You make your logic so that there can be no errors šŸ™ƒ Remember there really cant be many kind of errors pc programs can have.

Ps. he made mistake, its SAVE.

Code:
FUNCTION FC1

BEGIN

//some code here

set;
save;

END_FUNCTION
Would always set eno. If you want to use it to pass condition, you need to just have that logic instead of set.
 
Last edited:
PeterW, I do not intend it here. I would like to know how seniors treat errors in Logic Blocks. If I have made you unpleasant, I apologize here.

Nick B, thank you for your opinion. I hope you to give me examples of "SAFE instructions", please.


You haven't upset me it's just I think you have misconseptions on the use of a PLC. With 30 years experience of programming PLC's I hope I am senior enough to answer questions.

Maybe the question is not worded clearly, I don't know.

How do you return failure?

If you are talking about a fault in the code then the PLC will either crash or call the fault OB if you have enabled it.

If you are talking about a check failing, then you can create whatever you want, I would create an error byte and put in a number (0 = OK) and transfer that as an OUT.

My concern regarding your use of the UDT is this. A UDT is a number of differing data types that you can group together, like the control bits and status for a motor for wxample, to make it easier to manage your data structure. So when you say, I can return value and UDT, it doesn't make sense.

I understand English is not your first language and it must be difficult to get across what you want to ask at times, but if your question doesn't make sense then those parts should be clarified.

I'd ask you to write it in Japanese and I'd get my wife to translate, unfortunately she doesn't know technical English :)
 
Hi Genchan!
If you look f.x. at the communication FBs/SFBs from Siemens, you'll see there often is an output error flag, and an output status word. If the error flag is set, the error code can be found in the status word. I often use the same method myself.

+++++++

An other issue that comes to my mind is that the S7 CPU's will allow you to divide by 0 without stopping. This can be evaluated after the divide instruction and a strategy can be selected by checking one of the cpu status flags and do a jump (.... don't have S7 here...Alzheimer cannot help me either:unsure:...) was it JOS ? I'm sure you'll get the correct jump instruction from one of the other guys here soon.

Kalle
 
PeterW, I would like to say "UDT can be assigned to OUT parameter of a Logic Block" by using words "Returning UDT". I think the detail of "Return" is incorrect in this case.

I understood that most of seniors use ENO to report error to caller Logic Block.

Thank you for all.
 
PeterW, I would like to say "UDT can be assigned to OUT parameter of a Logic Block" by using words "Returning UDT". I think the detail of "Return" is incorrect in this case.

I understood that most of seniors use ENO to report error to caller Logic Block.

Thank you for all.
No, I have use the ENO as an error flag but I don't think the ENO was meant for that. I treat FBs and FCs differently. More often than not I try to mimmic the Allen Bradley equivalent function blocks like the MSG block. As stated above the usual way is to use an error bit and a return code, at least for FBs.

FCs use the RET_VAL to return a value. In this case I use the RET_VAL like a function return value in a C or C++ program.
 
Hi, Peter Nachtwey. In C or C++, ENO does not exist. I think ENO is corresponding "Exception in C++" and RET_VAL is corresponding "return value". If something is wrong in Logic Block (in cases of C++ Exception), it is more convenient to turn off ENO than using RET_VAL.
How do you think differences between FC and FB? I use FB rarely, I don't understand completely why FB exists. (I have been aware of some merits of FB.)
 

Similar Topics

Hey all, first time poster here. I am wondering if anyone has tried using a Keyence SR-X300 barcode scanner to a Micrologix 1400. Keyence sent...
Replies
0
Views
32
Hello everyone, One of our machine we use Siemens Cpu315-2dp. And this cpu communicate with 4 Lenze servo drives series 9300 via profibus. Also...
Replies
0
Views
179
Hi guys, I'm having problems converting WinAC (WinLC RTF F application) to S7 300 project based on CPU 319F-3PN or S7 400/416F-3PN. The problem is...
Replies
0
Views
615
Hello All I hope you are well and safe. I have a problem that I could use your appreciated input for: SW: SIMATIC MANAGER v5.5 SP3 HW1...
Replies
2
Views
1,228
Hi What stage of its life cycle, S7-300/400 controllers are at now? In my existing unit, we are using these controller and in near futher there is...
Replies
8
Views
7,072
Back
Top Bottom