Saturday 26 January 2013

Them cats

I have read quite a bit of web comics lately. A couple nice ones are Lackadaisy and Bittersweet Candy Bowl. Lackadaisy is a superbly drawn comic about a speakeasy called Lackadaisy and the folks running that place in 1920's during the prohibition. Bittersweet Candy Bowl in turn is a comic about high school teenagers who have in between them a bunch of one-way – and sometimes two-way – love relationships, and drama ensues.

These two don't have much in common, except that in both the main characters are cats. The Lackadaisy world is run by cats only, whereas BCB world is run by both cats and dogs and has bunch of other talking animals as well.

Nevertheless, the idea I had was: what if the folks from these two worlds came across each other? Never mind that they are from quite different eras or that the other cats walk around mostly naked and the others tend to be fully and stylishly dressed.

This would happen. Sooner or later.

The boy cat in comfy blue scarf is Mike from Bittersweet Candy Bowl. The lady cat in lovely orange dress is the ever chipper Ivy Pepper from Lackadaisy. The tools used are, as usual, ProMarker colored markers and Fine Liner black pens on marker-proof paper, all from Letraset.

Wednesday 17 October 2012

Review: Inkscape Beginner's Guide

Packt Publishing has published a book called Inkscape Beginner's Guide. I've had the chance to read this book and here I will share my thoughts about this book. I don't really belong to the people this book it targeted to – Inkscape beginners – but I have tried to look at this book as if I was not fluent Inkscape user already.

In brief, this book explores a wide variety of features available in Inkscape 0.48 in a straightforward and easy-to-follow way. Copious amounts of screen shots are used so that it is easy to see what kind of results one should expect when trying out the features described in the book. Naturally, the flip side of this is that none of the features are discussed in depth – the book would become huge if they were.

The book starts from the very beginnings, such as what are vector graphics, SVG and Inkscape and how to install Inkscape. In fact, it is not until chapter 4 that the reader is shown how to draw something. If I was writing a beginner's guide I probably would get into the drawing part earlier on, but how this book is written has its merits too: the basics are explained before the things that build upon them.

The target audience of the book seems to be aspiring print or web designers. Before drawing their first shape, the reader is shown how to define the page size and how to set up the different margins used in print design. Many of the examples show web page design tasks and there are several mentions of things "your programming team" can do, such as programmatically modifying the SVG file you have created.

Unfortunately the book has a slight unfinished feeling to it. Nothing big, for example the first chapter tells SVG is based on XML on multiple occasions, but never really tells what is XML. An other part of book shows how to change the page background opacity by changing the hexadecimal colour code from ffffff00 to ffffffff without telling what those codes mean and when the alpha slider is clearly visible in the provided screen shot. One chapter declares it will show how to use spiros, but shows spirals instead. Small things and a beginner would not even notice most, just multiple things that feel slightly odd.

One big thing I would change is the way how the Bezier tool is presented in the book, though this is really mostly a personal preference. Anyhow, it is a tool that I use often and make heavy use of its short cuts, but the book only shows how to draw straight lines with sharp corners and how they can be turned into round lines and corners afterwards. If I was doing my drawing the way it is shown in this book, it would take a lot more time. This is a general trend in the book elsewhere, too: it shows things you can do with Inkscape, but often not how to do them efficiently.

Not so much about the book contents, but I do like how the e-book is made. I got myself the PDF version and it looks well made and does come with full index. If I want to jump to, say, chapter 9 which explains filter effects, I can just select it from the side bar in Evince (or other PDF reader). Only issue I have with it is that my name appears on every page of the PDF – obviously it is there to combat piracy, but it also causes a mental highlight fairly often when you spot your own name on the document.

So, to recap: this book gives a wide overview of how to use Inkscape, but somewhat lacks in depth. I would believe this book can be useful for beginners – just as its title says – but not so much for anyone who already knows his way around Inkscape.

Sunday 16 September 2012

