Sunday, July 30, 2017

Debugging the FMP RTOS on QEMU

A few weeks ago I participated in the 7th edition of Tokyo's self-made OS meetup (自作OSもくもく会). This event was held at Cybozu offices in Nihonbashi which are quite colourful and have great views.


During the event there were lots of presentations that touched topics such as file systems, UEFI, kernel page handling, or memory allocation algorithms. I also gave a talk on how to debug the TOPPERS FMP real-time operating system on QEMU.

Monday, July 24, 2017

Adachi fireworks 2017

A few days ago, I went to see Adachi's fireworks (hanabi 花火 in Japanese), famous for being the first of the year in Tokyo (Adachi is a ward in the north of Tokyo).


The fireworks are launched from the south bank of the Arakawa river near Kita-Senju station. However, I suggest watching them from the north bank since it's less crowded and the views are fantastic as well. Go to Umejima station and follow the red path to get a nice viewing spot.


The place does get crowded but unless you are going with a big group of people, you shouldn't need to go early to secure a spot. We were 4 people and arriving at 19:00, just half and hour before the fireworks, would have been completely fine.


About 12,000 fireworks were launched in just an hour (19:30 to 20:30). Some of them were really impressive and looked huge. I took lots of pictures with my phone, some of them were blurry but some were ok.


Sometimes pieces of the fireworks would fly and reach our viewing spot. I suggest you bring some sunglasses to protect your eyes from the dust and objects coming down. It had been a while since I last went to a fireworks festival, and it was a great experience.

Monday, July 17, 2017

Blinking an LED with a simple PIC microcontroller

There are many different PIC microcontrollers. Some of them are powerful enough to be used with an arduino-like framework (pinguino) and others are much more constrained. For the former, I suggest using this PIC18F2553 I/SO evaluation board. For the latter, I suggest using a PIC12F675 I/P (or a reference kit). Despite being small and cheap, the PIC12F675 can be powerful enough for many simple applications. Let's take a look at its specs:
  • 10-bit A/D converter (4 channels)
  • 6 GPIO pins
  • Timers
  • Analog comparator
  • Memory (ROM: 1K words, RAM: 64B, EEPROM: 128B)
To compile code for the PIC12F675 you need to install the MPLAB-X IDE and the free edition of the MPLAB XC8 (PIC12F675 is an 8-bit microcontroller) compiler.


Then, prepare a circuit like the one in the picture on a breadboard. The PIC12F675 contains an internal oscillator so you don't need to supply one. Here we are just connecting the GP2 pin to an LED with a resistor. Additionally, we connect VPP to VDD through a 10kohm resistor and VDD to VSS (ground) with a 0.1uF for programming the chip with Pickit3.


Build the example source code provided by Paolo Rognoni with the MPLAB-X IDE. Connect the board to a 5V power supply and program it with a Pickit3.

Important: if you just bought the Pickit3 and get a "Connection failed" error and a RED status LED, the firmware in your Pickit3 may need an update. In that case, download the Pickit3 programmer application (I had to use v3.10) and open it with the Pickit3 unplugged. Plug it in and click Tools > Check communication. Hopefully it will be connected. Next, click on Tools > Download Pickit operating system, and choose 'hex' to write onto pickit3. Then, click on Tools > Revert to MPLAB Mode and exit the application (if it says no permissions for writing, change the folder permissions to writable). Finally, start MPLAB IPE program (already installed with MPLAB X), click "Connect" and it will update the firmware for you.

An oil painting after so many years

When I was a teenager, I used to attend an oil painting class not far from my home in Renedo. During that time, I copied a few famous oil paintings such as Gustave Caillebotte's Le pont de l’Europe. After more than 15 years, I decided to make a new oil painting. The problem was that I had forgotten almost everything. Or that's what I thought. In fact, as I started reading and during the painting process, I was able to recall most of the things I used to know. All that information was still there in my brain, just a little bit rusted!.


I began by coating a canvas board in dark green colours. Usually, a canvas made of linen is best, but this was kind of an experiment so I just used a canvas board from the 100 yen store Daiso. After the green layer dried, I drew the line work on top of it. This time I just copied a portrait that I found on a random website.


