Sunday, November 30, 2014

Maker Faire 2014: さらし首 (sarashi kubi)

Apart from the stroboscope, I brought a scary robot arm to the Tokyo Maker Faire. This project actually started a few months ago during a Shinamonolab meetup.

During the meetup, participants had to sketch up an idea for the Maker Faire. I thought of building an arm robot that would scare children and take a photo of them. Three other guys were also interested in building a robot so we got together as a team called roboband (ロボバンド).

My first step was building up the robotic arm. Since Tokyo HackerSpace recently acquired a laser cutter, I decided to use it for cutting the open hardware meArm v0.4 robot. Unfortunately, my first attempt ended in failure because I was using a 6mm thick MDF wood sheet which was not appropriate.

After reviewing the CAD model more carefully, I decided to buy 3mm acrylic sheet and cut it again. This time I managed to assemble the robot correctly (I still had many problems with the accuracy of the laser printer software). The servo motors (standard 9G) are very cheap if you buy them in

Next, I created a 3D model of my scary robot using Blender. I tried not to make it too complicated because my intention was to later convert it into papercraft.

The 3D model was converted into 2D papercraft using a software called pepakura. Cutting and putting all those parts together can take you almost one day.

Then, I applied some Epoxy resin (GM-6600) to make it harder and more robust. I used an organic vapor respirator with appropriate filters, safety googles and nitrile gloves while handling the resin in my balcony. It is not as dangerous as polyester resin but I don't think it's good for health either.

Regarding to the software I used the Arduino servo library to control the servo motors and light up the LEDs in his face whenever a character was sent from Raspi through the serial port. The Raspi itself was used to detect the presence of a face, through a cheap webcam and the simpleCV library, emit a scary sound through the pygame library and communicate with Arduino through the serial library.

The robot was quite popular among children which made me very happy. However, some children were a bit cruel against my little robot haha. In fact, when I got back home I noticed that the SD card on my raspi was broken, meaning that I lost all the photos of scary faces I took during the event. Next time I should add a case.

Maker Faire 2014: Stroboscope

Last month I organized a small workshop in Tokyo HackerSpace about reusing the motors inside an old DVD drive.

In that workshop, I explained how to control DC motors, spindle motors, stepper motors as well as other devices using an Arduino board. However, we didn't have time to actually prepare some cool project with them. I got inspired by the stroboscope at elabz, so I decided to make my own. It took my about 1 day and a halft to complete it, this is the result:

Let's take a look at the components:

  • Transparent acrylic base: based on the meArm v0.4 design, and I used a laser cutter for cutting it.
  • LED lamp: I got it from a 100yen shop and cut off the USB connector.
  • Spindle motor: I salvaged it from a DVD drive.
  • Electronics:

Then, I printed the animation frames provided by elabz and cut a black thick paper following it.

My stroboscope worked almost without problems (apart from having to change the batteries) for two days, and attracted the attention of many visitors. That was very rewarding.

Tokyo Maker Faire 2014