Neon Markers

The folks at Letraset were kind enough to send me a sample pack of their new Neon Markers. I tried them out and I feel they are quality items, though maybe limited to some special purposes.

Basically, the Neon Markers are artistic markers with fluorescent inks. The construction will be very familiar to anyone who has used ProMarkers from Letraset. Only discernible difference is that ProMarkers have small bullet tip on one end and larger chisel tip on the other, whereas Neon Markers have a bullet tip on both ends, one small and other larger.

The idea of fluorescent colours is that the colour appears impossibly bright, as if it was reflecting more light than there is. In fact, the colour is taking in light of a high frequency, such as ultraviolet light, and emitting it on lower frequency, such as yellow light.

The fact that Neon Marker colours react to ultraviolet light makes them especially attractive to situations where there's plenty of such light present. These colours will literally shine in places illuminated with little ordinary light and several blacklight bulbs.

Many of you may have already noticed that this fluorescent property is nothing new: in fact the common highlighter pens contain similar ink. I tried some highlighter pens I have and compared them to these Neon Markers. The colours hues are really similar to each other, but the colours of Neon Markers are clearly more saturated and vibrant than the colours of highlighters.

Here are the Neon Marker colours with some similar colours from the ProMarker range.

The Neon Marker colours in this picture are not too distinctive from what you can achieve with normal marker colours, except for luminous yellow and maybe for radiant orange. In the real life the differences were more visible, but the limited capabilities of the camera and computer monitors dull out the colours. So, if your target is to make something that will be shown on computer screen, the Neon Markers are so-so. Photocopying or ordinary four-colour printing will likely bump into same issue.

Here are the same colours when illuminated with a small ultraviolet torch.
 In ultraviolet light the Neon Markers really come to life, except for volt blue. That one just seems to have very little fluorescent properties and is almost the same colour as sky blue from ProMarker range. My camera seems to have somewhat freaked out with the colours in the picture illuminated with ultraviolet light, but you can still see the main point: the Neon Marker colours shine while other colours seem to become dull and dark in comparison to them.

So, to recap: these markers are so-so when the result is reproduced on computer screen. They are a lot better when people can see the original drawing you made. And when the original drawing is displayed under ultraviolet light aka. blacklight, that's when these markers work the best.

Wednesday 1 August 2012

The sound of Soundbox

So, at last I managed to take some video of the Soundbox device I have built. I have discussed this device in two earlier posts, notably the electronics and the case construction.


Here I first demo the two different voices, sine and noise, separately. After that, I try to build some nice sounding loop with both voices combined. The latter part is somewhat failure, though. On a previous try of recording the video I actually managed to build a loop that sounds mostly good, but some glitch messed up the audio on that.

This video had been sitting on my hard drive and Google's servers for quite a while, since at the time when I recorded it, I was unable to embed it into a post using the Blogger editor. But now, as I was writing an another post, I noticed that there were new options in the "Add image" dialog and I was able to post this video. Yay!

My Raspberry Pi Setup

I was not amongst the first to order a Raspberry Pi so I received mine only last week. Here's a story of how I set it up and what issues I encountered on the way.

This is my setup. On top centre in the Pi itself. Upwards from it goes the HDMI connection to the screen and on its right side is connected an 8 GB MicroSDHC card in an SD adapter. Below the Pi is a powered el-cheapo USB hub, to which are connected the receiver for wireless keyboard and mouse and the WLAN dongle. The USB hub also powers the Raspberry Pi. On the lower right is a 5 V 3 A power source.

From the get-go I experienced issues with my setup: it was not stable, but corrupted the file system in really short order. Usually running the raspi-setup program, going through the settings and rebooting was enough to screw up the file system beyond all repair.

First I tried to solve this issue by trying out a couple different OS distros, using different methods of powering the system and using minimal amount of peripherals. I tried the official Raspbian "wheezy" image, the Raspbian Pisces image and OpenELEC. I could get none of them work to an useful degree.