It took me some time to recall the names of the oil paint colours that I used to use. For the skin tones, I had to do some research and ended up using ultramarine blue, yellow cadmium, red cadmium and titanium white.


My first tries were really horrible. I had to let the painting dry and redraw everything again for a few times. Instead of applying paint all over, I should have put special emphasis on getting the shapes and values correct at first.


After some iterations, I was finally getting a bit closer to the portrait I was copying from. The woman looks different but here I wanted to focus on recalling the colouring process.


The end result was a small success compared to the initial tries. I learned a lot from my mistakes and it was also useful to know how far I am from being a good painter. I decided to leave the painting untouched, and I'll try to use all the learned lessons for the next one.

Shizuoka Hobby show 2017

In May, I attended the most important event in the world about plastic models: the Shizuoka hobby show. Shizuoka is the place where Tamiya was born, and is easy to reach by Shinkansen, although this time I used the cheaper Tokaido line.


The place was divided into two parts. One part was composed of commercial booths where companies were introducing their latest model kits. Doi-sensei held a nice workshop on figure painting using Turner Acrylic Gouache at the Model Art magazine booth. There was also a bookstore where I bought an awesome book titled 機械昆蟲制作のすべて (all about building machine insects).


The other part was composed of hundreds of tables where plastic model fans were exposing their dioramas and models. There were amazing pieces of art, and I learned a lot from them. There are many different genres in this hobby, and I kind of liked this kind of dioramas representing Japanese street scenes from the Shōwa era.


It was actually on the fans side where I met the author of 機械昆蟲制作のすべて who took the time to sign my book with this beautiful drawing. Thanks a lot!

Day trip to Karuizawa from Tokyo

Last May, I had some days off and I decided to visit Karuizawa. The only thing I knew about it was that John Lennon used to stay over with his family during the summer holidays. Karuizawa is very easy to reach from Tokyo. Using the Shinkansen, it only took me about 1h15 to get there.


Although the main roads were full of tourists and souvenir shops, there were also quiet neighborhoods composed of single houses with wide backyards that most probably only very rich people could afford. The presence of Christian churches, such as the Shaw Memorial Church above, was also notable.


I went past the Shaw Memorial Church and kept walking for a while until I ended up climbing a little mountain. The hike is really nice but make sure you bring some bells to avoid accidents with bears. I met very few people on my way up.



The views from the top are impressive and you can see the famous, and still, active volcano Mt. Asama which is near Karuizawa. By the way, Karuizawa is in Nagano prefecture but very close to the border with Gunma prefecture.



After the hike, I was a bit tired so I had some quality soba and a cup of tea nearby just before heading back to town on this colorful bus. Then, after some walking around the major road and buying some souvenirs I returned to Tokyo by Shinkansen. A really nice day trip.

Thursday, July 13, 2017

DIY mini drill press and router table all-in-one

I bought a Dremel 4000 rotary tool about 4 years ago. However, during all that time I had only used it a few times. One of the problems with the tool is that it's kind of hard to be precise when you use it free handed.


Then, I saw this awesome video on Youtube a few weeks ago and I thought: "I have to built my own!". The design is very well thought and contains some clever ideas. It is also simple and can be made with common tools and materials. I built mine at Kitewa, guided by the experience of its friendly owner Tim.


On one side, it is a drill press. A lever is used to push the Dremel down towards the piece of wood where you want to make a hole. Then, a extension spring connected to the back of the Dremel's board brings it back to its original position. The Dremel tool is hold in place by using two stainless-steel hose clamps. The main body parts are connected through 4mm screws and I used countersinks to make sure the surface was smooth. Another key tool for achieving nearly perfect right angles was the combination square.


On the other side, it is a router table. The Dremel's board has an insert nut on the right edge that allows us to lock its position with a knob. The groove where the knob slides down was made with the help of a plunge router. The design also includes a convenient fence to ensure that we sand or cut to the specified width.


Conclusions: the build took only two days, specially thanks to Tim. During the process I made multiple mistakes: the wood I used was a bit weak, specially for the base; the first extension spring that I bought didn't have enough strength to bring the Dremel back; and I made some holes in the wrong places. However it was overall a very satisfying learning experience for me.

