The dos and don'ts when working

This article contains a summary of the items that you must observe when working with logi.CAD 3:

If you need details on any item, click the link listed to the right of the item. This takes you to an article that usually contains a warning or a note (identified by icon images/download/thumbnails/414778331/ConfluenceWarning-version-1-modificationdate-1534246167423-api-v2.png or images/download/thumbnails/414778336/ConfluenceNote-version-1-modificationdate-1534246187230-api-v2.png ) specifying the item.
If you have more questions regarding an item and there are no information to be found in the user documentation of logi.CAD 3, contact the support team of logi.cals.

Other useful links:

step-by-step instructions
from installing until testing your first application

Tutorials

other actions

Reference documentation

fast searching within the user documentation

Where to quickly find a certain command?


When installing

Observe:

Details under:

no special characters in installation path of logi.CAD 3

Installing

no installation path incl. compiler path with more than 255 characters

Installing

Additionally, observe for target systems:

if Raspberry Pi is used as PLC:

version for →runtime system to be installing

Hardware/Software required for tutorial

if a 64 bit system of Linux is used as operating system:

have certain commands executed in a terminal window

64 bit linux

When starting

Observe:

Details under:

allowing access when Windows security alerts are displayed

Starting the development environment and the runtime environment

enter a new workspace per start of logi.CAD 3 (outside the installation directory of logi.CAD 3)

Starting the development environment and the runtime environment,
Choosing and switching workspace

start logi.CAD 3 in another language

How do I change the language for the user interface?,
Elements and messages in German language after start

When creating projects

Observe:

Details under:

no blanks or special characters in project name and location

Creating new project

do not create projects in the workspace

Creating new project

linked folders become "real" folders after importing

Importing project

When working in the project explorer

Observe:

Details under:

do not manipulate →libraries

Project explorer to manage project

do not change file extensions

Renaming resources

do not export linked folders to archive files

Exporting resources

modifications outside logi.CAD 3 make "Refreshing" necessary

Viewing state information on PLC,
When is the application loaded onto PLC out-of-date?

Show the folders src-gen or target only if you need to solve a problem.

for general information: Project explorer to manage project
for instructions to show the folders: Are my projects upwards and downwards compatible?

When creating the application

General programming guidelines

No identification of infinite loops and missing abort conditions respectively

Infinite loops as well as missing abort conditions are not identified by logi.CAD 3. Provide correct abort conditions (e.g. by using IF-statements) to prevent infinite loops.

Example for infinite loop without abort condition

Example for infinit loop with an abort condition

PROGRAM Test1
MyFun(1);
END_PROGRAM
 
FUNCTION MyFun
VAR_INPUT
In : INT;
END_VAR
 
MyFun(In + 1);
 
END_FUNCTION

If you load such applications onto the PLC anyway, the →runtime system might be terminated. In this case, a window with the following text appears: RTSLoader.exe stopped workingSolutions are listed in the troubleshooting article: PLC cannot be addressed. The runtime system is slow to respond or does not respond at all.

PROGRAM Test1
MyFun(1);
END_PROGRAM
 
FUNCTION MyFun
VAR_INPUT
In : INT;
END_VAR
IF In < 10 THEN
MyFun(In + 1);
END_IF;
END_FUNCTION

No check of recursions

Recursions for →functions and →methods are not forbidden or checked by logi.CAD 3 . Nevertheless, do not call a function/method from within itself and avoid 2 (or more) functions/methods calling each other (= mutual recursion) within your application.
Mind that recursions of functions/methods might cause unexpected results when your application is executed. For example, the application might be executed in an infinite loop and/or the →runtime system might not respond anymore.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg In contrast to this, recursions for →function blocks are recognized and highlighted as faulty.

When creating the application in ST

Observe:

Details under:

no check of invalid connections by logi.CAD 3

(e.g. when using the numeric functions, such as the EXPT block, or when using the MUL_TIME block)

Numeric functions
(e.g. EXPT block and MUL_TIME block)



do not use keywords for identifiers

Reserved keywords in ST

ST-elements, supported at present

articles within section "Supported ST-syntax"

Expressions with more than 20 operands/operators influence the performance.

Expressions in ST

no detection of mathematical errors when assigning expressions

Expressions in ST

The following ST-elements are supported with restrictions:

  • directly derived data types (e.g. max. levels for nestings)

  • array data type (no reference types, array data types with up to 4 dimensions,
    no validation when using variables and/or operators for array subscripts)

  • structured data type (no initialization for function blocks, no references to function blocks)

  • array variables (see array data type)

  • reference variables (e.g. no references to a type of a function block)

  • CASE statement (only expressions of ANY_INT for the selector)


a collection of things when using in-out variables (= VAR_IN_OUT)

Declaration of in-out variables in ST

