<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Array</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5bbcd6d4fa/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5bbcd6d4fa/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/5bbcd6d4fa/</id><updated>2020-02-27T20:09:17.853000Z</updated><subtitle>Recent posts to Array</subtitle><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#1801" rel="alternate"/><published>2020-02-27T20:09:17.853000Z</published><updated>2020-02-27T20:09:17.853000Z</updated><author><name>drChiavo</name><uri>https://forge.codesys.com/u/drchiavo/</uri></author><id>https://forge.codesys.com239ee5fa063254abd58fe0f819412fd175a4529d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ljean hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
An alternative can be to use the VAR_CONFIG mechanism. Then you can create an array of blocks and assign each output to the physical output in the VAR_CONFIG variable list:&lt;br/&gt;
It would consist in something like:&lt;br/&gt;
1) Create a FB:&lt;br/&gt;
FUNCTION_BLOCK MyBlock&lt;br/&gt;
VAR_INPUT&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR_OUTPUT&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR&lt;br/&gt;
    MyBit AT %Q*: BOOL;&lt;br/&gt;
END_VAR&lt;br/&gt;
2) In you program you can declare:&lt;br/&gt;
PROGRAM PLC_PRG&lt;br/&gt;
    MyArray : ARRAY &lt;span&gt;[0..7]&lt;/span&gt; OF MyBlock;&lt;br/&gt;
END_VAR&lt;br/&gt;
3) In the var config you must do:&lt;br/&gt;
VAR_CONFIG&lt;br/&gt;
    PLC_PRG.MyArray&lt;span&gt;[0]&lt;/span&gt;.MyBit AT %QX0.0 : BOOL;&lt;br/&gt;
    PLC_PRG.MyArray&lt;span&gt;[1]&lt;/span&gt;.MyBit AT %QX0.1 : BOOL;&lt;br/&gt;
.....&lt;br/&gt;
    PLC_PRG.MyArray&lt;span&gt;[7]&lt;/span&gt;.MyBit AT %QX0.7 : BOOL;&lt;br/&gt;