Sunday, July 2, 2017

Writing an oscilloscope frontend with PyQT

In previous posts, I talked about two DIY oscilloscopes that I had built (not dessigned): one based on Arduino and another one based on a dsPIC controller.


Although building my own DIY oscilloscope was fun, I had always wanted to get a real one. A few months ago I decided to buy a used one on Yahoo auctions. In particular, it was an Iwatsu BRINGO DS8812 digital oscilloscope (DSO).


Although there were good oscilloscopes for lower prices, the DS8812 fitted all my requirements:
  • Cheap (10,000yen, about 78 euro).
  • Small size, because my workspace was getting full of devices.
  • Enough bandwidth, channels, sampling rate and memory length.
    • DC~100MHz, 2 Channels, 500MS/s, 100kword/channel
  • A remote control protocol (through RS-232C) that was documented.

The only problem that this oscilloscope had, and the reason for its low price, was that the right menu was hard to see. I tried disassembling the oscilloscope and touching different connections but I wasn't able to improve it. For that reason, I decided to create a GUI interface to control and visualize the oscilloscope remotely through the RS-232C interface.


In order to control the oscilloscope, a cross serial cable was required. In my case, I already had a straight serial cable so I only had to buy a null-modem converter which worked great.

 $ picocom -c --omap crlf -b 115200 -f h /dev/ttyUSB0
    --omap crcrlf: outputs CR/LF instead CR (set osc to CR/LF delimiter)
    -h: enables RTS/CTS
    -c: local echo 

The most tricky part was passing the appropriate parameters to the serial terminal. Picocom is my favourite serial terminal, and these are the parameters I used.


With that in place, I finally managed to get a response from the oscilloscope using the command "DATE?" (commands that end with a question mark represent requests to the oscilloscope).


I programmed the frontend using PyQT (Python bindings for the QT GUI library). I found the QT designer to be particularly easy to use and robust. The source code is on my github account and it uses pyserial for communicating with the oscilloscope, and matplot for displaying waveforms.


Here is a snapshot of two square waveforms on each channel. The app is not very sophisticated but it does its job and can be easily extended in case I need more functionality.


For example, here I implemented an FFT view of the acquire waveforms. This was a paid functionality on the original oscilloscope.

Conclusions: I'm glad that I got a oscilloscope that I could controll remotely. Now I can easily store waveform data, analyze it or save it as an image file. I really enjoyed working with PyQT and the QT designer. They are very powerful and easy to use. Last but not least, I summarized my "endeavour" in a few slides and presented this project at OSunC in Kawagoe.

Sunday, May 21, 2017

Tokyo National Museum

I've been living near Tokyo for a while now, but for some reason I had never visited the Tokyo National Museum in Ueno. But I'm glad that I did it a couple of weeks ago.


The museum contains a great collection of historical objects including katanas (Japanese swords), ceramics, and paintings (I love the ukiyo-e collection, specially those paintings where yamauba and Kintarō appear). The entrance fee is quite reasonable if you skip the temporary exhibition.

Futsal in Kanagawa

One of my passions since I was young is playing futsal. What I like the most about futsal is all the "speed thinking" involved. Some people associate futsal with physical strength, but in my opinion thinking speed and accuracy when passing the ball are the essence of this game.


In Japan, futsal is often played outdoors and on artificial grass. There are many futsal stadiums that allow individual participation (個人参加) where you just go, pay for the time and join other futsal enthusiasts. I usually play once or twice a month. Recently I played with some good old friends that I used to play with when I was in Nagoya University. It was nice to meet them. My favourite place to play futsal in Kanagawa is Futsal Point in Suzuki-chou (a 20 min walk from Kawasaki station).

Reading picture books for children

During the last year, I have been invited several times to participate in a group of volunteers that read picture books for children in different languages. This kind of groups, called dantai in Japanese (団体), are very common in Japan. If you want to participate in one you just need to ask at your closest cultural/community centre (search for 文化センター,市民センター,コミュニティセンター, or 区民センター).


One of the books that we read very often is "The very hungry caterpillar". The title is translated as "La oruga muy hambrienta" in Spanish and "Harapeko aomushi" in Japanese. We also read other books including my own.


