Thursday, October 24, 2013

Weader - A simple atom/rss feed reader for Android

Ever since Google cancelled Google Reader I've been looking for a new feed reader.  I haven't found one I like so far.  I've tried Feedly, Newsblur, Tiny Tiny RSS and a bunch of others but none of them really did what I wanted, most tried to do too much, all I wanted was a simple and lean feed reader for Android that I could use while commuting to work.  Then I found FeedGoal.  I didn't like the user interface FeedGoal either, but it is open source and had a fairly nicely partitioned backend which would probably be possible to reuse.

So I've been playing around with FeedGoal for a few weeks and ended up writing a completely new user interface for it that I'm pretty happy with.  I've called my application "Weader", a play on my last name which begins with a W and "reader".  Imagine Elmer Fudd trying to pronounce "reader", that's how you pronounce it.

The application doesn't do anything fancy at all, all you get is a list of feeds and when you click on a feed you'll get a list of articles in that feed.  Click on the article and you'll get a full page with the contents and you can swipe left and right to go the next and previous articles.  And that's all there is.  No cloud services, no subscriptions, no sharing of links, no webapps, just reading feeds on an Android phone.

If anyone wants to try it out it's available on Google Play.  And oh, have I mentioned that it's open source and that all the sources can be found on GitHub?

Saturday, August 3, 2013

Coaxial Cables

It's been a long time since I wrote anything here so I guess it's time to write something.  A warning though, this post will talk about coaxial cables, so those with a low tolerance for boredom can stop reading now.

A few years ago I bought a TDR oscilloscope and wrote a bit about how you can use it to measure the performance of different kinds of cable.  So I went out and bought a bunch of different coaxial cables and tried to measure the RF performance of them.  The idea was to see how much difference the cables make before buying half a dozen cables to use in my lab.

My oscilloscope also has a function for Time-domain transmissiometry (TDT).  This functions uses the same pulse generator as the TDR function, but the cable is connected between two ports on the scope and instead of looking at the reflections, the scope will measure the signal that comes out the other end.  The pulse has a 250mV amplitude and a 25ps rise time and for a perfect cable what would be what the scope would show at the other end, but with real cables there will be distortion of the signal.

A square wave is composed of all the odd harmonics of the fundamental frequency for the square wave.  A first approximation of a square wave is just a sine wave, and by adding higher frequency harmonics the shape will get closer and closer to a perfect square wave with vertical edges that are infinitely short.


In the physical world is not possible to have harmonics with infinitely high frequencies, so all actual electrical signals will only approximate as square wave and will have a bit of ringing and non-zero rise and fall times.  The higher the bandwidth of the system the faster rise and fall times it will have and the closer it can get to the ideal square wave.

As a rule of thumb for analog oscilloscopes, the bandwidth neccesary to show a certain rise time is:
bandwidth * risetime = 0.45

So a 25ps risetime requires about 0.45 / 25ps = 18GHz of bandwith. 

This also shows up with cables, cables attenuate signals send through them, and the attenuation is frequency dependent.  Most cables attenuate high frequency signals more than low frequency signals and when measuring TDT this will slow down the rise time of the TDR pulse.  So a cable with higher bandwidth will generally show faster rise times.  A cable with with high bandwidth could have high total losses though, and vice versa.  A mains extension cord has horrible bandwidth but not that much losses, while a thin coax cable can have pretty good bandwidth but high resistance and losses.  Another thing to think about is the impedance of the cable, a thin and flexible cable might get bent or pinched so that the impedance varies and this can cause reflections and losses.



