scieee Science in your language
[en] (orig)

Implementation and Evaluation of an Interface between a virtual Open-Source Software Programmable Logic Controller and the Physical GPIO-Pins of the Host Machine

Abstract

The Bachelor Thesis focuses on developing an interface between virt-Soft-PLC and physical hardware GPIO-Pins of the host machine based on existing code for a different interface. For this purpose, an existing interface between virt-Soft-PLC (Awlsim) has been used as template for the new interface. As foundation of the work the mapping of the I/O between Host-Operating System (Hypervisor) and GuestOperating System (Virtual Machine with Soft-PLC) has been configured. The objective is the reading of a digital signal trough this port, the signal must be read in the virtual machine to be receive by the PLC software that works in this virtual machine. To read the signal the host machine Kernel has been modified, because the project requires Real Time. The I/O pins mapping between the Host and the Guest machine must be configured to exchange the signal between them.

Read accessible full text

Implementation and Evaluation of an Interface between a virtual Open-Source Software Programmable Logic Controller and the Physical GPIO-Pins of the Host Machine

Author: Navarro Martínez, Ainoa
Year: 2017
Source: https://idus.us.es/bitstreams/b4b43ea2-2fb2-4ced-893d-237fa7a7ab54/download
P oyec o Fin de G ado
G ado en Ingenie ía Elec ónica, Robó ica
y Meca ónica
Au ho : Ainoa Na a o Ma ínez
Tu o s: Ch is ian Ho n and Miguel Ángel Ridao Ca lini
Ins i u ü We kzeugmaschinen und Fab ikbe ieb
Indus ielle Au oma isie ungs echnik
Technische Uni e si ä Be lin
Dep. Ingenie ía de Sis emas y Au omá ica
Escuela Técnica Supe io de Ingenie ía
Uni e sidad de Se illa
Se illa, 2017
Implemen ación y E aluación de una In e az
en e el So wa e Open-Sou ce de un Con olado
Lógico P og amable Vi ual y los Pines
En ada/Salida de P opósi o Gene al de la
Máquina An i iona
Implemen a ion and E alua ion o an In e ace
be ween a i ual Open-Sou ce So wa e
P og ammable Logic Con olle and he Physical
GPIO-Pins o he Hos Machine
P oyec o Fin de G ado
G ado en Ingenie ía Elec ónica,
Robó ica y Meca ónica
2
3
P oyec o Fin de G ado en Ingenie ía Elec ónica, Robó ica y Meca ónica
Implemen a ion and E alua ion o an In e ace
be ween a i ual Open-Sou ce So wa e
P og ammable Logic Con olle and he Physical
GPIO-Pins o he Hos Machine
Implemen ación y E aluación de una In e az en e
el So wa e Open Sou ce de un Con olado Lógico
P og amable Vi ual y los Pines En ada/Salida de
P opósi o Gene al de la Máquina An i iona
Au ho :
Ainoa Na a o Ma ínez
Tu o s:
Ch is ian Ho n
Miguel Ángel Ridao Ca lini
Ins i u ü We kzeugmaschinen und Fab ikbe ieb
Indus ielle Au oma isie ungs echnik
Technische Uni e si ä Be lin
Dep. Ingenie ía de Sis emas y Au omá ica
Escuela Técnica Supe io de Ingenie ía
Uni e sidad de Se illa de Ingenie ía
Uni e sidad de Se illa
Se illa, 2017
4
5
P oyec o Fin de Ca e a: Implemen a ion and E alua ion o an In e ace be ween i ual Open-Sou ce
So wa e P og ammable Logic Con olle and Physical GPIO-Pins o he Hos Machine
Au o :
Ainoa Na a o Ma ínez
Tu o :
Miguel Ángel Ridao Ca lini
El ibunal nomb ado pa a juzga el P oyec o a iba indicado, compues o po los siguien es miemb os:
P esiden e:
Vocales:
Sec e a io:
Acue dan o o ga le la cali icación de:
Se illa, 2017
El Sec e a io del T ibunal

