A simple control application with Real Time Linux Peter Wurmsdobler Real Time Systems Lab 2001.09.12 Jong-Koo, Lim Paper Survey.

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

DEVICE DRIVER VINOD KAMATH CS691X PROJECT WORK. Introduction How to write/install device drivers Systems, Kernel Programming Character, Block and Network.
Linux device-driver issues
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
RT_FIFO, Device driver.
Lecture for Lab 3, Exp1 of EE505 (Developing Device Driver) T.A. Chulmin Kim CoreLab. Mar, 11, 2011 [XenSchedulerPaper_Hotcloud-commits] r21 - /
Computer System Laboratory
MPI Message Passing Interface
Threads Relation to processes Threads exist as subsets of processes Threads share memory and state information within a process Switching between threads.
USERSPACE I/O Reporter: R 張凱富.
Module R2 Overview. Process queues As processes enter the system and transition from state to state, they are stored queues. There may be many different.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Threads. Readings r Silberschatz et al : Chapter 4.
Chap 2 System Structures.
RTLINUX/RTFIFO and Tcl/Tk Nishant Upadhyaya Maung Wynn Aung Han Professor Insup Lee CIS642: Seminar in Real-time Systems University of Pennsylvania.
Server Architecture Models Operating Systems Hebrew University Spring 2004.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Improving IPC by Kernel Design Jochen Liedtke Shane Matthews Portland State University.
OPERATING SYSTEMS Introduction
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
CprE 458/558: Real-Time Systems (G. Manimaran)1 RTLinux Lab – Introduction Cpre 558 Anil
Operating System Program 5 I/O System DMA Device Driver.
Real-time Systems Lab, Computer Science and Engineering, ASU Linux Input Systems (ESP – Fall 2014) Computer Science & Engineering Department Arizona State.
Data Acquisition Data acquisition (DAQ) basics Connecting Signals Simple DAQ application Computer DAQ Device Terminal Block Cable Sensors.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Upgrade to Real Time Linux Target: A MATLAB-Based Graphical Control Environment Thesis Defense by Hai Xu CLEMSON U N I V E R S I T Y Department of Electrical.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 14, 2005 Operating System.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
Kernel Modules. Kernel Module Pieces of code that can be loaded and unloaded into the kernel upon demand. Compiled as an independent program With appropriate.
Source: Operating System Concepts by Silberschatz, Galvin and Gagne.
Logic Analyzer ECE-4220 Real-Time Embedded Systems Final Project Dallas Fletchall.
Overview Task State Diagram Task Priority Idle Hook AND Co-Routines
K ERNEL D EVELOPMENT CSC585 Class Project Dawn Nelson December 2009.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
LOGO System Call. Introduction System call is the mechanism used by an application program to request service from the OS. Users use it to communicate.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 4: Threads.
Welcome to the world of ARM. COURSE CONTENT Module 1: Introduction  Introduction of ARM Processors  Evolution of ARM  32 - bit Programming Module 2:
12/22/ Thread Model for Realizing Concurrency B. Ramamurthy.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
CSC 360, Instructor: Kui Wu Thread & PThread. CSC 360, Instructor: Kui Wu Agenda 1.What is thread? 2.User vs kernel threads 3.Thread models 4.Thread issues.
Lab 12 Department of Computer Science and Information Engineering National Taiwan University Lab12 – Driver 2014/12/16 1 /21.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Anomaly Detection and Damage Mitigation in Complex Systems by Amol M Khatkhate Pennsylvania State University.
Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 2, 2015 Jacob Beningo, CSDP Class 3: Uart Driver.
Fundamental Programming Fundamental Programming Introduction to Functions.
Lecture 3 Module Programming and Device Driver (Homework#1 included) Kyu Ho Park Sept. 15, 2015.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
KNU RTLAB A Real-Time Linux System For Autonomous Navigation And Flight Attitude Control Of An Uninhabited Aerial Vehicle Charles E. Hall, Jr. Mechanical.
CMSC 421 Spring 2004 Section 0202 Part II: Process Management Chapter 5 Threads.
CISC220 Spring 2010 James Atlas Lecture 04: Pointers, Functions, Memory Management, ADTs, Classes, Hardware, Software, Graphics, Networking, AI, Databases,
Experimental Software Engineering Course for Training Practitioners in Embedded Real-Time Systems Real-Time Systems LAB, School of Electronic Engineering,
Synchronization between native threads and java threads for embedded real-time systems Real Time Systems Lab June 3, 2002 Jong-Koo, Lim.
A thread is a basic unit of CPU utilization within a process Each thread has its own – thread ID – program counter – register set – stack It shares the.
Realizing Concurrency using the thread model
Mobile Operating System
Computer System Laboratory
Lecture 4: Operating System Structures
Thread Programming.
Threads and Cooperation
Baremetal C Programming for Embedded Systems
Realizing Concurrency using Posix Threads (pthreads)
Operating Systems Lecture 13.
Chapter 5: CPU Scheduling
Chapter 2: The Linux System Part 2
Chapter 2: The Linux System Part 3
Lecture Topics: 11/1 General Operating System Concepts Processes
Operating System Concepts
Implementation of Embedded OS
Presentation transcript:

A simple control application with Real Time Linux Peter Wurmsdobler Real Time Systems Lab Jong-Koo, Lim Paper Survey

2 Contents I.Abstraction II.Introduction III.Control algorithm implementation ① Application architecture ② Real time module ③ User space application IV.Conclusion

3 Abstraction  A simple control application using real time linux is presented  A linux kernel module is responsible for Getting a value from a DAQ-board Carrying out the control algorithm Outputing the result to the DAQ board  This user application can set control parameters and adjust a setpoint in shared memory, or start and stop the control process by FIFO-buffers

4 Introduction  ‘Control Engineer’ vs ‘Software Engineer’  The real time application based on linux presented in this paper should make an access to ‘real time linux’ easier for a control engineer by implementing a simple discrete time controller

5 Control algorithm implementation  There is already some control algorithm defined in time discrete scheme  Software architecture for its implementation Time critical tasks and less time critical tasks have to separated.  Application here implements, only a ‘simple discrete time controller’ with its parameters to be adjustable from a graphical user space application

6 Application architecture  Two parts, ① Simple graphical interface being non-real time module - xcontrol, the X-Windows control interface ② Small real time module - rtl_control.o, the real time linux control kernel module  Communication of two parts, by FIFO(first-in-first-out) buffers - rtl_fifo.o Shared memory - mbuff.o

7 Logical Software Structure

‘ The Modules’ used to talk two parts User space applicationKernel modules # define SHM_DEV_FILE (“/dev/mbuff”) # define SHM_NAME (“control”) # define SHM_SIZE (sizeof(shm_t)) typedef struct { unsigned int N; // length of measured vectors unsigned short int w; // {0,65535}, setpoint unsigned short int u[SAMPLES]; // {0,65535}, control current unsigned short int y[SAMPLES]; // {0,65535}, measured position Int a[LENGTH] ;// scaled control denominator of ORDER+1 Int b[LENGTH] ;// scaled control numerator of ORDER+1 } shm_t ; Shared Memory (shm.h) # define FIFO_SIZE (5000)// byte size for fifo buffer # define CONTROL_FIFO// for passing message to rt_control # define CONTROL_FILE “/dev/rtf0” # define EVENT_FIFO (1)// for triggering events in Xcontrol # define EVENT_FILE (1) “/dev/rtf1” # define START_CONTROL (‘a’) // xcontrol -> rtl_control # define STOP_CONTROL (‘b’) // xcontrol -> rtl_control # define TRIGGER_MEASURE (‘c’) // xcontrol -> rtl_control # define MEASURE_READY (‘a’) // rtl_control -> xcontrol # define INVALID_MEASURE (‘b’) // rtl_control -> xcontrol FIFO buffers (fifos.h) 8

The Other Modules extern int rt_bmc1000_ init (void); extern void rt_bmc1000_ release (void); extern unsigned shor int rt_bmc1000_ aget (void); extern void rt_bmc1000_ aset (unsigned short int channel, unsigned short int value); extern void rt_bmc1000_ mux_select (unsigned int channel, unsigned int range_code); BMC1000 DAQ board specific module (rt_bmc1000.h) 9

inline void rt_control_event_msg (unsigned char message) ; void * rt_control_thread (void *); static int rt_control_message_handler (unsigned int fifo); static void rt_control_start (void); static void rt_control_stop (void); static void rt_control_trigger_measure (void); All basic functions The Other Modules (cont.) 10 pthread_t control; // THE control thread, or task static int measure;// flag if measurement is on static shm_t *shm;// shared memory (sic!) static unsigned int index;// index in shared memory static int e[LENGTH]// control deviation buffer static int u[LENGTH]// control signal buffer static unsigned int k; // index k of actual value static unsigned short int Y; // THE measure value, input static unsigned short int U; // THE control value, output static unsigned short int W; // THE setpoint

Example of some basic function inline void rt_control_event_msg (unsigned char message) { rft_put(EVENT_FIFO, &message, 1) } static int rt_control_message_handler (unsigned int fifo); { unsigned char message; while(rft_get(fifo, &message, 1) > 0) { switch(message) { case START_CONTROL : rt_control_start(); break; case STOP_CONTROL : rt_control_stop(); break; case TRIGGER_MEASURE : rt_control_trigger_measure(); break; default : rt_control_event_msg(INVALID_MESSAGE) } return 0; } 11

12 Structure of RT Application User Process RT Fifo RT Process Peripheral Device Linux Kernel NetworkDisk X Windows Display RT-Kernel

Internal of in RTLinux Application pthread_t thread; void * start_routine(void * arg) {... } int init_module(void) { return pthread_create(&thread, NULL, start_routine, 0); } int cleanup_module(void) { pthread_delete(thread); } 13

In this RTL Application … void * rt_control_thread(void * arg) {... } int init_module(void) { … if (rt_bmc1000_init()) … // Initialize PCL818 DAQ board if (rtf_create(CONTROL_FIFO, FIFO_SIZE) < 0) … // Initialize rt-fifos if (rtf_create_handler(CONTROL_FIFO, rt_control_message_handler)) … // Initialize message handler if (shm_allocate(SHM_NAME, SHM_SIZE, (void **) &shm) < 0) … // Initialize shared memory … if (pthread_create(&thread, &attr, rt_control_thread, (void *)1) ) { printk( “ Initializing real time control thread failed ” ); return – ENOMEM; } printk ( “ %S Init module successful\n ”, RT_FILTER_ID); return (0); } int cleanup_module(void) { pthread_delete_np(control);// Delete control thread shm_deallocate(shm);// Release shared memory rtf_destroy (CONTROL_FIFO) ;// Release rt-fifos rt_bmc1000_release(); // Release the PC1000 DAQ board … } 14

15 Insert and Remove Module  insmod rtl_control.o This will make the init_module function to be called -Initailize everything such as hardware, rt-fifos, message handler, shared memory and kernel thread  rmmod rtl_control.o This will make the cleanup_module function to be called -The entire process is killed. -All resources being allocated are released.

User space application  This X-Windows interface is programmed using the GTK+ widget set library in combination with a scientific plot widget ( GTKplot ) 16 Graphic User Interface Input (Y) and Output (U), only with a sinusoilda input of 500 Hz at 10 kHz sampling rate

17 Conclusion  Arriving at the end of this paper, A control engineer even not too familiar with c should be able to understand the concept of implementing his control algorithm in real time linux. ☞