Tuesday, November 3, 2015

Tokyo Open Source Conference 2015 (Autumn)

A few weeks ago I went to Tokyo's Open Source Conference and tried to learn as much as I could. As always, it took place at Meisai (明星大学) University. You can find here some of the presentation slides and videos. Explaining everything would be too much of a burden so I will just write down a list of things I learned about:

ESP8266, Cloudstack (docker demo), GUST, fluentd, kinesis, storm, Diameter, OpenStack, Snappy, hacking Linux devices, Hatohol, GrowthForecast, mongodb, zabbix, hinemos, Symfony2, Snap, Optaplanner, Spark, Kuromoji, mecab, Kafka, hadoop, yarn, dronekit.io, moebuntu, Timeglider, Ubuntu JUJU, LTSP, TWRP, kibana, elasticsearch, PostGIS, OpenLayers.js, MapServer, TinyOWS, QGIS, Wikipedia word analyzer, aozorahack, plamo.

I also gave a short presentation during the lightning talks time about how to access your home's computer through a browser using the software shellinabox.

Tuesday, September 22, 2015

Hiking near Tokyo: Mt. Jinba

Since I moved to the Kantou region (Tokyo and surrounding prefectures), I have only hiked Mt. Nokogiri and Mt. Takao. This post reports on my third hike around Kantou: Mt. Jinba (陣馬山).

First, take a train to Fujino station (藤野駅). From Fujino station, get on the bus no.8, and get off at the last stop (和田, Wada). You are 355m high now. The bus ride is 247yen (as of Sept/2015) and takes 14min. You can pay either with an IC card (e.g. suica or pasmo) or in cash. You can check the timetable on google maps by specifying 神奈川県陣馬自然公園センター (Kanagawaken Jinba Shizen Kouen sentaa) as your destination. My bus departed at 9:50 and the next one was leaving at 13:10. Make sure that you check the departure times in advance.

Walk on the same direction as the bus. After 3-4 minutes you will find the entrance to Mt. Jinba on your right. Then, walk up until the top of Mt. Jinba (855m) which will take you about an hour and a half. At the top of the mountain there is this phallic sculpture of a horse. Notice that the name of the mountain is composed of two Kanjis: 陣 (Camp) and 馬 (horse). If you are lucky, Mt. Fuji will be visible from the top. But don't count on it during Summer or Autumn. From the top, I could also listen to quite a few amateur radio stations.

Walk down the mountain using a different trail (栃谷尾根, Tochiya One). There are several trails and it's a bit confusing. Make sure you follow the one indicated by the sign in the picture above.

Whereas the walk-up is mostly inside the forest where you can't see much, the walk-down has much better views. After approximately 50 minutes of walking, you will see a sign with the letters 陣馬の湯 (Jinba-no-yu) or 陣渓園 (jinkeien) written on it. You can have a hot bath and some tea there for 1000 yen (Sept/2015).

After a refreshing stop, continue walking down. For some reason, I found many dead snakes on the road. Fortunately, I also saw many insects alive. After 30 minutes, get on bus no. 8 back to Fujino station (陣馬登山口バス停) or just walk your way to Fujino station. It's not that far.

Conclusions: this is a nice super-easy hike perfect for a 1-day trip from Tokyo and surroundings. With only 580m of ascend and 740m of descend, you can complete this course in less than 3 hours. Most importantly, it's not crowded like Mt. Takao.

Sunday, September 13, 2015

First experiences with Software Defined Radio (SDR)

Software defined radio (SDR) consists of implementing most of the components in a radio transmitter or receiver (filters, modulators, mixers and the like) using software. The only parts that remain analogue (the RF front end) are a high frequency low-noise amplifier connected to the antenna, switchable band-pass filters, and a variable-frequency oscillator that moves the received signal down in frequency for it to be sampled with a high-speed analogue-to-digital (A/D) converter. I would say that the advance of A/D converters, with increasing conversion speeds, is the key enabler for this technology.

