Nontrivial IEC 61131-3 Code Examples - embedded

I am currently developing a method for symbolically executing and testing IEC 61131-3 applications.
For evaluating my approach, I require non-trivial programs written in any of the languages defined in the standard.
Are there any openly accessible code bases I could use for this?

The OSCAT libraries is the biggest open code base written in IEC61131-3 afaik. They provide different libraries for different use cases and for different plc vendors
Furthermore there are some example programs available on Beckhoff Infosys. For almost every library they provide a sample section. One of the biggest samples is the OOP extension sample (OOP extensions are included in the new version of IEC61131-3, not sure if you are interested in it).
Another source of examples is the Codesys Store. They have some free and some paid examples.
And one more I like (but its only in german). M. Seitz the author of a good plc programming book provides some accompanying samples, one of them a bit bigger (coffee machine). There is also a simulation and control library available.

A very good source for examples is Beckhoff's information system which is also available for download.
You can find good examples of different methods for example under different libraries.
Some links:
Programming Reference (Good source)
OOP Sample
Standard library (Library containing IEC standard functions)

Related

What is the difference between libc++ and libc++abi library in LLVM?

I saw the two projects are quite related, but what are the differences between them? The official webpage doesn't tell much about it.
I know that ABI (Application Binary Interface) is used to provide low-level binary interface among different platforms. So is libc++abi used to provide different implementations for different platforms, and general interface for libc++?
Would be better go give some specific example, e.g. what are included in libc++abi and what in libc++.
Thanks.
The Application Binary Interface, or ABI for short, is intended to provide certain low level functions from which to build the C++ standard library. It is a supporting library that is a separate component from the actual standard library. Along with libcxxabi, you may also come across Pathscale's libcxxrt or GCC's libsupcxx.
On the other hand, libc++ is an implementation of the C++ standard library that can be built using either of the 3 mentioned ABIs.

How to develop many-language / multi-platform lib?

Background: I want to develop a component therefore building a class library.
This component should be usable with many higher-order languages such as C, C#, C++, VB, Java, Haskell, Ruby, Erlang, ...
I do not want to exclude any users which are not using my development language.
Are there principles or tools which supports my project?
I searched a little bit and found Haxle for compiling into different languages, but it supports very few of them.
I would even develop parallel in all n languages to be supported, but if I want to change or fix something I have to maintain all other n-1 and the code is possibly distributed...
This is not what I know about clean code design and maintainability. So how to manage edits on code for the different languages?
What is the proper way to solve this? I am surely not the first one which want to build a library for multiple languages.
I want to develop this library (in this case for complexity reduction) in one target language but this time for multiple platforms (Unix, Win, Mac ...).
How to manage this? In fact there will be appreciated about 90% of code which is platform independent and 10% which differs for every OS.
What is the best way to control the changes in the platform dependent code? (The independent is easy ...)
What if I change so things in the part which uses Unix dependent code, then I have to trail all other platform and the code is possibly distributed.
I think #IFDEF is no option ...
Are there any experiences or hints?
I would be delighted if there are existing solutions to these problems, which are quite similar.
What you want is only possible if you provide interfaces for every language you want to support. Some kind of wrapper which transforms between the client language and ypu library.
This is possible but not practical in most cases for standalone libraries.
Take a look at webservices or or message orientad middleware. In this case your application will be provided within a special container which itself provides interface mechanism e.g.
SOAP, XML-RPC to call your application.
For 1), I would use an interface that all these languages can use. A common approach is something based on networking/TCP, like protobuffer, REST, SOAP. Many languages support these in their standard libraries, and interfaces designed with that are normally language agnostic.
There are basically two options - you could develop a network server or you could develop a JVM-based library which could be shared between some of the JVM languages like JRuby or Jython.
Update from #millimoose: you could also develop your library in C and create bindings for all other languages.
For multi-language:
I thought about TCP/middleware/webservices/REST/ which seems to be the recommended proceeding.
But I think it's all to much at runtime for only using a library.
Also the functionality is a little bit time-critical and so direct procedure calls are more fitting (instead of networking even on localhost). And the library user hasn't to construct an access component only to use the library functions.
So I think the way to go seems to be developing the library in a core language which is widely supported (C/C++, ...) and provide wrapper interfaces for the different target languages.
For multi-platform (mono-language):
No real answer has been provided also not in my mind.
Of course I could simply use Java (what I am familiar with) but what about other languages?
I am surely not the first one having this/these problem(s) ...

Import compiled code into C/C++ source code for microcontroller