Getting the power source in good shape was likely a notable part of getting the whole setup working. Originally I used a small adjustable power supply I had lying around. One issue was that the power supply heated up significantly when in use, even though it was rated for even more current than my setup consumed.

The other, maybe more major, issue was that the USB hub was powering the Pi from both the power input jack and the USB output jack. If I powered the Pi from a mobile phone charger and the USB hub from the adjustable power supply, unplugging the phone charger was not enough to power the Pi off. It has been reported that this can cause file system corruption, since while the electronics can be powered from the USB output jack, the 100 mA polyfuse in its power rails prevents the electronics from receiving enough power, causing the voltage to drop under recommended levels. This voltage drop can cause the SD card to behave erratically.

To prevent the USB hub from powering the Raspberry Pi through the USB output jack, I cracked the hub open and started to investigate.
Very simple device. Two-part plastic enclosure is held together only by tabs moulded to the bottom part. Inside is a one-sided circuit board with the USB connectors, one electrolytic capacitor, clock crystal, 3.3 V LDO regulator, unmarked microchip containing the USB hub logic and assorted resistors and small capacitors.

Here on the first picture you can see the modification I made to the hub: the USB connector to host computer is attached to the circuit board on top centre. The red and black leads of this connector, marked helpfully with letters R and B, were the leads that supplied the operating voltage from host to the board – or from board to the host. So, I cut them. Probably there was no need to cut the black lead and it would have sufficed to cut the red lead providing the +5 V connection and leave the 0 V black lead as-is, but I had already cut both leads when I realized this. Fortunately there's still the shield connection, which connects to the metal outsides of USB connectors and is likely tied to 0 V line anyhow. This modification makes this hub unusable as host-powered hub as the host can no longer power the hub or the devices connected to it, but I think I can live with that.
No modifications were done to the underside of the board. There's one interesting thing on the right side of the main IC, though. If you look closely, you can notice an seemingly out-of-place component connecting the right legs of C15 and R3. It might be a small capacitor. Anyhow it's in a somewhat odd angle and not connected to pads of its own, like all other components are. I can't make out, if it's a stray component that has happened to lodge itself there or if it's a cluge – maybe a component that needed to be added after a massive batch of circuit boards had already been manufactured.
Modifying the hub sorted out most of my power issues: now I could power the whole setup from one power source through the hub without accidentally powering the Pi through its USB outputs. The original power supply still got rather hot and I was somewhat suspicious of its capability to output stable 5 V, so I bought a small 5 V 3 A fixed-voltage switching mode power supply from Partco, a local electronic components supplier. This is plenty current capacity to drive the Pi and the peripherals I use. Nominally the Pi uses 700 mA, the WLAN adapter 500 mA and the keyboard and mouse receiver under 100 mA, so I have plenty of reserve power, should I want to connect an external hard disk drive or some such.

Even with the power issues solved, the file system corruption continued. Next up on the list was the SD card itself. On the left is a Transcend 4 GB Class 6 SDHC card I had been using in my old netbook to extend its fairly small SSD disks. Even though it had served me well on other uses, this card was totally unusable with the Pi. Major file system corruption and frustration ensued. When I switched to using the 8 GB Class 4 Kingston MicroSDHC and adapter on right, everything just started to work. No more file system corruption.


The markings on the back of the unusable card say "8281AB 4G 05D91" while the working card is marked "C08G" and "SDC4/8GB 56"

So, after a long wait for manufacturing and shipping, some hardware modification and changing memory cards I finally managed to get my Raspberry Pi in a working state. Right now it's nothing but a low-power silent device I can use to browse the web, but maybe I'll come up with some more interesting things to do with it soon.

Wednesday 4 January 2012

Soundbox — The construction

The Soundbox device I have built uses some construction techniques I want to share with you readers. I'm mainly talking about the enclosure and the texts on controls.