In case of STRING variables:

  • maximum length = 32.767

  • Character combination '$00' terminates the character string of a STRING variable.

Declaration of STRING variables (incl. access)

no identification of infinite loops in case of REPEAT and WHILE statements

WHILE statement in ST, REPEAT statement in ST

The following data types are not supported:

LTIME , WSTRING , WCHAR , LDATE_AND_TIME , LTIME_OF_DAY und LDATE

→generic data type

inaccuracies for floating-point numbers (REAL and LREAL values)

Supported data types (in ST)

Depending on the used target system:

Observe:

Details under:

Other provided system blocks:

  • target-system-depending blocks

  • more system blocks

When creating the application in FBD

Observe:

Details under:

possible to declare one POU within an FBD-object

Creating POU in FBD

other displayed colors for data types and/or other displayed FBD-elements (as illustrated in the IDE documentation)

Color and style for FBD-elements determined by data type

Also, observe the items under " When creating the application in ST ". These might be relevant for a FBD-logic, too.

When creating the application in LD

Observe:

Details under:

possible to declare one POU within an LD-object

Creating POU in LD

contacts/coils that are not provided in functions

Contacts in LD und Coils in LD

Also, observe the items under " When creating the application in ST ". These might be relevant for a ladder diagram, too.

When creating blocks with C-code

Possible problems for an application due to name conflicts in the C-code (e.g. in case of vendor blocks and import of a Simulink model).

If you are using not-unique names in the →C code and they are available in the global namespace, conflicts might be caused when using several blocks with such C code. However, these conflicts may not cause errors/warnings when building the application. As a result, the runtime behavior might be affected in an undesirable way.
Example: The Values of Variables view displays 2 variables to which the return value of POU1 an POU2 respectively has been assigned. The value for Program1.rc2 displays the unexpected value 1 while the value 2 is actually assigned in the C-code. The problem is caused due to the same name RESULT within the C-code of the 2 vendor blocks POU1 and POU2.
images/download/attachments/486703346/NameConflict01-version-1-modificationdate-1644238179360-api-v2.png

Additional information: This problem is valid for:

Workaround 1: Use POU-unique names (when possible, project- and POU-unique) for all C-identifiers that are available in a global namespace. If you are importing a Simulink model, the best practice is to use the unique names already in the Simulink model.
Workaround for the above example: Now the Values of Variables view displays the expected value 2 for Program1.rc2 because POU-unique names have been used within the C-code.
images/download/attachments/486703352/NameConflict02-version-1-modificationdate-1644238318505-api-v2.png

Workaround 2: If you provide the blocks with C-code in a library, specify the blocks in the library configuration with DEPLOY:=OBJECT (see under " Declaration of the contents of the library " for details on DEPLOY:=OBJECT ). As a result, the binary code for the POU is built separately when the library is created.

Used system blocks

Accuracy and behavior of mathematical functions

Mathematical functions that are processing floating-point numbers (REAL, LREAL) might return different results on different target system s – in particular, if the result of the function is located within the threshold of the data type. These different inaccuracies of the mathematical functions is caused by the following factors:

  • the →target system itself,

  • the compiler used for the target system and

  • the configured optimization flags for the compiler.

Do not use blocks/variables with LREAL for Controllino or Arduino Nano

If you create an application for a →Controllino or an →Arduino Nano, avoid the usage of blocks/variables processing/returning LREAL values. The usage of such blocks/variables is possible but the LREAL values are processed with the accuracy of REAL values.

Observe that the DIV_TIME block is internally always using LREAL values.

Behavior of convert blocks in case of a range of values not overlapping

TRUNC blocks and other convert functions with a REAL/LREAL input might return different results for different compilers and on different target system s as well, if the connected value is not within the range of values overlapping for the data type of the input and for the data type of the return value . These different results are caused by the following factors:

Therefore, enter code in your application to detect when the range of values is not overlapping (e.g. IF-statements in the ST-code). See under "Convert functions" and "ConvertEnh functions" which of the convert functions provide a REAL/LREAL input.

Known examples:

Target system