During Nov 23-24th I attended the Tokyo Maker Faire 2014 which was held in Tokyo Big Sight. This is a personal memo of things that caught my attention:
  • Soracam: a drone that chases you wherever you go with a GoPro Hero3+ Black camera.

  • A shamisen instrument played by servo motors. The music notation for shamisen was based on Kanji characters!.
  • Small pen plotter CNCs (youtube channel) by Ishikawa Kyousuke:
    • Frame: universal boards (normally used for soldering circuits)
    • Motors: normal DC motors with a variable resistor for feedback (normally you would use steppers), and a servo motor for the head. The DC motors are connected to a gear box that you can buy in a robot store near Ishikawa neji in Akihabara.
  • PCB pick and place: this is a typical CNC but with a small air pump (not a vacuum pump because it would be difficult to release the parts).
  • YM2413 shield: an arduino shield for generating midi sounds
  • Elevators to the space: I was told that about 23 teams were building prototypes of elevators (クライマー) to the space. They put together some money (I think 100,000yen/person or so) and bought a balloon which was released near Fuji-san up to 1200m (they said that if it was until the space it would take around 1 week to arrive). The balloon is connected to the ground through a carbon-nanotube cable (テザー). Their next goal is to reach 2400m.
  • Incredible marble machines made of wood, brass wire and a bit of magic.
  • 3G shields for arduino (a bit expensive)
  • Hover gesture detector for arduino
  • Aquamodelers (see also here): a group of fans of submarine drones.  They rent a pool together every month to try out their submarines. The guy made this start trek-like submarine using different techniques.
    • He started designing it in a 3D modelling program.
    • Then, he converted the model into 2D papercraft (I guess using pepakura)
    • Then he used sheets of ABS plastic to build the main body (small windows and objects are also done by cutting the sheets and gluing them on the top)
    • Parts with curves where done by sculpting foamed styrol (発砲スチロール), creating a mold of plaster (石膏型) and using Polyester resine and Fiberglass (FRP).
    • A LED lamp connected to multiple optical fibers for giving the effect of millions of small lights.
    • The submarine has a RC receiver (controlled from outside the pool) and uses water pumps to pilot the submarine. He used a Siphon pump (石油 ポンプ) and changed its motor.
  • Hydroforming: a guy explained me how he created his version of a famous star wars robot using aluminum. I learned of a nice technique, called hydroforming, for creating rounded shapes on metals such as aluminum.
  • 2525 power generation: they created a rotating table using wood and a flowerpot. Then they attached 4 bicycle 3W dynamos and then rectify them using 4 schottky diodes. The output (0~2.5V) was connected to two 50F capacitors and 2 DC-DC converters that output 5V to a controller that manages a camera and 5 LEDs.
  • 3DVR: a nice set of stereo googles made of 100yen shop components: for each eye you glue together 3 magnifying glasses, and then put the result inside some protection googles to keep them together. Then you install an application in your phone such as DiveCityCoaster or Taovisor, and you can see stuff in 3D.
  • Podea: this is a small factor laser cutter. What I learned was that you can convert any black and white picture into a dotted picture using GIMP (convert image to 2bit black and white using the Floyd-Steinberg algorithm). Then you can easily use your laser cutter to print in grayscale (search 点画 in Japanese).
  • i.materialise: an on-line 3D printing company in Japan. They told me that printing in PA (polyamid) was cheaper than other companies. They many other materials as well including ceramic, silver, gold.. Other on-line companies I know are shapeways, rinkak, DMM.
  • 3D printing contest: the entry deadline is Jan 19th, 2015.
  • Makeblock: an open source robot construction platform.
Other summaries:

Sunday, May 11, 2014

Mt. Nokogiri (鋸山), Nihon-ji (日本寺) and its huge buddha (大仏)

I made a trip to the mountain Nokogiri (鋸山) in Chiba prefecture. This mountain is renown for having the biggest statue of buddha (2nd and 3rd would be those in Nara and Kamakura) of all Japan. This statue belongs to Nihonji (lit. 'Japan temple') which is now under restoration (May 2014). Not only that, it is also a nice and easy hill to hike with all kinds of sculptures on the way to the submit. No special skills or equipment are required since the path is paved.

There are several ways you can get to Mt. Nokogiri. The map above describes the one I would suggest if you live not very far from Kawasaki. On the East exit of Kawasaki JR station there is a bus terminal. Go to the platform 22 and wait for the bus that goes to Kisarazu (timetable). The price of the bus is about 1440 yen one-way. Once you get to Kisarazu, take the JR Uchibō train line towards Hota station (Kanjis on the map). The price for the train is about 670 yen. Therefore, in total the transportation fees would rise up to the amount of 4220 yen.

Note: you can also get off one station before Hota station, at Hama-kanaya (浜金谷) station, if you prefer to take the cable car which brings you right near the top. If you live near Kurihama (久里浜), there is a ferry that goes from Kurihama to Kanaya (timetable) and costs about 720 yen one-way.

From Hota station, you turn right (towards the bank) and then walk for about 80m. Turn right again and pass under the train rails. You should start seeing some signs with the kanji 遊歩道. Follow those signs, they will take you to the entrance which is about 1.5Km away from Hota station.

The 1.5Km span from Hota station to the entrance to the mountain (see picture below) was perhaps the most enjoyable part of the whole trip. Since most tourists opt for the cable car approach, that path was mostly free from people. Perfect for portraying the beautiful scenes of the japanese countryside. Since I went in Spring flowers were specially beautiful.

At the entrance to the mountain, you must pay an entrance fee of about 600 yen (400 yen for children). In exchange, you receive a map of the mountain in English or Japanese (maps in Japanese, map in English).

The first thing I noticed when I entered the mountain was the songbirds. In particular, the penetrating sound produced by some Woodpecker birds (キツツキ) which were hammering the cortex of tree where they lied catched my attention (listen). Perhaps they were happy for having enough earthworms to eat.

