Development of Fault Tolerant Software for Embedded Realtime Systems, winter semester 2025/26
(EN google-translate)
(PL google-translate)
Start of the course: 9:00 a.m.
|
|
|
|
Wednesday, September 24, 2025
Topics today
|
|
1. Organizational matters
|
|
2. Why do malfunctions occur in Western technology in the first place -- an anthropological perspective
I would like to help you understand what makes Western technology so special. I would like to work with you to identify the strengths and, if they exist, the fundamental weaknesses of Western technology. One way to do this is through comparison. Technical anthropology is a science that compares technologies from different cultures.
Heßler, M., Liggieri, K.: Technikanthropologie: Handbuch für Wissenschaft und Studium, Nomos, Baden-Baden 2020.
Code 0-1: Literatur zu Technikanthropologie
As an example, I will use ship navigation in the following.
Example: Boatbuilding in Taumako, documentary film by Michael Tauchert.
Visual documentation
Navigation with Te Puke Booten -- Dr. Mimi George
ÜBUNG
|
3. Introduction to the topic of fault tolerance
81_FTSD/01_Fehlertoleranz
4. Introduction to the terms "fault," "error," and "failure"
Exercise
|
5. Introduction to the term "mitigation"
6. Examples of "mitigation" in modern technology
Exercise
|
7. Division into groups of two
8. Scheduling appointments for presentations on fault tolerance patterns
9. Practical application: Smart Watch
Bild 0-1: T-Watch 2020 V3 from Lilygo.
|
These are peripherals that can be controlled by programming on the watch:
|
|
Arthur C. Clarke
...in diesem Sinne:
|
Corresponding links, see:
necessary: esp32 Board Library 2.09 (exactly this one!)
10. Discussion of possible areas in the Smart Watch where fault tolerance can play a role
Wednesday, September 30, 2025
Topics today
|
1. Quiz
Define the terms "fault," "error," and "failure"
2. Initial collection of ideas on possible applications for the clock and possible fault tolerance patterns that could be used in this context
DAILY LIFE SMART HOME: control for children devices: smartphone time etc. by our watch recording audio, analyze it to get a warning for dangerous animals e.g. step counter (IMU sensor) remote control for TV, radio etc. (infrared data transmitter) recognition of too intensive sun exposure (Light intensity sensor) using bluetooth to connect to the phone for passing messages doing calls using microphone and loudspeaker performing alarms by using vibration games with distributed users teach people how to draw -- follow predefined geometrical forms and vibrate when too big difference receiving a notification if one has an appointment in the calendar SPORTS compass tracking / hiking / climbing mountains ...for detecting dangerous areas GPS for football player -- tracking and analyze the game to make up new strategies detect too high impacts from hits -- inform medical staff MEDICINE Reminder for taking medicine / body sensoring ... measurement of level of insuline e.g. heart rate monitoring sensor rescue system (alarm if no motion) rescue system (alarm if to hard motion) DISABLED PEOPLE support for blind people -- ostacles are provided by external WiFi, let's say on a train station Identify type of ground Iform about stops in busses by vibration WORK CONTEXTS
Code 0-2: Initial collection of ideas on possible applications for the clock and possible fault tolerance patterns that could be used in this context.
3. Overview: fault tolerance pattern
81_FTSD/01_Fehlertoleranz
4. Presentation: Hello World-program with T-WATCH
5. Preliminary exercises with Java/Processing
36_Java
78_Processing
74_EmbSyst/02_Eingebettete_Systeme/03_Android/06_Processing
6. Introduction to the Processing development environment
...will be done on PCs.
7. Presentation: Starting with T-WATCH
07_TWATCH_EN -- english version.
06_TWATCH -- german version.
8. Exercise: Hello World-program with T-WATCH
Follow steps here: 07_TWATCH_EN/03_Hello_world.
Wednesday, October 07, 2025
Topics today
|
1. Organization of presentation dates for fault tolerance patterns
WEDNESDAY 15.10. 22.10. 29.10.
05.11. 12.11. 19,11,
--------------------
26.11. 03.12. 10.12.
17.12.
Code 0-3: Dates for the presentations.
|
2. Systematic introduction to programming the watch
|
Programs made during the course:
#include <iostream>
using namespace std;
int main(void)
{
cout<<endl<<"Hello world!"<<endl;
return 0;
}
Code 0-4: hello.cpp
#include <iostream>
using namespace std;
int x=7; // declaration and initialization == definition
char y='4';
char text[]="My text."; // ends with 0 == ' '
int main(void)
{
cout<<endl<<"Hello world! "<<"x="<<x<<endl;
cout<<(int)y<<endl;
cout<<text<<endl;
cout<<size(text)<<endl;
return 0;
}
Code 0-5: hello2.cpp (variables)
#include <iostream>
using namespace std;
int mult(int x, int y)
{
int z = x*y;
return z;
}
int main(void)
{
cout<<"4*5="<<mult(4,5)<<endl;
return 0;
}
Code 0-6: hello3.cpp
#include <iostream>
using namespace std;
bool hasE(char text[])
{
int index = 0;
text[0]='#';
while(text[index]!=' ')
{
if(text[index]=='e' || text[index]=='E')
return true;
index++;
}
return false;
}
int main(void)
{
char sentence1[] = "This is cool!";
char sentence2[] = "This is an elephant!";
cout<<sentence1<<" ..has an e?:"<<hasE(sentence1)<<endl;
cout<<sentence2<<" ..has an e?:"<<hasE(sentence2)<<endl;
cout<<sentence1<<endl;
cout<<sentence2<<endl;
return 0;
}
Code 0-7: hello4.cpp (call by reference)
#include <iostream>
#include <math.h>
using namespace std;
class Vektor
{
public:
double x,y;
double calculateLength()
{
return sqrt(x*x+y*y);
}
};
int main(void)
{
Vektor v1,v2;
v1.x=3.0;
v1.y=4.0;
v2.x=1.0;
v2.y=0.0;
double l1 = v1.calculateLength();
double l2 = v2.calculateLength();
cout<<"|v1|="<<l1<<endl;
cout<<"|v2|="<<l2<<endl;
return 0;
}
Code 0-8: hello5.cpp (explain classes and objects in objectoriented programing)
3. Small programming tasks for using the screen, touchscreen, button, IMU sensor, and real-time clock.
|
07_TWATCH_EN/04_Simplified_Commands
Exercise 1: Switsch Background color by pressing the button multiple times between red, green, blue, red, green, blue, red, ... and so on.
#include "twatch.h"
#include "variables.h"
#include "functions.h"
int state=0;
void setup()
{
setupTWATCH();
backlight(true);
}
void loop()
{
if(button()) {
state++;
if(state > 2){
state=0;
}
switch(state){
case 0:
background(255,0,0);
break;
case 1:
background(0,255,0);
break;
case 2:
background(0,0,255);
break;
}
}
delay(100);
}
Code 0-9: Student solution.
Exercise 2: Program a type of water clock. The deviation of the clock from the horizontal position should be visualized graphically by moving a small circle on the display away from the center of the display.
#include "twatch.h"
#include "variables.h"
#include "functions.h"
float skalierung=0.5;
float KreisX=0;
float KreisY=0;
void setup()
{
setupTWATCH();
backlight(true);
}
void loop()
{
bool res = acceleration();
if(KreisX>240){
KreisX=240;
}else if(KreisX<0){
KreisX=0;
}else{
KreisX = 120 - (float)(accY*skalierung);
}
if(KreisY>240){
KreisY=240;
}else if(KreisY<0){
KreisY=0;
}else{
KreisY = 120 + (float)(accX*skalierung);
}
fill(0,0,255);
circle(KreisX,KreisY,20);
delay(50);
clear();
delay(50);
}
Code 0-10: Student solution.
Exercise 3: Program a type of stopwatch. The stopwatch should be accurate to one-hundredth of a second. To do this, analyze in project "TWATCH_PROC023" the "functions.h" tab to find out how to obtain the elapsed time in milliseconds.
4. Small project for an application program using the internal peripherals covered so far
Implement the following project: A warning system should sound an alarm via the vibration motor and a suitable display if the watch is not held horizontally for more than 10 seconds.
Wednesday, October 15, 2025
Topics today
|
1. Discussion of useful literature
The source for fault tolerance patterns is Hanmer's book:
|
To understand how to program an esp32, you can use the relevant programming manuals:
|
It may also be worthwhile to learn more about Processing, as the simplified programming of the clock is based on it:
|
If you also want to use a smartphone as a remote station, the following book is worth reading, as it covers the development of Android apps based on Processing:
|
Books of this type can be helpful. It does not necessarily have to be these specific ones. In addition to the THB library, you can also use the TU library (Volkswagen Library) in Berlin, near the bus station/Zoologischer Garten station.
2. Analysis of last week's projects
3. Notes on Internet programming
30_Informatik3/16_Nuetzliches/05_Internetprogrammierung/04_Java
4. Data transfer via Wi-Fi
|
EXERCISE
|
Concept for establishing a data connection via Wi-Fi
|
if(button()) //wird ausgeführt, wenn Knopf gedrückt
{
if(!WIFIOKAY) //Falls WIFi NICHT verfügbar
{
setupWIFI(hotspot,password,udpport); //...Verbindungsversuch starten
}
....
}
Code 0-11: Main tab of project TWATCH_PROC023 from line 227 onwards.
|
case 2: //Acceleration (Switch Anweisung bei MODE 2)
{
backlight(true);
cursor(0,0);
bool res = acceleration(); //Auslesen der Beschleunigungswerte
if(WIFIOKAY && udp.listen(UDPPORT)) //Wenn WiFi Verbindung vorhanden und ein Datenpaket vom PC empfangen wird...
{
udp.onPacket([](AsyncUDPPacket packet)
{
if(Serial) Serial.write(packet.data(), packet.length());
if(Serial) Serial.println();
packet.printf("accX=%d accY=%d accZ=%d", accX,accY,accZ); //Übertrage die Beschleunigungsdaten
});
}
...
}
...
Code 0-12: Main tab of project TWATCH_PROC023 from line 110 onwards.
|
#include "twatch.h" #include "variables.h" #include "functions.h" ... const char* hotspot = "hotspotX"; const char* password = "12345678"; int udpport = 6000; ...
Code 0-13: Main tab of project TWATCH_PROC023 from line 1 onwards.
|
void setup()
{
setupTWATCH();
setupSERIAL(115200);
setupWIFI(hotspot,password,udpport); Bereits hier wird ein Verbindungsversuch gestartet
setupMotor();
//setFont(3);
//setFont(2,255,55,0, 0,0,0);
setFont(1, 255,255,255, 255,0,0);
updateTime(); //RTC Zeit nehmen
backlight(true);
}
Code 0-14: Main tab of project TWATCH_PROC023 from line 1 onwards.
PC-side program
|
TWATCH_PROC005_hotspot.zip -- Processingsketch für den PC-seitigen Part.
TWATCH_PROC005_hotspot_ANDROID.zip -- Android version of the project.
import hypermedia.net.*;
String IP = "10.42.0.255";
int PORT = 6000; //für UDP benötigt.
UDP udp;
String NACHRICHT="";
public void setup()
{
size(700,500);
udp = new UDP( this, 6000 );
udp.listen( true );
frameRate(10);
}
public void draw()
{
background(255);
fill(0);
textSize(20);
text("Empfangen:",30,30);
text(NACHRICHT,30,60); //Nachricht der Uhr ggf. anzeigen.
udp.send("Test", IP, PORT ); //Zyklisch einen "PING" an die Uhr schicken.
}
void receive( byte[] data, String ip, int port ) //Callback Funktion, die auf hereinkommende Pakete reagiert.
{
// <-- extended handler
// get the "real" message =
// forget the ";
" at the end <-- !!! only for a communication with Pd !!!
//data = subset(data, 0, data.length-2);
String x = new String( data );
if(x!=null && !x.equals("Test")) //Nachricht der Uhr bereitstellen.
NACHRICHT = x;
}
Code 0-15: Processing sketch for the PC/laptop side.
5. Transferring a processing sketch to a mobile device
6. EXERCISE: Implementing an initial fault tolerance concept
Exercise 1
|
|
Exercise 2
|
Exercise 3
|
7. Continuing collecting project ideas
...see above:
2. Initial collection of ideas on possible applications for the clock and possible fault tolerance patterns that could be used in this context
Wednesday, October 22, 2025
Topics today
|
1. Presentation #1: Redundancy
2. Data transfer via Wi-Fi -- Snippet
see "WiFi" here 07_TWATCH_EN/04_Simplified_Commands
3. Modification of Wi-Fi -- Snippet towards a fault tolerant variant
4. Discussion about fault tolerant patterns applied in modified Wi-Fi -- Snippet
5. Analysing object oriented structure of TWATCH_PROC023 project
Pointer-to-Object-Example in C++ to explain special structure of original examples from TTGO library
#include <iostream>
#include <math.h>
using namespace std;
class Vektor
{
public:
double x,y;
double calculateLength()
{
return sqrt(x*x+y*y);
}
};
Vektor *vektor;
int main(void)
{
Vektor v1,v2;
Vektor *v3;
v3 = &v1;
vektor = new Vektor();
//v1.x=3.0;
//v1.y=4.0;
v3->x=3.0;
vektor->y=4.0;
vektor->x=3.0;
v3->y=4.0;
v2.x=1.0;
v2.y=0.0;
//double l1 = v1.calculateLength();
double l1 = vektor->calculateLength();
double l2 = v2.calculateLength();
cout<<"|v1|="<<l1<<endl;
cout<<"|v2|="<<l2<<endl;
return 0;
}
Code 0-16: Pointer-to-Object-Example in C++ to explain special structure of original examples from TTGO library
Several objects are declared in twatch.h:
//Several objects are declared in twatch.h:
AudioFileSourceFunction* file_wav;
AudioOutputI2S *output_wav;
AudioGeneratorWAV* wav_generator;
AsyncUDP udp;
/*
Zeilen Spalten
tft->setTextFont(8); 3 4
tft->setTextFont(6); 5 8
tft->setTextFont(4); 9 16
tft->setTextFont(2); 15 29
*/
TTGOClass *watch;
TFT_eSPI *tft;
BMA *sensor;
BackLight *hintergrundlicht; //Um es manipulieren zu können!!!
Code 0-17: Extract from twatch.h from TWATCH_PROC023 project
|
void setupTWATCH()
{
....
//Provide the t-watch-object in pointer watch:
watch = TTGOClass::getWatch();
....
//Provide tft (screen) object in pointer tft.
//It is taken from the inner of watch.
tft = watch->tft;
....
}
Code 0-18: Method setupTWATCH() -- Extract from twatch.h from TWATCH_PROC023 project,
Helpful methods are provided in an easy to use way in functions.h
void clear()
{
watch->tft->fillScreen(TFT_BLACK); // Clear screen
}
...
bool touch()
{
int16_t x,y;
bool tch = watch->getTouch(x,y);
mouseX=x;
mouseY=y;
return tch;
}
...
// drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint32_t color),
void line(int x1, int y1, int x2, int y2, int R, int G, int B)
{
tft->drawLine(x1, y1, x2, y2,
((255>>4))+((R>>4)<<12)+((G>>4)<<8)+((B>>4)<<4)
);
}
...
void line(int x1, int y1, int x2, int y2)
{
tft->drawLine(x1, y1, x2, y2,
((STROKE_ALPHA>>4))+((STROKE_RED>>4)<<12)+((STROKE_GREEN>>4)<<8)+((STROKE_BLUE>>4)<<4)
);
}
Code 0-19: Examples for definition of easy to use functions in functions.h for discussion.
Where you can get the information to extend the simple functions?
see:
|
Which header-files contain interfaces for which internal periphery?:
|
Relevant examples available in TTGO_TWatch_Library-1.4.3: Datei->Beispiele->TTGO TWatch Library->BasicUnit
|
Bild 0-2: Achieving the examples from TTGO_TWatch_Library-1.4.3
6. Continuing collecting project ideas
7. Exercises
Exercise #1 -- Escalation
Implement the following scenario with the smartwatch:
|
#include "twatch.h"
#include "variables.h"
#include "functions.h"
int countdown = 10;
int state = 0;
long Alarmzeit = 0;
int Alarminterval = 5000;
int tickinterval = 1000;
long lasttick = 0;
bool Knopf = false;
void setup() {
setupTWATCH();
setFont(1, 255, 255, 255, 255, 0, 0);
setupMotor();
backlight(true);
clear();
}
void loop() {
if (button())
{
state++;
if (state > 2) {
state = 0;
}
}
switch (state) {
case 0:
background(0, 255, 0);
countdown = 10;
break;
case 1:
if (countdown > 0)
{
if (millis() - lasttick > tickinterval)
{
clear();
cursor(0, 0);
editor(countdown);
countdown--;
lasttick = millis();
}
}
if (countdown == 0)
{
state = 2;
Alarmzeit = millis();
}
break;
case 2:
background(255, 0, 0);
delay(500);
clear();
delay(500);
if (button())
{
Knopf = true;
}
if (millis() - Alarmzeit > Alarminterval && Knopf == false)
{
motor();
} else if (Knopf == true)
{
state = 0;
}
break;
}
delay(50);
}
Code 0-20: student solution.
#include "twatch.h"
#include "variables.h"
#include "functions.h"
void setup()
{
setupTWATCH();
setFont(1, 255,255,255, 255,0,0);
setupMotor();
backlight(true);
}
int COUNTDOWN = 100;
bool COUNTDOWN_STARTED = false;
bool TOGGLE = true; //for flashing
void loop()
{
if(button())
{
if(COUNTDOWN_STARTED==true)
{
COUNTDOWN_STARTED = false;
COUNTDOWN = 100; //RESET
}
else
{
COUNTDOWN_STARTED = true;
}
}
clear();
cursor(0,0);
editor(COUNTDOWN/10);
editor("\n");
if(COUNTDOWN_STARTED==true && COUNTDOWN>0)
{
COUNTDOWN--;
}
else if(COUNTDOWN_STARTED==true && COUNTDOWN<=0)
{
if(TOGGLE==true)
{
background(255,0,0);
}
else
{
background(0,255,0);
}
TOGGLE = !TOGGLE;
if(COUNTDOWN<-50)
{
motor();
}
}
delay(100); //making button more reactive
}
Code 0-21: second solution.
Exercise #2 -- Continuation from last week
|
Exercise #3
|
Wednesday, October 29, 2025
Topics today
|
1. Presentation #2: Software Update
2. Presentation #3: Correcting Audits
3. Using the Internal Microphone of T-WATCH V3
07_TWATCH_EN/05_Microphone (english)
06_TWATCH/05_Microphone (deutsch)
4. Smart Home Application with T-WATCH V3
06_TWATCH/06_SmartHome (english)
06_TWATCH/06_SmartHome (deutsch)
5. More Literature
|
|
|
6. Continuing Collecting Project Ideas / Decision for your project
Today, the first participants should decide on a specific project idea and start working on the project.
7. Exercises
|
Wednesday, November 05, 2025
Aufgrund anhaltender Bahnprobleme starten wir heute um 09:15Uhr.
Due to ongoing rail problems, we will start at 9:15 a.m. today.
Topics today
|
1. Presentation #2: Software Update
2. Presentation #4: Maintenance Interface
3. Reading the temperature on the acceleration sensor
07_TWATCH_EN/07_Temperature
06_TWATCH/07_Temperature
4. Defining the project topics
Wednesday, November 12, 2025
Aufgrund anhaltender Bahnprobleme starten wir heute um 09:20Uhr.
Due to ongoing rail problems, we will start at 9:20 a.m. today.
Topics today
|
ARRAY example from today
TWATCH_PROC023_ARRAY001.zip
TWATCH_PROC023_ARRAY002.zip
TWATCH_PROC023_ARRAY003.zip
TWATCH_PROC023_ARRAY004.zip
Wednesday, November 19, 2025
Topics today
|