Without further ado, here are the contestants:


 Starting from the left, here are the results.

  1. 75 cm of RG405, a 2.2 mm diameter semi-flexible cable bought from rfsupplier.com.  Semi-flexible means that the cable is fairly stiff and not that easy to work with - you're really meant to connect the permanently and not move it around that much.  The received signal is down at 230mV at the other end, so the total losses are fairly high and the rise time is just below 30ps so the bandwidth is decent.
  2. 75 cm of RG402, a 3.6 mm semi-flexible cable also from rfsupplier.  Not as much losses as with the RG405, the received signal is 240mV and the rise time is also just below 30ps.  I guess this is to be expected, a thicker cable has slightly less resistance and less losses.
  3. 28 cm of semi-rigid cable bought from sdr-kits.net.  This was some surplus cable so I have no idea what the brand of the cable is.  I is short and semi-rigid means that it's stiff and hard to work with and can probably not be bent more than a dozen times without going bad.  It is the best cable I have though, very low losses, the received signal is at 245mV and the rise time is at 25ps, almost identical to the source.  I'm curious to how much of this performance is due to the cable being so short and how much is due to the quality of the cable.  It would be interesting to get a 25cm RG400 or RG402 cable and compare.
  4. 75 cm of RG400, a 5mm flexible cable from rfsupplier.  RG400 is specified to have a "max operating frequency" of 12.4GHz.  It's quite nice to work with since it is fairly flexible.  It did have fairly high losses with 235mV received signal and the rise time was 30ps.
  5. 75 cm of KSR195, a 5mm "low loss" cable from rfsupplier.  The cable is supposed to be a replacement for a standard cable called LMR195.  It's fairly stiff and hard to work with.  Low losses at 240mV received signal and the same 30ps rise time as most other cables.
     
  6. 65 cm of flexible cable from sdr-kits, also surplus with a Huber Suhner sticker on it. The loss was decent at 240mV but the rise time was 33ps, slightly slower than most other cables.  Nice to work with though and the angled connectors make it preferable for some tasks.  I'm also curious to how the angled connectors affect the rise time, does it make any difference or not?
  7. 75 cm of KSR420, a 6 mm "low loss" cable from rfsupplier.  Replacement for standard cable LMR240.  Fairly stiff and cumbersome.  Low losses at 245mV received signal and a rise time of 30ps.  There were noticeable impedance discontinuities at the SMA connector though which showed up in TDR measurements.
  8. 75 cm of KSR400, a 10 mm "low loss" cable from rfsupplier.  Replacement for standard cable LMR400.  Low losses at 245mV received signal and a rise time of 33ps.  Even stiffer and harder to bend than KSR420 and had even more impedance discontinuities in the connector.
     
  9. 50 cm piece of unspecified 2mm flexible cable which is not in the picture.  This is just some cable I had lying around.  Very thin and flexible and nice to work with.  Decent losses at 240mV but slow rise time at 35ps.
What's the result of all this?  Well, the differences were smaller than I expected, all cables are probably good up to 10GHz or so and have reasonable losses.  This informal testing was probably unfair to the low loss cables, they are meant to be used for long distances where loss is very important, testing on a 75cm piece of cable does not show off what they are good at.  I did find a data sheet for LMR400 which says that it is only specified for signals up to 2.4GHz.; according to the rule of thumb above, the 33ps for KSR400 means that for such a short length it had a bandwidth of more than 10GHz.  If I really wanted to test this cable properly I ought to buy 100m of cable and see how it performs. It's probably also kind of dumb to put SMA connectors on such cables since a SMA connector is so small compared to the diameter of the cable, using a N connector would probably work much better. 

So, if you need the best performance, buy a good (and probably expensive) and short semi-rigid cable.  Or call Huber Suhner and buy their Sucotest cable, I've used it before and yes it's expensive but it's also flexible and nice to work with; it's high performance and they will even calibrate it for you so that you know the attenuation for all frequencies up to the specified bandwidth of the cable.  I wish I could afford stuff like that nowdays.

Me, I'll probably buy a couple more cables with RG400, it's flexible nice to work with on a lab bench and has decent performanc.  I must also say that I'm quite happy with rfsupplier, I found them on eBay and they built exactly the cables I asked for at a good price and with fast delivery.  I was a bit worried about buying cables from China, but after measuring the cables rfsupplier delivered and comparing them to other variants I have nothing at all to complain about.  And I'll see if they have some cable similar to the last one in the list, since it's so thin and flexible it's even nicer to work with and for signals up to 1GHz or so it's probably quite good enough.

Monday, April 15, 2013

NFC, vad är det?

Jag har just skaffat en ny Android-telefon med stöd för "NFC".  NFC betyder "Near Field Communication" eller på ren svenska trådlös överföring av information mellan två prylar som är nära varandra.  På svenska brukar man annars prata om beröringsfria kort.  Ett exempel är kortet som används för att åka med Stockholms Lokaltrafik.

