Porting GNATPro to Lego Mindstorm NXT Piotr Piwko

  • Slides: 18
Download presentation
Porting GNATPro to Lego Mindstorm NXT Piotr Piwko piwko@adacore. com

Porting GNATPro to Lego Mindstorm NXT Piotr Piwko piwko@adacore. com

Summary • Introduction& Motivations • OSEK Operating. System • OSEK Implementation Language (OIL) •

Summary • Introduction& Motivations • OSEK Operating. System • OSEK Implementation Language (OIL) • nxt. OSEK – open source firmware • NXT Ada. Library • Demo application • Future improvements Slide: 2

Introduction & Motivations • Internship consisted : in – Porting the GNATPro ZFP Technology

Introduction & Motivations • Internship consisted : in – Porting the GNATPro ZFP Technology to ARM 7 – Writing an Ada binding for the nxt. OSEK API – Developing a working prototype • Motivations to have a port of GNATPro to Mindstorms – Provide a platform to learn embedded Ada programming – Popularize the GNAT Technology in the Academic Environment Slide: 3

OSEK overview(http: //www. osek-vdx. org/ ) • OSEK - "Open Systems and the Corresponding

OSEK overview(http: //www. osek-vdx. org/ ) • OSEK - "Open Systems and the Corresponding Interfaces for Automotive Electronics „ • Single processor operating system • OSEK is designed to require only a minimum of hardware resources • OSEK Implementation Language (OIL) • The code could be executed from ROM • Real-time multi tasking Slide: 4

OSEK history • History timeline of the OSEK standard 1993 1994 1995 1997 .

OSEK history • History timeline of the OSEK standard 1993 1994 1995 1997 . . . 2003 May 1993 January 1994 September 2003 1995 June 1997 OSEK has. The been The latest 1. 0 French founded version 2. 2. 1 car as version manufacturers of a the joint 2. 0 OSEK project version Operating PSA in the and German automotive of Renault OSEK System Operating joined industry. introducing System their VDXapproach (Vehicle Distributed e. Xecutive) Initial project partners: BMW, Bosch, Daimler. Chrysler, Opel, Siemens, VW and the University of Karlsruhe as coordinator. Slide: 5

OSEK compilation chain Source: OSEK Implementation Language Specyfication 2. 5 Slide: 6

OSEK compilation chain Source: OSEK Implementation Language Specyfication 2. 5 Slide: 6

OSEK application configuration files • OSEK Implementation Language(OIL) • The main. OIL objects: •

OSEK application configuration files • OSEK Implementation Language(OIL) • The main. OIL objects: • TASK My_Task { AUTOSTART = FALSE; SCHEDULE = FULL; PRIORITY = 3; ACTIVATION = 1; RESOURCE = My_Res; EVENT = My_Event; STACKSIZE = 512; }; • EVENT My_Event { MASK = AUTO; }; • COUNTER System_Counter { MINCYCLE = 1; MAXALLOWEDVALUE = 10000; /* One tick is equal to 1 msec */ TICKSPERBASE = 1; }; • RESOURCE REROURCE My_Res { RESOURCEPROPERTY = STANDARD; }; Slide: 7

OSEK application configuration files • ALARM Cyclic_Alarm { COUNTER = System_Counter; ACTION = ACTIVATETASK

OSEK application configuration files • ALARM Cyclic_Alarm { COUNTER = System_Counter; ACTION = ACTIVATETASK { TASK = My_Task; }; AUTOSTART = TRUE { ALARMTIME = 1; /* My_Task is executed every 500 msec */ CYCLETIME = 500; }; }; Slide: 8

nxt. OSEK (http: //lejos-osek. sourceforge. net/ ) • Open source firmware for LEGO MINDSTORMS

nxt. OSEK (http: //lejos-osek. sourceforge. net/ ) • Open source firmware for LEGO MINDSTORMS NXT • nxt. OSEK provides : – ANSI C/C++ programming environment by using GCC tool chain – C / C++ API for NXT Sensors, Motor, and other devices – TOPPERS OSEK – The open-source implementation of OSEK Real. Time Operating System that includes ARM 7 specific porting part • Features – USB – I 2 C bus – Floating Point – Direct boot from RAM (max. 64 Kbytes single nxt. OSEK application uploaded to RAM, no Flash write) Slide: 9

nxt. OSEK + GNATPro ZFP Source code which is written in Ada binding library

nxt. OSEK + GNATPro ZFP Source code which is written in Ada binding library for the nxt. OSEK API GNATPRO 6. 1. 1 arm-elf cross-compiler Slide: 10

NXT Ada. Library • Structure of the. Ada binding library nxt. OSEK. OS. NXT.

NXT Ada. Library • Structure of the. Ada binding library nxt. OSEK. OS. NXT. Types. Utils. Bluetooth. I 2 C. Sound. Display. Motor. Acceleration _Sensor. Gyroscopic _Sensor. Light _Sensor. Sonar_Sensor. Sound _Sensor. Touch _Sensor Slide: 11

Overall view • Relation between. Compiler, OSand API bindings with nxt. OSEK. OS; with

Overall view • Relation between. Compiler, OSand API bindings with nxt. OSEK. OS; with nxt. OSEK. Display; procedure My_Task; pragma Export (C, My_Task, "Task. Main. My. Task"); TASK My. Task { PRIORITY = 1; ACTIVATION = 1; SCHEDULE = FULL; STACKSIZE = 512; }; procedure My_Task is begin nxt. OSEK. Display. Update; nxt. OSEK. OS. Terminate_Task; end My_Task; ALARM My. Task_Alarm { COUNTER = Sys. Cnt; ACTION = ACTIVATETASK { TASK = My. Task; package nxt. OSEK. Display is }; procedure Update; AUTOSTART = TRUE private { pragma Import (C, Update, ALARMTIME = 1; "display_update"); CYCLETIME = 500; end nxt. OSEK. Display; }; package nxt. OSEK. OS is }; procedure Terminate_Task; private pragma Import (C, Terminate_Task, „terminate_task"); end nxt. OSEK. OS; Slide: 12

It’s demo time!– The Remote Control Vehicle • Control Vehicle Panel – Forward Rear-wheel

It’s demo time!– The Remote Control Vehicle • Control Vehicle Panel – Forward Rear-wheel anddrive backward (2 motors) movements (2 touch sensors) – Steering (gyroscopic System (1 motor) sensor) – Ultrasonic Communication Obstruction System. Detection (sonar sensor) - master device) – (Bluetooth Communication System (Bluetooth – slave device) Slide: 13

Inside the demo • Vehicle Bluetooth protocol Steeringsystem 1 motor Sonar task Cycle: 50

Inside the demo • Vehicle Bluetooth protocol Steeringsystem 1 motor Sonar task Cycle: 50 ms Critical distance: 30 cm Receive task Cycle: 5 ms Sonar warningflag Shared resource Main propulsions 2 motors Slide: 14

Inside the demo • Control panel Movement control 2 Touch sensors Buttons task Cycle:

Inside the demo • Control panel Movement control 2 Touch sensors Buttons task Cycle: 200 ms Bluetooth protocol Receive task Cycle: 50 ms Gyroscopicsensor Steering task Cycle: 5 ms LCD display Slide: 15

Distributing GNATPro for Mindstorm NXT • How we plan to distribute the toolset –

Distributing GNATPro for Mindstorm NXT • How we plan to distribute the toolset – Look at conferences where we can use the Lego Mindstorm NXT as a giveaway. – Make the technology available to the GAP and Libre communities. • What we want to include in the toolset – arm-elf GNAT cross-compiler – NXT Ada Library – nxt. OSEK – Examples Slide: 16

Future improvements • nxt. OSEK application configuration files builder • Object-oriented nxt. OSEKAda Library

Future improvements • nxt. OSEK application configuration files builder • Object-oriented nxt. OSEKAda Library • Other Ada run-time environment, ex. Ravenscar Slide: 17

Questions?

Questions?