<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to OOP modeling with Oscat Network</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/</id><updated>2020-02-27T13:48:57.864000Z</updated><subtitle>Recent posts to OOP modeling with Oscat Network</subtitle><entry><title>OOP modeling with Oscat Network</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/?limit=25#e3d9" rel="alternate"/><published>2020-02-27T13:48:57.864000Z</published><updated>2020-02-27T13:48:57.864000Z</updated><author><name>Mox</name><uri>https://forge.codesys.com/u/mox/</uri></author><id>https://forge.codesys.comd64c7c2220c3cc322f39fb279b9a084df5059c65</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello scott and thanks for your reply.&lt;/p&gt;
&lt;p&gt;I moved the declaration of all variable from both methods Minor_meth and Primary_meth inside the FB Moxa_new_FB. And it works my object was filled correctly. &lt;br/&gt;
Thanks a lot scott.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br/&gt;
Mox.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>OOP modeling with Oscat Network</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/?limit=25#71c1" rel="alternate"/><published>2020-02-27T13:48:57.704000Z</published><updated>2020-02-27T13:48:57.704000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.come05c3d596cfa2e090dd741909321ee8fb1dc90ed</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;Variables defined in methods are temporary is scope.  As soon as the method ends, they disappear.  So in your new FB, the variables IP_CONTROL2_1 and Channel_1_P in Primary_meth and Minor_meth are actually temporary.&lt;/p&gt;
&lt;p&gt;Declare them in FUNCTION_BLOCK Moxa_new_FB instead.  Then they will maintain existence from PLC scan to PLC scan.&lt;/p&gt;
&lt;p&gt;(I learned this the hard way when I tried to declare a counter inside a method - always started at 0, incremented to 1 and repeated).&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>OOP modeling with Oscat Network</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/ed4ed57da4/?limit=25#4520" rel="alternate"/><published>2020-02-27T13:48:57.587000Z</published><updated>2020-02-27T13:48:57.587000Z</updated><author><name>Mox</name><uri>https://forge.codesys.com/u/mox/</uri></author><id>https://forge.codesys.comc21a4221c75347b2f136eba1827d26962f7b057a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am trying to model Ethernet switches (Moxa EDS-508), and remote I/O (Wago Coupler 750-352) with an OOP approach thanks to Codesys. I am a beginner in Automation in general. Firstly, I succeed to fill these objects with different information through Modbus/TCP Slaves. Which are present in the Codesys Device Tree.&lt;/p&gt;
&lt;p&gt;But I wanted to have more flexibility with the modeling. So I imported both libraries OSCAT BASIC v3.3.3 and OSCAT NETWORK v1.2 in Codesys v3.5 SP9.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://store.codesys.com/oscat-basic.html" rel="nofollow"&gt;http://store.codesys.com/oscat-basic.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://store.codesys.com/oscat-network.html" rel="nofollow"&gt;http://store.codesys.com/oscat-network.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;My client is the target PLC a Raspberry-Pi, and it sends a Modbus TCP/IP request to the server, a Moxa switch. The switch only works with FC4 and UDP doesn't seem to work. (Error of timeout,16#FF00, is returned).&lt;br/&gt;
I choose to make an ST FB based on MB_CLIENT, from Oscat Network. I will use it to read registers and fill the objects. Moreover, I decided to make different FB with different size of data output.&lt;/p&gt;
&lt;p&gt;Read_Channel_FB_0 reads a unique Modbus TCP/IP register and release a word output (data_out). It possesses two methods: Read_Parameters_Affec() and Data_Builder().&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=705248OSCAT4.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Read_Channel_FB_1 reads a Modbus TCP/IP register and release an array of two words output (data_out). It possesses two methods: Data_Builder() and Read_Parameters_Affec() (Same method as Read_Channel_FB_0).&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=868638OSCAT5.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A Moxa is modelled by a FB, and composed with two structures: REFERENCE TO Minor_Information, REFERENCE TO Primary_Information. The information represent data more or less important from the Moxa, so the request Modbus TCP/IP are not at the same speed rate between information. Plus Moxa_FB gets a FB_Init to initialize its parameters from a GVL.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=225312OSCAT3.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now we build the object Moxa in a program thanks to IP_CONTROL2, from Oscat Network:&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=153213OSCAT1.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;When I call the different Read_Channel_FB in a program, there is no error code. And the Moxa_FB is filled correctly.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=560936OSCAT2.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I wanted to add the Read_Channel_FB inside a new FB: Moxa_new_FB. There are two methods Primary_meth() and Minor_meth().&lt;br/&gt;
Plus I removed the use of a GVL for a FB_Init in this FB.&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=662915OSCAT6.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is the call in a program:&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="http://www.hostingpics.net/viewer.php?id=961404OSCAT7.png" rel="nofollow"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But the affection didn’t occur. And I don’t have any errors.&lt;/p&gt;
&lt;p&gt;I need help, can someone explain me why the object doesn't fill correctly??&lt;br/&gt;
Sorry for the length of the post, but I tried to explain as much as possible the project.&lt;/p&gt;
&lt;p&gt;Mox.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_705248OSCAT4.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_868638OSCAT5.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_225312OSCAT3.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_153213OSCAT1.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_560936OSCAT2.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_662915OSCAT6.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://img4.hostingpics.net/thumbs/mini_961404OSCAT7.png"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>