[Beremiz-devel] Array location assignment in matiec

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Beremiz-devel] Array location assignment in matiec

Beremiz-Devel mailing list

Hello,

I got stuck on the problem when I try to compile with matiec ST code that contains following instruction:
```
VAR P AT %IW0 : ARRAY [1..5] OF INT;
END_VAR
```

I add complete code of this test in attachements.

This code is compatible with 2nd edition of IEC 61131-3 standard and similar definitions can be found at 2.4.3.2, e.g. example 4 in Table 18.

So matiec report message is coming as follows:
```
error: Bit size of data type is incompatible with bit size of location.
```

After some debugging I found out that following error produced in matiec while parsing right part of assigment that represented as instance of `invalid_type_name_c`.

Can anybody explain me, is there any ways to use array location memory assignment with matiec? For example in CodeSys and some similar software exists some deviations from standard for similar definitions.

Or if this is buggy behavior, can I help with fixing it?

-- 
Best regards,
Georgy Komarov

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel

plc.st (368 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Array location assignment in matiec

Mario de Sousa



 Hi,


 Matiec does not support located variables of ARRAY data types.
 
 One reason for this is that I don't know what the expected semantics are.

> VAR P AT %IW0 : ARRAY [1..5] OF INT;
> END_VAR

The standard includes examples such as you mentioned, but never really
explains how an array of 5 INTS (total 5*16 bits) can be mapped onto an output
with 16 bits.

 What were you expecting to happen with the above declaration?

 We could invent some additional semantics that are not defined n the standard
 (example, map onto %IW0, %IW1, %IW2, %IW3, %IW4), but we never got around to
implementing this...


   Mario.





On Monday, May 07, 2018 16:09:55 [hidden email] wrote:

> Hello,
>
> I got stuck on the problem when I try to compile with matiec ST code
> that contains following instruction:
> ```
> VAR P AT %IW0 : ARRAY [1..5] OF INT;
> END_VAR
> ```
>
> I add complete code of this test in attachements.**
>
> This code is compatible with 2nd edition of IEC 61131-3 standard and
> similar definitions can be found at 2.4.3.2, e.g. example 4 in Table 18.
>
> So matiec report message is coming as follows:
> ```
> error: Bit size of data type is incompatible with bit size of location.
> ```
>
> After some debugging I found out that following error produced in matiec
> while parsing right part of assigment that represented as instance of
> `invalid_type_name_c`.
>
> Can anybody explain me, is there any ways to use array location memory
> assignment with matiec? For example in CodeSys and some similar software
> exists some deviations from standard for similar definitions.
>
> Or if this is buggy behavior, can I help with fixing it?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel
Reply | Threaded
Open this post in threaded view
|

Re: [Beremiz-devel] Array location assignment in matiec

Georgy Komarov
Hello Mario,

Thank you for your reply.

With following declaration I except that elements of array `P` will be
referenced to range of Input locations starting from %IW0, i.e.:

```
P[1] AT %IW0
P[2] AT %IW1
...
P[5] AT %IW4
```

In my Beremiz project I want to access a large number of Inputs to read
and process their current values inside ST code. E.g. there can be
regions of contiguous Input registers that contains about 100 addresses
per program for a few custom modules that I'm working on. The most
elegant solution I'm guessing is using arrays instead explicit variables
declaration that referenced to each register.

It also allows me to optimize C-code generation routines for my modules
to avoid redundant memory-copy operations to access number of PLC's
inputs for our protocols.

> The standard includes examples such as you mentioned, but never really
> explains how an array of 5 INTS (total 5*16 bits) can be mapped onto an output
> with 16 bits.
In standard there is following entry (Table 18, 4):

```
VAR OUTARY AT %QW6 :
     ARRAY[0..9] OF INT := [10(1)];
END_VAR

Declares an array of 10 integers to be allocated to contiguous output
locations starting at %QW6, each with an initial value of 1.
```

So I suppose this is exactly what I'm trying to do.

On 5/7/18 9:11 PM, Mario de Sousa wrote:

>
>
>   Hi,
>
>
>   Matiec does not support located variables of ARRAY data types.
>  
>   One reason for this is that I don't know what the expected semantics are.
>
>> VAR P AT %IW0 : ARRAY [1..5] OF INT;
>> END_VAR
> The standard includes examples such as you mentioned, but never really
> explains how an array of 5 INTS (total 5*16 bits) can be mapped onto an output
> with 16 bits.
>
>   What were you expecting to happen with the above declaration?
>
>   We could invent some additional semantics that are not defined n the standard
>   (example, map onto %IW0, %IW1, %IW2, %IW3, %IW4), but we never got around to
> implementing this...
>
>
>     Mario.
>
>
>
>
>
> On Monday, May 07, 2018 16:09:55 [hidden email] wrote:
>> Hello,
>>
>> I got stuck on the problem when I try to compile with matiec ST code
>> that contains following instruction:
>> ```
>> VAR P AT %IW0 : ARRAY [1..5] OF INT;
>> END_VAR
>> ```
>>
>> I add complete code of this test in attachements.**
>>
>> This code is compatible with 2nd edition of IEC 61131-3 standard and
>> similar definitions can be found at 2.4.3.2, e.g. example 4 in Table 18.
>>
>> So matiec report message is coming as follows:
>> ```
>> error: Bit size of data type is incompatible with bit size of location.
>> ```
>>
>> After some debugging I found out that following error produced in matiec
>> while parsing right part of assigment that represented as instance of
>> `invalid_type_name_c`.
>>
>> Can anybody explain me, is there any ways to use array location memory
>> assignment with matiec? For example in CodeSys and some similar software
>> exists some deviations from standard for similar definitions.
>>
>> Or if this is buggy behavior, can I help with fixing it?
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Beremiz-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beremiz-devel

--
С уважением,
Георгий Комаров
+7(916)454-52-67


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Beremiz-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beremiz-devel