qsg precompiled openpowerlink demo raspberrypi2€¦ · this table lists the hardware items...

19
Copyright ©Kalycito 1/19 Quick start guide Precompiled openPOWERLINK demo on Raspberry Pi2 Identifier QSG_oplk_demo_RPi2 Version 1.0 Date 05-May-2015 Distribution Scope Public

Upload: dinhkhuong

Post on 18-Apr-2018

221 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 1/19

Quick start guide

Precompiled openPOWERLINK demo

on Raspberry Pi2

Identifier QSG_oplk_demo_RPi2

Version 1.0

Date 05-May-2015

Distribution Scope Public

Page 2: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 2/19

Revision Information Version Date Remark

1.0 05-May-2015 First version

License Information Everyone is permitted to copy and distribute verbatim copies of this document, but changing it is not allowed.

Disclaimer We reserve the right to change the content of this manual without prior notice. The information contained herein is believed to be accurate as of the date of publication; however, Kalycito makes no warranty, expressed or implied, with regards to the products or the documentation contained within this document. Kalycito shall not be liable in the event of incidental or consequential damages in connection with or arising from the furnishing, performance or use of these products. The software names, hardware names and trademarks used in this document are registered by the respective companies.

Page 3: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 3/19

Contents

1. Introduction .................................................................................................................................... 5

2. Test Setup: openPOWERLINK on Raspberry Pi2 ............................................................................. 5

2.1. Network architecture .............................................................................................................. 6

3. Dependencies .................................................................................................................................. 7

3.1. Hardware requirement ........................................................................................................... 7

3.2. Software requirement............................................................................................................. 7

4. Setup steps ...................................................................................................................................... 8

4.1. Get Ubuntu Linux on Raspberry Pi2 ........................................................................................ 8

4.2. Prepare the openPOWERLINK binaries ................................................................................... 8

4.3. Installing the environment for running POWERLINK .............................................................. 9

4.4. Running the openPOWERLINK master .................................................................................... 9

4.5. Running the openPOWERLINK slave ..................................................................................... 12

5. Send and receive data using the IO pins ....................................................................................... 16

5.1. Raspberry Pi2 GPIOs.............................................................................................................. 16

5.2. Interacting with the IO pins .................................................................................................. 17

6. Summary ....................................................................................................................................... 18

7. Reference links .............................................................................................................................. 19

Page 4: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 4/19

List of Figures

Figure 1: Network architecture: openPOWERLINK on Raspberry Pi2 .................................................... 6

Figure 2: Mounting and unzipping from the USB thumb drive............................................................... 9

Figure 3: Install POWERLINK dependencies ............................................................................................ 9

Figure 4: Running the openPOWERLINK master ................................................................................... 10

Figure 5: Choosing the network interface to run openPOWERLINK master ........................................ 10

Figure 6: Initializing the process image ................................................................................................. 11

Figure 7: openPOWERLINK master reaches operational state ............................................................. 11

Figure 8: Running the openPOWERLINK slave binaries ........................................................................ 12

Figure 9: Choosing the network interface to run openPOWERLINK slave ............................................ 13

Figure 10: Initializing the process image ............................................................................................... 13

Figure 11: openPOWERLINK slave reaches operational state .............................................................. 14

Figure 12: openPOWERLINK master log when openPOWERLINK slave reaches operational state ..... 15

Figure 13: Raspberry Pi2 GPIO Header ................................................................................................. 16

Figure 14: 0VDC input given to openPOWERLINK master .................................................................... 17

Figure 15: 3.3VDC input given to openPOWERLINK master ................................................................. 17

Figure 16: Output of openPOWERLINK slave at 0VDC .......................................................................... 18

Figure 17: Output of openPOWERLINK slave at 3.3VDC ....................................................................... 18

Page 5: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 5/19

1. Introduction

This is a quick start guide for running a precompiled openPOWERLINK demo using the Raspberry Pi2 boards. This can be used to

Build a distributed automation platform using POWERLINK network.

Sense and control IO pins over a real time Ethernet network. This can be used to control the signals of motors, sensors, relays via the automation network.

2. Test Setup: openPOWERLINK on Raspberry Pi2

