<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="html">Avian’s Blog</title>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/"/>
<link rel="self" type="application/atom+xml" href="http://www.tablix.org/~avian/blog/atom.xml"/>
<link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc/2.5/"/>
<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf"/>
<updated>2013-05-18T20:57:05+02:00</updated>
<author>
	<name>Tomaž Šolc</name>
        <uri>http://www.tablix.org/~avian/blog/</uri>
</author>
<id>http://www.tablix.org/~avian/blog/</id>


<entry>
<title type="text">GW Instek AFG-2005</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/05/gw_instek_afg_2005/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/05/gw_instek_afg_2005/</id>
<published>2013-05-18T20:57:05+02:00</published>
<updated>2013-05-18T20:57:05+02:00</updated>

<category term="Analog"/>


<summary type="text">
A review of GW Instek&#39;s low-end arbitrary function generator.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I've been missing a good function generator for a while now. Over time I've accumulated an assortment of various ad-hoc 555 oscillators and microcontroller hacks I've cobbled together whenever I needed to generate some kind of a signal to test a circuit I worked on. For a while I've been considering joining all of these in one box and slap some kind of an interface on top. I even bought a nice back-lit LCD display and some buttons for the front panel.</p>


<p>Then at one point more or less by accident I stumbled upon this low-end line of function generators from GW Instek and they looked cheaper and more versatile than what I was building myself. From what opinions I could find on the web about it they <a href="http://www.eevblog.com/forum/testgear/anyone-using-instek-afg-2000-or-afg-2100-arbitrary-function-generators/?PHPSESSID=f530fa30cbcab491132efdd5f171c783">mostly appeared positive</a>. Last week when it came in stock in this corner of the world I bought one.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/05/gw_instek_afg_2005_arbitrary_function_generator.jpg"><img alt="GW Instek AFG-2005 arbitrary function generator" src="http://www.tablix.org/~avian/blog/images2/2013/05/gw_instek_afg_2005_arbitrary_function_generator-t.jpg" /></a>

<p>After a couple of hours of playing with it I can say it's a perfectly functional instrument that as far as I can see works as specified. However as you might expect, the fact that it costs around 150 € less than the next cheapest arbitrary waveform generator definitely shows itself.</p>


<p>Interestingly, my complaints mostly have to deal with the user interface. For instance, the first thing I noticed is that there is no visual indicator whether the display is set to show signal amplitude for a 50 Ω or high-impedance output termination. Since this means a factor of two in output voltage level a wrong setting can easily be fatal for some circuits. I guess resetting to high-Z setting before turning off the generator would be a prudent habit to keep.</p>


<p>One thing that sold this device for me is the USB connectivity. After being <a href="http://www.tablix.org/~avian/blog/archives/2012/10/python_rftest_py/">spoiled by the equipment</a> I have at work, I missed being capable of running some automated tests for projects at home. While the manual doesn't mention the word USBTMC anywhere, the remote-control commands look suspiciously identical to the venerable industry-standard <a class="zem_slink" href="https://en.wikipedia.org/wiki/IEEE-488" title="IEEE-488">GPIB</a> language.</p>


<p>When I connected AFG-2005 to my computer, first thing I noticed is that it doesn't actually use USBTMC protocol. Instead, it's behaves like a serial modem with USB ACM interface. As far as Linux user space is concerned, this doesn't seem to make a big difference - both kernel drivers expose a simple character device for interaction with the device. For USBTMC I know that when the <i>write()</i> syscall returns, the device has already accepted the command and you can expect it will be giving the signal you programmed. But I'm not sure whether this also holds in this case.</p>


<p>The implementation of the protocol is somewhat buggy though. First of all, commands require a terminating ASCII line feed (<i>\n</i>) character, which isn't the case with USBTMC devices. Invalid commands are simply ignored - there are no error or diagnostic messages at all.</p>


<p>My device identifies itself like this for the <i>*IDN?</i> command:</p>


<pre>
GW INSTEK,AFG-2005,SN:EN810021,V1.11
</pre>


<p>It's quite easy to crash the instrument's firmware by feeding it malformed commands. In that case the front panel stops working and the only way to restore it back to normal is by using the hardware power button.</p>


<p>The front panel display itself is somewhat sluggish and if you issue a lot of commands through the USB it might take a while to catch up with all the settings, even though if you watch the signal generator's output you can see they are applied much faster. The multi-purpose knob has similar issues and if you turn it too fast the values start jumping around instead of going in one direction (this seem to be a common issue though - I've seen a lot of different devices have a problem with that).</p>


