This site uses cookies for functional purposes. To continue please read and agree to our Data Privacy.

By closing this message, you consent to our use of cookies on this device.

PLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

 

 How to create a Blog Entry

How to use the .Net Core on a PLCnext Control

If you're a C# programmer working with a PLCnext Control then you might want to use the **Microsoft® .NET Core** runtime. Here's how to install it on an AXC F 2152 control.

### Set up the runtime on the PLC 1. Download the Dotnetcore Runtime Binaries - [Microsoft .NET Core download site](https://www.microsoft.com/net/download/dotnet-core/2.1) - for the AXC F 2152 it is `Linux ARM 32bit` 1. Unzip the Runtime .zip file 1. Unzip the `Data` folder 1. Copy the unzipped files (host, shared and dotnet binary) to the controller at `/opt/DotnetRT` 1. Create a symlink to the binary (as root user) `ln -s /opt/DotnetRT/dotnet /usr/local/bin/dotnet` 1. Check if the link is setup correctly: `lrwxrwxrwx 1 admin plcnext 20 Nov 27 12:50 dotnet -> /opt/DotnetRT/dotnet` 1. Check if installation was succesfull: `dotnet --info` ``` admin@axcf2152:/opt/plcnext$ dotnet --info Host (useful for support): Version: 2.1.1 Commit: 6985b9f684 .NET Core SDKs installed: No SDKs were found. .NET Core runtimes installed: Microsoft.NETCore.App 2.1.1 [/opt/DotnetRT/shared/Microsoft.NETCore.App ``` ### Create a project 1. Switch to a PC for development and building of your .Net Core apps 1. Install .Net Core SDK 1. Create a new application `dotnet new console -o MyFirstTestProgram` 1. Switch to the folder `MyFirstTestProgram` 1. Write your code at `Program.cs` - by default there is a "Hello World!" program 1. Build it with `dotnet build` 1. Switch to `MyFirstTestProgram/bin/Debug/netcoreappX.X/` 1. Modify `MyFirstTestProgram.runtimeconfig.json` and set `"System.Globalization.Invariant": true` ``` { "runtimeOptions": { "tfm": "netcoreapp2.1", "framework": { "name": "Microsoft.NETCore.App", "version": "2.1.0" }, "configProperties": { "System.Globalization.Invariant": true } } } ``` ### Deploy and run your application 1. Copy `MyFirstTestProgram/bin/Debug/netcoreappX.X/` to the controller at `/opt/MyFirstTestProgram` 1. Execute the .Net application with `dotnet MyFirstTestProgram/netcoreapp2.1/MyFirstTestProgram.dll` ``` Hello World! ``` ### How to access I/O data from a C# application running on the .Net Core With the upcoming firmware 2.0 of PLCnext Technology (available by the end of 2018) it will be possible to access the GDS and the I/Os in an easy way via an API. In the meantime use workarounds, like net sockets, Modbus or a REST implementation in a C++ ESM program.