Bad cars gone electric

29.10.2011 20:50

Last week Slovenian chapter of EESTEC, the Electrical engineering student's European association, was running a workshop on electric cars in Ljubljana under the title Bad cars gone electric. I attended 6 public lectures on the topic (only 4 of which actually took place) in Center Evropa.

While the lectures provided an interesting insight into the industry behind electric vehicles they left me with few conclusions I can confidently share on.

A good case was made for semiconductor photovoltaics over biological means of converting sun's energy into a form usable in vehicles. Modern mass-market silicon cells achieve around 20% efficiency, while most plants manage to store below 1% of the energy in biomass. It's interesting how it was shown that solar cells on the roof of the car and it's parking spot could cover most of the energy needs required by an average car. But having solar cells on the parking spot at home while your car is with you in the office means you need to either charge another bunch of batteries at home or have enough grid capacity to charge the car there. Also, since a case was made that electric cars are made for the cities of tomorrow, how do you account for multi-story buildings, where not every car owner has a free patch of the sky she can use to top up her battery? Is it really a good idea to cover 1% of land with solar cells, even if it means economically unusable (but probably ecologically the best preserved) 1%?

One thing I haven't heard mentioned before is that you might use all the rechargeable batteries in parked cars as distributed grid energy storage. That might help with the fact that green energy sources tend to be destabilizing as far as energy distribution is concerned and such storage might provide additional stability. But again, you get plenty of problems there. How will you fairly compensate car owners for building and financing a part of infrastructure for you? How will you make sure that the car battery won't be used to stabilize the grid instead of powering my trip to the coast this weekend? Some of the positive effects of this particular idea presented on the workshop simply seemed to challenge the energy conservation law.

An expected solution to an awful lot of unresolved problems or limitations with electric propulsion seem to be smart computer systems of tomorrow. Low range? There will be a smart assistant in every car that will plan your journey to allow for enough charging time. Grid storage using a part of battery capacity? The smart grid will know when you will need your car and use the battery accordingly. Short battery lifetime? Smart charging and discharging controllers will fix that.

I don't believe that I will soon see a computer that will be able to predict to an usable accuracy that I will want to drive to the sea side tomorrow and that it should keep the battery topped up. But even leaving my personal doubts aside, the prospect worries me. It paints a future where everything is interconnected and there is some central intelligence somewhere that collects as much information as it can to predict personal wishes. This has obvious privacy and security issues which have not been addressed.

Depending on intelligent control instead of inherent stability also makes a system vulnerable to disasters. If the stability of the power grid depends on all the little cars being there with their batteries to support it and some intelligence to manage it, what happens when one of these components gets knocked out?

With cars that smart, I also wonder how soon the car companies will start employing software engineers instead of mechanics in their service shops. Recall the recent Jaguar software bug. They say no customers encountered it and the bug only got noticed when an Jaguar employee stumbled upon it. I wonder how many of their customers did notice and report it, only to be dismissed by a mechanic that did not recognize signs of a software bug.

Another problem that seems to be plaguing this industry is that everything must be compared to the regular, gasoline-burning cars. And that inevitably leads to comparing apples to oranges. Are you converting electrical kWh to equivalent liters of gasoline? Well, even for petrol cars the l/100 km figure is of somewhat limited usefulness. It gets even more complicated with CO2 emission figures people are throwing around. On a completely electric vehicle those depend more on how electricity is generated in your country than how much energy the vehicle requires to move around. This all gets complicated enough that numbers from different sources vary to such a degree that it's probably easy to nudge results in one or the other direction, depending on any hidden agendas.

I certainly believe burning oil in internal combustion engines will come to an end sooner or later. But confusing energy storage and primary sources while advertising your solution doesn't help anything but possibly to channel money into the right pockets. I won't believe some internal research that our existing national grid is capable of sustaining 800.000 electric cars while every new power plant is a struggle against environmental laws and not-in-my-back-yard public opinion. Nor when I hear news of over strained high-tension lines from the other side of the argument. It's simply too good to be true.

Posted by Tomaž | Categories: Life | Comments »

It all ends in Spam

22.10.2011 11:57

Back in September, when I was in Nürnberg, I also visited the Verkehrsmuseum. As expected, it houses a detailed history of German railways, from big steam engines of the industrial era to the latest ICE. Surprisingly though, the exhibit continues with a nice collection about post offices and telecommunications.