<p><a class="zem_slink" href="https://en.wikipedia.org/wiki/Arbitrary_waveform_generator" title="Arbitrary waveform generator">Arbitrary function generator</a> works nicely and can be easily programmed from a PC using a <i>DATA:DAC</i> command. What I don't quite understand is the syntax there. In contrast to other instruments I worked with, the manual says that the first argument is the <i>Start address of the arbitrary waveform</i>. It gives an example where this address is 1000, but that doesn't seem to work at all with my instrument. The only address where the ARB output works as expected is 0. Using other addresses I either get garbage output with no correlation to what I wanted to do or crash the firmware.</p>


<p>Arbitrary function generator has a 20 MHz maximum sampling frequency and firmware allows you to fully exploit that, even when the frequency of the signal exceeds 5 MHz maximum for pre-programmed waveforms. The results in that case are less than perfect of course. The most obvious problem is the significant DAC jitter. Here is how a square wave looks like at 10 MHz:</p>

<img alt="Jitter in the arbitrary waveform generator." src="http://www.tablix.org/~avian/blog/images2/2013/05/jitter_in_the_arbitrary_waveform_generator-t.png" />

<p>In conclusion, this instrument gives you quite a lot of value for its price. But unsurprisingly, it's not on the level of instruments that have a few zeros more on the left of the Euro sign. I can't stop myself thinking though that a lot of these problems would take a simple firmware patch to fix. If only the manufacturer would provide source and simple means of reprogramming.</p>


</div>
</content>

</entry>

<entry>
<title type="text">Wireless microphone simulation with VESNA</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/05/wireless_microphone_simulation_with_vesna/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/05/wireless_microphone_simulation_with_vesna/</id>
<published>2013-05-13T11:51:54+02:00</published>
<updated>2013-05-13T11:51:54+02:00</updated>

<category term="Analog"/>


<summary type="text">
Generating IEEE wireless microphone simulation profiles using the CC1101 transceiver on VESNA.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>It sounds strange, but analog FM wireless microphones (the kind you find in studios, theaters and soon-to-be-restaurants) are one of the obstacles in the efficient re-use of the UHF band that has been freed with the <a href="https://en.wikipedia.org/wiki/Digital_television_transition">digital switchover</a>. They operate in the same frequency band as the now silenced analogue TV broadcasts, but on the other hand have never been well regulated. While locations and frequencies of TV transmitters are well known, microphones can appear on a lot of different channels and practically in any location.</p>


<p>New devices operating in the TV white-spaces can't be allowed to interfere with them, so they either can't use frequencies where microphones appear (leading to unused spectrum) or they must detect them using <a href="http://www.tablix.org/~avian/blog/archives/2012/04/spectrum_sensing_in_a_nutshell/">spectrum sensing</a>. Reliable and energy-efficient detection of wireless microphones at low signal levels is an open research topic.</p>


<p>To test different ways of detecting microphones, IEEE has come up with simulation waveforms that can be easily reproduced on lab equipment and are reasonably similar to what microphones transmit in real-life usage. They simulate a silent microphone, microphone used with a soft voice and microphone used with a loud voice by frequency modulating a sine wave with different baseband frequencies and deviations (described in <a href="https://mentor.ieee.org/802.22/dcn/07/22-07-0124-00-0000-wireless-microphone-signal-simulation.doc">this Word document</a>).</p>


<p>For example, here's how a soft voice simulation looks like on a spectrum analyzer when transmitted by a big and expensive Rohde&amp;Schwarz vector signal generator. This is a 3.9 kHz tone modulated using a 15 kHz deviation:</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation.png"><img alt="Spectrogram of a wireless microphone simulation using a vector signal generator." src="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation-t.jpg" /></a>

<p>And this is the same signal transmitted with an <a class="zem_slink" href="https://en.wikipedia.org/wiki/Universal_Software_Radio_Peripheral" title="Universal Software Radio Peripheral">USRP</a> N210:</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation_2.png"><img alt="Spectrogram of a wireless microphone simulation using USRP N210." src="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation_2-t.jpg" /></a>

