Very Small Information Systems

Very Small Information Systems is a Wikiversity content development project where participants create, organize and develop learning resources for information systems that are very small.

The following summarizes the topics from two courses held at the Technical University in Vienna, Austria and two courses at the Institute of Informatics, CBS in Denmark.

This all is, of course, work in progress. We will evaluate it with a real course that runs during this summer semester.

Rasmus Pedersen, Martin Schoeberl

What are Very Small Information Systems?
Very Small Information Systems (VSIS for short) are similar to Embedded Systems. However, the focus of this course is a little bit different. The focus is more holistic and the class will feature a number of core topics in Java and JVM technology for example. The target group spans students from within electrical engineering to software engineering.

Information Systems is the discipline concerned with the development, use, application and influence of information systems. An information system, following a definition of Langefors, is a technologically implemented medium for recording, storing, and disseminating linguistic expressions, as well as for drawing conclusions from such expressions.

The technology used for implementing information systems by no means has to be computer technology. A notebook in which one lists certain items of interest is, according to that definition, an information system. Likewise, there are computer applications that do not comply with this definition of information systems. Embedded systems are an example. A computer application that is integrated into clothing or even the human body does not generally deal with linguistic expressions. One could, however, try to generalize Langefors' definition so as to cover more recent developments.

Introduction to Embedded Systems
Definition: An embedded system is a computer systems that is part of a larger system.

Examples:
 * Washing machine
 * Car engine control
 * Mobile phone

The course uses a Java processor board as an example for the lab. The processor (JOP) is open-source and implemented in an FPGA.

The example board provides a typical configuration of an embedded system:


 * Digital I/O
 * Analog input
 * Serial line
 * Ethernet connection
 * up to 100MHz CPU
 * 1MB memory
 * 512KB + 32MB Flash

Slides Detailed Source For Real Time Systems

Reading: Embedded Systems

Exercise: Get a Hello World program running on either the real hardware or the simulation of JOP. Exercise details

Introduction to JOP
A Video of a talk given at an ambedded Java workshop introduces JOP.

Introduction to Real-Time Programming
Real time programs are usualy written with several periodic threads. The Real-time Specification for Java (RTSJ) extends Java and the JVM to enable programming of real-time systems in Java.

The RTSJ is a quite complex specification. Therefore, on JOP a simpler real-time API for Java is available.

Real time programs are usually written with several periodic threads.

Introduction to Fixed Point Math
Definition: The ability to represent real numbers with a number representation intended for whole integer numbers.

Examples:
 * Use the Java  as a decimal number
 * Use one byte to hold the whole part of a number and a second byte to hold the fractional part of the number

Reading: First read about binary numbers and bit shifting to understand the low level details of fixed point operations. Then read the definition of Fixed Point Arithmetic and a book section on fixed point arithmetic in embedded systems.

Exercise:
 * By hand try to create the number 1.5 using a 4:4 byte (4:4 means that 4 bits are used for the whole part and 4 bits for the fraction)
 * Add it with it self
 * Subtract it
 * Multiply it and right shift to make it 4:4 again
 * Repeat the exercises with 32-bit Java  using the FP library below

Setup:
 * Download some fixed point (FP) Java library such as FPLib
 * Install it on your PC

Introduction to Embedded Real-Time Machine Learning
Definition: Machine learning is the ability learn and reason based on empirical data.

Examples:
 * Decide the category of an image based on previous seen images
 * Predict a future failure of an embedded system
 * Intelligent security system

Exercise: This is one comprehensive exercise to enable you to understand the basics of some selected algorithms that can help make your embedded system "smart".

The required parts are:
 * 1 JOP board
 * JOP code (BaseIO example)
 * DSVM code
 * 2 temperature sensors: X1 and X2 (RS components 191-2235)
 * 2 switches: S1 ans S2 (RS components 472-8229)
 * 2 LEDs: C1 and C2 (RS components 228-5607)

Setup:
 * Point the serial port toward yourself
 * JOP inputs are: G,A1,A2,5V,G,I1,I2,I3,I4,G,I5,I6,I7,I8,G,I9,I10,+VB
 * JOP outputs are (on the serial side): O1,O2,O3,O4, (VBAT,G,P1,P2)
 * Connect X1 and X2 to the analog inputs A1 and A2
 * Connect S1 and S2 to the digital inputs I1 and I2
 * Connect C1 and C2 to the output ports O1 and O2

General configuration: X1 and X2 (the temperature sensors) are used together with a lighter to provide 2 dimensional data points. The switch S1 is used to tell the system which class the current reading of X1 and X2 belongs to. If it is not pressed then it belongs to class 1 and if it is pressed then it belongs to class 2. Switch 2 is used to signal to the progam that the combination of X1, X2, and S1 is to be saved as training data. If the system is in testing state then S2 is used to ask for a classification of the current value of X1, X2. We will use the LEDs C1 and C2 to signal the result of a classification.

