<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/</id><updated>2020-02-27T14:25:41.378000Z</updated><subtitle>Recent posts to Return a value in FBD POU-Function</subtitle><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#5ca4" rel="alternate"/><published>2020-02-27T14:25:41.378000Z</published><updated>2020-02-27T14:25:41.378000Z</updated><author><name>cassiel</name><uri>https://forge.codesys.com/u/cassiel/</uri></author><id>https://forge.codesys.com48dda6e010a996cadcb67dfa440be130c9bd12f1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks a lot Josep and scott_cunningham for your hints! now I undertsand how to do a function that returns a value in FBD &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#b6f7" rel="alternate"/><published>2020-02-27T14:25:39.980000Z</published><updated>2020-02-27T14:25:39.980000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com3a614cc016adaf084ad84657f4b4f04afd1ac23a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;Thanks Josep - I forgot to mention using the function name for the return...&lt;/p&gt;
&lt;p&gt;&lt;a class="user-mention" href="/u/cassiel/"&gt;@cassiel&lt;/a&gt; Here is what your function should look like in FBD:&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: funct" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2953"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#e321" rel="alternate"/><published>2020-02-27T14:25:39.517000Z</published><updated>2020-02-27T14:25:39.517000Z</updated><author><name>josepmariarams</name><uri>https://forge.codesys.com/u/josepmariarams/</uri></author><id>https://forge.codesys.com054026497ac73d5786bad2143fdbb968a99ed30a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Use&lt;/p&gt;
&lt;p&gt;MyFunc:=ret_value&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#b6e2" rel="alternate"/><published>2020-02-27T14:25:39.064000Z</published><updated>2020-02-27T14:25:39.064000Z</updated><author><name>cassiel</name><uri>https://forge.codesys.com/u/cassiel/</uri></author><id>https://forge.codesys.com3fe4b911815da64ce7105e336e23ec3a18d80af1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;scott_cunningham hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
RETURN is a keyword for exiting a POU early, not for returning values like you find in other languages. In your example, the lines of code in your POU will be executed, ret_sum will be filled and you can access this value in your other POU that called the FB instance.  VAR_OUTPUTs automatically work - just put a value into the variable.&lt;br/&gt;
PLCopen Programming guidelines recommends to not use the RETURN command.  You can read more about it in the guidelines.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks a lot for your answer scott_cunningham, I downloaded PLCopen Programming guidelines and I start to study.&lt;br/&gt;
I understand the use of return in a Program or in a Function Block, but it's still not clear for me how to return a value in a Function (that returns a value e.g. INT) in FBD language.&lt;br/&gt;
In my first example I did an error adding the Var_Output ret_sum, now my FBD box that represent my function have 2 output ,the returned value of the function itself and the output variable ret_sum.&lt;br/&gt;
What I try to do is a pure function that returns a INT value and I want, for example, call this function in a Program. &lt;br/&gt;
I attach the new example but something is surely wrong,in fact when I go in simulation mode my function return alway 0 (and not 3+2=5) when I call it from my Program PLC_Prg. &lt;br/&gt;
I'm almoust sure that this happens because I don't know how set the returned value in a Function in FBD language.&lt;br/&gt;
I try to find this information in Codesys help without success, sorry.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: return_function.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2947"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#971c" rel="alternate"/><published>2020-02-27T14:25:37.748000Z</published><updated>2020-02-27T14:25:37.748000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com619dd1746c7b631ae05f19c642604962c48dd7b2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;RETURN is a keyword for exiting a POU early, not for returning values like you find in other languages. In your example, the lines of code in your POU will be executed, ret_sum will be filled and you can access this value in your other POU that called the FB instance.  VAR_OUTPUTs automatically work - just put a value into the variable.&lt;/p&gt;
&lt;p&gt;PLCopen Programming guidelines recommends to not use the RETURN command.  You can read more about it in the guidelines.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Return a value in FBD POU-Function</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fa9f13aa28/?limit=25#933d" rel="alternate"/><published>2020-02-27T14:25:37.332000Z</published><updated>2020-02-27T14:25:37.332000Z</updated><author><name>cassiel</name><uri>https://forge.codesys.com/u/cassiel/</uri></author><id>https://forge.codesys.com09fb9648ec24f886132634792bdb8ad98fceb9bf</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Good morning to all, &lt;br/&gt;
I'm new and I'm starting to study the FBD language in codesys, I have a big doubt:&lt;br/&gt;
I understand that the RETURN command in FBD stops the execution of a POU.&lt;br/&gt;
If I create a POU-function that returns a value, such as a function that takes two INT inputs and returns their sum, how can I return a result?&lt;br/&gt;
For example In the example I attach, I would like to return the value of ret_sum.&lt;br/&gt;
I think that:&lt;br/&gt;
true --- RETURN&lt;br/&gt;
Is not correct.&lt;br/&gt;
Thanks to who will respond.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: return_in_fbd.png" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=2916"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>