On animation

23.12.2015 22:02

The end of the year is getting near and I guess it's time again for some lighter topics. A year ago I was writing about my foray into drawing cartoon characters. I can't really say I advanced on that front very much. On the contrary, it seems that without regular practice I quickly revert to my old state of barely being able to draw anything beyond circuit diagrams. It's also apparent that I lack imagination to come up with anything better than some unoriginal ponies. I was however intrigued by some amateur animations I saw, which made me wonder how hard would it be to put some of my old drawings into motion. Unsurprisingly, it turned out that it is in fact hard. Over the past summer I managed to make barely a few seconds of animation that looks presentable.

I found few good tutorials on how to do animation. Most of the time I simply studied existing cartoons. Luckily, there's no shortage of content on the web you can look at frame-by-frame. For instance, by stepping through any of the existing animations of a horse trot it's easy to see what are the key frames for motion of different limbs. Which is how I came up with these frames for the walking animation.

Original sketch and key frame study for Onwards animation

It's like reverse engineering the way you recognize and perceive images and motion. Some of the things I learned were quite surprising: single frames often look horrible, but work perfectly good in motion. Other times, small changes between frames that make sense individually look terribly when played back. It turns out cartoon characters really only look good from a handful of angles. You can also get away with a lot of things in animation that make little physical sense. For instance, I did some exercises in calculating visual angles, angular speeds and relative sizes for the camera rotation clip you see below. They just don't make much sense even though I think it's not that apparent in the animation itself.

Of course, I don't have access to any kind of professional software, so I took what I guess you could call a software developer's approach to art.

I drew individual character cels in GIMP using a Wacom Intuos tablet, with scans of some of my old ink-and-pencil drawings as a reference. For the rotation clip I found it quite impossible to keep proportions correct without some kind of a guide, so I programmed a spherical model in Python and PIL. I imported the resulting frames into GIMP before drawing sketches over them. And then I went back to tweak the model because it looked awful and so on enough times to give me the Tetris effect.


(Click to watch Onwards! video)

Of course, drawing and coloring with a tablet saves a ton of time, because you can just copy-paste parts that do not change between frames. Still, making all the individual cels is very time consuming, which is why everything you see here is only one quarter of the full 24 frames per second. I found GIMP's Animation Playback window and the wonderful Export Layers plug-in most useful.

For backgrounds I used Inkscape, simply because it was easier to draw a bunch of straight lines with vectors instead of free-hand. Another reason was because I have yet to discover a simple method of drawing things in GIMP that do not have black outlines. I'm scared of real video editing software ever since I've used Cinelerra a few times in Kiberpipa years ago, so when ever possible, I turned to (messy) Makefiles and Python to do compositing. In the two clips you see here, the foreground cels were exported from GIMP into individual PNG files and the background was one or two large PNGs exported from Inkscape. Python scripts then used PIL to layer frames in the right order and right offsets.

In the end I couldn't escape using a video editor though. Music, credits and cross-fades were done in Kdenlive. I used FFmpeg to encode individual frames produced by my scripts into MJPEG files that I could import into Kdenlive.

Spin state

(Click to watch Spin state video)

So, after this exercise, what can I say about making cartoons? I certainly have a whole new respect for people that manage to produce even ten minutes worth of content in their free time. I've spent way too many evenings fussing over details in a second of video. On that note, this is also a scarily efficient method of procrastination on more important projects. On the other hand, seeing my character moving smoothly for the first time was a feeling comparable with the proverbial first LED blink on a new microcontroller or finally figuring out a math problem I've been working on for a month.

Posted by Tomaž | Categories: Ideas | Comments »

Minimalist microwave magic

17.12.2015 14:52

The other day at the Institute, Klemen brought me this microwave motion sensor. Apparently, it was left over from an old municipal lighting project where street lights were to be only turned on when something was moving in the vicinity. I don't know what came out of this idea, but the sensor itself is quite fascinating.

Microwave motion sensor module.

Bottom side of the motion sensor circuit.

There is no manufacturer name on the device. The bottom side of the PCB says GH1420 and IRP/07. It appears to be very similar to the AgilSense HB100 sensor module, but it's probably a cheap knock-off rather than the original. I haven't come across these yet, but it seems they are somewhat popular to use with Arduino (and as cheap DIY 10 GHz sources for amateur radio enthusiasts).

Microwave motion sensor block diagram.

Image by AgilSense

The application note from AgilSense contains the block diagram above. The device transmits a continuous wave at around 10.5 GHz on transmit antenna. Any signal that gets reflected back to the receive antenna is mixed with the local oscillator. If the input signal is Doppler-shifted because it reflected off a moving object, you get some low frequency signal on the output. The application note says that a typical signal is below 100 Hz and in the μV-range.

Top side of the motion sensor circuit.

After removing the metal can, the circuit appears fantastically minimalist. There are only two semiconductor elements, two passive elements and a dielectric resonator. The PCB substrate feels like plain old FR4. Copper traces are covered with solder mask and have what looks like immersion gold finish - unusual for a microwave RF circuit. If it weren't for the transistor in the high-frequency SMD package and the PCB microstrip wizardry, I wouldn't believe this runs at 10 GHz. They didn't even bother to solder the RF shield can onto the ground plane.

I'm not very familiar with extremely high-frequency design, but this does look more or less like what the block diagram above promises. The X shaped element is most likely a high-frequency NPN transistor used as an oscillator. Base is upper-right, collector is lower-left and the two remaining pins are the emitter (with vias to the ground plane on the other side). The +5 V power lead provides collector voltage through a resistor on the lower-right. The quarter-circle things on the PCB are butterfly stubs in low-pass filters.

The collector of the transistor is capacitively coupled with the base through the white cylindrical resonator. This provides the feedback that drives the oscillator. What's interesting is that there is no bias on the base of the transistor. Either it is working as a class C amplifier or there's something more fancy than a plain bipolar transistor in that SMD package.

The output of the oscillator is coupled to the transmit antenna on the bottom and to the mixer in the center. The little rectangular stubs on the way probably help with impedance matching or some filtering of oscillator harmonics. The trace from the receive antenna comes in on the top of the picture. The mixer is probably some kind of a diode arrangement, although I don't recognize this setup. The low-frequency output from the mixer then exits through another low-pass filter to the lower-left.

Apparently that's all you need for a simple Doppler radar. I was surprised at the extreme minimalism of this device and the apparent huge divide between design effort and manufacturing costs. I'm sure a lot of knowledge and work went into figuring out this PCB, but once that was done, it was probably very simple to copy. I wonder if this specific setup used to be covered by any patents.

Posted by Tomaž | Categories: Analog | Comments »