In the end you finally climb to the top floor and come to a dead end in this hall, lined with the time line of computers and history of the Internet. Past the iPad, at the Spam can, you have to turn around 180 degrees and walk to the exit.

Computer display at Verkehrsmuseum, Nürnberg

I'm not sure if the symbolism here was intentional. In a day you see how the engineering focus turned from efficiently moving physical things to pushing information around. In the end you stand in front of the ubiquitous can of Spam and think, did we really come all this way just to base everything on advertisements?

Posted by Tomaž | Categories: Life | Comments »

ATmega328 development kit

16.10.2011 13:44

Protostack recently sent me their new ATmega328 development kit complete with a USBasp programmer to test and review. A week ago it arrived in perfect condition from Australia, nicely wrapped in antistatic bags and a padded envelope. I've soldered it together and played around with it a bit and have some first impressions to share.

ATmega328 development kit in an antistatic bag

The development kit is in essence a dual-layer PCB with some basic circuitry for supporting a through-hole ATmega328 microcontroller, surrounded with a large prototyping pattern.

Obviously versatility in all respects was a priority. The board has space for either an on-board TO-220 regulator (with two possible pinouts covering the popular options like 7805 and 1117) or a CR2032 battery holder. The 34 page User's Guide contains descriptions of several power supply configurations for either external or internal power.

Ease of connectivity to the microcontroller has been equally well taken care of. Ports are nicely placed in alphabetical order on both sides of the chip so you don't have to memorize the pin-out. There's an an option of either a 6 or 10 pin ISP connector to fit any programmer you might already have. The prototyping area has the layout known from solder-less protoboards: ground and power rails horizontal and signal lines vertical. It can easily accommodate a few DIP integrated circuits and passive elements. Nice addition is also a special place where you can solder an 18-pin flat cable (IDC) connector which is usually a pain on such layouts.

The board is designed so that many can be stacked on top of each other (you can also get stackable PCBs that only contain the protoboard pattern without the CPU). That's why you also get patterns on the edges that can accommodate stacking headers for routing signals between boards.

Assembled Protostack ATmega328 development kit

Assembling it was trivial. Between the step-by-step instructions in the manual and the silk screen showing passive component values it's hard to get anything wrong. The kit includes the CPU on a socket, 10 pin ISP connector for the USBasp programmer and components for an on-board regulated power supply (battery clip isn't included), 20 MHz quartz oscillator and a LC filter for the ATmega's ADC power.

During assembly my only wish would be for thermals around pins on ground planes, which would make soldering them a bit easier. I would also put the 100 nF ceramic blocking capacitor as close as possible to the CPU instead of the other side of a power strip that crosses the board and back. Granted such a board isn't usually used for noise sensitive designs, but it's good practice nonetheless.

Programmer is a GPL design by Thomas Fischl and works with any non-ancient version of avrdude. ATmega328 is famous because of Arduino anyway, so using it with the free avr-gcc stack shouldn't be a problem.

The only snag I hit when I was uploading the first Hello, World! program was that the chip I got with the development board was ATMEGA328-PU, while avrdude only knows so far about the ATMEGA328P-PU. The chips are identical in all respects except that the P version (for picopower) consumes less current. This means that you either have to use the ATMEGA328P profile and force chip signature check with -F flag or patch avrdude with this patch I wrote.