Fast NFC är rätt luddigt, det handlar mer om marknadsföring och jag är mer intresserad av tekniken under.  Eftersom jag sitter fast på Arlanda just nu och väntar på ett försenat flyg så har jag passat på att läsa på lite.

Tydligen så stödjer Androids NFC fyra olika olika tekniker för kommunikation med beröringsfria kort:

NfcA - ISO 14443 Type A.  En radiokodningsstandard för hur man skickar data på 13.56MHz och som brukar användas för beröringsfria kort.  Längsta avstånd mellan läsare och kort brukar vara kring 5-10c och man kan få en överföringshastighet på några hundra kilobit/sekund.  Mifare är baserat på 14443 Type A.  Jag jobbat en hel del med Mifare som används i passersystem.  Mifare används också i en en massa betallösningar, bland annat Access-korten som används i Stockholms lokaltrafik, Oyster Card i Londons lokaltrafik och (upptäckte jag idag) tio-kortet på Arlanda Express.

NfcB - ISO 14443 Type B.  En annan radiokodningsstandard som är väldigt lik Type A men lite annorlunda.  "Det som är så bra med standarder, alla har en."  Den stora fördelen med Type B är att man tydligen kan överföra mer energi till kortet än vad Type A kan, så man kan göra mer intressanta saker i korten med Type B.  Det finns en standard som heter iClass som för det mesta använder Type B.

NfcV - ISO 15693.  Ytterligare en radiokodningstandard för 13.56MHz.  Till skillnad från ISO 14443-varianterna så kan den användas på längre avstånd, ända upp till någon meter.  Men man får betydligt lägre överföringshastighet, mellan 5-25kilobit/sekund.  Så för passersystem där man vill kunna öppna en dörr genom att komma nära den så vill man använda ISO 15693 istället för 14443.  Men man har inte tillräckligt med överföringshastighet för att kunna göra speciellt avancerade saker.  I iClass så ingår även ISO 15693.

NfcF - FeliCa.  En standard från Sony i Japan för olika beröringsfria betalkort som också jobbar på 13.56MHz.  Ganska lik ISO 14443 Type A/B men lite annorlunda.  FeliCa var nästan på väg att bli standardiserad som ISO 14443 Type C men det blev inget.  "Det som är så bra med standarder..."  Används för kollektivtrafik på en massa ställen i Asien som Bankok och Hong Kong.  Singapore EZ-Link använde tydligen Felica förut men har bytt till Mifare nuförtiden.

Bara för att vara någorlunda komplett så ska jag väl också nämna att det finns en äldre standard för beröringsfria kort som kallas för "EM Marin" som jobbar på 125kHz.  Överföringshastigheten är väldigt låg och det finns nästan ingen säkerhet, men det är robust och kan fungera på flera meters avstånd.  Om man har beröringsfria kort i huset där man bor så är det förmodligen EM Marin även om det börjar dyka upp Mifare även där.  Vad jag kan se så stödjs inte EM Marin av Android.

Wednesday, November 14, 2012

The Gnome 3 Disaster

Yes, this is yet another rant about Gnome 3.  Others have written about it before, but I just read the announcement that Gnome 3 Fallback mode will be dropped and just need to vent my feelings somewhere.

English is not my native language.  If it was I might have known enough expletives to properly describe my feelings about Gnome 3.  But in short it was a total disaster.

The single biggest mistake made was to break Gnome 2 and make it impossible to have Gnome 2 and Gnome 3 installed on the same machine. This made it impossible for people like me to keep running Gnome 2 when distributions decided to push Gnome 3.  Someone at the Gnome foundation really should have stopped to think for a moment and said:

"Do we really have to break Gnome 2, can't we rename things and tack on a 3 at the end of all incompatible file names and APIs so that Gnome 3 can coexist with Gnome 2?"

But apparently nobody thought that far.  Then former Gnome bigwig "Miguel de Icaza" tries to blamethe Linux developer culture for not caring about backwards compatibility, something that Linus Torvalds did not quite agree with.  What part of "We don't break user space" did the Gnome people miss?

