Skip to content

PLCgen TwinCAT self-certification: variables from MAIN not recognized in FUNCTION

Test report

Tool Version
ESCET nightly-20241023-115319
TwinCAT v3.1 build 4020.56
Test suite v27

Setup of TwinCAT as described here: https://cstweb.wtb.tue.nl/4tc00/twincat/setup.html#twincat-install. Project generated as described here: https://eclipse.dev/escet/cif/tools/plcgen/twincat.html#twincat-usage.

Test case: iter_limit3_funcs_event.cif, iter_limit3_funcs_scope.cif, sync_events_funcs_event.cif, sync_events_funcs_scope.cif

Encountered errors

I get a long list of errors, all caused by variables declared in MAIN not being recognized in the two FUNCTIONs tryEvent_a_c and tryEvent_a_u. This is an example of the generated error messages:

  • Unknown type: '(a_x > 0)' in \Untitled1\POUs\tryEvent_a_c.TcPOU at line 30
  • Identifier 'a_y' not defined in \Untitled1\POUs\tryEvent_a_c.TcPOU at line 30
  • Identifier 'a_x' not defined in \Untitled1\POUs\tryEvent_a_c.TcPOU at line 30

The relevant piece of generated code is for the three errors above is

IF a_x > 0 AND a_y > 0 THEN
    edge_a := 0;
ELSE

The problematic variables are declared in MAIN as follows:

PROGRAM MAIN
VAR
    a_x: DINT;
    a_y: DINT;
    firstRun: BOOL := TRUE;
    loopsExhausted: INT;
END_VAR

Error seems to be independent from #1038 (closed).

Addresses #1020 (closed) #679

(Edit: clean format error messages.)

Edited by Martijn Goorden