Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control Environment Thesis Defense by...

21
Upgrade to Real Time Linux Target: Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control A MATLAB-Based Graphical Control Environment Environment Thesis Defense by Hai Xu CLEMSON CLEMSON U N I V E R S I T Y Department of Electrical and Computer Engineering

Transcript of Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control Environment Thesis Defense by...

Upgrade to Real Time Linux Target: Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control A MATLAB-Based Graphical Control

EnvironmentEnvironment

Thesis Defense

byHai Xu

CLEMSONCLEMSONU N I V E R S I T Y

Department of Electrical and Computer Engineering

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Presentation Overview

• IntroductionIntroduction

• Technical Approach:Technical Approach: Memory AllocationMemory Allocation

Shared Memory PoolShared Memory Pool Log BufferLog Buffer

RTLT Hardware InterfaceRTLT Hardware Interface Hardware Client-Server Architecture in RTLTHardware Client-Server Architecture in RTLT How does RTLT work with SIMULINK ?How does RTLT work with SIMULINK ?

• What’s new in the upgraded version of RTLT ?What’s new in the upgraded version of RTLT ?

• LMotor (GUI)LMotor (GUI)

• ConclusionsConclusions

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Introduction

• RTLT (Real-Time Linux Target) is a software package that gives the user the ability to implement a SIMULINK block diagram on a standard Intel PC in hard real-time.

RTLT RTLT provides a provides a Graphical EnvironmentGraphical Environment for the implementation and for the implementation and execution of control algorithms.execution of control algorithms.

RTLT combines the superior RTLT combines the superior computation powercomputation power of MATLAB engine with of MATLAB engine with the the block diagram capabilitiesblock diagram capabilities of SIMULINK. of SIMULINK.

RTLT has been successfully used in many control experiments at RTLT has been successfully used in many control experiments at Clemson.Clemson.

• LMotor is a Graphic User Interface (GUI) for RTLT. LMotor provides visual modeling capabilities to help users understand complex systems.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Introduction (Cont’d)

• MATLAB is a software environment that allows a user to easily integrate computation and visualization tasks.

• SIMULINK is a software package for modeling, simulating, and analyzing dynamic systems in the MATLAB environment.

• Real-Time Workshop (RTW) is an automatic C language code generator for SIMULINK.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Technical Approach

• Memory Allocation:Memory Allocation: Shared Memory PoolShared Memory Pool Log BufferLog Buffer

• RTLT Hardware InterfaceRTLT Hardware Interface

• Hardware Client-Server Architecture in RTLTHardware Client-Server Architecture in RTLT

• How does RTLT work with SIMULINK ? How does RTLT work with SIMULINK ?

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Shared Memory Pool

Process 1 Process 2

Shared Memory Pool

Read/Write Data

• What is Shared Memory?What is Shared Memory?

2 or more processes can2 or more processes can access a access a singlesingle chunk of chunk of memory. memory. Communication isCommunication is achieved by reading andachieved by reading and writing to this block of writing to this block of memory.memory.

Shared Memory is a Shared Memory is a fastfast,, no-blockingno-blocking Inter-Process Inter-Process Communication (IPC)Communication (IPC) method.method.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Shared Memory Pool (Cont’d)

• What is Shared Memory Pool?What is Shared Memory Pool? Shared Memory Pool is a block of physical memory that is Shared Memory Pool is a block of physical memory that is reserved reserved

during boot upduring boot up.. Shared Memory Pool is allocated inShared Memory Pool is allocated in Kernel space Kernel space.. Shared Memory Pool can be used in Shared Memory Pool can be used in User space User space by using the Shared by using the Shared

Memory Management Memory Management APIAPIs (Application Program Interface) of s (Application Program Interface) of RTLT.RTLT.

RTLT uses a shared memory pool to facilitate the implementation RTLT uses a shared memory pool to facilitate the implementation of hardware of hardware client-serverclient-server architecture. architecture.

• The maximum size of the Shared Memory Pool is The maximum size of the Shared Memory Pool is 4 MB4 MB in Intel- in Intel- Pentium class machines and above. On earlier machines, it is 1 MB.Pentium class machines and above. On earlier machines, it is 1 MB.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Log Buffer

• Why we have to use Log Buffer?Why we have to use Log Buffer? To save large amounts of data, Shared Memory Pool is To save large amounts of data, Shared Memory Pool is not big not big

enoughenough..

• What is Log Buffer?What is Log Buffer? Created in the Created in the Kernel address spaceKernel address space (controlled by Linux Kernel) (controlled by Linux Kernel)

and mapped to and mapped to User spaceUser space. . The created log buffer is not in the Shared Memory Pool.The created log buffer is not in the Shared Memory Pool. At present, we can create At present, we can create onlyonly oneone log buffer in RTLT. log buffer in RTLT.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Log Buffer (cont’d)

• How to use Log Buffer?How to use Log Buffer?

The The base addressbase address and the and the sizesize of the log buffer are of the log buffer are initialized in Kernel space initialized in Kernel space and then mapped to the and then mapped to the User space. User space.

Both Kernel and User Both Kernel and User processes can access the processes can access the big "shared"big "shared" log buffer. log buffer.

Shared Shared Memory Memory

PoolPoolLog BufferLog Buffer

User SpaceUser SpaceKernel SpaceKernel Space

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Hardware Client-Server Architecture in RTLTHardware Client-Server Architecture in RTLT

• I/O Board Servers (Device Drivers):

- read input data from I/O Board through A/D channels or digital lines, etc. Write the data to the Shared Memory Pool.

- write output data from the Shared Memory Pool to the I/O Board.

