IL Guru Needed

W

Thread Starter

Willy Smith

Greetings!

I need to correspond with someone about 1131-3 IL. I am writing an IL compiler, and there are some things which are not clear to me from reading
the spec. For example, reference is made in section 2.4.1.2 to method of subscripting for IL:

"The form of subscripts in the IL language defined in subclause 3.2, and the graphic languages defined in clause 4, is restricted to single-element variables or integer literals." But I don't really see a good explanation
of this; the only reference I see for IL is hierarchical I/O addressing, which in my mind is not the same as an array. Besides, the hierarchical method doesn't seem to allow the use of variables in the notation.

Another point which doesn't seem obvious to me: is there an assumed "accumulator" in the processor model for each variable type? Or is there one "accumulator" for boolean, and one 64 bit "accumulator" that is used for the rest of the variable types? I'm wondering if execution of this code results in destruction of intermediate results for the INT value:


VAR I1,I2,I3: INT; END_VAR
VAR S1,S2,S3: SINT; END_VAR

LD I1
ADD I2
LD S1
SUB S2
ST I3
ST S3

I know that it is unlikely that anyone would want to write code with interspersed variable types, but I want my compiler to function according
to the spec. I'm hoping that someone out there knows enough about IL to comment. I have some other questions, but this will get me through some of the conceptual problems I'm having. Thanks in advance.

Cheers,

Willy Smith
Numatico, S. A.
Apartado 676-4005
San Antonio de Belén
Costa Rica
Tel +506.293.9943
Fax +1.413.332.0065
[email protected]
www.numatico.com
 
T

Toni Kaesbeck

Willy:

The IL in IEC 6111 assumes a "chamelon accumulator" . You can see that from the conversion functions, which are defined.

To make your compiler "according to the spec", the best thing you can do is to check out the compatibility spec's from PLCopen at http://www.plcopen.org . There you could also have a certification done and get sample programs for testing.

Toni

P.S. It's a fair piece of work (but I am sure you found that out already). Suggest you limit your first version to a limited set of data types you
support

This mail has been sent by:
Toni Kaesbeck
 
J

Johan Bengtsson

The subscript (the thing you place within the brackets) is restricted to the subtypes of ANY_INT (that is it have to be one of: LINT, DINT, INT, SINT, ULINT, UDINT, UINT, USINT). The array itself is another matter.

some way in in section 2.5.1.4 states:
"When all the formal input parameters to a standard funcion defined in 2.5.1.5 are of the same generic type then all the actual parameters shall be of the same type. If necessary,
the type conversion functions defined in 2.5.1.5.1 can be used to meet this requirement. the output value of the function shall then have the same type as the actual inputs..."

This basically mean, you are not allowed to mix types in ADD, SUB, etc. without doing type conversions first.


/Johan Bengtsson

----------------------------------------
P&L, the Academy of Automation
Box 252, S-281 23 H{ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: [email protected]
Internet: http://www.pol.se/
----------------------------------------
 
Top