Result of the mathematical function TRUNC_DINT(REAL#3.402823466e+38);

→logi.RTS for Windows

-2147483648

→Raspberry Pi

2147483647

RTOS32 compiler

-2147483648

The RTOS32 compiler reports an error in case of a specific division.

If you are using the RTOS32 compiler, avoid a specific division (see the following example) in your application.

Example for ST-code
PROGRAM Program1
DIV(DINT#-2_147_483_648, DINT#-1);
END_PROGRAM

When building the application, the compilers report the expected warning overflow in constant division, undefined behavior. But the RTOS32 compiler also reports an error divide or mod by zero. Other compilers do accept the code – only the mentioned warning is reported. To avoid the reporting of the error when using the RTOS32 compiler, do not use a division with the above-mentioned negative integers.

Observe:

Details under:

system blocks based on the →IEC-standard but with restrictions:

  • bitstring functions: SHL, SHR, ROL, ROR

  • compare functions: EQ, GE, GT, LE, LT, NE

  • convert functions: TO_BOOL, TO_DWORD, TO_LREAL, TO_LWORD, TO_REAL, TO_TIME, TO_WORD

  • numeric functions: ADD, DIV, EXPT, MOD, MOVE, MUL, SUB

  • select functions: LIMIT, MAX, MIN, MUX_BYTE, MUX_DINT,
    MUX_DWORD, MUX_INT, MUX_SINT, MUX_UDINT,
    MUX_UINT, MUX_USINT, MUX_WORD, SEL

  • string functions: CONCAT, DELETE, FIND, INSERT, LEN, LEFT, MID, REPLACE, RIGHT

  • time functions: ADD_TIME, CONCAT_DATE_TOD, MUL_TIME, SUB_DT_DT, SUB_TIME


system blocks based on the →IEC-standard but with enhancements:

  • bitstring functions: ROL , ROR , SHL, SHR

  • convert functions: TO_BOOL, TO_BYTE, TO_DINT,
    TO_DWORD, TO_INT, TO_LINT, TO_LREAL, TO_LWORD,
    TO_REAL, TO_SINT, TO_UDINT, TO_UINT, TO_ULINT,
    TO_USINT, TO_WORD

  • counter function blocks: CTD_UINT, CTU_UINT, CTUD_UINT

  • numeric functions: EXPT

  • select functions: MUX_BYTE, MUX_DINT, MUX_DWORD, MUX_INT, MUX_SINT, MUX_UDINT, MUX_UINT, MUX_USINT, MUX_WORD

system blocks in addition to the →IEC-standard:

  • enhanced bistable function blocks

  • enhanced bitstring functions

  • enhanced control function blocks

  • enhanced convert functions

  • enhanced numeric functions

  • enhanced select functions

  • enhanced timer function blocks

  • enhanced memory functions

When defining settings for the PLC

Observe:

Details under:

max. 32 tasks per resource

Declaring more tasks within PLC-object

restrictions when scheduling several program types

Assigning more program types (= creating new instances)

restrictions for VAR_CONFIG sections

Declaring VAR_CONFIG sections within PLC-object

When testing the application

Observe:

Details under:

display in Instances view: just base type for array variables

Inserting variables and monitoring values

changing value for variable ≠ forcing

Changing the values of variables: writing values to PLC

used target system might influence literals entered/displayed in logi.CAD 3

Testing the application or debugging the data

Additionally, observe for target systems:

default timer resolution for most Linux operating systems

Entering cycle time within PLC-object

When debugging the application

Observe:

Details under:

  • Debugging is only possible for applications loaded onto the built-in PLC.

  • Changes of the source files (during a debugging session) might cause unexpected jumps within the debugging session.

Control flow debugging: Debugging the application by setting breakpoints

  • The debugging session must be terminated, before logi.CAD 3 is terminated.

  • Terminating the debugging session makes the built-in PLC stop.

Terminating the debugging

When creating the application in →C or →C++

Observe:

Details under:

when creating projects, use different position for C/C++ projects

Die gleiche Positon für C-/C++-Projekte bzw. andere Projekte verursacht Probleme

  • Changed interfaces for C-/C++-functions without performing adjustments will cause errors when the application will be loaded onto PLC.

  • Do not enter comments in C++ style within a C-block.

When using the Raspberry Pi

Observe:

Details under:

requirements for SD card

Hardware and software required for Raspberry Pi tutorial

version for runtime system to be installed

Hardware and software required for Raspberry Pi tutorial

power supply for Raspberry Pi

Assembling Raspberry Pi and detecting IP-address

activated default locale en_GB.UTF-8 UTF-8

Configuring Raspberry Pi

in case of data transfer via MQTT: controlling the connection for TCP port

Preparing/Realizing the data transfer via MQTT

default timer resolution for most Linux operating systems (e.g. Raspbian)

Entering cycle time within PLC-object

When accessing hardware IOs via EC-Master and EC-Engineer

Observe:

Details under:

when preparing the environment: conditions for the network interface card

Preparing environment for accessing hardware IOs

installing runtime system under Windows (contains an evaluation version of EC-Master)

Preparing environment for accessing hardware IOs

do not change the resource-global variables

Accessing hardware IOs via EC-Engineer

When changing the layout

Observe:

Details under:

different steps for moving/docking views/editors
(if they are outside of logi.CAD 3)

Moving or docking views and editors,
Window has disappeared after moving

Performance

Observe:

Details under:

in case of performance issues

What do to increase the performance?