Classification exercise: The task is to train the system with a number of observations and then test if the system can classify new observations correctly.
 * Use X1, X2, S1 and S2 to create 10 new observations which are saved in appropriate data structures
 * Test the system using kNN to classify new observations. Use X1,X2,S2,C1, and C2 to do this
 * Try to vary the parameter k that determines the number of neighbors to look at

Clustering exercise: The task is to determine which cluster new observations belong to.
 * Use X1, X2, and S2 to create 10 new observations which are saved in appropriate data structures
 * Train the system using k-means to create perhaps 3 clusters
 * Test the system using X1, X2, C1 and C2. Perhaps use C1 and C2 as binary numbers or use System.out.println
 * Try to vary the parameter k that determines the number of clusters

Regression exercise: The task is work with dependent variables. We imagine that X2 depends on X1.
 * Use X1, X2, and S2 to sample 10 new observations which are saved in appropriate data structures
 * Estimate the regression function using least squares estimation
 * Test the system using X1, X2, and S2. Use System.out to print the predicted X2 based on the X1 input

Advanced classification exercise:
 * Repeat the classification exercise but use a support vector machine to perform the non-linear classification
 * Try both methods and see if you can create problems where one method is superior to the other

Extra exercise: You can use WEKA to run a classificatation, clustering, and regression on these example files.

HOW TO
A collection of tips and tricks for the JOP/baseio platform.

Sensor Interface
With the baseio board there are several ways to connect the signals from the physical worls to the embedded system:


 * Digital input: connect a switch between the input and GND
 * Digital output: connect the load between the output and V+
 * Analog input: a 20mA current input
 * FPGA pins

With a little help from an Opamp a wide variation of signals can be connect to the described inputs. A work horse type is an LM324. Tip: See Single supply op-amp circuit collection how to make your opamp circuit work with a single supply.

Voltage Input
The analog inputs are current inputs with a range between 0mA and 33mA. This current input is actually a 100R resistor connected to an 0-3.3V ADC. So a voltage source that can drive up to 33mA can be directly connected to this current input.

To extend the range simple use a series resistor at the input. E.g. to extend it to 0-10V use a 220R resistor.

If the voltage source has a to high source resistance use a voltage follower.

There is a nice description and diagram available that explains how to connect a sensor using a voltage follower, and how to construct a "simulator" with a variable resistor here.

Audio IO
See Creating a microphone for JOP for an ongoing project.

220V relay howto
There is a howto available on how to construct a 220V relay for the JOP here.

Semester Project and Academic Article
We emphasize that you make a project using the knowledge acquired throughout the semester. This project should be a functional prototype demonstrating some concept using the JOP processor. This project is described by you by writing an academically formatted article on prototype product.

Groups
You should form groups in the beginning of the semester. The optimal size is probably 2-4 students per group. When the group formation is done then you should create a Wiki page describing your project and code.

Projects
You can use the VSIS project plan as a starting point. It is a LaTeX file, which you can fill to suit the project needs.

Papers
The academic paper writing process can benefit from using the VSIS paper template. There is a nice template available here.

For references in BibTeX see http://liinwww.ira.uka.de/bibliography/, for articles:
 * http://citeseer.ist.psu.edu/
 * http://scholar.google.com/
 * ACM digital library
 * IEEE Xplore

Inserting Figures in Latex
An easy way of inserting a figure in latex is this:
 * Print the figure to a .pdf file.
 * Crop the PDF file by using Adobe Acrobat, so it only takes up the necessary space (Tools/Advanced editing/Crop tool).
 * Save the PDF file in a subfolder of your latex directory called figures.
 * To insert the figure in latex, insert the following:

\begin{figure} \includegraphics{figures/name_of_pdf-file} \caption{Insert text describing the figure.} \label{fig:examplefigure1} \end{figure}

"As shown in Figure \ref{fig:examplefigure1}."
 * You can reference the figure by using the syntax