END_VAR&lt;br/&gt;
I didn't test this code but I did something similar in the past and I think it should work!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And how can I use, for example this bit (PLC_PRG.MyArray&lt;span&gt;[0]&lt;/span&gt;.MyBit AT %QX0.0 : BOOL;) afterwards in function block or function?&lt;br/&gt;
Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#9f20" rel="alternate"/><published>2020-02-27T20:09:16.488000Z</published><updated>2020-02-27T20:09:16.488000Z</updated><author><name>ljean</name><uri>https://forge.codesys.com/u/ljean/</uri></author><id>https://forge.codesys.com38f19c01337fa48f499ea59801883d350667f346</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;An alternative can be to use the VAR_CONFIG mechanism. Then you can create an array of blocks and assign each output to the physical output in the VAR_CONFIG variable list:&lt;/p&gt;
&lt;p&gt;It would consist in something like:&lt;/p&gt;
&lt;p&gt;1) Create a FB:&lt;/p&gt;
&lt;p&gt;FUNCTION_BLOCK MyBlock&lt;/p&gt;
&lt;p&gt;VAR_INPUT&lt;/p&gt;
&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;VAR_OUTPUT&lt;/p&gt;
&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;VAR&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;MyBit&lt;/span&gt; &lt;span class="k"&gt;AT&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;Q&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;2) In you program you can declare:&lt;/p&gt;
&lt;p&gt;PROGRAM PLC_PRG&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;MyArray&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ARRAY&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="n"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;MyBlock&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;3) In the var config you must do:&lt;/p&gt;
&lt;p&gt;VAR_CONFIG&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PLC_PRG&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MyArray&lt;/span&gt;&lt;span class="p"&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;MyBit&lt;/span&gt; &lt;span class="k"&gt;AT&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;QX0&lt;/span&gt;&lt;span class="p"&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;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;PLC_PRG&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MyArray&lt;/span&gt;&lt;span class="p"&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;MyBit&lt;/span&gt; &lt;span class="k"&gt;AT&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;QX0&lt;/span&gt;&lt;span class="p"&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;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;.....&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;PLC_PRG&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MyArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;MyBit&lt;/span&gt; &lt;span class="k"&gt;AT&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;QX0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BOOL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_VAR&lt;/p&gt;
&lt;p&gt;I didn't test this code but I did something similar in the past and I think it should work!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#d069" rel="alternate"/><published>2020-02-27T20:09:12.794000Z</published><updated>2020-02-27T20:09:12.794000Z</updated><author><name>robkristiaan</name><uri>https://forge.codesys.com/u/robkristiaan/</uri></author><id>https://forge.codesys.com695f27dc1dfe41040adc0b94c382eca43a5ec6b6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;abOutp:array&lt;span&gt;[0..7]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;assign the outputs in abOutp&lt;/p&gt;
&lt;p&gt;then do this:&lt;/p&gt;
&lt;p&gt;byOutput.0:=abOutp&lt;span&gt;[0]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.1:=abOutp&lt;span&gt;[1]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.2:=abOutp&lt;span&gt;[2]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.3:=abOutp&lt;span&gt;[3]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.4:=abOutp&lt;span&gt;[4]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.5:=abOutp&lt;span&gt;[5]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.6:=abOutp&lt;span&gt;[6]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;byOutput.7:=abOutp&lt;span&gt;[7]&lt;/span&gt;;&lt;/p&gt;
&lt;p&gt;%QB1:= byOutput;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#ff18" rel="alternate"/><published>2020-02-27T20:09:11.480000Z</published><updated>2020-02-27T20:09:11.480000Z</updated><author><name>ndzied1</name><uri>https://forge.codesys.com/u/ndzied1/</uri></author><id>https://forge.codesys.com62e8490a3c4a6601d0092391a77f0ead0071e7fa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;For sure you can declare an array of bool without an address.&lt;/p&gt;
&lt;p&gt;You cannot, however, delcare an array of bool with a bit address.&lt;/p&gt;
&lt;p&gt;But, you can declare an array of bool with a byte address.&lt;/p&gt;
&lt;p&gt;In your example, you could declare the array&lt;/p&gt;
&lt;p&gt;OUTd AT %QB1 : ARRAY&lt;span&gt;[0..7]&lt;/span&gt; OF BOOL; &lt;/p&gt;
&lt;p&gt;So long as the actual address %QB1 exists, this should work fine.&lt;/p&gt;
&lt;p&gt;Maybe if you mention what you are actually trying to accomplish someone might have a way to do it already.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#148d" rel="alternate"/><published>2020-02-27T20:09:07.795000Z</published><updated>2020-02-27T20:09:07.795000Z</updated><author><name>Igor Petrov</name><uri>https://forge.codesys.com/u/igor-petrov/</uri></author><id>https://forge.codesys.com5dce25303506b7449dbd6af9c96370263c98dad4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;IMHO it is impossible to declare bit array in IEC (I know the solution with CoDeSys  3.1  but not with 2.3). You can only use bytes array. &lt;/p&gt;
&lt;p&gt;If you extreme need it then write special functions like  and . &lt;a class="" href="http://forum-en.3s-software.com/viewtopic.php?t=167&amp;amp;highlight=" rel="nofollow"&gt;See here the idea implementation example&lt;/a&gt; for inputs.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Array</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/5bbcd6d4fa/?limit=25#808c" rel="alternate"/><published>2020-02-27T20:09:06.482000Z</published><updated>2020-02-27T20:09:06.482000Z</updated><author><name>Paul</name><uri>https://forge.codesys.com/u/paul/</uri></author><id>https://forge.codesys.com3bacea24443ac0f608cfaeb27faf22d13d98080c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, I need to make array of output. &lt;/p&gt;
&lt;p&gt;Like: OUTd  AT %QX1.3 : ARRAY&lt;span&gt;[0..9]&lt;/span&gt; OF BOOL;&lt;/p&gt;
&lt;p&gt;This entry is not allowed. &lt;/p&gt;
&lt;p&gt;Start at address 1.3 …  &lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>