Blog

  • accelerated ray tracer

    In all the great online classes I attended over the last year, there was one topic missing. Finally I found an offering for a Computer Graphics class. After all, that’s the field I ‘ve been working in for the last five and a half years. The class is offered at edx.org and is from Berkley. It’s the first class I’m taking from edx, and the style of the class is comparable to coursera and udacity.

    The first part of the class was concerned about OpenGL, and we implemented an interactive scene viewer. Although I didn’t work directly with regular OpenGL before, only with WebGL which is based on OpenGL ES, it was mostly repetition. But nonetheless it was good training for working with homogeneous coordinates and matrices with different orderings. For grading, we had to produce 12 screenshots from the same scene with different transformations. Once it was implemented I had only to change the order of some transformations to have all images correct.

    The second part was concerned with ray tracing. Eventhough I was familiar with the basic concept, working with it was new to me. And in the class, we had to build a ray tracer from scratch.The theory sounded straight forward. But somehow I was not so lucky in implementing it. In every new part I made some silly mistake. I developed it not exemplary test driven, but with unit tests for every key part that I wanted to verify. With that in place I could usually find and correct the problem in time. For grading, we had to produce seven images. (more…)

  • rs232 bluetooth adapter

    Usually, headless embedded systems can be managed conveniently using ssh. The consumer focused devices have web interfaces. SSH is perfect, for when the system is running, but if the boot process has problems, there is no screen to read the boot messages that the kernel prints out.  For this purpose these devices usually log to a good old serial port, either exposed as an RS232 (+-12V) or internally with TTL level (usually 5 or 3.3V). Most desktop and notebook computers these days don’t have an RS232 port any more. But there are USB to Serial converters, which are a bit pricey but available in most stores. And then you need a serial nullmodem cable. I threw my old one away many years ago, thinking the serial age was over. But then I bought one again exactly to debug the boot process of an alix. But sometimes, the embedded system is in a location where it’s inconvenient to span a cable. That’s when an RS232 bluetooth adapter comes in handy.

    (more…)

  • RaspberryPi reading analog input using an AtTiny through i2c

    The raspberrypi has some GPIO (General Purpose Input Output) pins. That’s great for experimenting with electronics for example sensors and actuators. It’s totally different than an Arduino in many respects, but that’s something they have in common. Some of the pins have special functions. For example SPI, I2C, UART …

    There is a breakboard adapter for all the GPIO pins with a ribbon cable that you can order from the US. That’s cool, but ordering stuff from abroad can be expensive. And the pins look somehow like good old IDE. So I soldered an adapter myself and bought an IDE cable. Well, some pins worked, and some didn’t… Enough for the first round of experimenting, but it took a while to find out what’s going on. I just assumed that all the wires of the IDE cable were connected which for some reason was not the case.

    But something is missing that the arduino offers: analog. Before I really needed analog sensing capabilities, I found an article, describing a hack to read analog input by measuring the time it takes to discharge a capacitor through the resistance you want to measure. Immediately, I tried it myself with a photo resistor. The author warned, that the timings with the python script are not really accurate, and that the correct values for the components would have to be calculated. The Values I got were fluctuating wildly, and I couldn’t really see a difference with the brightness in all that noise.

    So I looked for something more accurate. I still have some AtTiny’s and they have analog inputs. But SPI is the only means of communication they support in hardware. Last week, I implemented uart receiving capabilities in software, but this time I was looking for i2c. (more…)

  • LED debugging the stereowrap hardware

    I found out earlier that 5V is not enough to drive the shutter glasses. With my breadboard setup for stereowrap, I fed 12V to the op amps from an external source. Now that I moved the thing to a strip board, I added a step up converter that generates 12V from the 5V available on the USB port. I used an LT1301 which comes with an application note for exactly my use case. It was easy to implement and worked from the first try.

    Then I temporarily switched from an arduino duemillanove to a leo stick. Although it’s a tiny clone which plugs directly into an USB port, it still seemed like a bit of an overkill. I thought of using one of the AtTiny’s for that project. As I was not too familiar with these yet, I first did a hello world blinking LED’s. Soon after, I learned that neither the Attiny45 nor the AtTiny85 have a hardware UART. Well, I thought, there is an arduino software serial library. Arduino libraries are generally very easy to use in the IDE. But as I programmed the chip directly this time I wanted to stay within CodeBlocks/CMake and use the arduino library from here. (more…)

  • payment slip reader

    Probably the first time I got in contact with one of the pen style payment slip readers, was when I was working for TCG. They only come with drivers for Windows and in the meantime also for Mac. I contacted their support more than once, asking for a linux driver. No success so far. So I decided to get one cheap from ricardo.ch (similar to ebay.com). I was really lucky, and got one that makes noise when shaking for CHF 5. A new one would cost more than CHF 200. They have a very effective way of making sure people buy new ones from time to time. They just don’t release drivers for the older devices on newer versions of Windows. Well, that happens a lot in the Windows world, that people are forced to buy new devices. So there are a lot of devices floating around on ricardo.ch which only run on WindowsXP 32bit. Mine is one of those, but since I want to use it on linux that should be no problem.

    When I first plugged it in, the USB id was recognized correctly:

    $ lsusb
    ...
    Bus 002 Device 010: ID 0a93:0002 C Technologies AB C-Pen 10

    But that was about it.

    Trying to capture the communication on the USB port worked nicely with WireShark under ubuntu. But as I had no driver for it, there was not much communication to monitor. So I had to capture on a Windows box. Not so easy in a Windows-free zone. I have a VMWare virtual machine on my harddisk that I used some time ago to maintain an ancient project. But the outdated WMWare-Player could not run with my current installation. I had to upgrade it. It compiled the kernel modules with some minor help. But then the VM wouldn’t boot. I suspect, they changed the hardware they emulate. That would be no problem with linux, but Windows has real trouble with changing hardware. That was the same reason, I could not migrate that VM to VirtualBox some years ago. So, I installed a new Windows VM with VirtualBox. But now I could not figure out how to make the USB device accessible to the guest OS. The next try was qemu. It’s not as point and clicky as the other two products, but it’s really powerful and comes with loads of features. I grow to like it ever more. (more…)

  • Fun with the canoe

    Mirella and me started a new hobby after we could borrow the kayaks from a friend in Peru. He even helped us buy cheap Peruvian kayaks that we brought home in our camper. These kayaks are sit on top‘s. The kind that they rent to tourists. They are easy to operate and easy to climb back on top after you fell into the water. You can even carry sleeping bags or a small child with it. With the children growing, we thought about buying a Canoe. In Switzerland that type of boat is actually called “Kanadier”, while Kanu is a different type. Last year we had a good opportunity to buy a used one on a camp side in Austria. I didn’t even know that there are so light ones in this size. It offers room for three people and a lot of baggage, and it’s easy to carry around alone as well at putting it on the roof of our camper which is at 2.75 meters. It’s a sandwich construction with PE in the middle and glass fibre on the hull. A short while ago I had some fun trying to get back in from the water. It’s not as easy as with the sit on top kayaks.

  • cmake with MSVC

    I have used cmake for a couple of years with my hobby projects, and I love it. It is a cross platform meta build system. Like with Qt, people tend to first think that “cross platform” is the main feature. But like with Qt it’s actually one great feature amongst many others. It brings so many advantages that I can’t even list them all here.  Since last week, we also use it for PointLine at work. While the process is straightforward on linux, there are some things worth mentioning when using it on Windows.

    Finding External libraries

    Cmake has lots of finder scripts for commonly used libraries, and they work great in most cases. But we want to have multiple versions of the same libraries side by side, and depending on the version of PointLine we develop for, use the appropriate versions of the libraries. To be precise, not just the libraries, but also the headers and debug symbols need to be present in different versions. And we want to be able to debug different versions of our product using different versions of the libraries, simultaneously on the same machine. (more…)

  • software defined radio on the cheap with a DVB stick

    I think I first learned about software defined radio a few years ago on the chaosradio podcast. I was totally excited about the idea, and immediately installed gnuradio not only on my computers, but at times also on the smartphone. The USRP has been on my wishlist ever since. That’s the hardware device most commonly used with gnuradio. The downside was the price tag. While the approx $ 1’000 are not much compared to commercial solutions, it was too much for just another project to toy around, and I didn’t have an idea for a project where I must have one so far.

    Then in last February (2012), I read on a blog post that was probably linked from hacker news that somebody found out that a cheap DVB tuner USB stick could be used as an SDR receiver. That was exactly what I’ve been waiting for the past few years, except that a device with TX would be even cooler. Immediately I went to the local electronics shops with a compatibility list. But in most shops they had no clue, and they couldn’t even find out what chipset was in the devices they sold. In a more professional shop they tried to find out the chipset, and they had a device that looked very similar to one on the compatibility list. But it didn’t work. So, I ordered one directly from china. It took almost two months to get here, but then it took another two month before I really started experimenting with it beyond checking if I could sample something to the harddisk. Here is some background information. (more…)

  • The cheapest netbook

    When I read this blog post telling that there are netbooks available from china for $65, where it is possible to install a proper linux distro, I knew I must have one. Yes, the specs are lowest end, but even more so is the price. It has a WonderMedia 8650 system on a chip. That’s an ARM CPU running at 800 MHz with 256MB RAM. These chips are normally used for low end tablets, and you see that with other things. The netbook has a 7 inch screen with 800*480 pixels and runs Android 2.2. So the device could be described as a tablet with a keyboard, touchpad, wifi, ethernet and three USB host ports, but no touchscreen, accelerometer, GPS, camera nor bluetooth.

    From AliExpress, I ordered a device that seemed to be the same as mentioned in the blog. (more…)

  • machine learning class

    Another one of these incredibly interesting online classes came to an end. Machine learning was one of the first two classes that started last fall. As I thought to make AI and ML in parallel would be too much, I decided for AI with the intention to make ML later. The second round of ML was announced for January, but actually started in April. Andrew Ng from Stanford, who some people call a rock star in ML, thought the class. The videos were longer than what I was used to, and I downloaded them to my Android to watch them in the train to work. The homework consisted of review questions and work assignments for octave. The last time I did something with MatLab was more than ten years ago, and I remembered nothing of it.

    The class started with gradient descent and logistic regression. And almost everything that followed was compared against and related to them.

    I had some prior experience in ML, but no formal training. At TCG I learned the basics from a co worker. Then I implemented a document classification engine using an SVM. I read many books on the topic. Later I develpoed a prediction system for good days and locations for paragliding, again using an SVM as well as an evolutionary optimization. (more…)