A month ago I went to see an exhibition of the author of "The very hungry caterpillar", Eric Carle, at the Setagaya art museum. Eric Carle's paintings were really interesting from the technical side as well. Many of them were a collage of pieces of semi-transparent textured paper painted with acrylic colours.

Saturday, May 20, 2017

OSC 2017 Spring

The Japanese Open Source Conference, usually known by its initials OSC in Japan, is a great event for open source enthusiasts. It is celebrated in different japanese cities and regions throughout the year such as Tokyo, Hamanako, Osaka, Hiroshima, Fukuoka, Kyoto, Nagoya, and many more. Here is their official OSC Twitter account.


Although I have attended the conference many times I had only reported once in 2013. This time I attended Tokyo OSC 2017 Spring which was held at Meisei University, a private University that has great rooms with multiple screens.



During the conference I made a short introduction to Fuego, an open source test framework that I'm contributing to recently. You can find the slides here. This wasn't my first presentation in OSC but it was the first one I did as part of my job. You can also find the videos and slides of other presentations given during the conference here. I was very interested in the Lagopus project, which supports DPDK (a cool framework for zero-copy network applications); the Vuls vulnerability scanner; and also Volumio, a Hi-Fi digital music Linux distro.


Although I normally use the Tama Dōbutsuen Station which is right in front of a zoo (Dōbutsuen means zoo), about 15 min walk to the OSC building, most people prefer to use the Chuo Daigaku-Meisei Daigaku Station on the Tama Monorail. Here is a picture of it on my way back to the station.

Conclusions: it's always fun to attend the OSC and learn about new trends, software and make new friends. Also I think it is especially fun if you make your own presentation.

Wednesday, May 17, 2017

Assembling a dsPIC-based DIY oscilloscope

In August 2015, I attended a Tokyo Hackerspace event called building a DIY oscilloscope. However, it wasn't until December 2016 that I finally assembled and tested it!.


During the event, we received a kit from Carl Blaksley that was based on an original design by Ajoy Raman. The hardware is quite simple and consists of 3 main components: the analogue interface, the processor and the USB interface. The analogue interface includes a few RC filters and 2 programmable gain amplifiers (SPI protocol) MCP6S22 (one for each channel). The amplified signal is then sampled by the processor, a dsPIC30F2020 which contains a 10-bit 2 Msps ADC (shared among the channels enabled). Finally, the USB interface is handled by the famous USB-serial FT232RL chip. Carl was nice and sent me the Kicad design files of the board. The assembly went quite smoothly but as always I had to debug a hardware problem that ended up being caused by my USB (a cross USB cable was needed).


The software was written in python and worked fine on Ubuntu 16.04 (there is also a visual basic version for Windows). To test it, I installed this amazing Android function generator application and connected it to the oscilloscope through a 100yen (sold at Seria) headphones stereo amplifier.

Saturday, April 22, 2017

Deciphering Akihabara signs

When I first came to Akihabara I couldn't help but feeling frustrated by the fact that I wasn't able to understand most of the signs on its buildings. 10 years later I don't have such problem anymore. In this post, I want to give you sort of a glimpse of what kind of stuff is written out there.