For beginners, I suggest to buy a DVB-T dongle based on the Realtek RTL2832U chip. These dongles, originally made for watching TV on your computer, are very cheap (I got mine for 1000 yen) and well-supported by the rtl-sdr project. If you have the money you can try other boards specifically made for SDR such as osmoSDR, FUNcube, USRP, bladeRF, HackRF or VNWA3 (as my friend Paco suggests) for example. As I explain in my SDR notes, you can test your DVB-T dongle on Linux using the following command (82.5MHz is the NHK radio frequency in Tokyo):

$ rtl_fm -f 82.5e6 -M wbfm -s 200000 -r 48000 - | aplay -r 48k -f S16_LE

Other radio frequencies I could listen from my home were:
  • NHK: 82.5MHz (Tokyo)
  • Tokyo FM: 80.0MHz (Tokyo)
  • FM yokohama: 84.7MHz (Yokohama)
  • Inter FM: 76.1MHz/89.7MHz (Tokyo) / 76.5MHz (Yokohama)
  • 放送大学: 77.1MHz (Tokyo)
  • J-WAVE: 81.3MHz (Tokyo)
  • Bay FM: 78.0 (Chiba)
  • Nack 5: 79.5 (Saitama)
  • Radio city: 84.0 MHz (Tokyo)
  • FM844: 84.4MHz (Tokyo)

Apart from being able to listen to a wide range of frequency bands, the fun part of SDR is that since the signal is all handled by software you can do whatever you want with it. For example, one of the most expensive equipment for an amateur radio fan is a spectrum analyzer. Thanks to SDR and an awesome software called 'gqrx' (powered by the amazing GNUradio project) you can turn your cheap DVB-T dongle into a spectrum analyzer.

Watching the spectrum was useful for understanding why my FM microphone wasn't behaving as expected. In fact, I found out that the center frequency of my FM transmitter was moving around quite a bit and that was the reason it was rather hard to tune.

An not only that, you can also easily create your own receiver designs by using a software called 'gnuradio-companion' that already has a lot of blocks ready for you to use. I shared my gnuradio-companion designs on my github account.

Conclusions: SDR is really fun and will give you insights on how signals are sent, received and processed. I wish I had had the chance to use SDR when I studied electrical engineering (telecommunications) at University. Make sure you check my notes and gnuradio-companion designs on github.

Ham Fair 2015 (Tokyo)

Last August I attended Tokyo's ham fair 2015.

Actually it was my second time attending this event, and I was very excited because this time I had my own amateur operator license (see my previous post here). The picture shows my call sign (JI1OJQ) painted with ketchup onto an omurice at a maid bar in Akihabara.

This year was also special because a friend of mine had his own booth. My friend sells retro stuff (vacuum valves and the like) at Ikenoya radio in Akihabara's electronic town. Apart from that, I found an interesting radio amateur group of people called yama-to-musen (mountains and radio). Climbing two separate mountains and trying to communicate from the top sounds like fun.

FM microphone kit from Aitendo

In one of my random visits to Aitendo I got the AKIT-334 FM microphone kit on sale (200 yen).

Unfortunately, once I compared the kit's circuit diagram with the components I actually got, I finally understood why the kit was selling so cheaply. In particular, I got a 20pF capacitor that should have been a 10pF; and 2 resistors with the wrong values that I replaced from my own stock. Also, thanks to this site I figured out that I had to cut the track that was shorting 2 of the C3 trimmer capacitor's leads. As if that wasn't enough, I also had to modify the LC resonant tank so that the transmitter would align to the FM frequency range in Japan (76~90 MHz). In particular, I made a solder bridge between the pads where capacitor C2 was supposed to be, and then put C2 (in my case 20pF) in parallel with the C3 trimmer.

The board comes without a coil so I had to make one myself. For me that was the fun part of building this kit. First, I calculated the theoretical value for the coil on this LC resonance calculator. You can also do it by yourself on any calculator application (I use qalculate) using the following formula:

Resonant frequency (Hz) = 1/(2*pi*sqrt(L*C)).

I tried to cover a bit more range so for 76.2MHz (C==40) ~ 108MHz (C==20), I got that my coil's inductance (L) should be 109nH. Next, you need to figure out the physical properties of your 109nH coil. For that use the following formula:

L = perm * (N^2 * Pi * R^2) / length

The permeability of air (perm) is 1 so that is a fixed value unless you use a core. By trial and error I ended up with these values:

109nF = 1 * (7^2 * pi * 2.4e−3^2) / 8e−3

That means a coil made of 7 turns, 2.4mm radius (including the wire), and 8mm length. For the magnet wire, I bought 0.6mm diameter (⌀) polyurethane copper round wire from Akihabara's Ikenoya radio, located in the famous electronics mall radio center (Tokyo hacker space has a nice list of electronic shops in Akihabara here). When I made the coil however, theory and practice differed and I had to tune my coil a little bit using an LC200A LC meter that I ordered from Aliexpress at a very reasonable price (~4000 yen).

This is how the FM microphone kit looks like when assembled. Notice how I applied a bit of hot glue to components that seemed to have more mechanical stress (the power switch, the battery case and the antenna), and I used a short cable for the antenna.

Finally, I used this FM radio receiver that I assembled from a kit sold at Sengoku (Akihabara). Don't worry about interfering with commercial radio stations since this kit can radiate just enough power to listen to yourself from a few centimetres, or perhaps a bit more depending on your antenna and receiver quality.

Reflow soldering and Achandeino

A week ago I got a super cheap arduino kit from Akihabara's Aitendo: Achandeiino. The name is a Japanese joke meaning "I'm just fine with A-chan". The kit's circuit diagram is here. It comes with a few SMD components. And so, I thought it was about time to learn how to do reflow soldering.

After cleaning the pads where the SMD components were supposed to be mounted on, I applied a bit of flux to them. Then, I put a bit of leaded solder paste (XG-50) on each pad (I think I could have used a bit less solder paste) using a toothpick (you could also use a solder paste syringe with a tip in the range of 0.26~0.43 millimetres). During this step it's important that you follow safety procedures because lead can cause cancer. Keep your room ventilated (I used a fan near a big open window) and don't touch it with your fingers because you could end up eating it (be careful when you use the toothpick or use nitrile gloves). You can also buy lead-free paste but it requires higher temperatures to melt, and that could well be as hazardous. When you are done, place your SMD components onto the solder paste using tweezers. After using the solder paste, you should ideally conserve it at a low temperature, within 2~10 °C, or otherwise it will dry out in a few weeks. However, you need to get a small refrigerator for that (never use the one you use to store food because the solder paste can slowly release toxic fumes even at a low temperature).