The enclosure itself is built from a simple box bought from a craft store. It was unfinished wooden box with two small hinges and a clasp to hold it closed. The lid and bottom parts were quite nicely suitable size for all the parts, I just needed to build the control panel inside this box.


The control panel is built from 4 mm plywood that I cut to the correct shape with a coping saw (not the best tool for the job, but that was what I happened to have at hand). Then I drilled the holes for the knobs and such. The speaker hole I cut with the coping saw. To keep the control panel in place, I glued some 9 × 9 mm wood bars to the inside of the box, 4 mm from the top of the bottom box so that the control panel will sit flush with the sides of the bottom part.

After constructing the box, I removed the hinges and the clasp and painted the box and control panel with several (maybe four) layers of white spray paint. What surprised me was how much that stuff stinks — I had to keep the parts outdoors for a couple days after painting so that my room would not smell of solvents. The finished box had a distinct solvent smell for like a month after it was done.


The two main knobs — pitch and arpeggio — are of my own design. They're seven-sided knobs with friction fit for the usual 6 mm potentiometer axle. I created the model in Blender and ordered them from a 3D printing company called Shapeways. The design didn't work quite as intended and I had to remove some material from underside of the knob so that the nut that holds the potentiometer in place fits under the knob. I also had to use 6 mm drill bit to widen the centre hole so that the potentiometer axle fits in there.


For the markings on the control panel and the two main knobs I used transfer lettering from Letraset. This is rub-down lettering, that is, you write by finding the required letter from the sheet, placing that to its intended place and rubbing down on the letter sheet so that the letter material is transferred from the sheet to your working piece. These are mainly intended to be used on paper, but they appear to work just fine on wood and plastic.


After writing all the texts I wanted, I coated the control panel, the two red knobs and the box with several (probably three) coats of clear spray lacquer. Before this it would have been possible to rub or scrape the lettering off, though it would have taken some effort. After the lacquer coat the lettering is there to stay. Even though the spray again had quite an amount of solvents, neither the lettering nor the plastic of the two red knobs was adversely affected.

After this, the rest is rather straightforward. I re-attached the hinges and the clasp I had removed before painting the box white. I installed the potentiometers, buttons, switches and the line jack to the control panel with their supplied nuts. The two LEDs and the speaker I attached with hot glue. Eventually I will have to figure out something more sturdy than hot glue for mounting the speaker, for it did come loose at the Alternative Party. The control panel is held in its place by the side walls of the box and the support bars inside the box, but there's nothing stopping you from lifting it upwards to reveal the electronics hidden inside.

Sunday 20 November 2011

Soundbox — what makes it tick

I did have the soundbox device I have built with me at Alternative Party 2011. It did attract a fair amount of interest, though nowhere near what my 32×8 LED screen did. I think I'll have to write a post about that LED screen and how it works some time. For quick info, it's built around an ATmega328, can show 16 different shades of green with gamma ramp and shows some classical effects such as plasma and fire.

Neither one of my projects gained nowhere near the interest that the Chernobyl reactor simulator by Helsinki Hacklab did, but that is only to be expected. That simulator was awesome, even though they didn't quite manage to get it to a playable state during the event.


I'll first describe the high-level workings of the soundbox, then the hardware side and last the software used.

High-level view

The device is a looper: it plays a short loop of sounds over and over again and the sounds can be altered while the device is playing. It provides two channels, each with its own waveform and each separately programmable. The loop is 128 sounds long and the actual length of loop in seconds depends on the setting of tempo knob.


The first sound channel plays sine wave and the second channel plays pitched noise. One of the device controls is a pitch knob that can be used to select the frequency of sine wave of noise to be programmed.

For sine wave there's also second knob — arpeggio — which can be used to alternate between the base pitch and a higher pitch at a high rate. The rate is fixed depending on tempo and the setting of arpeggio knob defines how much higher is the higher pitch.