In this demo,

One Raspberry Pi2 board acts as the openPOWERLINK master and the other two Raspberry Pi2 boards act as openPOWERLINK slaves.

o Setup Ubuntu Linux on the three Raspberry Pi2 boards. o Setup and run precompiled openPOWERLINK master and slave binaries on Linux on

Raspberry Pi2.

Test cyclic process data exchange (PDO) between openPOWERLINK master and openPOWERLINK slave over POWERLINK network.

o Connect openPOWERLINK master and two openPOWERLINK slaves via a network switch.

o Control the ON/OFF state of the openPOWERLINK slave GPIOs from openPOWERLINK master via cyclic data over POWERLINK network.

Note: For more information on the Process Data Object (PDO) refer to this URL http://openpowerlink.sourceforge.net/web/POWERLINK/PDO.html

Page 6: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 6/19

2.1. Network architecture

In this diagram, the openPOWERLINK master is connected to two openPOWERLINK slaves using a switch. A windows PC can also be connected to the switch to capture the packets from the POWERLINK network.

Figure 1: Network architecture: openPOWERLINK on Raspberry Pi2

Page 7: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 7/19

3. Dependencies

3.1. Hardware requirement

This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2.

S. No. Hardware Quantity

1 Raspberry Pi 2 board to act as the openPOWERLINK Master 1

2 Raspberry Pi 2 board to act as the openPOWERLINK Slaves 2

3 Network switch with at least 4 ports 1

4 Ethernet cables 4

5 Micro SD card reader 1

6 Micro SD card 3

7 USB thumb drive 1

8 HDMI display, USB keyboard and mouse 3 sets

9 Micro USB cables to power the Raspberry Pi2 boards 3 sets

10 Windows PC 1

3.2. Software requirement

This table lists the software packages and its dependencies to be downloaded to run openPOWERLINK on Raspberry Pi2.

S. No. Package Download URL

1 Ubuntu OS image http://lucario.info/archive/raspuntu-tjc-2015-02-16.zip

2 Win32 disk imager http://sourceforge.net/projects/win32diskimager/

3 openPOWERLINK_RaspberryPi2

https://sourceforge.net/projects/openpowerlink/files/QuickStartGuides/RaspberryPi2/openPOWERLINK_RaspberryPi2.tar.gz

4 Install_pcap http://www.kalycito.com/images/articles/rpi2/Install_pcap.sh.tar.gz

5 pcap library http://ftp.debian.org/debian/pool/main/libp/libpcap/libpcap-dev_1.6.2-2_all.deb

6 Dependency file 1 for “pcap library”

http://ftp.debian.org/debian/pool/main/libp/libpcap/libpcap0.8_1.6.2-2_armhf.deb

7 Dependency file 2 for “pcap library”

http://ftp.debian.org/debian/pool/main/libp/libpcap/libpcap0.8-dev_1.6.2-2_armhf.deb

8 Wiring PI https://git.drogon.net/?p=wiringPi;a=snapshot;h=5edd177112c99416f68ba3e8c6c4db6ed942e796;sf=tgz

9 Wireshark v1.2.1 https://www.wireshark.org/download.html

Note: The downloaded openPOWERLINK_RaspberryPi2.tar.gz package is preconfigured to run openPOWERLINK with the following configuration:

Cycle time of 50 milliseconds.

In Isochronous phase o 1 byte data transfer from openPOWERLINK master to openPOWERLINK slave o 1 byte data transfer from openPOWERLINK slave to openPOWERLINK master

Page 8: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 8/19

4. Setup steps

This section describes the software set up steps to be carried out to run openPOWERLINK on Raspberry Pi2. The instructions in this section have to be followed for all three Raspberry Pi2 boards.

4.1. Get Ubuntu Linux on Raspberry Pi2

This section describes the set up steps to be carried out on the Windows PC to prepare a Linux image on a SD card for the Raspberry Pi2. Before plugging anything into the Raspberry Pi2, make sure all the hardware and software listed in the section 4.1 and section 4.2 are in hand. Then follow the instructions given below:

Begin by slotting your SD card into the SD card reader and connect to the windows PC. Launch Win32 disk imager. Click on the blue folder icon next to the input box labelled 'Image File', browse to where