The next step consists of reflowing the solder paste by heating it up according to what it's called a thermal profile. You can use many different tools for heating the solder paste: hot air, a modified toaster oven, or a hot plate for example. In my case, I used a Yamazen HG-1200 hot plate for several reasons: first it's cheap (~3000 yen in my case), second it has a glass lid very convenient for checking the state of the process, and what's more important it can heat over 230 Celsius degrees (essential for reflow soldering). Besides that, this Japanese fellow explains a few tricks on his website that he had to learn the hard way in order to use the Yamazen hot plate successfully for reflowing solder paste. The thermal profile I ended up using was:
  • Pre-heat at 160 °C for 10 minutes.
  • Place the PCB onto the hot plate.
  • Wait for a minute.
  • Change the temperature to 170 °C.
  • Check the temperature: when it reaches 170 °C, switch the hot plate off.
  • Wait 2 minutes (the hot plate's temperature keeps raising up to 180 °C for some reason).
  • Change the temperature to 210 °C.
  • Check the temperature: when it gets to 210 °C turn it off again.
  • Check the temperature: when it gets to 220 °C, wait for 40s (the hot plate will peak at about 230 °C).
  • Finally, open the glass lid and let it cool down. Once its cooled down you can clean it with isopropyl alcohol and cotton sticks (q-tips)
During the process, I kept an eye on the temperature of the hot plate through a cheap (2000~3000 yen in my case) but very well-made infrared thermometer from SainSonic. Also, since the leaded solder paste releases toxic fumes when heated, I did the whole thing on my balcony and only came close to the hot plate a few times, while holding my breath, to check the temperature.

After reflowing, I used a multi-meter to check for possible shorts. Fortunately, there weren't so I just continued soldering the rest of components by hand with my soldering iron (a hakko FX600). If you get shorts or "bridges" try fixing them with your soldering iron.

And this is the result. Next, you need to buy the ATMEGA328P-PU microcontroller either with or without bootloader, and a USB-Serial converter like this for loading your Arduino sketches.

Conclusions: reflow soldering is fun and easy once you have the appropriate tools. It is great for soldering little SMD components which are cheap and allow you to create high density boards.

Thursday, September 3, 2015

Disassembling a hair clipper

After several years of use, my electric hair clipper (a.k.a. trimmer) finally broke. For that reason, I decided to buy a new one. When I saw that the prices were actually quite cheap, I got interested about how manufacturers are cutting down on costs.

The body of my hair clipper consisted of just 2 pieces of plastic and a mechanical switch connected directly to the internal board. A detachable part (not shown in the picture) with two blades oscillates from side to side driven by the internal DC motor and a fancy spring. The electronics are as simple as it gets with just a classic AC->DC rectifier whose output is connected directly to a Mabuchi FK-290PY-051100 DC motor (100VDC, 6800RPM without load).

The motor has a cam attached that allows transforming rotary motion into linear motion for moving one of the two blades.

The board's circuit diagram is a classic that any electronics hobbyist should know. The input wave (mains electricity) is a SINE with 100V amplitude and a frequency of 50Hz (Tokyo). The 1MΩ resistor is used to increase the input impedance (ideally infinite). Then, a 100nF/125VAC ceramic capacitor is used to filter out noise from the mains signal. The result is rectified through a diode bridge (i.e.: a full-wave rectifier), and then smooth out with an electrolytic capacitor in parallel (a low pass filter). The output voltage is 98,88VDC instead of 100VDC because of the forward voltage (Vf≈0.56) of 2 diodes. In sum, here is the bill-of-materials (BOM):
  • Resistors: 1x1MΩ, 1x150Ω
  • Capacitors: 1x100nF (125VDC), 1x4.7μF (160VDC, electrolytic)
  • Diodes: 4x1N4004-TP (Vf=~0.56)
  • Motor: Mabuchi FK-290PY-051100 (~4 dollars)
  • Camshaft
  • Blades
  • Spring
  • Plastic body
  • Power cord
  • Others: size attachments, oil, brush..
  • PCB
Conclusions: making profit from selling an electric hair clipper at about 2000~4000 yen looks quite challenging to me, unless you sell enough of them so that you can average out the cost of the initial mold for the plastic body and attachments. There are lots of brands competing in the market with completely different plastic bodies. I wonder if all of them are selling enough to compensate those initial costs.

Saturday, August 15, 2015

My first Blitz3D mini games

My first experience with programming games (actually, my first programming experience at all) was with DIV Games Studio, an awesome framework for making video games created by a Spanish company called Hammer technologies. At that time I also started learning about digital 3D modeling thanks to awesome magazines such as Jumping. I had the idea of making a 3D game, but unfortunately DIV Games Studio was designed mostly for 2D games. After some searching I found Blitz3D, a simple environment for game creation that supported 3D objects and seemed easy to program. With the help of a friendly IRC community, I managed to build my first demo games in no time.

Since Blitz3D recently went open source and can be downloaded from their site for free (instructions), I decided to recover those old games and put them on my github. Apart from a little game in Javascript, I haven't made any games since then. Lately, I've been experimenting with the popular Cocos2D platform and I hope I can get some time for Unity as well.

Thursday, August 13, 2015

My first marble machine

Marble machines are one of the best ways I know of for experimenting with mechanisms such as levers, pulleys, inclined planes, gears, or cams. The one in the following video is the first one I've built:

But let's start from the beginning. During last year's Maker faire I got surprised by the skills of Denha sensei at building his own complex marble machines.

After the Maker Faire, I spent hours admiring his creations and how he checks every detail in a methodical way. I came to the conclusion that a marble machine is usually made of some of the following components:

For my first marble machine I tried to make it simple. For that reason, I only used two common artifacts: a wheel elevator and an inclined plane. For finding the centre of the wheel, I used simple geometry. However, I had to drill a big hole for the bearing to fit in. That affected the accuracy of the centre. For that reason, I had to use a small spring that would automatically adjust the distance between the wheel and the motor's shaft (probably it would have been easier if I had used brass wire for the wheel's axis instead of a bearing). The inclined plane was made using a chisel. This is the list of materials I used:
  • Geared motor: MOT114A1B 6V 60RPM 12GA (Sengoku 1280yen)
  • Gear for the shaft of the motor (Sengoku) and a rubber cover (Ishikawa-neji)
  • Balls 7mm diameter (Tokyu hands)
  • A small spring (from a pen)
  • Brass wire 1mm diameter (Radio depaato in Akiba)
  • Wood (a home center and Daiso)
  • On/Off push switch (from an junk board)
  • 2*AA batteries with a case (Daiso and Akizuki denshi)
  • Aluminium plate (Yokyu hands)
  • Bearing (from an broken stepper motor)