<p>As I mentioned before, VESNA also has some <a href="http://www.tablix.org/~avian/blog/archives/2013/04/vesna_and_signal_synthesis/">signal generation capabilities</a>. This is how it looks like when the signal is simulated using a <a href="https://en.wikipedia.org/wiki/Direct_digital_synthesizer">direct digital synthesis</a> algorithm and a 4FSK modulator on the CC1101 transceiver:</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation_1.png"><img alt="Spectrogram of a wireless microphone simulation using VESNA SNE-ISMTV." src="http://www.tablix.org/~avian/blog/images2/2013/05/spectrogram_of_a_wireless_microphone_simulation_1-t.jpg" /></a>

<p>The order-of-magnitude in price difference in hardware shows itself well enough here as transmission from VESNA obviously differs quite a bit from the desired. But still it's good enough for some detection experiments and of course, you can't have a USRP mounted on every light pole.</p>


<p>Although I haven't yet done detailed measurements, VESNA's transmission actually does seem to comply with FCC's requirement regarding spurious levels for wireless microphones (but not with more stringent European ETSI regulations).</p>


</div>
</content>

</entry>

<entry>
<title type="text">World wide wheel, reinventing of</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/05/world_wide_wheel_reinventing_of/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/05/world_wide_wheel_reinventing_of/</id>
<published>2013-05-09T22:00:36+02:00</published>
<updated>2013-05-09T22:00:36+02:00</updated>

<category term="Life"/>


<summary type="text">
Ranting about how modern web keeps reinventing old features poorly, mostly due to bad browser interfaces.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>The direction browsers and web technology are moving these days truly baffles me. As usual in the software world, it's all about piling one shiny feature on top of another. Now, I'm not against shiny <i>per se</i>, but it seems that a lot of these innovations are by people that haven't even took an hour to look at the already existing body of knowledge and standards that has accumulated over the years. With the frenzy of rolling releases and implementation-is-the-standard hotness, it's not even surprising that those are then implemented by browsers before someone with a long enough beard can stand up and shout <i>Hey! We already thought of that in this here RFC.</i></p>


<p>Take for example all the buzz about finally solving the problem with authentication on the web. <i>Finally</i>, <a href="https://login.persona.org/">there's a way</a> to securely sign into a website without all the mess with hundreds of hard-for-me-to-remember yet easy-to-guess-by-the-cracker user name and password combinations. Wonderful. Except that this exact thing existed on the web since people did cave paintings and used Netscape to browse the web. It's called <a href="https://en.wikipedia.org/wiki/Secure_Sockets_Layer">SSL client side certificates</a> and, amazingly, worked well enough for on-line banking and government sites even before the invention of pottery and cloud-based identity providers.</p>


<p>But that's just the most glaring case. Another front where this madness continues is pushing things from the old <a class="zem_slink" href="https://en.wikipedia.org/wiki/List_of_HTTP_header_fields" title="List of HTTP header fields">HTTP headers</a> to the fancy new HTML5. Take for example <a href="http://svarden.se/blog/2013-04-22-right-click-and-save-as/">a proposal</a> to add a HTML attribute that defines whether a browser should display something or save it to disk by default. This functionality has existed for ages in the form of a HTTP header, yet this is somehow dismissed as a <i>server-side solution</i> (what does that even mean?).</p>