6
7
G a i ude
I am g a e ul o he oppo uni y o e ed by Ch is ian Ho n o ca y ou his p ojec , as well as he suppo and
pa ience he has always o e ed me.
I am g a e ul o he Technical Uni e si y o Be lin o he space and necessa y esou ces o he ealiza ion o
he p ojec , as well as all hose people who ha e o e ed hei help as Udo Templine , who has always a ended
me when I eques ed help.
I hank Miguel Ángel Ridao o his ad ice and suppo o make his p ojec ab oad.
Finally, I would like o hank my amily and iends, as well as José Luis Holgado Ál a ez o he a ec ion,
suppo , pa ience and calm necessa y o make his wo k possible.
Ainoa Na a o Ma ínez
Se illa, 2017
Ag adecimien os
Ag adezco la opo unidad b indada po Ch is ian Ho n pa a ealiza es e p oyec o, así como el apoyo y la
paciencia que me ha o ecido en odo momen o.
Ag adezco a la Uni e sidad Técnica de Be lín el espacio y los ecu sos necesa ios pa a la ealización del
p oyec o, así como aquellas odas pe sonas que han o ecido su ayuda como Udo Templine , que siemp e me
ha a endido cuando he eque ido su ayuda.
Ag adezco a Miguel Ángel Ridao sus consejos y su apoyo pa a pode ealiza es e p oyec o en el ex anje o.
Po úl imo, me gus a ía ag adece a mi amilia y amigos, así como a José Luis Holgado Ál a ez el ca iño, el
apoyo, la paciencia y la calma necesa ias pa a pode lle a acaba es e abajo.
Ainoa Na a o Ma ínez
Se illa, 2017
8
9
Abs ac
The Bachelo Thesis ocuses on de eloping an in e ace be ween i -So -PLC and physical ha dwa e
GPIO-Pins o he hos machine based on exis ing code o a di e en in e ace. Fo his pu pose, an
exis ing in e ace be ween i -So -PLC (Awlsim) has been used as empla e o he new in e ace. As
ounda ion o he wo k he mapping o he I/O be ween Hos -Ope a ing Sys em (Hype iso ) and Gues -
Ope a ing Sys em (Vi ual Machine wi h So -PLC) has been con igu ed.
The objec i e is he eading o a digi al signal ough his po , he signal mus be ead in he i ual machine o
be ecei e by he PLC so wa e ha wo ks in his i ual machine.
To ead he signal he hos machine Ke nel has been modi ied, because he p ojec equi es Real Time.
The I/O pins mapping be ween he Hos and he Gues machine mus be con igu ed o exchange he signal
be ween hem.
16
Figu es Index
Figu e 1 PLC Ha dwa e 19
Figu e 2 Gene al Scheme 22
Figu e 3 Digi al Inpu /ou pu 23
Figu e 4 Selec ing Ke nel con igu a ions 28
Figu e 5 Selec ing Ke nel con igu a ions 28
Figu e 6 Selec ing Ke nel con igu a ions 29
Figu e 7 Selec ing Ke nel con igu a ions 29
Figu e 8 Selec ing Ke nel con igu a ions 30
Figu e 9 Selec ing Ke nel con igu a ions 30
Figu e 10 Selec ing Ke nel con igu a ions 31
Figu e 11 Selec ing Ke nel con igu a ions 31
Figu e 12 S ep 0 Vi ual Machine Ins alla ion 36
Figu e 13 S ep 1 Vi ual Machine Ins alla ion 36
Figu e 14 S ep 2 Vi ual Machine Ins alla ion 37
Figu e 15 S ep 3 Vi ual Machine Ins alla ion 37
Figu e 16 S ep 4 Vi ual Machine Ins alla ion 38
Figu e 17 S ep 5 Vi ual Machine Ins alla ion 38
Figu e 18 Digi al I/O, oscilloscope and signal gene a o connec ion 42
Figu e 19 Digi al I/O, oscilloscope and signal gene a o connec ion 42
Figu e 20 Compa ison be ween he ecei ed (blue) and he desi ed (yellow) signal 43
Figu e 21 Delay using Ke nel 4.7 45
Figu e 22 Delay using Ke nel 4.1.5 45
Figu e 23 Checking he a ailabili y o V -d i ualiza ion 46
Figu e 24 Selec ing Ke nel con igu a ions 48
Figu e 25 Selec ing Ke nel con igu a ions 49
Figu e 26 Selec ing Ke nel con igu a ions 49
Figu e 27 Selec ing Ke nel con igu a ions 50
Figu e 28 Selec ing Ke nel con igu a ions 50
Figu e 29 Selec ing Ke nel con igu a ions 51
Figu e 30 Selec ing Ke nel con igu a ions 51
Figu e 31 Selec ing Ke nel con igu a ions 52