This is a list of tools I used:
  • A precision hand drill
  • A precision wood saw
  • Dremel 4000 with various bits
  • Tweezers
  • Cable cutter
  • Long/round nose pliers
  • Tape
  • A universal vise
  • Chisels
  • Sand paper
Conclusions: I failed many times, but I also learned a lot during the process of building my own marble machine. Indeed it was harder than what I had expected. I will try to build upon these lessons learned, and make a better marble machine next time. You can check my notes for more details.

Sunday, July 26, 2015

Kanazawa: nicotech and tourism

I had wanted to visit Kanazawa city for more than 8 years, since my Japanese teacher in Spain (Hattori-sensei) made a reference to it during a class. After the Shinkansen to Kanazawa was finished a couple of months ago I had no choice but to visit it.

What a better excuse than the celebration of the Nicotech event in Kanazawa, which gathers DIY hackers/makers to show their new crazy inventions such as a dice that always comes up 6; or a relay-controlled melodica presented by nezumi-san. Other inventors: natok (@natok), and @mayusaki3 (check the twitter hash #NT金沢).

If anything, Kanazawa is famous for its splendorous Kenrokuen (兼六園) garden, developed by the Maeda clan and one of the 3 great gardens in Japan. If you were only going to spend a few hours in Kanazawa, the Kenrokuen garden would be the thing to see. When you are there, try to find a sign with a haiku written by Bashō that says: あかあかと日は難面もあきの風 (akaaka to hi wa tsurenaku mo aki no kaze). As many other haikus, this one also talks about the change between seasons, in particular from Summer to Autumn. My personal translation would be something like: "The sun shines red, ignoring the Autumn winds". Here are a few other translations. A decomposition of this haiku can be found here (in Japanese).

Other attractions in the city are its tea houses (Chaya). There are two famous tea house districts: Higashi (east) and Nishi (west) Chaya. However, I'd suggest you to check this non-touristic tea house called Shōkōan (旧園邸・松向庵). See the access map and pictures from inside.

Kanazawa also has a famous fish market called Ōmichō, where you can buy different types of fish and seafood. There are also a few restaurants if you want to try sushi, crab, kaisen-don (a bowl of rice with different slices of raw fish) or any other delicatessen. Here is a nice guide to the food of Kanazawa in pdf. I would also recommend the restaurant "arroz" (rice in Spanish) where you can eat a delicious "cocido" as the one in the picture above.

Kanazawa has also a Samurai district called Nagamachi (長町) though it's not as big as the other tourist attractions.

What I liked the most about Kanazawa was its relaxed atmosphere; the river that crosses the city which was very close to the place I stayed in; and the fact that you can rent a bicycle to go around the city.

Sunday, June 28, 2015

Getting an amateur radio operator license in Japan (4th level)

About one year ago, I went to see the Japan Ham fair in Tokyo. Despite having studied about radio communications at University, the amateur radio (ham) world was still unknown to me.

Near the entrance there was a stage with talks about the ham world. Many of them were introductory so I listened to a few. I wanted to learn what's so fun about amateur radio that you can't do with the Internet. These are a few ways to enjoy amateur radio that I learned of at the ham fair:
  • Talking to your neighbours: a good way to make new friends.
  • Hiking a mountain and trying to get far-away signals from the top.
  • Talking to people from all around the world: I was pointed out by someone that amateur radio operators are usually well-educated people and allow for good conversation.
  • Enjoying it from a technical point of view: improve your equipment with better antennas or transceivers.

The ham fair wasn't just about introductory talks though. There were many booths organized by amateur radio fans and radio equipment sellers. In a way, it reminded me of a Makerfaire exhibition. In fact, this fair can be very convenient if you need to buy oscilloscopes, function generators or frequency counters at a low price tag.

With all the excitement, I decided that this was cool and elitist (kidding!), and that it might be worth giving it a try. I bought a book for the 4-th level (easiest) of the Japanese amateur radio operator license test, which is all you need to get started. On the spur of the moment I also bought an entry-level walkie talkie valid for the 144MHz and 430MHz bands (see other frequency bands here).

I took the test the Japanese way. That means I had to learn many Japanese technical words. In retrospective, I'm glad I went the hard way because now it's easier for me to talk about amateur radio with other Japanese fans. Note however that you can also take the exam in another country and have it validated by JARL (Japanese Amateur Radio). The test is held in several Japanese cities. If you live near Tokyo, then you are lucky because you can just show up on the test day without previous registration. Check the dates here. You just need to go to 日本無線協会 (map link) bringing with you a copy of your 住民票 (get it at your ward office), 2 photos, a pencil and the money for the exam (~5070 yen) and the operator license (~2270 yen). The test is divided in two parts: engineering and law. As I went through the book I tried to summarize most of the knowledge required in the two diagrams above. I have also prepared a cleaned-up text version here in English for you. I hope it's useful to someone. After passing the exam, on the same day, I applied for the operator license. A couple of weeks later, I got my license card by post and next I applied for the radio station license (you need two licenses: operator and station). Ok, I guess that's all for this post. Hope to see you at Japan ham fair 2015!!

Friday, June 26, 2015

Makerfaire Shenzhen 2015

Last weekend I visited Shenzhen to attend the Makerfaire. I used a low-cost airlines called Vanilla Air (20,000 yen for a return flight from Narita airport) to get to Hong Kong airport. From there I took a shared limousine car to my hotel (220 Hong Kong dollars). There are cheaper ways to go. However, this was the best choice as I would later realize that it would have been a nightmare to find my hotel otherwise.

This were the views from my hotel room (Shenzhen She & He Apartment Shenlan). The hotel was actually an apartment in a tall building. Despite its low price, the apartment was rather clean and it had a fridge and a kitchen. It's location was perfect for going to the Makerfaire on foot.

Makerfaire's location was awesomely situated among several modern buildings, and was decorated with numerous posters and maker-related objects. However, it was mostly open air so I was wondering what would happen if it started to rain. Fortunately, Shenzhen is a very sunny city and apart from a light rain on the last day we had mostly good weather.

As usual, all booths were filled with creativity and new ideas. There were booths showing hobby projects as in many other Makerfaires I've attended. Surprisingly though, there were many more booths showing already finished products. I think that that was the main difference with other Makerfaires I've been too. As a manufacturing hub, I guess that living in Shenzhen makes it easier to develop your ideas all the way to the final product. There were also big commercial booths from companies such as Seeed studio (who announced Genuino in partnership with Arduino) and Mediatek.

Once I had seen all of the booths several times, I decided to go downtown and checkout Shenzhen's electronics town. I took the subway (Shekou line) and stopped at Huaqiang North (华强北) station. Then I tried to find buildings with the name SEG or 华强电子世界 (Huaqiang electronics world) on them. There were several ones actually. Typically, the first floor is dedicated to small booths selling electronic parts, and booths on higher floors sell consumer electronics and the like.

My impressions of Shenzhen as a city were very good. It was a clean and safe city with modern buildings and department stores. There were lots of new buildings in construction so I expect Shenzhen to become one of the biggest cities on Earth in a near future. I'm sure I will be back here.