Just a few minutes of steps and you'll find the famous buddha statue (daibutsu). Let's be honest, after having seen several of them I lost the ability to get surprised. However, I was really surprised when I found something that I had overview while looking up the information for the trip: the 100 shaku kannon. This is a relief sculpture carved in quarry stone and hidden near the top of the mountain. This one really made my day, and reminded me of those famous relief sculptures and monuments in Petra.

This post wouldn't be complete without pictures from the observation deck on top of Nokogiri. The first one shows the cost of the Bōsō peninsula, and the second one is Tokyo bay. On a clear day (usually in Winter) I read that Mt. Fuji can be seen from there.

Sunday, March 2, 2014

Manually parsing a wave file in Java

In Java it is possible to get data directly from an audio device, audio file or URL (see examples here and here) through a standard package. In this article, we will manually parse a wave audio file to learn about its format which is rather simple: a part that states the format of the samples (e.g.: stereo 16bit 44100Hz) and a part with the samples themselves.

00 "RIFF"
04 File size in bytes - 8
08 "WAVE"

[Format chunk]
12 "fmt " (format chunk mark)
16  Format chunk size - 8 (16 for PCM)
20  Format tag (1 for PCM)
22  Number of Channels (e.g.: 2)
24  SamplesPerSec (e.g.: 8000Hz)
28  AvgBytesPerSec = (Sample Rate * BytesPerFrame).
32  BlockAlign = BytesPerFrame = (BitsPerSample * Channels)/8 
34  BitsPerSample (e.g.: 8)

[Data chunk]
36 "data"
40 Data chunk size - 8
44 Frame_0: sample_channel0[0], sample_channel1[0], ..
   Frame_1: sample_channel0[1], sample_channel1[1], ..
   Frame_n: sample_channel0[n], sample_channel1[n], ..

If you don't believe me you can check it by yourself:

$ arecord -f U8 -c 1 -r 8000 -d 5 pepe.wav
Recording WAVE 'pepe.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
$ ls -l pepe.wav 
-rw-r--r-- 1 xxx xxx 40044 Mar  2 20:14 pepe.wav
$ od -A d -N 44 -w4 -v -t a pepe.wav 
0000000   R   I   F   F
0000008   W   A   V   E
0000012   f   m   t  sp
0000036   d   a   t   a
$ od -A d -N 44 -w4 -v -t u2 pepe.wav 
0000000 18770 17990   RIFF
0000004 40036     0   file size (40044) - 8)
0000008 16727 17750   WAVE
0000012 28006  8308   fmt
0000016    16     0   16 bytes of format data
0000020     1     1   1 channel
0000024  8000     0   8000 samples/sec
0000028  8000     0   8000 bytes/sec
0000032     1     8   8 bits/sample (1 byte/frame)
0000036 24932 24948   ata
0000040 40000     0   4000 samples

Now here is the point. Suppose that we just want to play with a wave file in a specific format. Then, we can skip the first 44 format bytes and go straight to the data. In particular, if the format of the wave file is "mono 8bit" things get as simple as this:

$ vi
public class pepe {
  public static void main(String[] args) {
    int bytes, cursor, unsigned;
    try {
      FileInputStream s = new FileInputStream("./pepe.wav");
      BufferedInputStream b = new BufferedInputStream(s);
      byte[] data = new byte[128];
      cursor = 0;
      while ((bytes = > 0) {
        // do something
        for(int i=0; i<bytes; i++) {
                unsigned = data[i] & 0xFF; // Java..
                System.out.println(cursor + " " + unsigned);
    } catch(Exception e) {
$ javac
$ java pepe > data.txt
$ gnuplot
gnuplot> set size ratio 0.3
gnuplot> plot "data.txt" with lines

Hope that's useful for you.

Ubuntu Spanish accents | Tildes en Ubuntu.

This is a method for writing Spanish accents on Ubuntu when you don't have a Spanish keyboard. I tested it on Ubuntu 12.0.4 LTS (classic desktop). I am using a Japanese keyboard with an English environment.

System tools -> System settings -> Keyboard layouts -> Layout ->
Options -> Compose key option -> Right Alt

Note: if you can't find "System tools" menu, execute the command 'gnome-control-center'

Then you can write Spanish accents as follows:

RightAlt-a + ' = á

RightAlt-e + ' = é
RightAlt-i + ' = í
RightAlt-o + ' = ó
RightAlt-u + ' = ú
RightAlt-n + - = ñ
RightAlt-? + ? = ¿

Note: RigthAlt is the Alt key on the right side of the keyboard.