So, to wrap this up. This looks like a nice board for developing a prototype or for one-off projects where you don't want to roll your own PCB. It's not a fully-tricked out affair with included buttons and display, but if you like simplicity it's hard to get more basic than this. At $20.80 it's three-quarters of the cost of an Arduino Uno and gives you the same CPU with more convenient prototyping (if you're used to soldering that is) but omits the integrated USB. It allows you to use a stack of free as in freedom tools to develop and would be a nice start for an open hardware project. Last but not least, Protostack has flat rate worldwide shipping, which is always a nice touch for us in the everywhere else zone.

Posted by Tomaž | Categories: Digital | Comments »

DD doesn't cut it

14.10.2011 23:26

You can add the Seagate Momentus XT to the list of quirky storage devices.

I was cleaning a few disks in the usual way, by overwriting the data with zeros like this:

$ dd if=/dev/zero of=/dev/sdb bs=4096

I don't believe such data is recoverable by any ordinary means, so I don't do overkills like multiple passes with random garbage and such. However I am, as always, wary of broken software that doesn't do what it's told. So I check each disk afterwards by abusing the hexdump utility like this:

$ hd /dev/sdb
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

If all I get back are zeros, nicely collapsed into a single line like in the example above, then the data has been securely erased. I've never actually seen this test fail, until today. Imagine my surprise when hd revealed a good 10 MB chunk of data around 4 GB from the start of the 500 GB drive that should not be there.

I can't attribute this to anything else than some weird firmware bug. dd reported writing 500 GB data as expected. There was nothing in the kernel log. The boundaries of this unerased region didn't have any nice round numbers I could recognize. In the unerased data I could recognize parts of files from the disk (including a full copy of the GPL) although some parts seemed to be partially erased. For instance, one block would have 1 non-zero byte out of 8, another 3 bytes and so on. Again I could find no simple pattern.

A second dd command, targeted at the unerased region did remove the data for good, so it wasn't caused by some permanent error. Just to be sure I also did an ATA Secure Erase on the drive.

Weird. This is a hybrid drive with flash and magnetic storage which means it has a more complicated firmware than ordinary drives, so I guess it's expected to also have more bugs. In fact a search for "momentus xt firmware" reveals a bunch of problems, although none look similar to what I've stumbled upon. I'm just wondering how often such mishaps happen and go unnoticed when the buffer that should be written contains something more important than a bunch of zeros.

Posted by Tomaž | Categories: Digital | Comments »

Receiver module follow-up

07.10.2011 22:15

Here are a few more notes about the 433 MHz super-regen receiver module I've been previously writing about.

I'm trying to make a multipurpose USB-connected receiver for packet transmissions from various sensing devices, like cheap weather stations. For this purpose I attempted to digitize the demodulated signal from the receiver with a USB connected audio interface and write some decoding software on the PC.

It turns out that my first, successful tests of this receiver module on a protoboard were just a lucky coincidence. While the sensitivity and range seem to be exceptional, that also brings a lot of trouble. It's incredibly difficult to avoid interference from near by devices. In one case, for instance, that turned out to be a nearby idle switch-mode phone charger. Running this receiver in the vicinity of (or even powered from) such a lively source of RF energy as a high-speed USB device proved to be especially challenging. The receiver is not very selective, so a very broad range of RF frequencies can trigger a spurious signal on the output. One particularly puzzling example is when I get a 50 Hz signal on the demodulator output when the device is powered from USB and my oscilloscope ground is connected somewhere in the circuit.

When trying to solve this problem I've also stumbled upon the apparently well known fact that multiple super-regen receivers will interfere with each other if they are close by. Apparently the oscillators in both receivers will affect each other and you get impulses on the outputs of both.

Anyway, this is prototype board I'm currently working on:

Prototype USB connected 433 MHz AM receiver

There's the USB interface on the left and the receiver module on the right. What would otherwise just be a couple of straightforward connections between two circuit boards is now a mesh of filter capacitors and resistors. PCB design guidelines for reduced EMI PDF document from Texas Instruments has a good overview of the techniques I used.

I took special care for proper grounding. The other side of the board is a solid grounded copper fill. +5V supply from the USB goes through two RC filters as close as possible to the connector to minimize any length of wire that could act as an antenna. There are additional blocking capacitors as close as possible to the RF and AF parts of the receiver module.

The demodulated signal line has similar RC terminations on both ends to prevent emissions.

The USB part will be completely covered by a grounded metal RF shield. It's the only part that still needs to be done. As it is the receiver still receives mostly interference from the USB bus and I'm hoping the shield will take care of that. If not and it turns out the interference is going out through the wires, I still have a few SMT chokes that might do the trick better than the RC filters I'm using now.

Posted by Tomaž | Categories: Analog | Comments »

Goodbye Zemanta

03.10.2011 23:26

In July I gave my notice. Today I signed off the final agreement. I'm no longer an employee of Zemanta. I don't regret choosing to work there, neither do I regret quitting.

I joined Zemanta just after my graduation in 2007. In part because I was somewhat disappointed at the Faculty I was studying at. Zemanta offered me an interesting challenge in a completely different part of science, opportunity to brush up my software engineering skills and a radical change in environment.

The months we spent on 4 Purves Road was in hindsight one of the most intense periods of my life. Both in the terms of learning new things, writing code and working and living together with a small team in a house in London. It was as close to the top of the world feeling as I got.

Moving back to Slovenia was also moving back to reality. Things we hacked together in London had to be put into production state, maintained and developed further. This was the time I finished up Zemanta's word sense disambiguation engine and in-text links recommendations and started working on a proprietary triple-store. All of which got through several iterations and ended up in a state I was reasonably proud of.

I learned a lot about the facts of real-life programming. The purely engineering work was already replacing research and innovation, but I still felt I was participating in development of something useful. Changing the world wasn't out of the question yet.

Then my work more or less turned into doing data integrations with various corporate customers of the more or less reputable content type. It was the financial crisis and I did what I could to help keep the company afloat, even if that meant a year of boring, repetitive work. I got out of practice with my previous work in natural language processing but did learn how communication between large corporate hierarchical structures is held and how I don't want to be anywhere near such discussions again.

After another round of investment, the crisis was over. The team increased in ranks again in 2011 and I moved away from touching up Excel sheets.

The work became addictive. It was just enough challenging not to be boring, but not breaking a sweat either. Neither could you call it innovative - I'm fairly certain a web crawler has been reinvented a thousand times over. But it was also incredibly rewarding in terms of work done and tickets crossed over. I sometimes spent evenings thinking up architectural changes and hunting little bugs long into the night.

I guess I got scared a little that if I'm not going to break the habit now I'll just keep sitting in this cozy niche.

The work on the aggregator is also characteristic of how my programming practice in Zemanta was turning. I was doing less and less original work and more and more mopping up past mistakes, fixing bugs nobody understood and cleaning up botched code bases. It's hard to keep working in a team where the person next to you might be the next cause of a lost weekend. Bugs bother me, and I tend to fix them.

Early morning in Zemanta office

I was skeptical of the bright new web 2.0 world from the start. But at Zemanta I had the feeling that I was contributing something positive to society. By developing genuinely useful language technologies and bringing them to the people I thought of all the web start-up business as just the current means of funding such development. And I want to believe that I was not alone with this feeling at Zemanta. Things changed and I found myself one day in a company that tried to emulate your average web start-up by catering to the lowest common denominator and having big media for customers and users as the product.

When I'm engrossed in work I tend not to notice such gradual changes in the environment, so the realization was a big disappointment that hit me all at once. It was an incident that got inflated way out of proportion and left me hugely disappointed at the company and people involved. They say that sharing a common goal with people doesn't mean they have the same motivation as you. I guess I learned that lesson the hard way.

The company culture itself changed in a significant way. I was no longer in an enthusiastic start-up but a company that started hiring expensive external consultants to increase productivity. Scrum. Agile development. Consultants that performed a couple of interviews and then came up with recipes that increase productivity 1200% [sic]. Two valued colleagues quit just before I did and that was the first time I heard that the company has management and that you can get in trouble by disagreeing with them. This company's problem is that people answer back too much and don't do what they're told was one memorable quote.

There's a saying that good engineering is beautiful, but beautiful engineering isn't necessarily good. There were good parts, but what I mostly saw in the consultant's work was plastering signs of a good team over the problems even though having those signs doesn't necessarily mean that you're a good team. Meetings after meetings, where nobody listened to nobody. I increasingly got the feeling that my technical knowledge and insight wasn't needed as only short term requirements ever got planned.

For the last few months I was purely running on inertia. It gradually decreased as the team changed and I could no longer feel the attachment I used to.

Sharks by Sam Sandberg

Photo by Sam Sandberg

Quitting was hard for me. Some manage to keep a firm wall between their professional projects and personal feelings. When I take over a project I try to do my best and I can only do that when I get personally involved. That's why it's now hard to leave things behind and wipe the code I've been working on for years from my hard drive. But I just could no longer ignore all the things that have been bothering me in the back of my head.

Last weeks I spent in the office I was working triple time. Closing up current things, interviewing new candidates to replace me and handing off responsibilities to current staff and having what you could consider exit interviews. On Friday around 10 pm I committed my last bug fix, turned off the lights and went home.

I was given the opportunity and means to reconsider my decision in two months, something I feel honored about. But I didn't change my mind.

When I came in today to give my signature I was expecting to go to one last lunch with the former colleagues. Instead, on request from the new lead engineer, I spent the lunch time giving a Q & A about some parts of the codebase.

No, I don't regret quitting. I only regret not being more vocal before the clock rang midnight. Zemanta, if this is the path you chose, I wish you best of luck. I will not follow it.

Posted by Tomaž | Categories: Life | Comments »