We'd like to offer a compiled library that implement a protocol layer to be imported into C/C++ source code project for microcontrollers. And eventually expose a sort of compiled function to the source code project. let's say a sort of "dll". Is there any know technique to realize something of similar?
While it is possible to provide functions via a library, generally in the microcontroller/embedded realm it quickly becomes impractical.
Each microcontroller core will have a unique instruction set. Further, micros from the same family may have a variety of extensions which are either supported or not... So you're left with providing a library file for each individual microcontroller (from each vendor) that you'd like to support.
But...
In my experience, calling conventions between compilers are not the same. So a library compiled by one toolchain will not be able to be linked to object files created by another toolchain.
That leads you to then provide a library for each individual micro from each vendor for each toolchain someone might use. Ick. Oh, and don't rely on an OS calls either, as you don't know what you'll be linked with...
A more conventional approach is to use the same approach RTOS vendors tend to use: provide the source, and protect your IP with licensing terms. The reality is that if your end users want to, they can step through the assembly and figure out exactly what is happening, so you're not hiding your implementation that carefully anyway.

Autosar -- for software developer

Can you suggest on this points related to Autosar, taking into consideration I am a software developer who can write some software in C?
Now I Develop a functionality in C, that has to read some ECU specific data, process it & update some ECU specific data (which can be some variable or i/o signal).
Now how I will be using Autosar RTE & virtual functional bus?
What will be there use to a software developer?
Also, as Autosar says "standardization of interfaces" what does it mean? Does it mean that if some else anywhere around the world is also developing same functionality (in C language, like me) we both will be using same name of the API's for those I/O signals?
How RTE will be helpful for me in Unit testing? Or what really RTE is doing from software developer point of view?
http://www.autosar.org/gfx/AUTOSAR_TechnicalOverview_b.jpg
I read a lot technical terms... but being a software developer these points are important for me to know. Can you explain it a bit to me.
Your reply will be appreciated.
I don't think it is going to be that easy...
I believe that you are developing Autosar SWC (software component).
I would recommend for you to develop a portable C module. That has very clear inputs, outputs and req. on execution (check Autosar runnables).
Remember Autosar ECU includes RTOS, therefore your module will be part of a OS task.
When and if you come to the point of building an Autosar ECU, you will be able to wrap the module and connect ins/outs with Autosar virtual functional bus signals. For that you will need Autosar framework and probably configuration tools. These are complex and expensive.
Unit test the module the usual way you test C module.
Good luck.
P.S. RTE is just the "glue" code generated automatically by configuration tools according the configuration of ECU BSW and System Extract for that ECU. You will worry about it during wrapping.
The Idea behind dividing the functionality in AUTOSAR SWC and Basic software is to make the application SW development independent of any platform. To answer your questions.
RTE is giving the application a signal based interface, hence you expect the other SW components (inter-ECU /intra-ECU) to provide the required data in the form of signals, you dont care about the platform or type of communication medium
Yes by standardizing the interfaces (all kind of interactions), a software component or any Basic software module can be Fixed into the SW architecture. Read more about the different type of AUTOSAR interfaces.
Refer to answer 1
RTE is there as a layer to 'abstract' the inner components of the system. For example, if you need to get access to the system's installed flash memory, you have to use the RTE-related memory functions.
You are correct. You only need to read the specifications and use the corresponding functions to get your desired result in an AUTOSAR system.
RTE makes sure that the developers of the software components and the middle-layer systems would work properly with minimal interaction between them. SWC developers just need to read the AUTOSAR standard and follow it to ensure compatibility with the middle-layer systems, since it is expected that the middle-layer system developers would follow that same standard in providing functionalities on their side. It also helps developers with the portability of their software.
I think all your questions can be answered by reading the AUTOSAR standard documents at the AUTOSAR website. Most of my limited knowledge in development of AUTOSAR systems (started reading about it for close to a month already), I got there.
I am a Software developer who Developed a Console Application Tool for Autosar RTE, Test Case Generation for RTE, and wrote Unit Testing Scripts for the tool I created.
I Developed these using C# and NUnit Framework. Same can be Developed using C or a java or any other language. Ultimate goal is to generate AUTOSAR modules (.c and .h files) based on the requirement.
1. Software Developer Scope
As a Software Developer, i had a task to implement complete RTE and Test Applications for the Implemented RTE code.
Inputs and Outputs:
Basically our inputs were Software Component files and ECU Extract which were in ARXML format and Outputs were Rte and test application source and header files (.c and .h) which were created based on the requirements.
Tasks as a developer:
Here, as a developer, we need to perform Input parsing from AXXML to our own data structure, Schema Validation, Modal Validation, File generation etc.
2. Standardization
Yes, AUTOSAR Architecture provides standardized interface. Irrespective of the implementation strategy, API structure remains same which eases the usage. This acts as a generalised library where you can use already developed Module or you can implement the module in your own way by considering API specification. All you need is to follow the specifications provided for every module you use.
Requirement varies from Company to Company but the way of using APIs remains same.
3. Unit Testing
Unit Testing has nothing to do with RTE or AUTOSAR modules. You will be testing the Uints of Your Code. When i say your code, it is the one which you used to develop any particular module (eg. Rte.c) and not testing the generated module itself. You will be testing the Source code you developed to generate the specfic module. Your source code is not part of RTE or any other module implementation but is tool which generates the module implementation.
Overview:
Software developer have various scope in generating AUTOSAR modules depends on the Requirement.
You can develop a tool which will generate AUTOSAR modules.
You can develop an Editor which will is used to edit/create AUTOSAR XML files. (Eg: Artop)
Developing might sound complex as we do not get direct resources other than specifications. Once you are in, you will learn a lot.
To answer your question
If you will go through the Layered Architecture of AUTOSAR, you will come to know this architecture is followed to minimize the dependency of the each module
(layer) with lower layer.
Again, RTE is a like wrapper to separate the lower layered dependency, this enables to work on each layer independently. Most of the virtual buses are mapped with RTE, in my experience I have worked on IOC which is allowed to map with RTE and which communicates with other SWC's with memory and core boudary. To OS Developer its via to the application layer and Mapped software partitions.
The standard is used to maintain uniformation in all software layers, however to meet the requirements the developers may have different way of implementation and design, but the API's and requirements will be universal.
This is useful for standardised intefacing too.
For Unit testing of the developers OS design and implementation RTE works as abstract module.
Reading Specs for different module will resolve most of doubts.

