This guide is for setting up an environment to develop PLCnext projects with the starter kit using Docker and VSCode.
To run Linux containers with Docker on a Windows system, WSL 2 is required. Follow the steps below to get set up:
-
Install WSL 2 and Ubuntu 22.04
- Open PowerShell by typing
powershell
in the Windows search bar. - Run the following commands:
wsl --install wsl --set-default-version 2 wsl --install -d Ubuntu-22.04 wsl --set-version Ubuntu-22.04 2
- This will install WSL 2 and set up Ubuntu 22.04 as your default Linux distribution.
- Open PowerShell by typing
-
Install Docker and Configure WSL 2
- Install Docker Desktop for Windows.
- During installation, ensure that Docker is configured to use the WSL 2 backend.
-
Install VSCode and Configure for Docker Use
- Download and install VSCode.
- Install the Remote - Containers extension.
-
Clone the PLCnextDevops Repository into Your WSL 2 Workspace
- Open Ubuntu terminal
- Set up SSH keys in your WSL environment if needed. (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?platform=linux)
- Clone the PLCnextDevops repository:
git clone <PLCnextDevops-url>
-
Open PLCnextDevops in VSCode Using Docker and WSL 2
- From the Ubuntu terminal, navigate to the cloned repository folder:
cd path/to/PLCnextDevops code .
- In VSCode, select the folder containing the PLCnextDevops repo and choose the option to "Reopen in Container."
- Wait for the Docker image to build and the container to start.
- A select workspace prompt will open navigate to PLCnext-DevOps folder.
- From the Ubuntu terminal, navigate to the cloned repository folder:
This task is used to create a new PLCNext PLM project. It sets up the initial project structure and prepares it for further development.
- Open the Command Palette: Press
Ctrl+Shift+P
in VS Code. - Run the Task: Type
Tasks: Run Task
and pressEnter
. - Select
plcnext_new_Project
: Choose theplcnext_new_Project
task from the list. - Input Project Name: You will be prompted to enter the project name (e.g.,
NewProject
).
- Creates a new project in the
src/projects
directory with the specified project name. - Sets the target to
AXCF2152
. - Generates the necessary code and configuration.
- Displays a completion message indicating that the new PLCNext project has been successfully created.
The project is now ready for further development, such as adding components and programs.
This task is used to create a new program within an existing PLCNext PLM project. It adds a new program to a specified component.
- Open the Command Palette: Press
Ctrl+Shift+P
in VS Code. - Run the Task: Type
Tasks: Run Task
and pressEnter
. - Select
plcnext_new_program
: Choose theplcnext_new_program
task from the list. - Input Project and Program Details:
- Enter the project name (e.g.,
NewProject
). - Enter the component name (e.g.,
MainComponent
). - Enter the program name (e.g.,
NewProgram
).
- Enter the project name (e.g.,
- Navigates to the specified project directory.
- Creates a new program under the specified component.
- Generates the necessary code and configuration.
- Displays a completion message indicating that the new PLCNext program has been successfully created.
The new program is now ready for further development and integration into the project.
This task is used to create a new component within an existing PLCNext PLM project. It adds a new component to the project.
- Open the Command Palette: Press
Ctrl+Shift+P
in VS Code. - Run the Task: Type
Tasks: Run Task
and pressEnter
. - Select
plcnext_new_component
: Choose theplcnext_new_component
task from the list. - Input Project and Component Details:
- Enter the project name (e.g.,
NewProject
). - Enter the component name (e.g.,
NewComponent
).
- Enter the project name (e.g.,
- Navigates to the specified project directory.
- Creates a new component with the given name.
- Generates the necessary code and configuration.
- Displays a completion message indicating that the new PLCNext component has been successfully created.
The new component is now ready for further development and can be used to structure your project's functionality.
This task is used to build an existing PLCNext PLM project. Unlike the plcnext_gen_build
task, this task does not regenerate the code and configuration files, so it should not be used if there have been changes to port definitions or other configurations that require regeneration.
- Open the Command Palette: Press
Ctrl+Shift+P
in VS Code. - Run the Task: Type
Tasks: Run Task
and pressEnter
. - Select
plcnext_build
: Choose theplcnext_build
task from the list. - Input Project Name: You will be prompted to enter the project name (e.g.,
NewProject
).
- Sets the build type to
Release
. - Navigates to the project directory
/src/projects/<project_name>
. - Builds the project without regenerating code and configuration.
- Deploys the project.
- Copies the generated
.pcwlx
binary file to/home/plc/Windows_PLCNextEngineer_Libraries
.
- Navigate to the project directory
/src/projects/<project_name>
. - Right-click on the
.pcwlx
file and select "Download." - Download the
.pcwlx
file intoC:\Users\<user>\Documents\PLCnext Engineer\Libraries
. - The library should then appear in PLCnext Engineer.
This task is used to build a PLCNext PLM project. It generates code, configures the project, builds it, and deploys the final binary file to a specified directory inside the Docker container.
-
Open the Command Palette: Press
Ctrl+Shift+P
in VS Code. -
Run the Task: Type
Tasks: Run Task
and press Enter. -
Select
plcnext_gen_build
: Choose theplcnext_gen_build
task from the list. -
Input Project Name: You will be prompted to enter the project name (e.g.,
Hello
). -
Task Execution: The task will:
- Set the build type to
Release
. - Navigate to the project directory
/src/projects/<project_name>
. - Generate code and configuration.
- Build and deploy the project.
- Copy the generated
.pcwlx
binary file to/home/plc/Windows_PLCNextEngineer_Libraries
.
- Set the build type to
-
Project Use
- Navigate to the project directory
/src/projects/<project_name>
. - Right-click on the
.pcwlx
file and select "Download." - Download the
.pcwlx
file intoC:\Users\<user>\Documents\PLCnext Engineer\Libraries
. - The library should then appear in PLCnext Engineer.
- Navigate to the project directory