your Ubuntu-image is and double click on it. Next click on the button under 'Device' and pick the device you want to write the image to,

from the drop down menu. o Make sure it matches the letter assigned to your SD card in the computer window,

then click 'Write'. o Doing this will wipe your card so make sure there's nothing on it you want to keep.

It will likely take at least 10 minutes or so to complete. o Once the 'Write Successful' window appears, remove the micro SD card and insert it

into the Raspberry Pi2 board.

Next, plug in your USB keyboard and Mouse into the USB slots on the Raspberry Pi2.

Make sure that your HDMI display (monitor or TV) is powered on, and that you have selected the right input (e.g. HDMI 1, DVI etc.) method.

Then connect your HDMI cable from your Raspberry Pi2 to your display.

Power on the Pi2 board. It should boot into an Ubuntu intro screen showing two logins. o Select the user 'linaro' and enter the password 'linaro' to login.

4.2. Prepare the openPOWERLINK binaries

This section describes the set up steps to be carried out on the Windows PC to copy the downloaded software into the USB thumb drive.

Copy the ‘openPOWERLINK_RaspberryPi2.tar.gz’ package into the USB thumb drive.

Copy the WiringPI package into the USB thumb drive.

Copy the pcap library, dependency file 1, dependency file 2, Install_pcap.sh.tar.gz files into the USB thumb drive.

Page 9: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 9/19

4.3. Installing the environment for running POWERLINK

This section describes the set up steps to be carried out on the Raspberry Pi2 board to copy the downloaded software from the USB thumb drive to the Raspberry Pi2 board. Plug in the USB thumb drive to the USB port of the Raspberry Pi2. Follow the instructions below:

Transfer openPOWERLINK_RaspberryPi2.tar.gz package and the dependency files for Pcap to Raspberry Pi2 board o sudo su o mount /dev/sda1 /mnt/ o cp -R /mnt/* /home/linaro/

Figure 2: Mounting the USB thumb drive

Run the following commands to install pcap on all the three Raspberry Pi2 boards: o tar –xvf Install_pcap.sh.tar.gz o chmod +x Install_pcap.sh o ./Install_pcap.sh

Figure 3: Install POWERLINK dependencies

4.4. Running the openPOWERLINK master

This section describes steps to run the openPOWERLINK master using the precompiled binaries.

On the Raspberry Pi2 board to be used as the openPOWERLINK master follow the below commands: o tar –xvf openPOWERLINK_RaspberryPi2.tar.gz o cd openPOWERLINK_RaspberryPi2/MN/demo_mn_console o chmod +x demo_mn_console o cd openPOWERLINK_RaspberryPi2/MN/oplkd-pcap o chmod +x oplkmnd-pcap o cd openPOWERLINK_RaspberryPi2/MN/ o chmod +x demo_mn_console o chmod +x oplkd-pcap o chmod +x Run_oplk_MN.sh o ./Run_oplk_MN.sh

Page 10: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 10/19

Figure 4: Running the openPOWERLINK master

Choose the interface “eth0” when prompted to select the interface to be used for POWERLINK.

Figure 5: Choosing the network interface to run openPOWERLINK master

Page 11: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 11/19

Then the openPOWERLINK master will initialize the process image and start the POWERLINK stack.

Figure 6: Initializing the process image

Finally the openPOWERLINK master will reach operational state with the event “NmtEventEnterMsOperational” as shown in the below screenshot.

Figure 7: openPOWERLINK master reaches operational state

Page 12: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 12/19

4.5. Running the openPOWERLINK slave

This section describes how to run the openPOWERLINK slave using the precompiled binaries.

On the Raspberry Pi2 boards to be used as openPOWERLINK slaves. Follow the below commands: o tar –xvf openPOWERLINK_RaspberryPi2.tar.gz o cd openPOWERLINK_RaspberryPi2/CN_1/demo_cn_console o chmod +x demo_cn_console o cd openPOWERLINK_RaspberryPi2/CN_1/oplkd-pcap o chmod +x oplkcnd-pcap o cd openPOWERLINK_RaspberryPi2/CN_1/ o chmod +x demo_cn_console o chmod +x oplkd-pcap o chmod +x Run_oplk_CN_1.sh o ./ Run_oplk_CN_1.sh

Figure 8: Running the openPOWERLINK slave binaries

Page 13: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 13/19

Choose the interface “eth0” when prompted to select the interface to be used for POWERLINK.

Figure 9: Choosing the network interface to run openPOWERLINK slave

Then the openPOWERLINK slave will initialize the process image and start the POWERLINK stack.

Figure 10: Initializing the process image

Page 14: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 14/19

Finally the openPOWERLINK slave will reach operational state with the event “NmtEventStartNode” as shown in the below screenshot.

Figure 11: openPOWERLINK slave reaches operational state

Page 15: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 15/19

On the openPOWERLINK master console, the master gives out the log “NmtCsOperational” when the openPOWERLINK slave reaches operational state as shown in the below screenshot.

Figure 12: openPOWERLINK master log when openPOWERLINK slave reaches operational state

That’s it; you've got a running POWERLINK network!

Page 16: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 16/19

5. Send and receive data using the IO pins

This section will describe:

How to access the Raspberry Pi2 GPIOs

How to control the ON/OFF state of the openPOWERLINK slave GPIOs from openPOWERLINK master via cyclic data (PDO) over POWERLINK network.

5.1. Raspberry Pi2 GPIOs

The Raspberry Pi2 has a 26-pin General Purpose Input/output (GPIO) of which 8 are general purposes digital I/O pins – these can be programmed as either digital outputs or inputs.

Figure 13: Raspberry Pi2 GPIO Header

Page 17: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 17/19

5.2. Interacting with the IO pins

This section demonstrates how to control the ON/OFF state of the openPOWERLINK slave GPIOs from openPOWERLINK master via PDO over POWERLINK network. The precompiled binaries perform the steps needed to manipulate the GPIOs while transmitting and receiving the data over POWERLINK network,

Providing “0VDC” to the header pin #11 of openPOWERLINK master

Figure 14: 0VDC input given to openPOWERLINK master

Providing “3.3VDC” to the header pin #11 of openPOWERLINK master

Figure 15: 3.3VDC input given to openPOWERLINK master

Input

at

Pin #11

Ground

3.3V

Input

at Pin

#11

Page 18: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 18/19

The openPOWERLINK slaves receive the PDO from the openPOWERLINK master and o Enable its header pin#11 to “0VDC” if the data received from the openPOWERLINK

master is “0”

Figure 16: Output of openPOWERLINK slave at 0VDC

o Enable its header pin#11 to “3.3VDC” if the data received from the openPOWERLINK

master is “1”

Figure 17: Output of openPOWERLINK slave at 3.3VDC

6. Summary

With the instructions provided in this quick start guide, you can

Prepare the Linux and openPOWERLINK environment on Raspberry Pi2 boards

Setup and run the openPOWERLINK network with one master and two slaves

Interface a signal to the input GPIO pin of the openPOWERLINK master

Thereby control the ON/OFF state of the corresponding output GPIO pin of the openPOWERLINK slaves over the POWERLINK network

Output at

Pin #11 Ground

Output at

Pin #11 Ground

Page 19: QSG precompiled openPOWERLINK demo RaspberryPi2€¦ · This table lists the hardware items required to run openPOWERLINK on Raspberry Pi2. S. No. Hardware Quantity 1 Raspberry Pi

Copyright ©Kalycito 19/19

An LED can be connected in series with an appropriate resistor value across PIN #11(OUTPUT) and PIN #39 (GND) of the Raspberry Pi2 openPOWERLINK slave to visually see the status of the output data on the openPOWERLINK slave. That’s it; you can now control the ON/OFF states of Raspberry Pi2 GPIOs via POWERLINK network! This GPIO demo over POWERLINK on Raspberry Pi2 provides a platform to enable users to quickly and cost effectively build and evaluate their own real-time distributed automation projects with open source resources.

7. Reference links

For the quick start documentation, click here

To know more about POWERLINK, click here

To know more about POWERLINK Master, click here

To download Open Source POWERLINK stack, click here

For specifications related to POWERLINK, click here