<p>I wonder how many web developers today are even aware that there exists a mechanism for a client to tell the browser which language the user prefers (but we <i>most certainly need</i> the annoying language selection whole-screen pop-up-and-click-through!). Or that the client can tell the server whether it would rather have a PNG for downloading or a friendly HTML page for viewing in a browser (<i>meh</i>, we'll just fudge that with some magic on-click Javascript handlers).</p>


<p>Now I can see someone laughing and saying how ridiculous this idea is and if I have ever even tried to use one of those ancient features. No it's not, and I have. It's consistently painful. But it's only so because for some reason, browsers long ago decided to make <a href="http://pilif.github.io/2008/05/why-is-nobody-using-ssl-client-certificates/">the most horrible interface</a> to such functionality imaginable to man and then forgot to ever fix it. Mostly it's hidden 10 levels down in some obscure dialog box and if banks wouldn't give you click-by-click instructions on how to import a certificate, 99% of people would give up after a few hours and continue chiseling clay tablets. Now imagine if a tenth of time spent in reinventing the wheel would be spent just improving the usability of existing features. Why can't I go to a web page and get a prompt: <i>Hey! This web page wants you to login. Do you want me to use one of these existing certificates or generate a new, throw-away one?</i>. World would be just a tiny bit better, believe me.</p>


<p>In the end, I think modern browsers have focused way too much on improving the situation for the remote web page they are displaying and neglected the local part around it. And I believe this direction is bad in the long run. Consider also the <a href="https://en.wikipedia.org/wiki/Directive_on_Privacy_and_Electronic_Communications">European cookie directive</a>. I'm pretty sure this bizarre catch-22 situation where web pages are now required to manage cookie preferences for you would not be needed if browsers provided a sane interface for handling these preferences in the first place. My Firefox has three places (that I know of!) where I can set which websites are allowed to store persistent state on my computer. Plus it manages to regularly lose them, but that's a different story.</p>


</div>
</content>

</entry>

<entry>
<title type="text">Custom display resolutions in QEMU</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/05/custom_display_resolutions_in_qemu/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/05/custom_display_resolutions_in_qemu/</id>
<published>2013-05-04T19:19:55+02:00</published>
<updated>2013-05-04T19:19:55+02:00</updated>

<category term="Code"/>


<summary type="text">
Instructions on how to add support for an arbitrary display resolution in QEMU&#39;s virtualized VGA card.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p><a class="zem_slink" href="http://qemu.org" title="QEMU">QEMU</a> emulates a VESA-compliant VGA card that supports a static set of standard and a-bit-less-standard display resolutions. However, this set is far from universal and for example doesn't include the wide-screen 1600x900 resolution on <a href="http://www.tablix.org/~avian/blog/archives/2011/12/hp_elitebook_8460p/">my laptop</a>. This means that running a virtualized OS full-screen would always stretch the display somewhat and give a blurry image.</p>


<p>Here's how I fixed that. Following instructions should pretty much work for adding an arbitrary resolution to QEMU's virtualized graphics card (but only when using <i>-vga std</i>). They are based on <a href="http://git.pld-linux.org/gitweb.cgi?p=packages/qemu.git;a=commit;h=d90027067df523cf21065ecf75ec8ea2bc715cf6">this patch</a>.</p>


<p>Fetch QEMU source (I used 1.4.0) and edit <i>roms/vgabios/vbetables-gen.c</i>. For instance, to add 1600x900 I applied this patch:</p>


<pre>
--- qemu-1.4.0.orig/roms/vgabios/vbetables-gen.c	2013-02-16 00:09:22.000000000 +0100
+++ qemu-1.4.0/roms/vgabios/vbetables-gen.c	2013-05-04 11:46:55.000000000 +0200
@@ -76,6 +76,9 @@
 { 2560, 1600, 16                     , 0x18a},
 { 2560, 1600, 24                     , 0x18b},
 { 2560, 1600, 32                     , 0x18c},
+{ 1600,  900, 16                     , 0x18d},
+{ 1600,  900, 24                     , 0x18e},
+{ 1600,  900, 32                     , 0x18f},
 { 0, },
 };
</pre>


<p>Now re-build the VGA BIOS binary image (<i>apt-get install bcc</i> first):</p>


<pre>
$ <b>cd roms/vgabios</b>
$ <b>make stdvga-bios</b>
</pre>


<p>QEMU's <i>make install</i> will not install the image you just built. Instead, it will use an already built binary they ship with the source. Therefore you have to install it manually:</p>


<pre>
$ <b>cp VGABIOS-lgpl-latest.stdvga.bin $PREFIX/share/qemu/vgabios-stdvga.bin</b>
</pre>


<p>Of course, replace <i>$PREFIX</i> with the prefix you used when installing QEMU (<i>/usr/local</i> by default). Now when you start a virtualized OS you should see the resolution you added to <i>vbetables-gen.c</i> (for example as reported by <i>xrandr</i> or under <i>Screen resolution</i> in Windows).</p>


</div>
</content>

</entry>

<entry>
<title type="text">Cost of a Kindle server</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/05/cost_of_a_kindle_server/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/05/cost_of_a_kindle_server/</id>
<published>2013-05-01T10:48:47+02:00</published>
<updated>2013-05-01T10:48:47+02:00</updated>

<category term="Life"/>


<summary type="text">
Running a Kindle 24 hours a day as a server costs half a cup of coffee per month.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>I was wondering how much <a href="http://www.tablix.org/~avian/blog/archives/2013/02/booting_kindle_3/">running a Kindle</a> as an always-on, underpowered Debian box was costing me in terms of electricity. So I plugged it into one of the <a href="http://www.tablix.org/~avian/blog/archives/2012/07/energycount_3000_part_2/">Energycount 3000</a> devices and monitored its power consumption over the last 4 days. This took into account the power consumption of the Kindle as well as the efficiency of a small Nokia cell phone charger I'm using to power it.</p>


