<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Struct FB Input, type coercion</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/68fa79ca81/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/68fa79ca81/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/68fa79ca81/</id><updated>2021-10-23T12:16:23.393000Z</updated><subtitle>Recent posts to Struct FB Input, type coercion</subtitle><entry><title>Struct FB Input, type coercion</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/68fa79ca81/?limit=25#48ae" rel="alternate"/><published>2021-10-23T12:16:23.393000Z</published><updated>2021-10-23T12:16:23.393000Z</updated><author><name>somlioy</name><uri>https://forge.codesys.com/u/somlioy/</uri></author><id>https://forge.codesys.com832309f08843a09e0367ff377e5bc8102c8b3f5a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I have 16 modbus slaves which have an idiotic modbus register layout, so I can't do 1 single query for several registers, but 1 query for each register I want.&lt;/p&gt;
&lt;p&gt;This means I have to do a lot of manual mapping on the function block for the devices, usually I have 2 variables per device like this, which are mapped to the modbus data:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;VAR_INPUT   &lt;/span&gt;
&lt;span class="err"&gt;    awDataIn            : ARRAY[0..20] OF WORD; &lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;span class="err"&gt;VAR_OUTPUT&lt;/span&gt;
&lt;span class="err"&gt;    awDataOut           : ARRAY[0..5] OF WORD;&lt;/span&gt;
&lt;span class="err"&gt;END_VAR&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And the arrays are mapped internally in the function block.&lt;/p&gt;
&lt;p&gt;Since I cant do this with the stupid modbus slaves, I was thinking I could pass the modbus struct directly to the function block instead, however, each modbus device will have their own struct (typPump_1_tcp, typPump_2_tcp etc...), but with the same content. These structs are created automatically in e!cockpit by the modbus configurator.&lt;/p&gt;
&lt;p&gt;How can I have an "universal" input on my function block and do some sort of type coercion on the modbus structs?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>