Category: Projects

  • sniffing i2c with the BusPirate

    I received my BusPirate v4 a while ago, but didn’t really use it so far. That’s a cool analysis/debug tool for serial buses such as uart, spi, i2c and the like. For me i2c is the most interesting. From time to time, the communication doesn’t work as it should, and so far, I worked it out with trial and error. I hope the BusPirate can be of help in such situations in the future. So, here is my first test run.

    The BusPirate is controlled through an uart textual interface:

    minicom -D /dev/ttyACM1 -b 115200

    When you connect to it, it performs a self test, and then you can choose the mode by entering m. In my case, that’s 4 for i2c. Next I get to choose between hardware and software. I don’t know the implications yet, but what I see is that hardware offers higher speeds, and locks up more often. Then I get to choose the bus speed. 100KHz is the standard. With ? you can always get a list of possible commands. (0) shows a list of available macros. (1) scans all possible addresses for connected devices, just like i2cdetect would do it on the computer. (2) finally is what I was after, that’s the i2c sniffer.

    I was actually hoping it could find out why I’m having problems reading back a simple value from an AtMega8 to a RaspberyPi. The AtMega8 is at address 0x11 and the command to read the value is 0xA1. I verified with a serial connection to the AtMega8 that it has a proper value, but on the RaspberryPi I always get a 0. At least the command was received on the AVR as I could verify with the UART, but writing the value back is the problem. So here is what the sniffer outputs for the attempted read:

    [[[][]][[[0x01+][0x04-[][[0x20+][[[[[][0x20-[][0x4C+][0x04-[][0x24+][0x20-][]]]

    Let’s decipher those numbers. Plus means ACK and minus means NACK. Opening square bracked means start bit, and closing square bracket means stop bit. The expected sequence would be 0x22 (the address for sending to the AVR) 0xA1 (send back which value) 0x23 (the address for receiving from the AVR) 0x08 (or whatever value was stored on the AVR). But the above output doesn’t look like this at all. So, lets try to communicate from the BusPirate to the AVR directly. Here we go: (more…)

  • AtTiny Advent Wreath

    An advent wreath in late spring, you ask? Yes, the timing is a bit off, and that’s not just because the coldest spring in ages has not finished yet. While browsing for the topic of my last post, I discovered a nice little one-evening-project: Geeky advent from tinkerlog.
    I had all the required parts here, so I just gave it a try. The adaptation from the AtTiny13 to an AtTiny45 was straight forward. But finding the right threshold value for the ambient light sensor was a bit trickier. Especially, as the ADC didn’t work at first. That was probably a difference between the two AtTiny’s. But once I configured the ADC properly for the AtTiny45, I flashed it a couple of times with different values, and turned the room light on an off, until I had a good threshold value.
    It’s interesting how the flickering is done with the random values and the manual PWM. And especially, how one of the LED’s is used to sense the ambient light was intriguing. To save battery power during the day, it goes to sleep and waits for the watchdog timer to wake it up. It then senses the ambient light. If it is bright, it goes straight back to sleep. If it’s dark, it lights up the LED’s. Going through the four modes for the four weeks of advent is done by resetting, or just quickly disconnecting the power from the battery.

    But now I look forward for the summer to come, before we can put the mini advent wreath to use…

    As my modified code is so similar to the original, it’s not really worth to create a project on github. So, I just pasted the code below.

    (more…)

  • AtMega breadboard header

    A while ago, I ordered some AtTiny breadboard headers from tinkerlog.com. Unfortunately, they didn’t have any boards for AtMega’s left. The ones for the AtTiny’s are very handy, and I used them whenever prototyping something with an AtTiny. In fact, I used it almost whenever flashing an AtTiny. Many times I wished I had one of these tiny boards for the AtMega’s and at some point I even forgot that they existed. Often times I just included in ICSP header on the stripboard.

    Last week I thought I must have such a board for the AtMega’s as well, and created one with a bit of stripboard. The wiring is not pretty, but the device works well, and is a real help when prototyping.

    Fritzing layout on github

  • Jaguar headliners repair

    Remember the Asterix & Obelix comics, and that the only thing they feared was that heaven would fall on their heads? That happened to me lately. But it was not as bad as that might sound. Well, the joke doesn’t quite work in English. In German, we call the headliners of a car “heaven”. Last summer, when I had the power steering of my vintage Jaguar XJS repaired, the car was in the sun for a few weeks. Thus, the fabric on the inside of the roof loosened and hung down.

    Now, I finally had it repaired. I found a holstery  in Goldau (kk-cabrio). To bring the price down a bit, and also out of interest, we agreed that I would take a day off, and help with the tedious parts. While Kuschj would do the more complicated stuff that requires experience not to break anything.

    That worked out really well. I dismounted and mounted the misc stuff from the car, and helped with the headliners. To make sure the new fabric wouldn’t fall off again, I had to scrub off all the old glue from the pressed glass wool mold. Also the trims at the side of the roof got new fabric. There was a spot which had a hole, that was visible for all of the eleven years I have owned that car.

    In the afternoon, we disassembled the passenger seat. It was in need of sewing on the side.

    After everything is done, it’s now much more pleasant to sit into the old cat.

  • Variable fan speed for the camper

    The T3 VW camper vans came with a three step fan speed switch. Maybe it broke just like that, or maybe it was due to the kids playing with it endlessly. No matter what, the broken switch was a good opportunity for an upgrade. I ordered a 15A PWM motor speed controller which I thought should be big enough. Its potentiometer was broken on arrival, so I got a more rugged one from the local shop.

    Connecting it was more complicated than I thought. With the original three step switch, the motor was directly connected to ground, and the highest tier connected it directly to 12V. The other two tiers had resistors in series. My naive expectation was that the ground would be common between source and motor, in the PWM unit as well. But instead the plus was common and the minus was PWM switched. So I had to search the connection from the motor to ground and cut it.
    In the end, it works like a charm…

  • tinkering with the kids

    This Easter weekends the weather was really crap, so we stayed home. We had lots of time to spend with the kids, and we all enjoyed that. The boys are still a bit too young for the projects I usually do, but we just did our first electronics lession.. Even if Levin didn’t fully understand how a photon derails an electron in the silicon of the solar cell, he still liked to see how the prop blew more air when he better aligned the cell to the sun.

    What you need is just a pack of match sticks, some glue, a small solar cell and a tail boom of a broken RC helicopter.

    Levin also created a Triceratops. You see it on the photos, that’s the dinosaur with the three horns.

  • BitCoin hits CHF 100 mark

    Yesterday one BitCoin was, for the first time, worth more than CHF 100!

    When I first learned about BitCoin in early 2011, CPU mining was still enabled in the default client. I mined for a few days, but it was probably already too late for the CPU. GPU’s took over before that. Last year, you needed FPGA’s to profitably mine, and now it’s shifting over to fully custom ASIC’s. I still sometimes mine with the GPU in the background while the Computer is running anyway, and I don’t use the GPU for anything else. It didn’t find a block so far. But for me that’s kind of like playing the lottery. The chances are slim, but if my computer could find the proper hash, that would cash in 25 BTC at the moment which would equate to CHF 2’500. And that slim chance starts over roughly every ten minutes.

    There is a site somewhere on the net (I forgot the location) where you get free BTC. Back in those days, you got 0.05 BTC. That’s how I started off. This would now equate to CHF 5, but these days you get much less.

    Since July 2011, I accept BitCoins as payment for the paraeasy.ch paragliding tandem flights. In fact only one guy payed that way so far. In October 2011 the flight cost 75 BTC at a rate of less than CHF 3 per BTC. If I still had those 75 BTC, they would be worth a whopping CHF 7’500 today.

    I was thrilled last August, when it had an 80% increase within two weeks. But what happened this year was just insane. The price went from CHF 11 to CHF 110 in just three months. There were weeks with 10 to 15% increase every day.

    The other day I walked past a local bank, and saw an advertisement for a defensive savings plan with an 8 year obligation where you get 1% profit. Of course it’s an unfair comparison. Noone knows what will happen next to the BTC value. It could drop any day for any number of reasons, or it could keep rising. I wouldn’t invest my savings so far.

    There is a lot of speculation going on about the future value of BTC, and how certain events could influence that. Last week I read an interesting article about that. But there is also a lot of speculation about a bubble about to burst. Indeed the recent rise in value was so unnaturally fast, that it looks like a bubble. But such a bubble already bursted in 2011, and BTC recovered remarkably well.

    Let’s not concentrate on the value itself. I think for BTC it would actually be better if the value was a bit more stable. The system was designed as a means to transfer money quick and easy. The main motivator was being able to transfer funds around the globe without waiting for a couple of days to arrive, and paying ridiculous transfer fees, as with current bank wire transfers, credit cards or paypal. That’s where BTC really shines. Of course it’s nice to see the value of your Coins rise, but I hope a possible bubble will not harm the system too much, and I strongly hope if that bubble should really burst, BTC will recover even stronger.

    Update : additional links to good articles:

    The bitcoin bubble and the future of currency

    Are BitCoins the future?

    The target value of BitCoin

    BitCoin in the 3rd world

  • Adding a display to rfid time tracking

    More than a year ago, I blogged here about using RFID to track presence times in the BORM ERP system. I used the system a lot since then. But the BlinkM was really limited as the only immediate feedback channel. To use it with multiple users, a display was needed. The default Arduino compatible displays seemed a bit overpriced, and the Nokia phone that I disassembled didn’t have the same display as I used for the spectrum analyzer. But these displays are available for a bargain from china. The only problem was that the bifferboard didn’t have enough GPIO pins available to drive the “SPI plus extras” interface. But i2c was already configured for the BlinkM.

    So, the most obvious solution was to use an AtMega8 as an intermediary. I defined a simple protocol and implemented it as i2c and uart on the AVR. I also wrote a small python class to interface it from the client side. As I buffer only one complete command, I had to add some delays in the python script to make sure the AVR can complete the command before the next one arrives. Apart from that, it all worked well when testing on an Alix or RaspberryPi. But i2c communication refused to work entirely when testing with the bifferboard. Not even i2cdetect could locate the device. That was bad, since I wanted to use it with the Bifferboard, and the other two were only for testing during the development. I checked with the oscilloscope, and found out that the i2c clock on the bifferboard runs with only 33kHz while the other two run at the standard 100kHz. So I tried to adjust the i2c clock settings on the AVR, as well as different options with the external oscillators and clock settings, but I was still still out of luck. Then I replaced the AtMega8 with an AtMega168 and it immediately worked. Next, I tried another AtMega8 and this one also worked with the Bifferboard. I switched back and forth and re-flashed them with the exact same settings. Still, one of them worked with all tested linux devices, while the other one still refused to work with the Bifferboard. So I concluded, one of these cheap AVR’s from china must be flaky, and I just used the other one. Seems like that’s what you get for one 6th of the price you pay for these chips in Switzerland.

    Apart from the display, I also added an RGB LED that behaves like the BlinkM before. And on top of that a small piezo buzzer. But since I could hardly hear it’s sound when driven with 3.3V, I didn’t bother re-soldering it when it fell off.

    Now, my co-workers also started logging their times with RFID.

    The code is still on github.

  • minimalist lasershow

    For a long time I marvelled at sites with self built laser shows. There is truly amazing stuff out there. But most of them look like really lots of work. And with simple commercial units getting cheaper, I don’t know if all that effort can be justified. So I had a look at the commercial ones, and found out that DMX units are not enough if you want real-time control. I would need an ILDA connection for that. These units start at about CHF300. I’m considering it, but I’m not quite ready for the investment. To get started I wanted to toy a bit really cheap. I saw the posts where they glue mirrors onto loudspeakers for a long time, but that didn’t convince me. Then I saw someone using the lens mechanism of a CD-ROM for both axis simultaneously. That looked more interesting. Too bad, I disposed a CD-Rom drive just a week before seeing this.

    I wasnt keen enough to drive the coils directly from the micro controller as in the instructable. Coils, like motors and relays are inductive loads that can induce high voltages in the opposite direction, once stopped. As the mechanism goes both ways, a h-bridge seemed appropriate. I had some L293D here which fitted the bill perfectly. To draw simple patterns, an AtMega8 should be enough, I thought. Because I had no more fitting sockets, I soldered it directly onto the PCB, hoping I wouldn’t have to remove it.

    As I had no suitable mirror around, I cut out a small piece of a CD. I hot-glued it to a part of a paper clip, which ran through a hole of another small PCB, and hot-glued the other end to the lens. Applying voltage to the coils moved the mirror.

    I wanted to draw a circle, but what I saw at the wall didn’t resemble to a circle at all. Debugging the thing, I discovered, that one of the four PWM outputs of the micro controller didn’t work at all. I read in the Arduino docs, that some PWM pins could be slower, so I avoided these from the start, but one didn’t work at all. I tried a couple of alternatives, also the slower ones, but no. Then I found out that the AtMega8 has only three PWM channels, and I only looked at the Arduino docs for the AtMega168 with which I did the first tests.

    I’m sure with an AVR that has 4 PWM’s and a bit of tweaking, I should get better patterns. But with this design I’ll never get real-time laser show control, and it’s not suitable for ILDA test patterns. But it was fun experimenting nonetheless.

    As usual, the code is at GitHub.

  • my first package in the official debian repository

    I have created deb packages for a couple of years now. Primarily for software that I created myself, or was somehow involved. But sometimes I also packaged stuff that I just used, and wanted to be able to conveniently install and upgrade on different systems. One of these was printrun, a host software for reprap 3d printers. I packaged it, and provided packages for ubuntu in my ppa, and packages for debian in my own little repository. Then one day, Scott, a debian developer contacted me, asking if I was interested in getting the package to a state ready for inclusion in the official debian repository. The debian standards are very high, and so far, my packages didn’t need to meet those standards. But I wanted to improve my packaging skills anyway, and that looked like a great opportunity to learn from someone experienced. (more…)