<p>ec3k reported an average power of 1.0 W (and maximum 2.6 W). Dividing the watt-seconds count with time also yielded 1 W to three decimal places. This nice round number makes me suspect that it's due to limited precision of the measurement, but let's consider it accurate for the moment.</p>


<p>1 W is equal to 0.72 kWh per month. With the current prices I'm paying for electricity this costs me 0.083 € per month. For comparison, a cup of synthetic-tasting coffee from a machine at work costs around twice as much and running my desktop machine all the time would be around a hundred times as expensive.</p>


</div>
</content>

</entry>

<entry>
<title type="text">Interesting battery failure mode</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/04/interesting_battery_failure_mode/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/04/interesting_battery_failure_mode/</id>
<published>2013-04-28T13:29:16+02:00</published>
<updated>2013-04-28T13:29:16+02:00</updated>

<category term="Life"/>


<summary type="text">
This broken Amazon Kindle battery has negative voltage on the SCL and SDA terminals.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Thanks to my <a href="http://www.tablix.org/~avian/blog/archives/2012/09/dont_sit_on_your_kindle/">previous posts</a> about Amazon Kindle, I have another broken specimen on my desk now. This one seems to have experienced an interesting battery failure.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/04/amazon_kindle_3_batteries.jpg"><img alt="Amazon Kindle 3 batteries" src="http://www.tablix.org/~avian/blog/images2/2013/04/amazon_kindle_3_batteries-t.jpg" /></a>

<p>Kindle's battery has 4 terminals: ground, a positive terminal for power and SDA and SCL pins for I<sup>2</sup>C communication with the integrated battery management circuit. On a normal battery, the positive terminal is around 3.7 V above ground, depending on the charge level of the Li-ion cell and the I<sup>2</sup>C lines are on ground level, because they need external pull-ups.</p>


<p>This broken battery however has the positive terminal at 0 V compared to ground terminal while the I<sup>2</sup>C pins are at -2.5 V. I can't imagine what kind of failure mode could cause pins to go lower than ground, unless the polarity of the cell got reversed somehow. I don't see any way how a failure in the battery management circuit or a loose connection somewhere could cause such readings. I'm pretty sure it's not an artifact of my multimeter either, because the battery can draw some milliamps of current from the ground to one of the I<sup>2</sup>C pins. For the record, this looks like an original 1830 mAh battery. Date of manufacture is April 2011 and type is <i>170-1032-01 Rev. A</i>.</p>


<p>The master I<sup>2</sup>C interface on the Kindle wasn't damaged though, because it boots and reads out battery state just fine when attached to a different battery. There does seem to be a problem with bad a connection somewhere on the motherboard, because it crashes if I lightly knock on the CPU package. Possibly a hairline crack in some solder joint. But that's a topic for some other time.</p>


</div>
</content>

</entry>

<entry>
<title type="text">VESNA and signal synthesis</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/04/vesna_and_signal_synthesis/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/04/vesna_and_signal_synthesis/</id>
<published>2013-04-26T20:49:32+02:00</published>
<updated>2013-04-26T20:49:32+02:00</updated>

<category term="Digital"/>


<summary type="text">
Generating RF signals using VESNA and inexpensive transceiver hardware.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Experimental radio equipment on VESNA can be used for more than <a href="http://www.tablix.org/~avian/blog/archives/2012/04/spectrum_sensing_in_a_nutshell/">spectrum sensing</a>. Radio boards based on Texas Instruments CC2500 and CC1101 transceivers can also be used for packet transmission and reception and, perhaps somewhat surprisingly, also as flexible signal generators. These can be used in experiments when you want for instance to introduce a controlled interference in some system or to check if your spectrum sensor is working correctly.</p>


<p>Usually when I'm talking with people about what our hardware is capable of the conversation often starts with amazement at how small the radio part is and then inevitably turns to the question whether VESNA has a software defined radio. I have to answer no, it doesn't, and then there's usually an awkward silence because that seems like a dead-end for any serious research work these days.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/04/cc1101_transceiver_on_sne_ismtv_868.jpg"><img alt="CC1101 transceiver on SNE-ISMTV-868" src="http://www.tablix.org/~avian/blog/images2/2013/04/cc1101_transceiver_on_sne_ismtv_868-t.jpg" /></a>

