Real-time Linux (Xenomai)

 Radboud University Nijmegen

Exercise #9: Rotating LEDs


This exercise cannot be done on a simulated version of Xenomai in VMware or VirtualBox; it requires a Raspberry Pi connected to a mechanical construction. Rotating LEDs

Introduction

The knowledge of the previous exercises about real-time programming with Xenomai will be applied to a construction with rotating LEDs.

Objectives

The primary objectives of this exercise are:

Description

The construction contains the following hardware:
  • The LEDs are connected to eight GPIO ports on the Raspberry Pi as shown in the figure. Note that a high signal (1) means that the LED will be on; with a low signal (0) it will be off.
  • There is a light sensor on the bottom; when a hole in the rotating disc passes the LED-lightsensor the LED light will be detected by the sensor. This will causes the light sensor to go from a low signal (no light) to a high signal (light).
    The light sensor signal is connected to GPIO pin 23 of the Raspberry Pi. Because the light sensor is interrupted for a small time, the sensor signal will be like :   _______---________
    This can be used, for instance, to measure the time needed to pass the sensor since the Raspberry Pi can be programmed to give an interrupt when going from low to high and from high to low.
  • The motor that rotates the disc has two speeds, low and high.
LEDs D0 = GPIO 2
D1 = GPIO 3
D2 = GPIO 4
D3 = GPIO 17
D4 = GPIO 27
D5 = GPIO 22
D6 = GPIO 10
D7 = GPIO 9

Test the hardware

The hardware can be tested in two ways.

Exercises

Make sure the solutions do not depend on a particular instance of the hardware. Moreover, all solutions should work with both speeds of the motor.
Deliver all programs, the Makefile, and a report which explains the results and the programs.

Exercise 9a.

Report the results for both speeds of the motor.

Exercise 9b.

Develop a program which writes the symbol X exactly at the top.

Exercise 9c.

Develop a program which writes the symbol X exactly at the bottom (where the light sensor is); the right past of the X should be to the right of the sensor, the left part to the left of the sensor.

Exercise 9d.

Develop a program which lets the X move over the rotating disc with a period of 60 seconds (like the second hand of and old-style analog clock).

Exercise 9e (optional).

Write more on the clock, e.g., a text, the time, a game, a rotating ball, a walking person, etc.
To write text, the following code might be useful to include letters:

Last Updated: 24 September 2020 (Jozef Hooman)
Created by: Harco Kuppens
h.kuppens@cs.ru.nl