• I/O Board Clients (Real-Time targets):

- read input data from the Shared Memory Pool.

- write the processed data to Shared Memory Pool.

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Hardware Client-Server Architecture in RTLT (Cont’d)Hardware Client-Server Architecture in RTLT (Cont’d)

I/O Board Client 1

I/O Board Client 2

I/O Board Client n

Control Program 1Control Program 1

I/O Board Server1

I/O Board Server2

I/O Board Servern

Control Program 2Control Program 2

I/O Board Clientm

I/O Board 1

I/O Board 2

I/O Board n

via Shared Memoryvia Shared Memory

via Shared Memoryvia Shared Memory

via Shared Memoryvia Shared Memory

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Hardware Interface for RTLT

• Supported Supported Inexpensive Motion Control Board:Inexpensive Motion Control Board:

- MultiQ2, MultiQ3, ServoToGo, PCL812, Pmac and AtiFT- MultiQ2, MultiQ3, ServoToGo, PCL812, Pmac and AtiFT

• Supported Interfaces:Supported Interfaces:

- A/D- A/D

- D/A- D/A

- Encoder- Encoder

- Digital I/O- Digital I/O

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK ?How does RTLT work with SIMULINK ?

• Create the Control Program with the SIMULINK block diagram and RTLT SIMULINK Library blocks:

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK?How does RTLT work with SIMULINK? (Cont’d) (Cont’d)

• Digital To Analog ConverterDigital To Analog Converter: Redirects the Input Signal to the Converter Block : Redirects the Input Signal to the Converter Block to the Specified D/A channelto the Specified D/A channel

• Analog To Digital ConverterAnalog To Digital Converter: Reads Input Signal from the A/D channel: Reads Input Signal from the A/D channel

• Digital OutputDigital Output: Outputs TTL Level Signal to Specified Line (bit): Outputs TTL Level Signal to Specified Line (bit)

• Digital InputDigital Input: Reads TTL Level Signal from Specified Line (bit): Reads TTL Level Signal from Specified Line (bit)

• Read EncoderRead Encoder: Reads the Quadrature Encoder Signal and Converts to a : Reads the Quadrature Encoder Signal and Converts to a Number (Representing, for example, Angular Displacement of a Rotor)Number (Representing, for example, Angular Displacement of a Rotor)

• Set EncoderSet Encoder: Allows User to Set the Encoder Reading to a Pre- Determined : Allows User to Set the Encoder Reading to a Pre- Determined Value (Used to commutate, for example, SR, Stepper and BLDC motors)Value (Used to commutate, for example, SR, Stepper and BLDC motors)

• Reset FTReset FT: : The Reset FT block allows the user to reset the bias array of the ATI The Reset FT block allows the user to reset the bias array of the ATI Force/Torque sensor system. (for ATI FT board only)Force/Torque sensor system. (for ATI FT board only)

• Hardware AdapterHardware Adapter: Special Block that Provides a Reference to a Particular I/O : Special Block that Provides a Reference to a Particular I/O BoardBoard

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK? How does RTLT work with SIMULINK? (Cont’d)(Cont’d)

• A Control Program Example:

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK?How does RTLT work with SIMULINK? (Cont’d) (Cont’d)

• Initialize Simulation Parameters:Initialize Simulation Parameters:

I/O BoardI/O Board Simulation ParametersSimulation Parameters

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK? How does RTLT work with SIMULINK? (Cont’d)(Cont’d)

• Build Real-Time Target and Execute:Build Real-Time Target and Execute:

External Model Control PanelExternal Model Control Panel

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

How does RTLT work with SIMULINK? How does RTLT work with SIMULINK? (Cont’d)(Cont’d)

• Some Optional Simulation Parameters:Some Optional Simulation Parameters:

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

What’s new ?What’s new ?

• Newer stable Linux KernelNewer stable Linux Kernel

– From version 2.2.13 to 2.2.18From version 2.2.13 to 2.2.18

• Newer MATLABNewer MATLAB

– From version 5.3 to 6.0From version 5.3 to 6.0

• Newer RTLinuxNewer RTLinux

– From version 2.0 to 3.0From version 2.0 to 3.0

• Newer RedHat LinuxNewer RedHat Linux

– From version 6.x to 7.0From version 6.x to 7.0

• LMotorLMotor

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

LMotorLMotor

• What is LMotor ?What is LMotor ?

LMotor is a Graphic User Interface (GUI) for RTLTLMotor is a Graphic User Interface (GUI) for RTLT

LMotor features include :LMotor features include :

on-line parameter tuningon-line parameter tuning without recompiling the MATLAB model without recompiling the MATLAB model

allowing users to allowing users to watchwatch the Real-Time values of selected log variables the Real-Time values of selected log variables

monitoring of logged variables during control execution in the form of monitoring of logged variables during control execution in the form of real-time plotreal-time plot windows windows

superior real-time plottingsuperior real-time plotting capabilities in conjunction with MATLAB capabilities in conjunction with MATLAB compatible data loggingcompatible data logging

exporting logged dataexporting logged data to MATLAB compatible data format (M-files). to MATLAB compatible data format (M-files).

Clemson University Controls & MechatronicsClemson University Controls & Mechatronics

Conclusions

• Salient Features of the Real-Time Linux Target

Utilizes the Computational Power of MATLAB

Block Diagram- based Approach (SIMULINK)

Online Data Plotting

Online Parameter Tuning

MATLAB Compatible Data Export (M- Files)

Multiple I/O Boards Support

Data Sharing

• Future Work

Upgrade the RTLT to newer Linux Kernel and RTLinux.

More I/O board drivers support

Optimize the LMotor