Is there any Subtext IDE or equivalent Example-driven Visual Programming Language/Interface published on the Internet?

I'm really excited about this new and experimental language named Subtext. But it's author haven't released nothing about it besides some papers and videos. Should I clone it? There are similar alternatives?
UPDATE I'm looking for an example-driven VPL, not just a VPL.
As Edwards' says in his related work section, the Self programming language is very similar. It shares subtext's emphsis on directness, uniformity, and liveness, but doesn't emphasize a tabular format (Schematic tables).
A lot of of work went into the Solaris version:
http://research.sun.com/self/papers/papers.html
seems there's a Mac & linux version, not sure how mature it is:
http://selflanguage.org/
Here's a video demo'ing Self, where they emphasize directness, uniformity, and liveness:
http://www.smalltalk.org.br/movies/
When you say "any VPL", do you mean none at all, or not a run-of-the-mill one? From the wording of the title question, I'll assume the latter. Here're a couple with some serious programming theory behind them:
Morphic is/was a/the UI piece of Self, and is now ported to Squeak:
http://wiki.squeak.org/squeak/2139
Prograph was a way-cool system, but I don't know of an available version.
A bit further out there is Kahn's Toontalk, based on Pictorial Janus:
http://www.toontalk.com/
I am sure you are aware of VPL On Wikipedia that lists many different VPL languages. You have not supplied information on what you are trying to achieve but another site is Synopsis. This is a commercial product.
From their website:
Synopsis is a completely visual RAD tool for Windows that frees you from having to write textual code and learning unnecesary programming details. With Synopsis you can concentrate on creating software instead of wrestling with mundane and complex low-level development tasks.
The image below shows how this application looks:
(source: codemorphis.com)
Granted my knowledge on this subject is limited and I do follow this to see if something really powerful can be created. I did see a project on CodeProject or CodePlex that was written in C# that allowed VPL but I cant find that URL.
If I ever do find that application I will edit this post!
You haven't provided more information about features you expect from such a VPL environment, but I think that "Tersus" could be interesting thing to look at. There're many VPLs, but mainly they're targeted as educational tools or addition to particular technologies (i.e VPL for Microsoft Robotics Studio) to simplify common tasks programming. The "Tersus" is full blown application development platform. It's open source and free to download for many OSes.
http://www.tersus.com
Coherence — The Director’s Cut
The Coherence home page is up at http://coherence-lang.org. The submitted version of the paper is there, with a new intro and a surprise ending.
Coherence claims to be an experimental programming language, a continuation of Subtext using other means.
Intentional shipped, but they are still kind of alpha, with limited distribution and testing. You can make example driven DSLs, but I don't know if the environment itself works that way.
http://lambda-the-ultimate.org/node/3287
You could look at the work on eve that is happening too:
http://incidentalcomplexity.com/