Raspberry Pi Dev: Difference between revisions

From Axel Public Wiki
Jump to navigation Jump to search
No edit summary
Line 40: Line 40:
=Plugin details=
=Plugin details=
The plugin LLXPlugin_PIFACE is a subset of what we have implemented to manage Raspberry PI I/O, and it's designed to drive the PiFace expansion, that is driven by the Raspberry SPI interface.<br>
The plugin LLXPlugin_PIFACE is a subset of what we have implemented to manage Raspberry PI I/O, and it's designed to drive the PiFace expansion, that is driven by the Raspberry SPI interface.<br>
The plugin is composed by several files:
* '''Makefile''': that cross compiles the plugin, and also defines some macros that selects some configuration in the headers. Please leave this thefines as they are.
* '''LLXPlugin_PIFACE.cpp''': this file contais the interface with LLExec core, in here are defined data blocks and functions to be called.
* '''io.cpp''' and '''io.h''': these are the sources implementing the spi communication, look at theese if you want to interact with PiFace board.
=LLExecLinux.conf=
=LLExecLinux.conf=
=Edit pll library=
=Edit pll library=

Revision as of 15:33, 21 November 2017

Summary

The purpose of this page is to allow expert Raspberry PI developers to extend the PLC runtime.
It shows up how the interface to PiFace I/O board can be implemented from scratch.
You can clone the example to implements inteface with your own I/O module.

Prerequisites

To follow this guide you need:

  • A Raspberry PI with a running and licensed PLC runtime (LLExec >= 2.6.2 is suggested).
You can install the runtime following the guide in http://www.axelsw.it/pwiki/index.php?title=Raspberry_Pi
  • A Raspbian cross-compile toolchain
You can download it from https://github.com/raspberrypi/tools

Setup your Linux machine

Please uncompress the toolchain and find the path of the compiler tools: for example suppose they are under the folder

/home/axel/toolchain_RPI_orig/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin

In this case you have to edit your .profile file and add the row

export PATH=/home/axel/toolchain_RPI_orig/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH

in order to make the compiler available to the system.
At this point make folder and uncompress PluginHeaders_2.6.2.zip in it. You can download the file from our site, in the Dowload section.
Plugin headers expose the LLExec API to interface with the runtime, they require that some defines are set in order to compile correctly. As you will see after, these defines will be already defined in the Makefile.
Now please download and uncompress the file LLXPlugin_PIFACE.zip in the previous foldere where you have already uncompressed the plugin headers.
Please note that every release of LLExec has its own plugin header, so be shure that the release number of the headers matches with the release of LLExec installed. No backward compatibility is guaranted:please compile your plugin for a specific release of LLExec.

Compile the plugin

In order to compile the plugin please go to the directory you have previously uncompressed, ie

/home/axel/plugin_headers_root/LLXPlugin_PIFACE

type

make

If you have done correctly all the previous steps, this will generate the file LLXPlugin_PIFACE.so Please copy this file on the RaspberryPI in the same directory where the runtime is installed.

Plugin concepts

LLExec is a modular runtime designed to run on top of (realtime) operating systems;also we have another type of runtime that can be embedded in the firmware of the board, but this is not the case.
Every thing in the runtime is a plugin, the runtime itself is a plugin, while the core module (LLExec) is only responsible for load and link the modules together, implements communication with LogicLab and schedules all the tasks involved.
There are many plugins implementing various features like fieldbusses, local I/O and so on.
If you wants to extennd the runtime to manage your I/O, you have to implement and link your plugin.
The simplest way a plugin can expose its I/Os to the PLC is by means of data blocks, that are region of memory, with a logical address, shared between the plugin and the PLC code.
You can also define functions that are invoked syncronously with the PLC tasks, and functions that will be exposed to the PLC and called from the PLC code, like standard IEC 61131 functions.
Once you have written your plugin, you can write a library, which can be included in your PLC program, to access the entities you have published in your plugin.
In the next chapters you will see the detail of the plugin PIFACE, and the details of the pll library that expose the plugin features.
At last you have to modify LLExec configuration file LLExecLinux.conf in order to run your plugin.

Plugin details

The plugin LLXPlugin_PIFACE is a subset of what we have implemented to manage Raspberry PI I/O, and it's designed to drive the PiFace expansion, that is driven by the Raspberry SPI interface.
The plugin is composed by several files:

  • Makefile: that cross compiles the plugin, and also defines some macros that selects some configuration in the headers. Please leave this thefines as they are.
  • LLXPlugin_PIFACE.cpp: this file contais the interface with LLExec core, in here are defined data blocks and functions to be called.
  • io.cpp and io.h: these are the sources implementing the spi communication, look at theese if you want to interact with PiFace board.

LLExecLinux.conf

Edit pll library

Configure runtime

Access from LogicLab

Further readings