Let's start with the easy ones. If you learn katakana, which consists of only 48 characters, you'll be able to read quite a few words and luckily guess their meaning. (1) has カラオケ written on it which reads Karaoke, so that whole building is full of karaoke rooms. There is another sign in that building that starts with 本 (hon = book) and continues with Book Off. Book Off is a famous franchise where you can buy (and read) second-hand books and manga. (2) has ラジオセンター which reads as rajio sentaa and means radio centre (could you guess it?). Radio centre is almost a historical place already, full of electronic veterans in small stands selling electronics, amateur radio equipment and lots of retro stuff. (3) GEO is the name of a well-known DVD, Game and Manga rental franchise. But it seems it's started a mobile offering. On this sign you can see the words 格安スマホ (kakuyasu sumaho = supercheap smartphones) written. 格安 is often used on signs so it's easy to remember. (4) This one has English on it so you should know what it is about. インターネットまんが喫茶 (Internet Manga Kissa = Internet & Comics cafe) is a place where you can chill and rest your feet. Usually you get your own little compartment where you can seat, use a computer with Internet, read comics (if you are able to) and have some soft drinks. The value for the price is really good and it's something you can only experience here. In smaller characters you can read 完全分煙 (Kanzen Bun'en = smoking and non-smoking areas are completely separated), シャワー完備 (shawaa Kanbi = Fully-equipped Showers), スマホ充電OK (sumaho juuden OK = it's OK to charge your smartphone), 24時間営業 (24 jikan eigyou = 24 hours business), コムコム秋葉原点 (komukomu akihabara ten = komukomu akihabara shop, where komu means that it gets full of people), 当ビル5F受付 (toubiru 5F uketsuke = reception on the 5th floor of this building). Below the sign we have a 麻雀 mahjong shop saying ウエルカム which you should understand if you learned katakana (welcome). And right below that, on the 2nd and 3rd floor (in Japan the count starts at 1) we have a maid cafe, another place you should try at least once. On the first floor we see the 24時間 sign again, and 富士そば (Fuji soba) where you can eat soba. (5) We see まんが喫茶 again and then 免税商店 (menzei shouten = tax-free shop) which are all around in Akihabara. 歓迎光臨 is Chinese but the first two characters have also meaning in Japanese (歓迎 Kangei = welcome), so basically they are targeting potential Chinese/Taiwanese buyers. (6) Akihabara is the land of anime and games. Just by taking a look around you can catch up with the latest trends or learn of new anime series to come. 明日のステージへ! (ashita no suteeji e) means something like "towards tomorrow's stage). TVアニメ好評放送中 (TV anime kouhyou housouchuu = TV anime with good critics currently on show) is something you find all the time when you walk into an anime or manga shop. Below that sign we can see 日本武道館, this is Nippon budoukan a place where many famous music bands have played. Not surprising we can see there's going to be a live performance (note that the anime, BanG Dream, is about music) there on the 21st of August, 2017. チケット最速先行 (chiketto saisoku senkou) means that tickets are sold on a first-come-first-served basis. If you read this now, you can go to the BanG Dream official site and see the same advertisements about the "4th Live". In this kind of concerts you can see the people that are behind those anime songs and voices you like so much. (7) We see again another sign about BanG Dream, it must be something big. But let's decipher the sign in black&red. 鉄道模型 (tetsudou mokei = train models) is a shop where they sell stuff for making your own train models. This area in particular has many other shops for modeling trains, tanks, planes, gundam figures and stuff like that.



I had 2 more pictures to decipher but I guess this post took already too long. I will let you "relax" watching a few excerpts from a BanG Dream's live!.

Conclusions: the main takeaway from this post is that if you come to Japan for the first time and you want to understand something from what's written on Japanese signs, then you better learn katakana. That will help you understand words such as rajio (radio), sentaa (centre), sumaho (smartpho[ne]), shawaa (shower), uerukamu (welcome), suteeji (stage), intaanetto (internet), biru (buil[ding]), or chiketto (ticket).

Sunday, April 16, 2017

Shōwappoi

The Shōwa period in Japan refers to the years when the Shōwa Emperor Hirohito reigned (1926~1989). For a lot of people around the world, these years and particularly the 60s, 70s and 80s were somehow very special. Shōwappoi (昭和っぽい) is a Japanese expression commonly used to describe a place or object from those good old times, or anything that has such retro look.


I really like walking around Japanese Shōwappoi neibourghoods and see the remains of that era. This photo was taken near one of the 53 stations of the old Tōkaidō road, the Shinagawa-juku (a few minutes from Shinagawa station).


Coming from Tokyo station, there is this Shōwappoi place called Yūraku concourse that I find particularly interesting. It connects Yūrakuchō and Ginza. You can eat under that little bridge just in front of a few old samurai movie posters. There are many other Shōwappoi places in Tokyo such as Sugamo, which additionally has a beautiful park called Rikugien, or Nippori.


山本高樹 (Yamamoto Takaki) is a master of Shōwappoi dioramas. He has written two books on Shōwa dioramas, you can buy them here and here.