17
Figu e 32 Selec ing Ke nel con igu a ions 53
Figu e 33 Selec ing Ke nel con igu a ions 54
18
19
1 In oduc ion
1.1 The Bi h o he PLC
A PLC is a p og ammable logic con olle , is a compu e used in indus ial au oma iza ion, i has unlimi ed
applica ions since i can ule all he con ol p ocesses in a ac o y o in an assembly line.
The i s PLC was in en ed a he end o he se en ies by Bed o d Associa es ha de eloped Modicon
(Modula Digi al Con olle ), i pu pose was subs i u ing he old wi ed elay sys em ha Gene al Mo o s was
using in i s ac o ies. Since ha momen PLC s a ed o sp ead all o e he wo ld because i s mul iple inpu
ou pu signal, which make hem pe ec o ule any kind o indus ial p ocess. PLCs can also ule emo e
p ocess in Real Time.
The i s language ha PLCs uses was a lis o ins uc ions, bu i was no he only de eloping language, ladde
logic, Block diag ams o S uc u ed ex a e examples o hem. I also uses se e al ypes o communica ion
p o ocols such as SCADA, P o ibus, E he ne , Modbus… depending on he applica ion.
I s mul ipu pose, lexibili y, ease, scalabili y and compa ibili y makes he PLC pe ec o any kind o
indus ial au oma iza ion, hose a e he easons o i s success.
1.2 PLC`s Ha dwa e
The ha dwa e o a PLC i s cons i u ed by he powe supply, he CPU, I/O In e ace modules, he
communica ions in e ace, he p og am and da a memo y module and he p og amming de ice.
Figu e 1 PLC Ha dwa e
20
Powe Supply
The powe supply is used o supply he equi ed ene gy o he CPU as well as he es o he I/O ci cui s
a ached o he PLC and he p og amming de ice.
CPU
The CPU con ols he RAM, coun e s, elays, ime s … The CPU eads all he inpu and ou pu signals
in ol ed in he p ocess o un he applica ion p og am.
I/O In e ace Modules
The In e ace Modules allows he communica ion be ween he CPU and all he elec omechanical componen s
in ol ed in he p ocess using buses o ha pu pose, I/O In e aces manage all he di e en ensions and
cu en s o he ci cui s o connec all he ac ua o s and senso s.
Communica ion In e ace
The communica ion in e ace sends and ecei es all he da a he communica ion ne wo k ha may use
di e en communica ion p o ocols like E he ne , P o ibus …
P og am and Da a Memo y
The memo y keeps all he in o ma ion o un he con ol p og am like he p ocess da a and he con ol da a.
A PLC has wo mainly ypes o memo ies, ola ile (RAM) and non- ola ile memo y (EPROM).
P og amming De ice
The p og amming De ice p o ides he in e ace be ween he PLC and he p og amme , his de ice could be a
egula compu e wi h a dedica ed so wa e o p og am he PLC.
1.3 S a e o he a
The di e en manu ac u e s o each PLC de elop, suppo and p o ide he equi ed so wa e o p og am
and use PLCs.
Nowadays PLCs a e widely sp ead, he applica ions and he elec onic de ices in ol ed in he new con ol
sys em a e endless, so he pa e n ies o coo dina e all, de elope s need he eedom o un, dis ibu e, copy,
and modi y he so wa e wi hou es ic ions. The end in las yea s is o c ea e Open sou ce PLC`s so wa e,
in he pas PLC`s and i s applica ions o manage hem whe e in eg a ed and sold by he manu ac u e s, also he
ope a i e sys em whe e hey we e unning was p ede e mined. The ope a i e sys ems equi ed o un PLC`s
so wa e we e no ee, bu hese days he use o Linux o un SCADA o DCS sys em has se e al ad an ages
like mo e secu i y, s abili y as well as less cos s.
The e a e lo s o di e en p ojec s like Open PLC, Awlsim, Small PLC, ha a e open sou ce p ojec s ha y
o de elop Open Sou ce PLC`s so wa e as well as Ha dwa e.
21
1.4 Mo i a ion
PLCs a e e y used in he indus y, o make hem e en mo e mul ipu pose, Open-Sou ce and accessible o any
kind o OS, compu e , applica ion o p ocess ha i s al eady unning we e he mo i a ion o de elop his
p ojec .
A o me p ojec ha subs i u es he ha dwa e o an old Siemens PLC o make he con ol applica ion
de eloped wi h a Siemens so wa e unning in he cloud, mo i a ed me o y o send a signal o communica e
a machine wi h an Open-Sou ce so wa e o p og am PLCs (Alwsim).
To accomplish his p ojec a new in e ace ha wo ks in Real Time had o be de eloped, his in e ace is based
in Awlsim. The mapping be ween he I/O po o he Hos and he Gues machine was done o achie e he
communica ion. The ha dwa e as well as o he esou ces o his p ojec we e p o ided by he Uni e si y o
Be lin.

22
2 P ojec Ta ge
The a ge o he p ojec consis s in eading an incoming signal h ough a GPIO-pins po ha he compu e
A k-1550 has, his signal mus be ead by a Gues Vi ual Machine unning in he Hos Machine ins alled in
he compu e .
To achie e he eading, a communica ion in e ace be ween he Hos , he Gues and he GPIO-pins mus be
de eloped, o ha he i -So -PLC (Awlsim) in e ace is used as an example o de eloping he equi ed
in e ace.
As he signal needs o be ead as quickly as possible, Real- ime is a need, o use Real Time, he Linux ke nel
ins alled in he hos and in he gues machine mus be pa ched and modi ied o use Real Time.
A e ha he signal needs o be gene a ed and ead by a p og am, o ha pu pose use - space di ec access o
he pins is equi ed o ead he signal.
Once he signal is ead by he hos machine, he nex s ep would be o i ualize he GPIO-pins in he gues
machine o ead he signal.
Figu e 2 Gene al Scheme
23
3 Ha dwa e
3.1 The compu e A k-1550
The A k-1550 is he compu e which has been used o de elop he p ojec , his compu e was chosen because
o i s ea u es, specially designed o embedded applica ions and i s Digi al I/O.
The A k-1550 is a Fanless embedded compu e designed by Ad an ech, all he elec onics a e in eg a ed in a
compac and p o ec ed designed. The dimensions a e 223 x 46.6 x 133.0 mm and is powe ed by 12V DC
inpu , i has a single boa d and i o e s:
• In el® Dual Co e Cele on 2980U 1.6 GHz / Co e i5 4300U 1.9 GHz SoC
• One Ho Swappable 2.5" SATA HDD Bay and mSATA slo
• T iple Independen Displays by VGA + HDMI + LVDS (LVDS op ion)
• Op ional VESA / DIN Rail Moun ing ki s
• Suppo s 2 x In el GbE and 1 x GPIO
• Buil -in 1 x ull size MiniPCIe (i.e.: 3G module) and 1 x hal size MiniPCIe slo (i.e.: WIFI module)
• Lockable DC jack design
• Suppo s iManage , SUSIAccess and Embedded So wa e APIs
• Suppo In el Tu bo Boos Technology 2.0 in Co e i5 4300U
3.1.1 The Digi al I/O
The mos in e es ing ea u e o his p ojec is he Digi al I/O, i has an 8-bi DIO connec o and one g ound
pin. Each bi can be se as a digi al inpu o ou pu independen ly. The signal will be sen h ough his po o
communica e he ha dwa e wi h he gues machine PLC so wa e.
Figu e 3 Digi al Inpu /ou pu
24
Digi al I/O Connec o Pins
Pin
Signal Name
1
DIO bi 4
2
DIO bi 3
3
DIO bi 2
4
DIO bi 1
5
DIO bi 0
6
GND
7
DIO bi 5
8
DIO bi 6
9
DIO bi 7
Table 2 Digi al I/O Connec o Pins
The pin numbe six is he g ound and he pins ou and i e will be used as an ou pu and inpu espec i ely.
The signal mus be sen h ough his po , he signal will be gene a ed wi h a signal gene a o and will be sen
o he pin numbe i e, hen p og am ha was de eloped, will ead his signal and will send i o he pin
numbe ou , so he signal can be ead and showed in an oscilloscope using a es p obe.
25
4 So wa e
4.1 Awlsim: S7 Compa ible So -PLC
Awlsim is an Open-Sou ce so wa e o p og am P og ammable Logic Con olle s (PLCs) om Siemens
which is compa ible wi h AWL/STL So -PLC, i has been w i en in Py hon. Awlsim is he empla e o
de elop he new in e ace.
Awlsim can un on Windows as well as any o he pla o ms ha suppo Py hon, like Linux o Mac OS
X.
Since Real Time is a mus o his p ojec , Awlsim can ge se e al housand o millions o AWL/STL
ins uc ions pe second, his ea u e is in e es ing, e en hough he execu ion speed eally depends on he
machine whe e Awlsim i is being execu ed as well as he Py hon in e p e e .
Awlsim ins alla ion is equi ed because he de eloping o he new in e ace is based on i .
4.1.1 Ins alla ion o Awlsim
To use Awlsim-gui he Awlsim elease 0.55 Sou ce package mus be downloaded om:
h ps://bues.ch/cms/au oma ion/awlsim.h ml#download
Since he Hos Machine is an A k-1550 embedded compu e om Ad an ech and i s Ope a i e Sys em
Ubun u 16.04, a ew addi ional ools we e equi ed o un Awlsim-gui, one o hem is Building PySide on
he sys em.
4.1.1.1 P e equisi es
The ins alla ion o se e al dependencies is needed as well as he la es e sion o pip dis ibu ion o ins all
Alwsim.
The i s s ep will be he ins alla ion o he building dependencies:
$ sudo ap -ge ins all build-essen ial gi cmake libq 4-de libphonon-
de py hon2.7-de libxml2-de libxsl 1-de q mobili y-de libq webki -
de
q mobil y-de package could be ound in he ollowing link:
h ps://packages.ubun u.com/ us y/q mobili y-de
The second s ep will be he ins alla ion o pip acco ding o he py hon e sion used:
$ wge h ps://boo s ap.pypa.io/ge -pip.py
$ sudo py hon2.7 ge -pip.py
I he py hon e sion used is Py hon 3.2, exis s an incompa ibili y ha does no allow Awlsim-gui o un,
o download he ge -pip.py a chi e equi ed o his Py hon e sion can be ound he e:
h ps://pip.pypa.io/en/s able/ins alling/
32
Selec exi and un:
$ make
$ sudo make modules_ins all
$ sudo make ins all
Depending on he compu e his p ocess may ake a while.
A e he g ub mus be upda ed:
$ sudo upda e-g ub
Reboo he sys em and selec he new Ke nel in he g ub.

4.3 KVM (Ke nel-Based Vi ual Machine)
KVM is a solu ion o implemen a ull i ualiza ion wi h Linux. I is o med by a Ke nel module and
o he ools in he use space. KVM is an Open-Sou ce so wa e de eloped by Qum ane .
To use KVM a x86 o x86_64 p ocesso wi h i ualiza ion suppo is needed. KVM can un
Linux/Unix/Windows gues s o 32 o 64 bi s.
KVM allows he execu ion o se e al Vi ual Machines using ISO images wi h di e en OS (ope a i e
sys em). Each i ual machine has i s own ha dwa e which is i ualized, such as a Ha d Disk D i e, a
Ne wo k In e ace Ca d o a G aphics Ca d …
KVM has been used o ully i ualize he Gues machine inside he Hos machine.
4.3.1 Ins alla ion o KVM
Be o e ins alling KVM he CPU mus suppo ha dwa e i ualiza ion, o ha his command mus be
un:
$ eg ep -c '( mx|s m)' /p oc/cpuin o
I he esul is one o mo e he CPU suppo s ha dwa e i ualiza ion, he nex s ep will be enabling he
i ualiza ion in he BIOS:
$ k m-ok
I he esul is KVM accele a ion can be used i means he ins alla ion can be made, o s a , se e al
packages a e equi ed, such as:
$ sudo ap -ge ins all qemu-k m lib i -bin ubun u- m-builde
b idge-u ils
• qemu-k m is he backend
• lib i -bin p o ides lib i d o adminis e qemu and k m ins ances using lib i
• ubun u- m-builde o building i ual machines
• b idge-u ils o se up a ne wo k o a hos ed i ual machine
A e he use name mus be added o he g oup lib i d:
$ sudo adduse `id -un` lib i d
Adding use '<use name>' o g oup 'lib i d' ...
34
To e i y he ins alla ion un:
$ i sh lis –all
To elog in o es a he Ke nel modules:
$ mmod k m
$ modp obe -a k m
35
4.4 Vi -manage
To c ea e and manage he i ual machine (gues machine), i -manage will be used.
i -Manage is a GUI ool o manage i ual machines h ough lib i . I manages KVM, XEN and LCX
i ual machines. I ep esen s he CPU usage as well as he Hos CPU usage and he Memo y usage o
each i ual machine.
As KVM is equi ed, i -manage is a com o able and easy GUI ool o manage he i ual machine.
4.4.1 Ins alla ion o Vi -manage (g aphical use in e ace)
The ins alla ion o i -manage also equi es se e al packages like lib i -bin and b idge-u ils, which a e
al eady ins alled, as well as he ins alla ion o KVM.
$ sudo ap -ge ins all i -manage
Then, un i -manage :
$ sudo i -manage
Be o e c ea ing a i ual machine, a new connec ion o local QEMU ins ance om ile mus be se
→Add Connec ion menu. Selec QEMU/KVM in he i ual machine lis .
4.4.2 Ins alla ion o a Vi ual Machine wi h Ubun u 16.04
Using he i -manage g aphical use in e ace selec → C ea e a new i ual machine in he ool ba .
36
Figu e 12 S ep 0 Vi ual Machine Ins alla ion
Then w i e he name o you i ual machine, in his case he i ual machine was called MV1, and hen selec
how o ins all he ope a ing sys em.
Figu e 13 S ep 1 Vi ual Machine Ins alla ion
This i ual machine was ins alled using a ISO image o Ubun u 16.04, which can be downloaded om he
sou ce page:
h ps://www.ubun u.com/download/desk op
37
Figu e 14 S ep 2 Vi ual Machine Ins alla ion
The hi d s ep will be choosing he Memo y and CPU se ing, 1024 MB o he RAM and 1 CPU, hese alues
may change depending on he needs.
Figu e 15 S ep 3 Vi ual Machine Ins alla ion
The ou h s ep will be he s o age con igu a ion ha will be assigned o he i ual machine.

38
Figu e 16 S ep 4 Vi ual Machine Ins alla ion
The las s ep, e i y he se ings and modi y se e al ad anced op ions like ne wo king se ings (selec de aul ),
he i ualiza ion ype (KVM) and he a chi ec u e (x86_64). Then p ess Finish.
Figu e 17 S ep 5 Vi ual Machine Ins alla ion
39
When he i ual machine uns o he i s ime he ins alla ion o Ubun u will s a , a e he ins alla ion he
i ual machine can be used.
The ins alla ion o he Ke nel, as well as he ins alla ion o Awlsim mus be done in he i ual machine oo,
ollowing he same s eps ha we e used in he hos machine.
40
4.5 DKMS (dynamic Ke nel Module Suppo )
As he compila ion o he d i e module is equi ed o use he po , DKMS is needed o his pu pose.
DKMS package helps o compile and ins all supplemen a y e sions o Ke nel modules in o he Ke nel ee.
I was de eloped by he Company Dell, one ad an age o DKMS esides in he addi ion o new Ke nel
modules wi hou ins alling a new one, as well as adding new d i e on a sys em, ha ’s why DKMS is e y
use ul o his p ojec .
4.5.1 DKMS Ins alla ion and Use
The package can be ins alled unning he command:
sudo ap -ge ins all build-essen ial dkms
A e ins alling, a dkms.con a chi e mus be c ea ed and w i en in o de o compile and ins all he equi ed
module, in his case imanage -co e.
# cd /home/ia /d i e /iManage
# ouch dkms.con #c ea e dkms.con ile
# gedi dkms.con
In he dkms.con a chi e he ollowing lines a e equi ed:
MAKE="make -C KERNELDIR=/lib/modules/${ke nel e }/build"
CLEAN="make -C clean"
BUILT_MODULE_NAME=iManage
BUILT_MODULE_LOCATION=.
PACKAGE_NAME=iManage
PACKAGE_VERSION=1
REMAKE_INITRD=yes
Then ins alling he equi ed module in o DKMS, he module ins alla ion iles mus be copied in o he Ke nel
sou ce ee:
# ls
README dkms.con lib s c
# sudo cp -R . /us /s c/iManage -1
# sudo dkms add -m iManage – 1
The equi ed module has been added o he lis o modules o build, o ins all he module in o he cu en
Ke nel he ollowing commands mus be un:
# sudo dkms build -m iManage - 1
# sudo dkms ins all -m iManage - 1
Some e o s may appea bu e en hough he compila ion and ins alla ion o he equi ed module wo k
41
5 Sending he Signal o he Hos Machine
5.1 Ad an ech iManage Linux D i e Se
Ad an ech iManage Linux D i e Se is a se o pla o m d i e s which con ains he needed suppo o use he
8-bi Digi al I/O. To manage he GPIOs he Ke nel con ig op ion CONFIG_GPIO_SYSFS needs o be
enabled.
5.1.2 Loading he modules
I he module building and ins alla ion using DKMS is well done, he module should be ins alled, bu no
loaded, o load he module:
$ sudo modp obe imanage -co e
5.1.3 Using GPIO om Use -Space
To y he GPIOs his p og am was implemen ed, i w i es he alue o he signal ha comes in o he pin 504,
he de ice’s ou h pin, hen i s alue is w i en in o he pin 505 which is he de ice’s i h pin:
$ sudo su
$ cd /sys/class/gpio
$ echo 504 > expo
$ echo in > gpio504/di ec ion
$ echo 505 > expo
$ echo ou > gpio505/di ec ion
$cd $HOME
#!/bin/sh
#modp obe imanage -co e
#echo $1> /sys/class/gpio/expo
#echo ou > /sys/class//gpio/$1/di ec ion
while busybox echo hey > /de /null
do
alue=`ca /sys/class/gpio/gpio505/ alue`
echo “$ alue” > /sys/class/gpio/gpio504/ alue
done
The aim o his p og am is o show ha he communica ion be ween he Digi al I/O o he hos machine and
he Linux OS is possible.
48
6.3 Ke nel Con igu a ion and building
To change he Ke nel con igu a ion, he nex command mus be un:
$ make menucon ig
Then se e al con igu a ions mus be selec ed in he menu:
• Selec P ocesso ype and u u es→ P eemp ion Model (Fully P eemp ible Ke nel (RT)) → Enable Fully
P eemp ible Ke nel (RT)
Figu e 24 Selec ing Ke nel con igu a ions

49
Figu e 25 Selec ing Ke nel con igu a ions
Figu e 26 Selec ing Ke nel con igu a ions
50
• Selec Gene al Se up→ Enable P omp o de elopmen and/o incomple e code/d i e s
Figu e 27 Selec ing Ke nel con igu a ions
Figu e 28 Selec ing Ke nel con igu a ions
51
• Selec Bus Op ions→ Enable Suppo o DMA Remapping De ices (Expe imen al)
Figu e 29 Selec ing Ke nel con igu a ions
Figu e 30 Selec ing Ke nel con igu a ions
52
• Selec Bus Op ions→ Enable DMA Remapping De ices by de aul
Figu e 31 Selec ing Ke nel con igu a ions
53
• Selec Bus Op ions→ Enable Suppo o In e up Remapping (EXPERIMENTAL)
Figu e 32 Selec ing Ke nel con igu a ions

54
• Selec Bus Op ions→ Enable PCI S ub d i e
Figu e 33 Selec ing Ke nel con igu a ions
Those con igu a ions ha e been modi ied in o use a Fully P eemp ible Ke nel o wo k in Real Time and o
assign de ices wi h V -d in KVM V -d Suppo o communica e he Digi al I/O wi h he gues machine.
Selec exi and un:
$ make CC=gcc-4.9
$ sudo make modules_ins all
$ sudo make ins all
The i s command is e y impo an , as a 3.0 Ke nel e sion was equi ed, he Ke nel mus be compiled wi h
a gcc e sion unde gcc-5 one.
Depending on he compu e his p ocess may ake a while.
A e he g ub mus be upda ed:
$ sudo upda e-g ub
Reboo he sys em and selec he new Ke nel in he g ub.
55
Conclusion and Fu u e In es iga ions
A e eboo ing he sys em and using he new Ke nel e sion ha was equi ed o i ualize he Digi al I/O o
ead he signal om he gues machine, he sys em was no wo king p ope ly, he pe o mance o any kind o
p og am was slow, also se e al d i e s we e missing, like he E he ne one. This p oblem was sol ed, e en he
d i e s ha we e missing we e ins alled, he sys em was no s ill wo king p ope ly.
As i was impossible con inue wo king wi h his Ke nel e sion ha allows he i ualiza ion o he po , he
con inua ion o he p ojec was no possible because he communica ion be ween he gues machine and he
digi al I/O is no achie able. A possible cause may be ha he d i e se o manage he Digi al I/O was no
de eloped by he ha dwa e de elope so i may no wo k as i is expec ed. Also, he equi ed expe imen al
Ke nel op ions we e emo ed om he new Ke nel eleases which a e no suppo ed anymo e.
E en hough he communica ion be ween he Digi al I/O and he Linux sys em wo ks wi hou p oblems as i
was shown wi h he oscilloscope images ha ep esen s he desi ed signal and he ecei ed signal ha Linux
ge s.
To con inue and imp o e he p ojec he delay mus minimized using ano he Ke nel con igu a ion ha should
be modi ied.
Abou he i ualiza ion o he Digi al I/O ha equi es V -d, he ins alla ion and compila ion o a Ke nel
e sion unde he 3.0 and y i he expe imen al con igu a ions equi ed wo k.
O he possibili y may include o he ha dwa e o he use o o he OS o y he po i ualiza ion in he gues
machine.
56
Bibliog aphy
[1] Con olado Lógico P og amable. (10 Oc 2017). Wikipedia.o g. 23 Oc 2017 om
h ps://es.wikipedia.o g/wiki/Con olado _l%C3%B3gico_p og amable
[2] C.Ramí ez Villa eal. (28 Sep 2005). Con olado es Lógicos P og amables. Mailxmail.com. 23 Oc 2017
om h p://www.mailxmail.com/cu so-con olado es-logicos-p og amables/concep os-gene ales-
p og amacion
[3] Au óma as P og amables. (Dec 2001). Sc.ehu.es. 23 Oc 2017 om
h p://www.sc.ehu.es/sbweb/webcen o/au oma ica/WebCQMH1/PAGINA%20PRINCIPAL/index.h m
[4] A k-1550. (1983-2017). Ad an ech.com. 23 Oc 2017 om
h p://www.ad an ech.com/p oduc s/1-2jkbyz/a k-1550/mod_780d96d -217e-46ea-ab74-543125943316
[5] Ad an ech-ARK-1550-Da ashee . Ecauk.com.
23 Oc 2017 om h ps://ecauk.com/ iles/2014/02/Ad an ech-ARK-1550-Da ashee .pd
[6] Use Manual ARK-1550. (2014) P oso . u.
23 Oc 2017 om h ps://www.p oso . u/cms/ /455727.pd
[7] A. Ma ia. (20 Jun 2017). HOWTO se up Linux wi h PREEMPT_RT p ope ly. Wiki.linux unda ion.o g.
23 Oc 2017 om
h ps://wiki.linux ounda ion.o g/ eal ime/documen a ion/how o/applica ions/p eemp _se up
[8] Building a -p eemp ke nel o Debian Jessie - x86-amd64. machineki .io.
23 Oc 2017 om h p://www.machineki .io/docs/de eloping/building- -p eemp -ke nel/
[9] Index o /pub/linux/ke nel/p ojec s/ /. (2017). ke nel.o g.
23 Oc 2017 om h ps://www.ke nel.o g/pub/linux/ke nel/p ojec s/ /
[10] RT PREEMPT HOWTO. (17 Jul 2017). R .wiki.ke nel.o g.
23 Oc 2017 om h ps:// .wiki.ke nel.o g/index.php/RT_PREEMPT_HOWTO#Pa ching_ he_Ke nel
57
[11] S Ros ed & D.V. Ha . (Jun 2007). In e nals o he RT Pa ch. Ke nel.o g.
23 Oc 2017 om h ps://www.ke nel.o g/doc/ols/2007/ols2007 2-pages-161-172.pd
[12] PySide Team. (2014). Building PySide on a Linux Sys em (Ubun u 12.04 - 14.04). pyside. ead hedocs.io.
23 Oc 2017 om h p://pyside. ead hedocs.io/en/la es /building/linux.h ml
[13] Daniel P.Be angé (2009-2017). Manage i ual machines wi h i -manage . Vi -manage .o g.
23 Oc 2017 om h ps:// i -manage .o g/
[14] Lee sha p. (10 Ap 2016). KVM/Vi Manage . Help.ubun u.com.
23 Oc 2017 om h ps://help.ubun u.com/communi y/KVM/Vi Manage
[15] Ubun u o desk op. (2017). Ubun u.com. 23 Oc 2017 om h ps://www.ubun u.com/desk op
[16] P.Bonzini. (10 Sep 2015). Real ime KVM. Lwn.ne . 23 Oc 2017 om h ps://lwn.ne /A icles/656807/
[17] Rik an Riel. (2015). Real- ime KVM om he g ound up. E en s.linux ounda ion.o g
23 Oc 2017 om h p://e en s.linux ounda ion.o g/si es/e en s/ iles/slides/k m o um2015- eal imek m.pd
[18] H.Schwie e ing. (6 May 2017). KVM wiki.ubun uuse s.de.
23 Oc 2017 om h ps://wiki.ubun uuse s.de/KVM/
[19] GRUB. (20 Jun 2011). Guia-ubun u.com. 23 Oc 2017 om
h ps://www.guia-ubun u.com/index.php/GRUB
[20] M.Büsch. (30 Aug 2017). Bues.ch. 23 Oc 2017 om h ps://bues.ch/cms/au oma ion/awlsim.h ml
[21] D.Ki kland. (2010). dkms - Dynamic Ke nel Module Suppo . Manpages.ubun u.com.
23 Oc 2017 om h p://manpages.ubun u.com/manpages/zes y/man8/dkms.8.h ml
[22] Lina d . (18 Ma 2017). DKMS. Help.ubun u.com.
23 Oc 2017 om h ps://help.ubun u.com/communi y/DKMS
[23] Dynamic Ke nel Module Suppo . Wiki.a chlinux.o g.
23 Oc 2017 om h ps://wiki.a chlinux.o g/index.php/Dynamic_Ke nel_Module_Suppo
[24] GPIO. (28 Jul 2017). Linux-sunxi.o g. 23 Oc 2017 om h p://linux-sunxi.o g/GPIO
[25] GPIO. (27 Oc 2011). Elinux.o g. 23 Oc 2017 om h ps://elinux.o g/GPIO