Loading application onto Controllino or Arduino Nano

Starting logi.CAD 3

Condition for an extended version of logi.CAD 3: You have already installed the required license.

  1. Go to the folder where you installed logi.CAD 3.

  2. Locate the file logiCAD3.exe to start logi.CAD 3 and double-click it.

  3. If you have installed one version of logi.CAD 3 only on your system, select the default workspace and click OK in the dialog.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg Mind the guidelines/recommendations for a workspace. Moreover, consider the guidelines/recommendations for projects that you are going to create in logi.CAD 3. See "Starting the development environment and the runtime environment" for those guidelines/recommendations.

  4. Only required at the first start of logi.CAD 3:

Creating project for target system

  1. In menu File or from the context menu within the project explorer, select New and Project...

  2. In the dialog, expand logi.CAD 3 Templates, select the corresponding project template and click Next >.
    The following instructions apply to the following target systems:

    Target system

    Select this project template:

    Controllino MINI

    Moving Light for Controllino MINI (provided under logi.CAD 3 Sample Projects for Hardware Connection)

    For the Controllinos of a different size, use the project templates provided for these sizes.

    Arduino Nano

    logi.CAD 3 Project for Arduino Nano V3

  3. On the next page, enter the project name, uncheck Use default location and enter a location outside the workspace, then click Finish.

    No blanks or special characters in project name and location

    Make sure that there are no blanks or special characters (such as umlauts, e.g. ä, ö, ü) in a project name and in the installation path. If anyway, logi.CAD 3 will not be able to load the application onto the PLC.
    For the paths and project names, letters A – Z or a – z, numbers 0 – 9, dots (character .), underlines (character _) and dashes (character -) are allowed. Examples for allowed project names: my.project, my-project, my_Project_01

    Result: The project is displayed within the project explorer. The existing ST-object program (in folder src) already contains a sample application for the corresponding target system. For example: The Arduino functions are used.

Entering definitions for target system within PLC-object

  1. Open the existing PLC-object controllinoMini or arduinoNanoV3.
    For Controllinos of a different size, open the corresponding PLC-object which the project is providing.

  2. Search for PARAMS in the opened editor for the PLC-object and enter the COM port determined earlier behind "port": (this is necessary twice).

    Example for specifications, if you use a Controllino MINI on COM port '3'
    {
    TARGET targetControllinoMINI
    PARAMS := '{
    "transport": {
    "type": "RS232",
    "parameters": {
    "port": 3,
    "baud": 115200
    }
    },
    "infrastructure": {
    "programmer": "AVRDUDE",
    "parameters": {
    "port": 3,
    "baud": 115200,
    "programmer": "arduino",
    "processor": "atmega328p"
    }
    }
    }';
    END_TARGET
    }
  3. Save the PLC-object.

Loading application onto target system and testing

  1. Open the perspective Application Testing: menu Window, Open Perspective and Application Testing

  2. Load the application onto the Controllino of size MINI as follows: In the Instance view, select ControllinoMINIConfiguration\controllinoMINI. First click images/download/attachments/405733746/ConnectToPLC-version-1-modificationdate-1529910447299-api-v2.png and then images/download/attachments/405733741/LoadProgram-version-1-modificationdate-1529910412582-api-v2.png .
    For the Controllinos of a different size or for Arduino Nano: Click the item which is provided for the corresponding target system in the Instances view.

  3. Recommended: Make sure that the connection state Online and the execution state Running is displayed.
    If the execution Error or Gateway does not reach PLC is displayed, see "Faulty state and no connection to Controllino or Arduino Nano possible" for causes and solutions.

These steps conclude the tutorial to put a →Controllino or an →Arduino Nano into operation. The following section might be of interest to you, if you want to address functionality of the target system that is not addressed by the system blocks of logi.CAD 3.

Example: Reading analog values in by using a C++-block

This example illustrates how a C++-block calls the required Arduino functions.

  1. In an ST-object, declare a data type with named values in order to represent the pin. The pins provided at the hardware can be deduced from the pinout of the Controllino: https://controllino.biz/controllino/downloads/

    Example for data type with named values
    TYPE
    ControllinoMiniAnalog : USINT(A0 := 14,
    A1 := 15,
    A2 := 16,
    A3 := 17,
    A4 := 20,
    A5 := 21
    );
    END_TYPE
  2. Create the interface for a C++-block (context menu in the project explorer, command New and ST-Interface, define the required ST-interface for the C++-block and save this ST-interface.
    Details: see "Creating the interface for a C-block or C++-block (deprecated)"

    Example for ST interface
    { extern_cxx }
     
    FUNCTION AnalogRead : UINT
    VAR_INPUT
    pin : ControllinoMiniAnalog;
    END_VAR
    END_FUNCTION
  3. Set the correct build configuration for the project and create the required code in the C++-block. Details: see "Entering code within the C-block or C++-block (deprecated)"

    Example for code
    #ifndef LC_PROT_LCFU___ANALOGREAD__C
    #define LC_PROT_LCFU___ANALOGREAD__C
     
    #include <lcfu___analogread.h>
     
    #include <Controllino.h>
     
    /* Functions */
    void lcfu___ANALOGREAD(LC_TD_Function_ANALOGREAD* LC_this, LC_TD_DataType_CONTROLLINOMINIANALOG LC_VD_PIN, struct _lcoplck_epdb_1_impl* pEPDB)
    {
    LC_this->LC_VD_ANALOGREAD = analogRead(LC_VD_PIN);
    }
     
    #endif

    The pin numbers of the relevanten pin of the Controllino can be deduced from the header file Controllino.h. In order to view the content of this file, integrate it e.g. into the C++-code (= line #include <Controllino.h>). Afterwards position the cursor onto this line and press the F3-key.

  4. In the main program (e.g. a ST-program), create the code so that the reading of the analog value is done cyclically.

    Example for ST-program
    PROGRAM Program1
    VAR
    analogValue : UINT;
    END_VAR
    analogValue := AnalogRead(ControllinoMiniAnalog#A0);
    END_PROGRAM