All Projects → Inxton → Examples-Inxton.Package.Vortex.Core

Inxton / Examples-Inxton.Package.Vortex.Core

Licence: other
Repository contains introductory examples to Inxton.Package.Vortex.Core

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to Examples-Inxton.Package.Vortex.Core

TcOpen
Application framework for industrial automation built on top of TwinCAT3 and .NET.
Stars: ✭ 187 (+484.38%)
Mutual labels:  twincat, beckhoff, industrial-automation, twincat3, twincat-ads, beckhoff-twincat-plc
ads-client
Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
Stars: ✭ 44 (+37.5%)
Mutual labels:  ads, twincat, beckhoff, twincat3, twincat-ads
TcBlack
Opnionated code formatter for TwinCAT.
Stars: ✭ 67 (+109.38%)
Mutual labels:  twincat, beckhoff, industrial-automation, twincat3, beckhoff-twincat-plc
TcUnit-Runner
Program that makes it possible to automate runs of TcUnit unit tests
Stars: ✭ 23 (-28.12%)
Mutual labels:  twincat, beckhoff, industrial-automation, twincat3
TwinRx
.NET library for connecting with Beckhoff TwinCAT PLC via Reactive Extensions (Rx)
Stars: ✭ 16 (-50%)
Mutual labels:  twincat, beckhoff, twincat-ads, beckhoff-twincat-plc
SoftBeckhoff
Virtual Beckhoff PLC for local testing with docker support
Stars: ✭ 40 (+25%)
Mutual labels:  ads, twincat, beckhoff, twincat3
awesome-industry4.0
Curated list of Industry 4.0 research, popular events, open-source software projects and learning resources that are worth looking into!
Stars: ✭ 57 (+78.13%)
Mutual labels:  industrial-automation, iiot, industry-40
tame4
JS library for the access to a TwinCAT PLC. Current version V4.3.1 final.
Stars: ✭ 37 (+15.63%)
Mutual labels:  twincat, beckhoff, twincat-ads
ioBroker.beckhoff
ioBroker Adapter to Communicate with Beckhoff Automation System over ADS
Stars: ✭ 14 (-56.25%)
Mutual labels:  ads, twincat, beckhoff
node-ads
NodeJS Twincat ADS protocol implementation
Stars: ✭ 49 (+53.13%)
Mutual labels:  ads, twincat, beckhoff
TwinCAT.JsonExtension
TwinCAT variables to and from json
Stars: ✭ 39 (+21.88%)
Mutual labels:  twincat, beckhoff, twincat-ads
fanuc-driver
Configurable Fanuc Focas data collector and post processor.
Stars: ✭ 38 (+18.75%)
Mutual labels:  iiot, industry-40
ads-xbox-controller
Use an xbox controller with TwinCAT
Stars: ✭ 18 (-43.75%)
Mutual labels:  ads, twincat3
Vernemq
A distributed MQTT message broker based on Erlang/OTP. Built for high quality & Industrial use cases.
Stars: ✭ 2,628 (+8112.5%)
Mutual labels:  industrial-automation, industry-40
affiliate
Add affiliation tags to links automatically in the browser
Stars: ✭ 77 (+140.63%)
Mutual labels:  ads
smashblock
📡 🛡️A self-updating extensive blocklist filter for AdGaurd. Be sure to 🌟 this repository for updates!
Stars: ✭ 66 (+106.25%)
Mutual labels:  ads
daily-monetization
Serve ads from different providers
Stars: ✭ 29 (-9.37%)
Mutual labels:  ads
CoinHive
A nice friendly simple and easly customizable GUI for coinhives javascript miner to embed onto websites so users of your site can interact with features of the miner on every single page this javascript miner is to help those who have problems with advertisements/advertising/ads popups banners mobile redirects malvertising/malware etc and provid…
Stars: ✭ 58 (+81.25%)
Mutual labels:  ads
Adware-ads-network-server
Online Advertising Network Server
Stars: ✭ 44 (+37.5%)
Mutual labels:  ads
quasar
Quick opcUA Server generAtion fRamework
Stars: ✭ 31 (-3.12%)
Mutual labels:  industrial-automation

Inxton logo

N.B. ALL EXAMPLES ARE NOW IN VS2019 FORMAT