<p>True, these transceivers don't provide software access to the undemodulated baseband samples (like for instance USRP does). However they are still amazingly flexible. They offer plenty of reconfigurability and, after you get to know some of their quirks, can be adapted for a lot of weird use cases without hardware changes. If you skip the various high-level digital parts of the chip for proprietary packet format handling there's a flexible front-end in there that allows you to choose between a handful of frequency, amplitude and phase modulators and several options for channel filters and such.</p>


<p>The closest you can come to software defined radio is a transparent continuous transmit mode where you can feed the transceiver arbitrary binary data from the microcontroller and it will simply get modulated and fed into the antenna. There is a catch though, since the chips offer at most 2-bit quantization of the baseband signal before modulation (they were designed for simple digital transmissions after all). This means that you have to get creative if you want to approximate an analog modulation and be ready for plenty of quantization noise.</p>


<p>This is how it looks like on a spectrum analyzer when you run a <a href="https://en.wikipedia.org/wiki/Direct_digital_synthesizer">direct digital synthesis</a> algorithm on the microcontroller that generates a baseband sawtooth frequency sweep and use the amplitude modulator to up-convert it to 2.4 GHz:</p>

<object data="http://www.youtube.com/v/soLS7GZFQTQ?hl=en_US&amp;version=3&amp;rel=0" height="315" type="application/x-shockwave-flash" width="560"><param name="movie" value="http://www.youtube.com/v/soLS7GZFQTQ?hl=en_US&amp;version=3&amp;rel=0" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" />
<p><i>(watch the video on <a href="http://www.youtube.com/watch?v=soLS7GZFQTQ">YouTube</a>)</i></p>
</object>

<p>Using <a href="https://en.wikipedia.org/wiki/Delta-sigma_modulation">delta-sigma modulation</a> you can approximate arbitrary waveforms in this way. For instance, you can make a passable simulation of an (analog) wireless microphone transmission using a 4-FSK modulator in CC1101 tuned into the UHF band.</p>


<p>Of course, setting this up takes more work than popping a few blocks into <a class="zem_slink" href="https://en.wikipedia.org/wiki/GNU_Radio_Companion" title="GNU Radio Companion">GNU Radio Companion</a> and part of my job is to make it more accessible to people using VESNA and our VESNA-based testbeds. If you're interested in such signal generation using Texas Instruments CC series, some platform-independent code capable of doing this should start hitting the <a href="https://github.com/sensorlab/vesna-spectrum-sensor">vesna-spectrum-sensor</a> repository on GitHub in the next few weeks.</p>


</div>
</content>

</entry>

<entry>
<title type="text">Multilib weirdness</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/04/multilib_weirdness/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/04/multilib_weirdness/</id>
<published>2013-04-13T21:41:45+02:00</published>
<updated>2013-04-14T13:41:27+02:00</updated>

<category term="Code"/>


<summary type="text">
GCC&#39;s multilib also takes into account compiler defaults that might be different from those used when libraries were compiled.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Multilib is a mechanism in GCC for handling multiple binary versions of a single library that have been compiled using different compiler options. This is useful for instance when compiler options affect the ABI and the linker has to choose the correct library version to link your program with. ARM architecture with its multitude of ABIs and floating point unit options is a prime example where this comes in handy.</p>


<p>Multilib works by mapping compiler command-line options to directories where libraries can be found. For instance, GCC compiled with my fork of <a href="https://github.com/avian2/summon-arm-toolchain">summon-arm-toolchain</a> says this about its multilib support:</p>


<pre>
$ <b>arm-none-eabi-gcc -print-multi-lib</b>
.;
thumb;@mthumb
fpu;@mfloat-abi=hard
</pre>


<p>What <a href="http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-print_002dmulti_002dlib-724">this says</a> is that binaries compiled with <i>-mthumb</i> will be linked with libraries that appear under <i>thumb/</i> and binaries with <i>-mfloat-abi=hard</i> will use libraries under <i>fpu/</i> relative to the usual library search path.</p>


<p>However:</p>


<pre>
$ <b>arm-none-eabi-gcc -print-multi-directory -mthumb</b>
thumb
$ <b>arm-none-eabi-gcc -print-multi-directory -mfloat-abi=hard</b>
.
</pre>


