PLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

Installing PC Worx Target for Simulink 1.4x

Beginning with version 1.40, the PC Worx Target for Simulink installer does not contain PLCnext SDKs any more, but comes with the PLCnCLI that accompanies the PLCnext Runtime System. The required SDKs need to be installed manually using the PLCnCLI, and registered to MATLAB/Simulink.

Requirements

From The Mathworks, Inc.:

  • MATLAB® Simulink®
    • for Target v1.40: MATLAB® releases R2016a … R2019a
    • for Target v1.42: MATLAB® releases R2017a, R2018a, R2019a only
  • MATLAB® Coder
  • Simulink® Coder

Phoenix Contact download links

  1. PC Worx Target for Simulink
  2. PLCnext Engineer, the PLCnext Technology Engineering environment
  3. For use with Target v1.40 only: PLCnCLI, the PLCnext Command Line Interface
  4. SDK according to your PLCnext Control:

Note: Make sure to take always that version of PLCnext Engineer/SDK/PLCnCLI that matches the firmware version on your PLCnext Control

Installation

Install PC Worx Target for Simulink

  1. Make sure the above requirements are met
  2. Close all running applications
  3. Install PLCnext Engineer, if not already present
  4. Execute the PC Worx Target for Simulink installer
  5. In the Setup Wizard, choose "Custom setup"
  6. For Target v1.40, deselect the whole "PLC" branch:
    Custom Setup dialog v1.40 For Target v1.42, deselect the whole "PC Worx..." branch but keep the "PLCnext Engineer" branch selected:
    Custom Setup dialog v1.40
  7. In the "MATLAB/Simulink" branch, deselect the "RFC..." classic controller entries
  8. Continue the installation with "Next" and follow the on-screen instructions
    → The HLLI firmware library is automatically installed into the user directory of PLCnext Engineer

Install the SDK for your PLCnext Control

Note: Manual PLCnCLI installation is only necessary in combination with Target for Simulink v1.40.
With Target for Simulink v1.42, PLCnCLI is part of the installation package, and if already installed, it will be automatically updated to the latest version.

  1. Install PLCnCLI, if not already present. Note: In case you need to take another destination path or want to make the SDK available throughout MATLAB, set that path to the PLCnCLI up as a system environment variable in the Advanced System Settings of Windows. Check the correct setup by issuing where plcncli in the command line.
  2. From the command line, issue this command for the PLCnext Control model(s) you want to use with Simulink:
    plcncli install sdk -p "path-to.tar.xz" -d "destination-path" Note: The should be as short as possible, e.g. "C:\PLCnextSDK\". The SDK packages tend to have long names including the firmware version, so keep the path for unpacking as short as possible for not exceeding the maximum path length of Windows which is limited to 255 characters.
  3. Restart MATLAB
    → The directory name appears in the target drop-down list. The installed SDKs will be listed in the model configuration.

Configure the SDK for the Simulink model

  1. Start Matlab and create an empty model
  2. Open the model configuration dialog and select the system target file "pxc_hlli.tlc" and apply.
    Model Configuration 1
    (The view might differ depending on your Matlab version)
    → The configuration dialog should be extended automatically with several "HLLI" configuration pages in the Code Generation section.

  3. In the section "HLLI Target Settings" you will find the targets as listed in the PLCnCLI view: select the SDK which shall be used.
    Model Configuration 2

Troubleshooting

The target selection is described in the documentation, but may lead to some confusion because there is only one system target file for all Phoenix Contact controllers, both PLCnext Control targets and classic PLC targets.

  1. In the Windows command line tool, switch to a directory other than the installation directory of the PLCnCLI and issue the command where plcncli.
    → The installation directory is displayed. If no directory is shown the installation directory of the PLCnCLI must be added to the system environment "PATH" variable by means of the Advanced System Settings of Windows.

  2. Check your installation environment. Check the installed SDKs with the command line command plcncli get sdks. The output should look similar to the following screenshot, depending on the SDKs you have installed on your host system.
    PLCnCLI get sdks

Note: If your SDK is not listed, you might need to add it with the command plcncli install sdk and the appropiate -p and -d parameters as described above.

Optional methods to register SDKs in MATLAB / Simulink

If these steps do not work for your installation, there are two undocumented options to register an SDK.
Note: These options may be removed in a future version.

Option 1:

  1. Unpack the SDK to any directory of your choice.
    Note: The SDK packages tend to have long names including the firmware version, so keep the path for unpacking as short as possible for not exceeding the maximum path length of Windows which is limited to 255 characters.
  2. Execute the command PCWorx.setupSdkRoot from the MATLAB command window.
    → This command creates an alternative environment variable referencing to a root directory where SDKs are installed. In the example above this would be "D:\SDK\".
  3. Restart MATLAB.

Option 2:

  1. Unpack the SDK to the "targets" folder in the installation directory of the Simulink toolbox. The name should contain the controller name and the SDK version (for example "AXCF2152_v2019.0").
    Toolbox directory
  2. Restart MATLAB.