Nowadays Programmable Logic Controllers (PLC) are required to do more than ever before. Access database, make HTTP requests, build JSONs - stuff they were never meant to do. Even though it's possible, the PLC code is repetitive and hard to navigate, forcing the programmers to spend too much time fixing errors instead of focusing on improvements.

Thanks to Inxton.Vortex.Framework, you can use a high-level programming language like C# to make your solution more efficient and easier to operate. Use the PLC for what it was designed to do and leave all the advanced problems to a modern environment like .NET.

About this example projects

These examples aim to present the use and capabilities of Inxton.Package.Vortex.Core that is a basic, but powerful set of tools that allow you to interact with Beckhoff TwinCAT3 PLC data from .NET (e.g. C#, VB, etc) in a fast and scalable way. This package is part of Inxton.Vortex.Framework.

tc3-inxton-future.png

Compiler

Inxton.Vortex.Compiler is the founding block of the Inxton.Vortex.Framework. It provides one to one C# objects from the TwinCAT3 PLC program so you can use any .NET based platform to access PLC data.

TwinCAT 3 project that contains HansPlc program will be translated into a .NET project called HansPlcConnector. This is the bridge between TwinCAT 3 PLC and .NET.

HansPlcConnector contains TwinObjects - .NET representation of a complex PLC data type (STRUCT, UNION, FB, GVL, PRG). Each of these data structures is represented by a standalone C# class with the same name and attributes as its PLC counterpart. The root class that represents the HansPlc (the actual PLC project) is HansPlcTwinController.

inxton_transpile.gif

Learn more about compiler here.

Learn more about TwinObject here

Accessing the PLC data

Autogenerated code in HansPlcConnector project gives you structured access to PLC data in various forms via TwinObject. This object contains respective primitive variables as TwinPrimitive(s) and can have nested other TwinObject(s) of its PLC counterpart. The default entry point to the twin objects of the PLC program is the TwinController object.

Each TwinObject implements IOnline and IShadow interfaces to access its TwinPrimitives and TwinObjects.

  • IOnline interface which exposes members with direct communication ability with the PLC system.

    • Cyclic access - two-way access to the PLC variables. Cyclic values are being read and written in an optimized periodic loop.
    • Synchronous access - immediate two-way access to the PLC variable.
  • IShadow interface allows an offline manipulation of the object's data.

There is a separate class Plainer that is produced during the trans-piling process which is light (POCO like) representation of the same data structure, that can be is used in scenarios involving serialization.

onliner-shadow-plain.png

Learn more about TwinPrimitives here.

Getting started

Check the prerequisites

Make sure you have everything you need to start using examples in this repository here.

Clone this repository

git clone https://github.com/Inxton/Examples-Inxton.Package.Vortex.Core.git

Or download zip here

Open the solution

Inxton.Vortex.Core.Examples.sln

When you explore the solution you will find that we have a XAE project that contains HansPlc project. HansPlc project has its .NET Twin project called HansPlcConnector. These two projects constitute the starting point for all subsequent examples.

Restore packages

Open Nuget manage for solution and restore missing packages. update_packages

Update Packages

In case you have any problem with package. You will need to do it also if you get a message saying that 'vortex builder does not exist' when trying to run the compiler. Open Tools -> NuGet Package Manager -> NuGet Package Console, go to Package Manager Console and execute:

Update-Package -Reinstall

If you get any error messages you can ignore them at this point.

Activate the configuration

Activate your configuration, download the PLC to your target system and run it as any other TwinCAT 3 project. You will need to set the target system to the target you have available (e.g. local)

Follow instructions from Beckhoff - Activating a TwinCAT 3 project

Install developer license

Get more information and your license here

Connect your app with PLC

Let's have a simple PLC project - a simple counter.

PROGRAM prgSimple
VAR
    _counter : ULINT;
    _counterActive : BOOL;
END_VAR

Run the program in the PLC main loop.

PROGRAM MAIN
---
prgSimple();

You will need to set up AMS ID and port (if changed for some reason). Open file ../HansPlcConnector/Entry.cs

#define LOCAL // Comment if your target is remote

using Vortex.Adapters.Connector.Tc3.Adapter;

namespace HansPlc
{
    public static class Entry
    {
#if LOCAL
        const string AmsId = null; // your ams id or set to 'null' if local
        const int Port = 851;
#else
        const string AmsId = "172.20.10.102.1.1"; // set your target ams id
        const int Port = 851;
#endif
        public static HansPlcTwinController HansPlc { get; } = new HansPlcTwinController(Tc3ConnectorAdapter.Create(AmsId, Port));
    }
}

Let's establish a connection between the PLC and your .NET app.

var hans = HansPlc.Entry.HansPlc;
hans.Connector.BuildAndStart();

Access to PLC variables from C# is very simple thanks to TwinObject and IntelliSense

Write to PLC variable from C#.

var simple = hans.prgSimple; // this is how you access the program
simple._counterActive.Synchron = true;
simple._counter.Cyclic = 132;

Read PLC variable using C#

var currentCount = simple._counter.Synchron;
if(currentCount > 133)
{
    Console.WriteLine($"Current count is way too high! it's {currentCount}");
}

NOTE: Each property provides access to a variable via Synchron and Cyclic.

Examples

Simple

Simple examples have a rudimentary plc counter. We aimed to show basic manipulation with twins of the PLC. Accessing variables, reading, writing, displaying (WPF, and WinForms).

Onliner implements INotifyPropertyChanged therefore binding works as with any other property.

<TextBlock Text="{Binding _counter.Cyclic}" />

REMARKS: It is possible to use WinForms to create valuable applications. WinForm offers a simple approach, you might be more familiar with the technology. On the other hand, it requires more manual coding. If you want, however, get the best from the framework consider starting with WPF. WPF offers very powerful data binding, styling, templates, effective work with components. WPF, on the other hand, has usually steep learning curve for classical programmers. It is, however, worth the effort.

Inxton logo

AddedProperties

This example is trying to expose the feature that allows you to introduce additional properties to twin objects in the PLC code

Define a simple function block with two variables and use pragma attribute addProperty to decorate variables with additional attributes Name and Units.

FUNCTION_BLOCK fbDrive
VAR
    {attribute addProperty Name "Position"}
    {attribute addProperty Units "mm"}  
    Position : LREAL;
    
    {attribute addProperty Name "Speed"}
    {attribute addProperty Units "mm/s"}
    Speed : LREAL;
END_VAR

Create an instance of the function block and add an attribute name.

PROGRAM prgAddedProperties
VAR
    {attribute addProperty Name "Drive X"}
    fbDriveX : fbDrive;
END_VAR
---
fbDriveX();

Access added properties from C#.

var program = hans.prgAddedProperties;
var driveName = program.fbDriveX.AttributeName;  // Drive X
var drivePosition = program.fbDriveX.Position.Synchron;
var drivePositionUnits = program.fbDriveX.Position.AttributeUnits; // mm

var driveSpeed = program.fbDriveX.Speed.Cyclic;
var driveSpeedUnits = program.fbDriveX.Speed.AttributeUnits; // mm/s
               
Console.WriteLine($"{driveName} is at position {drivePosition} {drivePositionUnits} and  moving at speed {driveSpeed} {driveSpeedUnits}"); 

Inxton logo

Weather stations

In this example, we are showing the ease with which you can use the power of .net ecosystem with the PLC. We are reading the data from some weather stations from around the world (via .net library) and we pass the data to the PLC. Plc then makes its own statements about the weather situation in different parts of the world.

Console application shows different ways to access PLCs' variables (Cyclical, Synchronous, Batched). There are descriptive comments in the code that should help you grasp basic concepts.

In addition, this project demonstrates the ability to localize PLC strings in an easy and straightforward way. The framework takes care of translating PLC STRING, WSTRING at runtime using applications' resources. Notice that localizable PLC strings are enclosed between <# and #>. Inxton logo

Need help?

🧪 Create an issue here

📫 We use mail too [email protected]

🐤 Contact us on Twitter @Inxton

📽 Check out our YouTube

🌐 For more info check out our website INXTON.com

Contributing

We are more than happy to hear your feedback, ideas! Just submit it here

What to do next?

Checkout documentation Inxton.Package.Vortex.Core

Install the extension from Visual Studio Marketplace


Developed with 💗 at MTS - putting the heart into manufacturing.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].