<p>While <i>thumb</i> option seems to work as expected, the hardware-float libraries don't appear to be used. Why is that?</p>


<p>It turns out that multilib is somewhat smarter than what the documentation and <i>-print-multi-lib</i> would lead you to believe. It doesn't just check the options that you give GCC explicitly on the command line but also their default values.</p>


<p>It seems that <i>-print-multi-lib</i> assumes built-in default values for these options. It believes that <i>fpu/</i> versions have been compiled using ARM, not thumb mode. But since <i>-marm</i> is default, it doesn't print it out explicitly.</p>


<p>However, this GCC has been compiled using <i>--with-mode=thumb</i>, which changes the default to <i>-mthumb</i>:</p>


<pre>
$ <b>arm-none-eabi-gcc -v</b>
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/home/avian/local/libexec/gcc/arm-none-eabi/4.6.3/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-4.6.3/configure --target=arm-none-eabi
--prefix=/home/avian/local --enable-interwork --enable-multilib --with-newlib
--disable-shared --with-gnu-as --with-gnu-ld --disable-nls --disable-werror
--with-system-zlib --with-arch=armv7-m --with-mode=thumb --with-float=soft
Thread model: single
gcc version 4.6.3 (GCC)
</pre>


<p>Multilib is smart enough to know that libraries under <i>fpu/</i> won't work with code compiled with <i>-mthumb</i> and falls back to the default directory and hopes for the best. So, to get the compiler to use libraries under <i>fpu/</i>, you have to explicitly set it to ARM mode:</p>


<pre>
$ <b>arm-none-eabi-gcc -print-multi-directory -marm -mfloat-abi=hard</b>
fpu
</pre>


<p>By the way, the combinations of options and directory names printed out by <i>-print-multi-lib</i> are set using <a href="http://gcc.gnu.org/onlinedocs/gccint/Target-Fragment.html">MULTILIB_OPTIONS</a> and friends in <i>gcc/config/arm/t-arm-elf</i> in the GCC source tree.</p>


</div>
</content>

</entry>

<entry>
<title type="text">The lowly connector</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/04/the_lowly_connector/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/04/the_lowly_connector/</id>
<published>2013-04-11T20:47:23+02:00</published>
<updated>2013-04-13T22:08:08+02:00</updated>

<category term="Digital"/>


<summary type="text">
When designing a microcontroller board consider the longevity and ease of use of connectors used in development and debugging.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p>Here's a small addendum to my <a href="http://www.tablix.org/~avian/blog/archives/2012/06/microcontroller_board_design_tips/">previous list of lessons</a> regarding easy debugability of microcontroller boards.</p>


<p>It's not a bad idea to pay a bit of extra attention to the connectors that will be used when developing and debugging software. It's likely these will see much more use than any other connector on the board, especially if the board is also meant for teaching or research like VESNA.</p>


<p>The first concern is that it should be hard to connect it in a wrong way. <a href="https://en.wikipedia.org/wiki/IDC_connector">IDC</a> and similar pin header connectors are popular for JTAG. Use a male part that has a shroud so that it's impossible to connect it when displaced by a pin or turned 180 degrees. That might sound obvious, but when you're debugging that tricky race condition and switching the debugger between three systems on your table late in the evening, the last thing you need is a burned out board because of a misplaced connector.</p>


<p>The other thing that is also worth considering is the life time of the connector itself. While the life time of the part on the board might not be problematic, the part that stays with the developer can be. For VESNA one of the most common reasons to make a trip to the soldering station is a torn wire in the connector for the serial debug console. We use something similar to the <a href="https://en.wikipedia.org/wiki/Berg_connector">Berg connector</a> and that one doesn't really take many connect-disconnect cycles before either wires get torn out or little springs break and the metal part falls out of the plastic housing. It's not always obvious that has happened and again it's a pain to realize after a long debugging session that the reason a board is talking garbage is not due to a bug you're trying to catch but rather due to a broken ground line in your debug console.</p>


</div>
</content>

</entry>

<entry>
<title type="text">Update on CC2500 deterioration</title>
<author>
<name>Tomaž</name>


</author>
<link rel="alternate" type="text/html" href="http://www.tablix.org/~avian/blog/archives/2013/03/update_on_cc2500_deterioration/"/>
<id>http://www.tablix.org/~avian/blog/archives/2013/03/update_on_cc2500_deterioration/</id>
<published>2013-03-25T15:32:10+01:00</published>
<updated>2013-03-25T15:32:10+01:00</updated>

