Sonntag, 28. November 2010

protothread and arduino, a first easy example

I wrote a little example to demonstrate the possibilities of protothread and an avr µc. I decided to use some arduino specific functions like pinMode(), digitalWrite() and digitalRead() because i think this way it is very easy to understand what's happening in the code. But you should always keep in mind that these functions are up to 50 times slower than direct port access. It's easy to change the read and write functions to direct port access later on in a project if more I/O power is needed. For me arduino is a rapid prototyping platform...

Samstag, 27. November 2010

protothread, a powerfull library

Some weeks ago, while browsing around the net i found Adam Dunkels website.
Back in 2005 he wrote protothread as an easy way to implement blocking conditions.
"Protothreads are a extremely lightweight, stackless threads that provides a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without using complex state machines or full multi-threading. Protothreads provides conditional blocking inside a C function." []
Basically protothread is the implementation of stack less coroutines. Of course no real coroutines because the basic µc has only one core and no scheduler. What it does, is that it gives you the possibility to manage your code in a very easy way using 'thread a like functionality'. It consists of a few include files defining macro's that are used to implement threads as switch/case constructs.
The trick was originally invented by Tom Duff and dubbed Duff's device.

Mittwoch, 24. November 2010

harte ware

Hey all, welcome to my blog!
Harteware is german and is the direct translation of 'hardware'. This term is never used anyhow.
Two years ago i started to code in c/c++ on the avr platform with the arduino environment. Before that i did a lot of electronic soldering, so i started mixing both worlds: the hard- and the software.
Love it or hate it, but arduino has brought a lot of new people to this whole hardware thing and myself to the µc world.

At the moment i have a few projects going on which i am going to summarize and file here. Also i am in the process of migrating away from the arduino IDE while still use some of the provided comfort. I am using kate as an editor and the arduino IDE to compile the code. To do so, just check the box on the 'use external editor' box in the preferences menu. In parallel i am trying eclipse with the avr plugin as IDE, but i am still having trouble with the resulting codesize, so until i fix that i'll just use kate.

If you have something to add, your critic and/or tipps are always welcomed!