Instead they introduced Gnome 3 Fallback mode which really made nobody happy, it was quite different from Gnome 2 with lots of things broken.  It was a temporary stopgap that obviously would be dropped sooner rather than later when the Gnome 3 people grew tired of it.  And then they act surprised that nobody is willing to step up and maintain it.  And by the way, one of the big reasons to why Gnome 2 and Gnome 3 can't coexist on the same system is the Fallback mode, that's where most of the file name conflicts come from.

What also surprised me a lot was that the Fedora Project seemed to have drunk the cool-aid and pushed Gnome 3 into Fedora. Why didn't anyone at Fedora push back and tell the Gnome people that it simply wasn't acceptable to break Gnome 2 and that they'd have fix it before being included in Fedora?  But no, when Fedora 15 arrived it came with Gnome 3 and no way of running Gnome 2.

At that time I had just bought a new Sandy Bridge based computer which wouldn't run Fedora 14, it required hardware support that was only available in Fedora 15 so I was between a rock and a hard place, run Fedora 14 and go through the pain of trying to add the hardware support for Sandy Bridge by hand, or install Fedora 15 and get the hardware support but be forced to use Gnome 3.  Actually, what I did was to test Gnome 3 for a while and finally realize that I really could not stand it; then I built my own Gnome 2 packages and used those instead. That at least allowed me to get by for a while but it did cost me a lot of time to make everything work and to resolve conflicts later on.

Now we have the MATE Desktop, a fork of Gnome 2 which is available in Fedora 17.  Very good, finally some sanity.  But it does have some problems, mate-applets is missing and I really liked some of the applets that gnome had such as the system monitor applet that shows me CPU/disk/network usage.  Also, since MATE is a fork where everything has been renamed to avoid file name conflicts and legal issues, which means that there is no binary compatibility Gnome 2.  So I've had to redo all my customization of my Gnome desktop by hand.  There are also some regressions where things that used to work well on Gnome 2 no longer work on MATE or are slightly broken.  MATE seems to be actively developed, so this will undoubtedly be fixed sooner or later.

But I'm still quite pissed.  This is the year when Microsoft totally messed up the desktop formerly known as Metro.  Gartner and other organizations have been spewing FUD about "Lost productivity stemming from learning curves and compatibility can eat up direct-cost savings when moving to Linux on the desktop", Well, it would probably have been easier to train a user on Gnome 2 than on Windows 8. The last year has been a lost year for the Linux Desktop and the Gnome Foundation have fumbled away one of their biggest opportunities ever.

What also bugs me is that they don't seem to realize how badly they messed up.  Every time I read something from the Gnome Foundation they keep saying what a success Gnome 3 is and that everyone loves it (well, most users are not savvy enough to recompile Gnome 2 so they have to make do with what the distribution makers hand them, so it's not surprising that most people take the road of least resistance and use Gnome 3 on Fedora or Unity on Ubuntu).  I have not seen one clear message from the Gnome Foundation saying "we messed up, sorry" or anyone from the Fedora Project saying "allowing Gnome 3 into Fedora and breaking Gnome 2 was a mistake".  It probably won't ever happen.

But what I would like to see happening (since going back into time to the beginning of 2011 and stopping them from breaking Gnome 2 is rather tricky) is this:

  • Drop fallback mode from Gnome 3.  It's being done.  Good.
    It should never have been introduced at all.
  • Fix the parts of Gnome 3 that stop it from coexisting with Gnome 2.  Rename executables, icons, files, APIs, D-Bus objects and whatnot in Gnome 3 that conflict with Gnome 2.
  • Allow MATE to continue using all the old Gnome names so that the MATE Desktop actually becomes the Gnome 2 desktop and is compatible with old applications.
  • Don't change Gnome 2/MATE a lot, decide that it is a mature product and only fix things that are obviously broken.  Sure, compatibility with Gnome 3 is nice and maybe newer versions could use some of the infrastructure in Gnome 3 that doesn't break Gnome 2.  Or improving the user experience when mixing Gnome 2 and Gnome 3 applications (for example, making themes apply to both Gnome 2 and Gnome 3 applications so that they look the same).  But don't make any major changes in how Gnome 2 works.
That would go a long way towards fixing things and making up for all the trouble that has been caused.