Software
The VSIS class is about the process of creating a piece of working software. That includes the software development process using a source version control tool. There are a number of good version control tools available and we have chosen to offer the two dominating systems: CVS and Subversion for this class - it's up to the students to choose between the two systems. We are using a project at Sourceforge to supply a good CVS/Subversion practice server for the Wikiversity VSIS class. The process of creating a new project is roughly as follows: Schoeberl]]
 * Create a user account at Sourceforge with a recognizable name
 * E-mail your user account name to Rasmus Pedersen or [[b:User:Schoeberl|Martin
 * One of us will add you to the wsis project at SF
 * Then deside whether your project source should be controlled using CVS og Subversion.
 * GOING FOR CVS, two ways are obvious for creating your project (called a module):
 * 1) CVS MODULE, USING ECLIPSE:
 * Create a new project e.g. of type ‘Simple->Project’, the name of the project will be the module name
 * Right-click on the project and select Team->Share Project...
 * Create a new repository location with:
 * Host: wsis.cvs.sourceforge.net
 * Repository path: /cvsroot/wsis
 * User: [your sourceforge username]
 * Password: ...
 * Connection type: extssh
 * Proceed through the rest of the steps
 * 2) CVS MODULE, USING TORTOISE-CVS: 'Tortoise-cvs is a component of WinCvs Get WinCvs here.
 * Right click in the windows explorer and choose CVS->Make New Module...
 * In the "Make new module" dialog box, input the following information:
 * CVSROOT: :ext:'username'@cvs.sourgeforge.net/cvsroot/wsis
 * Server: wsis.cvs.sourceforge.net
 *  Repository folder: /cvsroot/wsis
 *  Username:  'username'
 *  Module:  'modulename'
 * Leave Protocol parameters and port blank.
 * You can also use WinCvs to access your module.
 * EXTERNAL CVS INFORMATION:
 * Information about WinCvs
 * WinCvs main page
 * WinCvs setup information
 * Information about Sourceforge CVS
 * CVS documentation - 'Another HowTo'
 * Information for Shell users
 * Using CVS from Shell FAQ
 * Understanding definition and concepts of the sourceforge CVS
 * General CVS terminology
 * GOING FOR SUBVERSION, these are ways to get started:
 * 1) SUBVERSION MODULE, USING TORTOISE-SVN
 * Create a folder containing at least one file.
 * Right click the folder and choose TortoiseSVN->import (no - not export?!)
 * URL of repository is https://svn.sourceforge.net/svnroot/wsis/a-name-for-your-module leave the rest and click 'ok'
 * Accept the unknown certificate?!
 * Type your sourceforge username/password when prompted
 * Check that the file(s) in you folder was added and click 'ok'.
 * At this point, you have created a project/module/folder called a-name-for-your-module. However, you have not checked out a working copy of your module - the folder you created is NOT a working copy, actually it’s useless and should be deleted. To get a working copy, right click on a new, empty folder and choose SVN Checkout... the URL for your module is - not surprisingly - the one you imported you file(s) into: https://svn.sourceforge.net/svnroot/wsis/the-name-of-your-module
 * 2) SUBVERSION FROM ECLIPSE
 * ...is possible, but it requires an Eclipse plugin, like Subclipse.
 * EXTERNAL SUBVERSION INFORMATION:
 * Guide for setting up TortoiseSVN for Sourceforge projects
 * The E-book: Version Control with Subversion

Please make your code GPL and feel free to use other groups' code

Workshop
The VSIS class should conduct a workshop at the end of the semester. See VSIS Workshop HOWTO.

Milestones
We will try to set up some milestones that you should try to aim for. It is presented in terms of percentage of the total semester length.
 * 10%: JOP installed, Latex working
 * 25%: Project template PDF filled out and confirmed OK by the teachers
 * 90%: First complete draft of academic paper and first running prototype presented on Workshop
 * 100%: Exam with prototype demonstration and oral defense of academic article

Quiz
At the end of this course you should be able to answer the following questions:


 * What is an embedded system? How was your experience during the project with an embedded system?


 * What are the limitations in embedded system programming? What was your experience with programming for an embedded system compared to programming for a PC or server?


 * What is a Java virtual machine (JVM)


 * Explain threads in general and their usage (programming model) in embedded (real-time) systems.


 * What is the heap?


 * Give some examples of the interface between the real world and an embedded computer. What have you used in your project?


 * Communication is, besides control, the second most important aspect for embedded systems. Describe different ways of communication you could realize with the baseio board (the one that you have used in your project work).


 * Explain the method of tuning the (machine learning) algorithms on the PC (using Matlab, WEKA, YALE, LIBSVM or another machine learning package) and subsequently embedding it.


 * What is the advantages and disadvantages of embedding the learning part of the algorithm in the embedded system?


 * Please explain the role of inner and outer cross-validation in relation to your project? What approach did you take?


 * What are the advantages of using fixed-point math on the embedded system? What are the disadvantages? What is the role of scaling?


 * Please name some classification algorithms, some regression algorithms, and some clustering algorithms? For each algorithm, please explain the primary parameters that influence embedded system constraints such as battery life, low frequency CPU, and limited memory.

Resources

 * [[Image:Vsis_exercises.pdf | Exercises in PDF]]

For a quick start, till we have incorporated the information into this course, we provide links to external resources.


 * The Java Virtual Machine in Hardware


 * The very small information systems (VSIS) plugin for JOP
 * Teaching Material on JOP
 * Very Small Information Systems
 * RS Components
 * Pinouts and adresses on the BaseIO board

All hands-on assignments will use an open-source Java processor.

For a deeper technical course take the Computer Architecture Lab

Embedded Systems Links

 * RoboCup
 * Lego Mindstorms

Students
Add yourself to this list for this semester. It is strongly suggested for our testbed, the students from CBS. However, feel free to join this course from all over the world.

Summer semester 2006

Summer semester 2007

Research
Teaching and research make up a University. Therefore we try to use Wikiversity also for research within the Research page.

Research Assistant Projects
On the Research Assistant page you can find follow-up projects of this course.