<category term="Analog"/>


<summary type="text">
An update regarding degradation of CC2500-based radios in an out-door environment.
</summary>


<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">

<p><a href="http://www.tablix.org/~avian/blog/archives/2012/11/deteriorating_radios/">Last November</a> I was writing about an issue with 2.4 GHz transceivers that were deployed on street lights as part of Jožef Stefan Institute's testbed for radio communications. Some radios based on Texas Instruments CC2500 integrated circuit seemed to degrade after they were mounted out doors. In the most extreme case, there was almost an -30 dB drop in receiver sensitivity and maximum transmit power dropped to insignificant levels.</p>


<p>The leading theory at the time was that some component has deteriorated over time due to environmental effects. After some initial testing it appeared that the coaxial cable between the radio PCB and the connector is to blame. However having more boards with this issue in the lab showed that in most cases it's not possible to restore original characteristics only by changing the coaxial cable.</p>

<a href="http://www.tablix.org/~avian/blog/images2/2012/11/a_pile_of_sne_ismtv_boards_and_pigtail_cables.jpg"><img alt="A pile of SNE-ISMTV boards and pigtail cables." src="http://www.tablix.org/~avian/blog/images2/2012/11/a_pile_of_sne_ismtv_boards_and_pigtail_cables-t.jpg" /></a>

<p>I then fired up the soldering iron and did a brute-force approach: on three bad radio boards I manually replaced components one by one, preforming <a href="http://www.tablix.org/~avian/blog/archives/2012/10/python_rftest_py/">automated tests</a> of the board after each replacement. While replacing the coaxial cable did have a small effect (0.3 dB in the best case), only replacing the CC2500 integrated circuit itself seemed to restore the correct performance. So the suspicion immediately fell on the transceiver chip itself.</p>


<p>Since I did not exhaustively test all radios for sensitivity and transmit power before deployment, I couldn't be sure whether the radios have been bad from the start or whether they degraded due to environment. The fact that only radios that have been deployed out-doors have had this issue pointed to the second explanation, but since more radios were deployed out-doors than in-doors that could have been a coincidence as well.</p>


<p>As a test, I also brutally heated up one of the newly replaced CC2500 chips with a hot air gun. After such test, the radio board had similar symptoms as the boards that were unmounted from the testbed as defective: the digital part of the IC still functioned correctly, but receiver's sensitivity dropped permanently by 33 dB. Unfortunately I did not record the temperature to see how much heating is actually required.</p>


<p>To test the other theory, I set up a long-running experiment on the testbed that recorded received signal strength between neighboring pairs of newly replaced radios 4 times a day between December 2012 and March 2013. If radios were deteriorating over time, I should be able to see the signal strength drop during these three months.</p>


<p>Here are two typical plots of these measurements over time:</p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/03/long_term_rssi_measurement_between_nodes_12_and_15.png"><img alt="Long term RSSI measurement between nodes 12 and 15." src="http://www.tablix.org/~avian/blog/images2/2013/03/long_term_rssi_measurement_between_nodes_12_and_15-t.jpg" /></a>

<p></p>

<a href="http://www.tablix.org/~avian/blog/images2/2013/03/long_term_rssi_measurement_between_nodes_2_and_25.png"><img alt="Long term RSSI measurement between nodes 2 and 25." src="http://www.tablix.org/~avian/blog/images2/2013/03/long_term_rssi_measurement_between_nodes_2_and_25-t.jpg" /></a>

<p>As you can see, while there is a lot of variation in the signal strength, there is no obvious downward trend. Variation is probably due to weather and or large things moving around the radios (these are mounted in an industrial zone, so moving trucks and other such things are not an uncommon occurrence).</p>


<p>So, it currently looks like we either mounted already defective radios or they were damaged by a one-time event after deployment (which is hard to imagine). The fact that over-heating damages radios in a similar way may point to an error in manufacturing, although that's not a popular opinion, since these boards were soldered using a lead solder and radio ICs are supposed to support a RoHS process that involves higher temperatures. It's also a theoretical possibility that the radios were damaged during summer (the test above was obviously done over winter months), although again <a href="http://www.tablix.org/~avian/blog/archives/2012/05/white_box_model/">it's very unlikely</a> that sun would overheat the radios.</p>


</div>
</content>

</entry>

</feed>