And it would be very nice if someone from the Gnome Foundation would publically admit that they have made mistakes in how the transition from Gnome 2 to Gnome 3 was handled.  It won't make any difference to how much pain they have caused over the last year, but it would be quite nice anyway.   And it might even mean that we can all learn a bit from this so the next time someone wants to introduce the next new big thing we can avoid the making the same mistakes.  But as long as the Gnome Foundation insists that everything is fine there is no chance of doing that.

Note: even though I personally loathe the way the Gnome 3 desktop works (it's just not made for me and my usage patterns), I have nothing against people trying experimenting with new user interfaces.  Go ahead, "innovate" all you want, but don't break old stuff.  The first releases of Gnome also sucked quite badly and at that time I kept using fvwm2 instead.  But finally I grew tired of recompiling fvwm2 and by that time Gnome had matured and turned into a quite useful desktop.  That's how you make changes, build something new and let Luddites like me use the old stuff, when the new stuff is good enough and has matured we'll join you willingly.  Maybe.

Monday, November 12, 2012

Persistent device naming on Fedora 17

In their infinite wisdom the people behind Fedora 17 decided to remove the udev scripts that provided persistent network names.  I kind of liked those scripts so I just created a small RPM package which just contains the files from a Fedora 16 installation.

So head over to http://code.google.com/p/wingel-udev-persistent-net and try it out.

Saturday, December 3, 2011

A TDR scope

I've gone and bought an old oscilloscope, a Tektronix 11801B.  The 11801 is a 20 year old design, but it still has some pretty impressive specifications: 50GHz analog bandwidth and takes a sample in 10fs (yes, femtoseconds).  With the scope I got a SD-24 sampling module which only has 20GHz bandwidth but it also has a pulse generator to make TDR measurements.

So what is TDR?  It is an acronym for "Time Domain Reflectometry".  What it means is that the scope generates a really fast voltage pulse into a cable and at the same time it is sampling the voltage at the source and showing how the voltage changes over time.  With an infinitely long perfect cable the pulse will travel along the cable forever, but in many cases there are imperfections in the cable that reflect the pulse back to the source and change the shape of the signal seen there. 

There are lots of articles about TDR out there, just google a bit and you'll find a lot of information.  I will just write a bit of what I can measure with my scope.


The SD-24 module has a SMA connector on the front.  If I leave that connector open, the pulse travels from the generator, and reaches the connector.  Since there is nothing there is looks like an infinite resistance so the pulse has nowhere to go and is reflected back.  The reflected pulse is added to the outgoing pulse which doubles the voltage.  This is how it looks at the scope.
Open circuit
The step on the left is the pulse generated by the scope and the step in the middle is the reflection.  I have told the scope to grade the horizontal axis in meters, so the scope tells me that Δm, the distance the pulse has travelled, is about 77.6mm.  Since the pulse has travelled to the connector and back again, the length of the cable between the source and the connector is half of that, Δm/2, which is 38.8mm.  Actually, the scope always measures time, the time between the two steps is about 370ps and assuming that the signal travels at 70% of the speed of light in the cable, the scope calculates that the distance travelled is 370E-2 * 300E6 * 70% = 77.6mm.

If I instead short the output, the pulse is shorted to ground at the end and the voltage of the reflected pulse is inverted, so the sum of the outgoing pulse and the reflected pulse is zero.
Short circuit
Note that the measured length of the cable is slightly longer, which is quite correct since the shorting plug I added to the end of the connector sticks out a bit so the signal has to travel a slightly longer distance.

There are no cables with infinite length, but it is possible to fake it by terminating a cable with a resistor having the same resistance as the characteristic impedance of the cable. Most oscilloscopes and coaxial cables used in a lab have a characteristic impedance of 50Ω, so putting a matching 50Ω terminating resistor at the end will absorb the pulse and there will be no reflection at all.
50Ω termination
Note that there is a bit of a bulge where the terminator is because the SMA connector on the scope or the terminator doesn't have a perfect 50Ω impedance. With a perfect termination there would just be a flat line, but there are no perfect terminators either.

If the termination resistor is larger than 50Ω there will be a positive reflected pulse, but the voltage of the pulse will be less than with an open circuit.  Here the output is terminated with a 100Ω resistor.
100Ω termination
The measured impedance of the cable inside the scope, ρ1, is about 50.20Ω and the measured impedance of the terminating resistor, ρ2, is 99.25Ω.  Pretty good eh?

Similarly, with a smaller terminating resistance there will be a smaller inverted reflected pulse.
25Ω termination
The measured impedance of the terminating resistor is 25.87Ω.

It is quite important to tighten the SMA connectors properly.  This is how the signal looks with the same 50Ω terminator when it hasn't been properly tightened.  Because there isn't a proper connection the impedance becomes higher and a rather big reflection is generated, the measured impedance is 77.87Ω which is quite a lot.
Improperly tightened 50Ω terminator

One of the more practical uses of TDR is to measure the distance to a short or open circuit on cables.  If I attach a matched 50cm long coaxial cable to the connector on the scope, the pulse will travel to the end of the cable before being reflected back. The end of this cable was left open, so the same reflection as with the open port is seen, just delayed a lot.
50cm of coaxial cable
The measured length, which includes the cable inside the scope, is 562mm which matches reality fairly well: about 40mm of cable inside the scope and another 500mm of coaxial cable outside.  The measured length depends on the propagation speed of electricity in the specific kind of coaxial cable used, but normally it's around 70% of the speed of light.  With the exact propagation speed for a certain cable it is possible to get a much better distance measurement.

This kind of measurement is really useful when trying to figure out where a 1000 meter long buried cable has been damaged.  With TDR it's possible to measure the distance to the cut (or short circuit) with a good resolution, so the technicians trying to repair the cable will know exactly where to dig.

Imperfections on the cable will also show up as impedance changes and cause reflections.  This is how a cable looks when it is being pinched hard.
Pinched coaxial cable
Because the shield comes closer to the center conductor when pinched, the impedance becomes smaller.  It's not extremely bad, only 10% difference in impedance, but if this was a TV antenna, this could show up as a ghost image on the screen.  In a high speed digital communications system, the reflection could be bad enough to corrupt data, or at least slow down transmission because a packet of data has to be resent.  TDR can be used to find this kind of imperfections in a 1000 meter cable too.

Sunday, November 27, 2011

SD Sniffer part 2

I've finally had time to play around a bit more with the SD sniffer I designed a few weeks ago.  I started placing all the active components on the board and also got to curse myself for choosing the tiny, tiny, SC70 packages for the comparators.  The SC70 package is tiny and the components  were quite tricky to solder, mostly because I don't have access to a stereo microscope any more.  But it all worked out in the end.

Since I have used the OpalKelly FPGA board before and have a lot of existing code for it, it didn't take long to hack together an FPGA image that could control the D/A converter on the board to set the reference voltage for the comparators.  With that done it was possible to probe the outputs from the comparators with a scope and see that the signals matched the signals on the SD bus.  One of the purposes with this board was to not put too much load on the SD data lines, and this actually seems to work.  I have a high speed SD card which runs at 48MHz which gets a lot of errors if I probe the CLK line with a normal 10x scope probe.  With the sniffer board it works fine at 48MHz without any errors.

A little while later I could actually get the signals into the FPGA and then stream them onto my PC.  The current FPGA image is rather simple, on every SD CLK edge it samples the SD CMD and SD DATA lines and stores them in a FIFO buffer inside the FPGA.  The Cypress FX2 USB controller on the OpalKelly board then streams the data from the FIFO to the PC.   This is basically what the USBee does, so this has the same limitation of 30MHz clock speed on the bus.  So the only advantage so far is that my SD sniffer doesn't affect the SD bus signals as much as the USBee does.

But since I have access to the FPGA on the OpalKelly board there's a lot more that can be done.  The USBee wastes a fair bit of the USB bandwidth since it always transfers 8 bits to the host for each sample.  The SD bus only uses 5 bits per sample, the CMD line and four DATA lines, so 3 out of every 8 bits going over the USB bus are unused.  With the FPGA it's quite simple to pack eight 5 bit samples into five 8 bit words.  So to be able to handle a 50MHz bus it needs 50*5/8 = 31.25MBit/s throughput on the USB bus which is just about what's possible.

But first I'll clean up the existing code a bit and then start working on some way of processing and presenting the raw SD bus data.