<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Readable IO names</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/606ca945f1/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/606ca945f1/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/606ca945f1/</id><updated>2024-09-28T11:54:00.818000Z</updated><subtitle>Recent posts to Readable IO names</subtitle><entry><title>Readable IO names</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/606ca945f1/?limit=25#e67c" rel="alternate"/><published>2024-09-28T11:54:00.818000Z</published><updated>2024-09-28T11:54:00.818000Z</updated><author><name>TimvH</name><uri>https://forge.codesys.com/u/timvh/</uri></author><id>https://forge.codesys.com9407016fa7391fa8030bf18816a5e42b2ce7f57a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;IF you create an ENUM&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s"&gt;'qualified_only'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="s"&gt;'strict'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kr"&gt;TYPE&lt;/span&gt; &lt;span class="n"&gt;E_IO&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;FIRST&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;SECDOND&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;END_TYPE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should be able to access the array items like:&lt;br/&gt;
IOCard_OUTPUT&lt;span&gt;[E_IO.FIRST]&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Readable IO names</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/606ca945f1/?limit=25#a425" rel="alternate"/><published>2024-09-26T10:04:23.356000Z</published><updated>2024-09-26T10:04:23.356000Z</updated><author><name>george32</name><uri>https://forge.codesys.com/u/george32/</uri></author><id>https://forge.codesys.com141ecd1538934851e02f2808bfbb16674fcffecc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Folks,&lt;/p&gt;
&lt;p&gt;I have a quite basic understanding of how PLC programming works. However I keep getting stuck on 1 problem&lt;br/&gt;
I could not get my head around. &lt;/p&gt;
&lt;p&gt;The problem is as follow:&lt;/p&gt;
&lt;p&gt;I have a PLC with 60 IO (20 inputs, 40 outputs). Each IO is defined as a function block.&lt;br/&gt;
Furthermore I have an external IO card connected trough a CanBus connection.&lt;br/&gt;
This IO card has 4 analog input channels (USINT), 4 digital inputs (Bool) and 4, digital outputs (Bool)&lt;/p&gt;
&lt;p&gt;Because I have 2 different components which both has data have I made 4 arrays to store the data off every component in one variable. &lt;/p&gt;
&lt;p&gt;PLC_Input: Array &lt;span&gt;[1..20]&lt;/span&gt; of BOOL;&lt;br/&gt;
PLC_Output: Array &lt;span&gt;[1..40]&lt;/span&gt; of BOOL&lt;br/&gt;
IOCard_Input: Array &lt;span&gt;[1..8]&lt;/span&gt; of BOOL&lt;br/&gt;
IOCard_Output: Array &lt;span&gt;[1..4]&lt;/span&gt; of BOOL&lt;/p&gt;
&lt;p&gt;Because the control and reading of the different in and outputs is done by a TCP connection I want &lt;br/&gt;
to use some kind of enumeration or struct to give each index a name so that my main would be a little bit more readable instead of all the magic numbers. Also this would make my program more dynamic for the furter in case I need to changes some in the IO nummers.&lt;/p&gt;
&lt;p&gt;For example: pump is placed on the fysical terminal strip number place 54, which is the 3th output of the IO card in the program:&lt;/p&gt;
&lt;p&gt;if I am sending a message with value 54 I would like to control IOCard_Output&lt;a class="alink" href="/forge/talk-ru/3/"&gt;[3]&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If there is a solution or methode to get this done, I can eventually do the following in my main program:&lt;/p&gt;
&lt;p&gt;IOCard_Output&lt;span&gt;[Pump]&lt;/span&gt;. &lt;/p&gt;
&lt;p&gt;I have tried the following: IOCard_Output&lt;span&gt;[Pump - 51]&lt;/span&gt; with an enumration but this keeps raising an error&lt;/p&gt;
&lt;p&gt;I hope some of you could help me further with this problem. &lt;/p&gt;
&lt;p&gt;In gross lines: I want to couple all the different IO to a more readable name and this readable name should control the right Array index &lt;/p&gt;
&lt;p&gt;Thanks in advance,&lt;br/&gt;
George&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>