Also there's a beat LED that flashes four times during every loop through the sound loop — white at the beginning of loop and red the other three times. This is to help the user see how fast a tempo the device is using.

The front panel also features a built-in speaker which is mere 5 cm across but can produce surprisingly high volumes — even at the active party hall it was able to put out enough volume to be clearly audible at close quarters. I've tried some small commercial speaker devices intended to be attached to portable CD/MP3 players and found that they can't put out nearly enough volume in such situations, so I was somewhat surprised that this simple device could.

The hardware design

The  hearth of this device is Atmel ATmega88 microcontroller running at 16 MHz. Sporting 8 kB of flash memory and 8 kB of RAM, this microcontroller is the little brother of ATmega328 that is used in the popular Arduino prototyping board.

Early version of the hardware

With the built-in analog-to-digital converter in ATmega88 it is simple to read the positions of the three 10 kΩ linear potentiometers used for pitch, arpeggio and tempo. The potentiometers are connected across device ground and regulated 5 V lines, so turning a potentiometer changes the voltage at its middle pin linearly between these two voltages. This voltage is read with the ADC in the microcontroller and used to control the sound generation.

The microcontroller outputs the sound using Pulse-width modulation and uses a simple resistor-capacitor low-pass filter so that only frequencies below the Nyquist frequency of the output are passed to amplifier and eventually to speaker. Or at least this was the idea — I don't know quite exactly the frequency response of the filter I built, especially as I ended up swapping some of the capacitors to different value than the one originally planned, since I didn't have any with correct value and could not be bothered to visit the electronics store to get a couple capacitors. Anyhow, it sounds good and looking at the output with an oscilloscope doesn't show modulation frequency passed through, so I guess it's fine.

After the low-pass filter is the volume control: a 10 kΩ logarithmic potentiometer. After it there's a LM386 amplifier chip that drives the speaker or the device connected to the line out jack. One notable thing is that this amplifier chip is not connected to the regulated 5 V line that is being used to drive the ATmega88, but to the unregulated voltage straight from the batteries. This is done to maximize the voltage available to the amplifier chip — which means more volume — and to ease the load on the regulator, which is simple 7805 linear regulator that can generate considerable amounts of heat if heavily loaded or if the difference between its input and output voltages is large.

Speaking of batteries and voltage regulation, the power source for this device is six AA size NiMH cells. With nominal voltage of 1.2 V each, the total voltage is 7.2 V — high enough so that the 7805 can produce stable 5 V supply and well inside the operating voltage range for LM386.

The software

The software for the soundbox is written in C using the AVR libc library.

The sounds to be played are stored in two 128 bytes long arrays, one for each voice. Each byte in these arrays corresponds to one sound to be played, the value defining the pitch of the sound.

At the hearth of the sound generation is a numerically controlled oscillator (NCO). The oscillator for sine voice uses 256 samples long phase-to-amplitude converter array that is filled with sine values at device boot up. The noise channel uses similar table filled with random values with Gaussian distribution, creating a table that contains white noise. The oscillator for noise channel advances in its table 4096 times slower than sine oscillator of same frequency. This value has been chosen experimentally so that sine and noise with same pitch setting would sound like having somewhat similar pitch.

The sound generation itself is done inside the overflow interrupt of an pulse width modulation timer that's built-in in ATmega88. Each time the timer overflows — every 256 processor ticks in my configuration — a new sound amplitude is computed from the two NCOs and written in pulse width control register.

Reading inputs and setting the frequencies of the two NCOs is done in the main program loop. Each loop of the main program moves one step forward in sound arrays, reads inputs, writes new sound values to sound arrays if needed and sets the frequency controls of NCOs according to the values in sound arrays. After this it runs NOP command in a loop a suitable number of times to wait until new sound is to be played.

That's it for this time. I'm thinking of posting something about how I made the enclosure, especially the labels on the panel and buttons. Maybe some recording of the sounds I get from the device, too.