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
- Download the Dotnetcore Runtime Binaries (Microsoft .NET Core download site);
for the AXC F 2152 it isLinux ARM 32bit.
Note: You may also use a newer version, e.g. 3.0 - Unzip the Runtime .zip file
- Unzip the
Datafolder - Copy the unzipped files (host, shared and dotnet binary) to the controller at
/opt/DotnetRT - Create a symlink to the binary (as root user):
ln -s /opt/DotnetRT/dotnet /usr/local/bin/dotnet - Check if the link is setup correctly:
lrwxrwxrwx 1 admin plcnext 20 Nov 27 12:50 dotnet -> /opt/DotnetRT/dotnet - Check if installation was succesful with
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
- Switch to a PC for development and building of your .Net Core apps
- Install .Net Core SDK
- Create a new application
dotnet new console -o MyFirstTestProgram - Switch to the folder
MyFirstTestProgram - Write your code at
Program.cs– by default there is a “Hello World!” program - Build it with
dotnet build - Switch to
MyFirstTestProgram/bin/Debug/netcoreappX.X/ - Modify
MyFirstTestProgram.runtimeconfig.jsonand 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
- Copy
MyFirstTestProgram/bin/Debug/netcoreappX.X/to the controller at/opt/MyFirstTestProgram - Execute the .Net application with
dotnet MyFirstTestProgram/netcoreapp2.1/MyFirstTestProgram.dll
Hello World!
Access I/O data from a C# application running on the .Net Core
To access the GDS and the I/Os, use .Net sockets, Modbus or a REST implementation in a C++ ESM program.
Leave a Reply
You must be logged in to post a comment.