Archive for October, 2009

Sound controlled lamp

October 20, 2009

That’s a project I’ve done long time ago, but never talked about it in my website.

Here is the link.

Advertisements

OLED displays are getting better every day

October 18, 2009

OLED is a display technology that attracted me from the beginning.

The advantages are:

  • Wider viewing angle (near 180 degrees)
  • Lower response time (order of microseconds, not milliseconds like LCDs)
  • Better contrast compared with LCDs
  • Power consumption depends on the actual number of pixels lit, so it can be lower than LCDs
  • Piexls directly emit light, no need of a backlight
  • Can be made flexible

I used OLED displays in two of my projects, the multi function watch, which uses a 96×64 pixel monochrome yellow OLED, and the Miosix player, with a 128×128 pixel 262K color OLED, and can confirm the advantages of this technology.

However, the reason of this blog post is this video I found on youtube:http://www.youtube.com/watch?v=f8S8tbQMp2k. It looks like another advance in OLED technology. Other than being flexible, it has another advantage: it is much more resistant than an LCD. I hope it will be mass produced soon 🙂

Using C++ on microcontrollers code size tricks

October 11, 2009

I posted a new article on my website.

It talks about some tecniques to minimize the code size when using GCC and C++ with microcontrollers. It also includes a fully functional template project for an LPC2138 microcontroller.

GCC optimization flags

October 1, 2009

Recently I was talking to a friend of mine who is doing his thesis on parallelizing software on the CELL processor (the one used in the PS3). When benchamrking they found a program that runs nearly four times faster if compiled with the -O3 option. I’ve always specified optimization flags in my projects, and I was aware that they speed up the code a lot, by I was surprised by that figure: four times faster, and without changing the source code!

So, I decided to write a blog post about it. First, let’s start with GCC basics. To compile a C++ file you usually type:

g++ -c file.cpp
g++ -o file file.o

The first line compiles the source code int an object file (file.o), and the second performs the linking step.

To specify an optimization flag, you add -OX to the compiler, were X can be 0,1,2,3 or s; like this:

g++ -O3 -c file.cpp
g++ -o file file.o

Ok, but what optimization flags to choose?

When debugging code, it is necessary to use -O0, which is the equivalent of passing no optimization flags. This is because optimizations confuse debuggers that have difficulties in single stepping your code. (Of course, if you want to debug your code with gdb, you’ll want to enable debugging data, by passing the -g option to the compiler)

When you are releasing your application, it is time to enable optimizations. My advice is to choose the optimization flags in this way:

  • By default, use -O2. It makes your code run fast enough for most applications.
  • If your application need to run very fast, use -O3. This increases the size of the executable file (for example, because it might perform loop unrolling), but it makes it run faster.
  • If you need to minimize the executable size, use -Os plus the -s option that strips from the executable everything except what’s really necessary.