Sunday, April 9, 2017

Pinguchan: a book for children

After I started attending life drawing sessions a year ago, my motivation for painting also started to grew. I learned new techniques for painting with watercolours, and a few months later I wrote my first book for children: Pinguchan goes back to school. Pinguchan is named after the Spanish for penguin (pingüino).


The book has 14 pages (excluding the cover) and is available for purchase in Spanish or Japanese on Amazon kindle (you need to install the app in your phone/tablet). The book is distributed without DRM. You can also download a free copy in my broken English here and help me to fix the translation, I promise it will remain free of charge.


After reading a few children books, I started sketching mine. One thing I knew from the beginning is that I wouldn't be able to use the realistic style I was used to. I had no experience with more iconic drawings but I knew that it was going to be necessary for me to learn how to do them.


At first, I didn't think too much about the story. I just kept penciling one page a day, usually after work. Once I wrote them all I put them on the floor of my room and tried to visualize the story as a whole. I removed some parts, added others and even changed the order of some pages.


Once I felt satisfied with the story I started painting them all. For the painting, I used my watercolours and stretched the paper afterwards using the binder clips method I explained before. Then, I scanned the original works, cleaned them with the computer and added the text. For the Spanish version I used the comili book font which is distributed under the SIL Open Font license, and for the Japanese one I just used the standard font for Kindle. Finally, I put all of the pages together and generated the book in Kindle format using the Kindle Kids’ Book Creator application.


The Japanese version of the book was by far the most succesful, and I got a lot of requests from people who would like to buy it in printed form. I have also read my book (as well as other children books) to children and families in various local events. Seeing children smile and react to a story that you've created really feels amazing.

Conclusions: I had never been good at drawing with a non-realistic style, but since I knew it was essential for the book I had no choice but doing it. I think I managed to create some cute illustrations after all, so that's one lesson I learned: try and do it!. Another lesson I learned was that for the first time, when you still lack of experience, it can be good to just go ahead and draw without a plan as long as you can fix it later. For my next book now I have a bit more experience so I will try to plan the story from the beginning.

Saturday, April 8, 2017

My second diorama: Greyhound

A few months after presenting my first diorama to tamiya's 8th 1/48 scale modellers contest I created another one and presented it to the kiyahobby annual contest kiyacon (キヤコン 2017).



The theme for the 2017 edition of the kiyacon contest was open-top AFVs (armoured fighting vehicles). The first thing I thought when I read "open-top" was: what happens when it rains then?". In my rather short experience as a modeller, I had never seen a rain scene in a diorama. For that reason, I decided to challenge myself and try to model a rainy scene. For this diorama, I chose tamiya's 1/48 Greyhound and used a circular base that I got for 100 yen. The key to achieve this rainy effect was to undertand that colours get darker when wet, and to apply clear varnish overall to get that shinny look.


I created the floor by scratching the surface of a styrene board on which I had traced a cobblestone picture. You can use gimp or photoshop to adapt the perspective of a photo for this purpose. I used a thick needle attached to a pin vice tool.


Next, I applied diluted modeling paste and compound inspired by an article in Satoshi Araki's blog. On top of that I applied a base layer of german grey, and then added details and different colours using a brush. The rails were made using tamiya's H-shaped bar although I think I should have just cut a tamiya's plastic board to make the shape a bit more realistic.



I modified the original figure using tamiya's putty (basic type) so that it looked like it was holding an umbrella. A nice trick is to put a bit of menthol lip balm on your fingers and a cooking sheet so that tamiya's putty doesn't stick to your them. Another trick is to attach a short wire to the shoes, so that you can nail the figure down into the floor.


For the umbrella, I used some wire and masking tape. This was very experimental but for being the first time I think it worked reasonably well.

Conclusions: making the diorama simple was a great idea because I enjoyed every step, the results didn't look overworked and more importantly I made it to the contest's deadline. The contest is really famous in Japan and many senior modellers presented amazing works. Despite me being still a beginner, I actually got a prize in the contest as well!. I think the key for winning that prize was that I tried something different (expressing a rain scene). In my next diorama, I want to try something that hasn't been done yet and be more creative.