FYS4240 / FYS3240, is all about how Micro-controllers, PC Processors and busses are made and gives you a very wide perspective in choice of connection technologies and micro controllers. Topics from internal structure of micro controllers to interfaces on it and parallel programming on multi core / multi processor machines. It also includes LABView and C programming for AVR micro controllers in the lab assignments. This course is recommended to take by all electronics, Robotics students and I would have a much wider point of view if I had taken this course in the beginning of my studies (something that did not happen because of lack of communication between physics department and departments of informatic). Here you can download the exam paper for spring 2011. (more…)
Computer based instrumentation and micro controllers, FYS4240 / FYS3240
August 31st, 2011 | Posted by in Arduino | Electronics | My Studies | Programming | Rapid Prototyping | Robotics | Shahab | UiO | VC++ | Video - (0 Comments)JavaMail, sending emails from your Java application
August 26th, 2011 | Posted by in IT | Java | Programming | Shahab - (0 Comments)The JavaMail API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API is available as an optional package for use with Java SE platform and is also included in the Java EE platform. Download JavaMail jar files from here. Full JavaMail API. For a full example with source code of JavaMail, click on “more” link down here. (more…)
RxTx / Serial Communication on Windows
August 25th, 2011 | Posted by in Arduino | Electronics | IT | Java | Programming | Shahab - (0 Comments)- unzip rxtx-*-win32.zip
- copy rxtxSerial.dll / rxtxParallel.dll to %JAVA_HOME%\bin
(e.g. c:\Program Files\Java\j2re1.4.1_01) - copy RXTXcomm.jar to %JAVA_HOME%\lib\ext
OpenCV installation Tutorial, MS Visual C++ 2008
May 31st, 2011 | Posted by in Image Processing | IT | Programming | Shahab | VC++ - (0 Comments)Installing OpenCV might sound very easy when you read it on some forums/websites, but there are some small changes in most of these tutorials that prevent the connection between OpenCV and MS Visual C++. In this tutorial we(my dear friend Puya Afsharian and I) try to guide you through the installation of these two products and the right way to make them talk with each other.
Although people say it is easy to make OpenCV 2.2 to work with MS Visual C++ 2010, but we did not get it to work properly while it seems that MS visual c++ 2008 works perfect with OpenCV 2.1. Here are the download links for both products :
OpenCV 2.1 : http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
This file is modified to work with MS Visual C++ 2008 and therefore there is no need to install CMake again.
MS Visual C++ 2008(Free of charge) : http://www.microsoft.com/downloads/en/details.aspx?familyid=a5c84275-3b97-4ab7-a40d-3802b2af5fc2&displaylang=en
Click More down here to read the rest of the tutorial …
CourseApp Final Report
May 30th, 2011 | Posted by in Android | IT | Java | My Projects | My Studies | Others | Presentations | Programming | Rapid Prototyping | Shahab | UiO - (0 Comments)What is CourseApp ?
CourseApp Final Presentation :
CourseApp Final Report :
http://www.uio.no/studier/emner/matnat/ifi/INF5261/v11/studentprojects/android/FinalReport_INF5261.pdf
Arduino Ethernet shield problem when on External Power
May 23rd, 2011 | Posted by in Arduino | Electronics | Shahab - (0 Comments)When Arduino/ethernet shield is connected with an external voltage source I have to press reset button to make it work. But when I use it with the USB source everything works fine. This code is not exactly pretty, but it solves the problem of the need to restart on Ethernet shield startup. Open relay and hooked the coil pins to ground and digital pin 02, and the switched pins to ground and the reset pin. The trick is to before initializing the Ethernet library, check an address in EEPROM. If the flag is 0, we set it to 1 and then trigger the relay, and the unit resets. If the flag is 1, we assume that we just did a warm reset and set the flag back to 0, for next time we power up.
<pre>int relayPin = 02;
int addr = 128;
void eepThang() {
eep_value = EEPROM.read(addr);
if (eep_value == 1) {
Serial.println("already reset. writing 0");
EEPROM.write(addr, 0);
}
else {
Serial.println("not reset.. writing 1, restarting");
Serial.println(eep_value);
EEPROM.write(addr, 1);
Serial.println("done wrote... here we go");
digitalWrite(relayPin, HIGH);
delay(1000);
}
}</pre>
source : http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225354009/15
Processing, the key for Arduino board independent programming
May 23rd, 2011 | Posted by in Arduino | Electronics | Java | Processing | Programming | Robotics | Shahab - (0 Comments)When it comes to Arduino, there are several ways to do things. Using simple Arduino IDE to communicate with the board through serial port. Write a Java program to do it, or maybe do send orders to Arduino through your program that is not uploaded on Arduino card and can be changed anytime without even updating the pde file on the board. The tool that gives you the power to do this is called Processing & the library used exactly for Arduino is called StandardFirmdata. The very good thing about Processing is that it is based on Java and all Java codes works right out of the box on it. You can also import processing libraries into your Java framwork and enjoy the power of processing right in the middle of your Java project(in Eclipse).
The instruction to get Processing & Arduino talk together :
- Download this file.
- Unzip the library and copy the “arduino” folder into the “libraries” sub-folder of your Processing Sketchbook. (You can find the location of your Sketchbook by opening the Processing Preferences. If you haven’t made a “libraries” sub-folder, create one.)
- Run Arduino, open the Examples > Firmata > StandardFirmata sketch, and upload it to the Arduino board.
- Configure Processing for serial:http://processing.org/reference/libraries/serial/
- In Processing, open one of the examples that comes with with the Arduino library(in the same folder that we just unzipped).
- Edit the example code to select the correct serial port.
- Run the example.
Processing Serial communication in Eclipse
May 21st, 2011 | Posted by in Java | Processing | Programming | Shahab - (0 Comments)If you are combining Java & Processing using Eclipse, probably you would have problems using Serial library in Processing with just importing Processing Core jar file. You do need to import the Serial jar file from following path :
Path…/Library/Java/Extensions
This should be added as an external Jar file in properties of your project at Eclipse.
Android development tricks
May 19th, 2011 | Posted by in Android | Java | My Projects | My Studies | Programming | Shahab | UiO - (0 Comments)This is a summay of the tricks I have learned making an application called courseApp project. This application was developed in the Mobile Information Systems that I took at University of Oslo. Eclipse is a very good tool to use for Android development. To start with you need to download Andriod SDK. After installing both of these(and ofcourse Java Development Kit, JDK which is a pre-requirement for both of these), you need to make Eclipse and Android SDK talk together. This is done by a plugin called “ADT plugin for Eclipse” from Google. You can read more about how to install this plugin by clicking here. In case of Android SDK installation(the exe file) doesn’t recognize JDK on your computer, you can simply download the zip file and extract it. Don’t forget appending that folder to the %PATH% environment variable. Now some more tips follows :
background color for your layout :
add the following code to your layout XML code(#ff32cf is the color code)
android:background="#ff23cf"
Background Image for your layout :
1- Add the image you want to the layout folder of your project.
2- Add the following code to your layout XML code
android:background="@drawable/bbg"
EditText features :
one of the features I want to talk about is android:singleLine which is very useful. If you want to get some info from the user, this text box is a good tool to use, but make sure you set the SingleLine variable to true. If not if they paste a 20 lines of text by mistake your whole GUI gets out of shape. Also if you want to use this for example to write an email text, then this should be set to false as you want it to contain several lines. The good thing about several lines EditText is that they do have scrolling function.
<EditText ... android:singleLine="true">//Single Line box for getting email address </span><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"><EditText ... android:singleLine="false">//Multi Line box for getting email text
in case you want limit the number of lines of an EditText:
<span style="font-family: monospace; font-size: 12px; line-height: 18px; white-space: pre;"><EditText android:layout_width="fill_parent"</span> <pre><code> android:layout_height="wrap_content" android:gravity="center" android:singleLine="false" android:lines="5" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" /></code><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">
Simple Item List :
Setting up a simple Item list with an already filled Arrayadapter.
static final String[] COUNTRIES = new String[] {"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra","Angola", "..."}
<pre>setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, COUNTRIES));
getListView().setTextFilterEnabled(true);</pre>
Drop Down List :
In Android drop down list is a little bit complicated to give value to. You first need to add one Spinner to your layout and then connect it to
String[] Countries = { "India", "France", "Japan", "China", "U.S" };
// //////////////////Countries Spinner/////////////////////////////////
SpinnerCountries = (Spinner) findViewById(R.id.Spinner01);
// //////////////////////////////////////////////////////////////
// create an arrayAdapter an assign it to the spinner
AdapterCountries = new ArrayAdapter<CharSequence>(this,
android.R.layout.simple_spinner_item);
AdapterCountries
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
SpinnerCountries.setAdapter(AdapterCountries);
int lenCountries = Countries.length;
for (int i = 0; i < lenCountries; i++) {
// test += Areas[i] + "\n";
AdapterCountries.add(Countries[i]);
}
Disabling the Landscape Mode :
You have two ways to do this, either in the code, or in the XML layout file :
XML :
</span><span style="font-family: monospace; font-size: 12px; line-height: 18px; white-space: pre;"><activity android:name=".SomeActivity"</span> <pre> <pre><code> android:label="@string/app_name" android:screenOrientation="portrait"></code>
OR in the code :
[/java]
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Fixed Portrait orientation[/java]
Layouts in Android :
LinearLayout :
LinearLayout aligns all children in a single direction — vertically or horizontally, depending on how you define the orientation attribute. All children are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a horizontal list will only be one row high (the height of the tallest child, plus padding). A LinearLayout respects margins between children and the gravity (right, center, or left alignment) of each child.
TableLayout :
TableLayout positions its children into rows and columns. TableLayout containers do not display border lines for their rows, columns, or cells. The table will have as many columns as the row with the most cells. A table can leave cells empty, but cells cannot span columns, as they can in HTML.
RelativeLayout
RelativeLayout lets child views specify their position relative to the parent view or to each other (specified by ID). So you can align two elements by right border, or make one below another, centered in the screen, centered left, and so on. Elements are rendered in the order given, so if the first element is centered in the screen, other elements aligning themselves to that element will be aligned relative to screen center. Also, because of this ordering, if using XML to specify this layout, the element that you will reference (in order to position other view objects) must be listed in the XML file before you refer to it from the other views via its reference ID.
OpenCV, Tutorials based on my experience coming soon
May 10th, 2011 | Posted by in Programming | Shahab | VC++ - (0 Comments)OpenCV is a rich computer vision library compatible with many programming languages opening doors for lots of opportunities … Soon I will write a tutorial here about it …

update :
Here is my tutorial on how to install OpenCV and make it work with VC++ 2008


