Pimp my miner

For a while now, I thought about mounting a simple display somewhere that shows the most important parameters of my BitCoin miner. First I started with an AtMega equipped with an Ethernet module. But parsing json without any library support became too cumbersome quickly. So I copy pasted together a small python script, and used a nokia display that I already equipped with an i2c interface. If I knew how easy it is, to use those json interfaces, I would have implemented this display project earlier. The code is at the bottom. It is specific to my setup with p2pool and CHF, but it is so easy to change that you can adapt it to whatever your setting is. The python script now runs on an Alix on the same i2c bus as my simple home automation transmitter. Now all that is left to do, is adding a line to /etc/crontab to execute the script once a minute.

As you can see on the image below, the hash rate is too hight for a stock Saturn. That is because I recently added an extension module. So it has now three instead of two hashing modules. All of a sudden, KncMiner announced they had 200 extension modules for the October batch, and that future modules would be incompatible. So, that was pretty much the only chance for an upgrade. My existing power supply should have room for one more module, and they were moderately priced. The demand was high enough that they were sold out in three minutes. The i30 cooler that was recommended was not available at the time, so I had to use an Xtreme rev2. I had a fun time finding out how to correctly mount it. Even for the original, there was no manual or description how to mount it. Just look at the existing modules said someone in the forum.

Continue reading “Pimp my miner”

chording bluetooth keyboard

Wearable computing is much older than Google glass, and even head mounted displays were around for a while. Personally, I’m looking forward to affordable devices of that type. The display seems to be a very good solution, while voice entry can be awkward. The Hak5 podcast aired an episode last year about a guy that has walked around with a head mounted display and a computer in his backpack for a long time. While the display is certainly cool, what was most intriguing to me was the keyboard. He uses a one hand device with key press combinations that he can operate while walking around.

I didn’t find his exact model when searching the Internet, and while there are some devices around in this category, the selection is very sparse. They are called chorded keyboards, and were first introduced in 1968 at what is often called “The Mother of All Demos“. Then I found out that there is an open standard for this sort of thing. It’s called GKOS and stands for Global Keyboard Open Standard. They experiment in lots of different directions, but no commercial product seems to have come out of this so far. Amongst the different experiments, there is an Arduino project to build a GKOS keyboard, but I considered an Arduino with custom buttons too bulky for practical use.

A while ago, I ordered a cheap 6-key HID device that I wanted to use to try GKOS myself. I tried a while with key remapping but to no avail. And I strongly suspected, the device could not handle key combinations at all.

Last week, I somehow remembered my failed past attempts, and thought that a bluetooth device would be cool. I quickly confirmed that all the DIY bluetooth modules that I had were not capable of HID but only UART. Then I found a simple to use bluetooth HID module, that was apparently released just two months ago. What a coincidence!

The first test with the GKOS Arduino code on a breadboard was successful. So, I disassembled the USB device, and re-soldered the buttons to an AtMega8 and added a lithium battery from a defunct tiny quadrocopter.  But after I soldered everything together, only some keys would work. I was sure, an AtMega8 would be able to handle this simple task with ease, but I had to use an Atmega328 to make it work. It costs a few bucks more, but much less than the time for finding out what the problem with the AtMega8 was. I didn’t inspect the code throughly enough yet, but maybe the AtMega8 is just missing some hardware interrupts.

So far, I’m very slow at typing, and I have to peek at the cheat sheet for most characters, but with a bit of training that should improve. My prototype works well for two handed operation, but I think one handed operation would be the way to go, although I don’t know if GKOS is really suited for that.

BitCoin mining pools

As stated in an earlier post, after I was mining for a few days, the 50btc mining pool was hacked. A month later, I’m still waiting for my coins. So I tried some other pools. As advised in many places, I avoided the biggest pools, thus mitigating the risk of a 51% attack. I mined for about three days each with 50btc, slush, bitminter and eligius. Like 50btc, slush and bitminter required registration and payed for the submitted work to an account on the site. You could manually cash out, or define automatic payouts with a threshold. These pools are good for ease of mind when you start mining, or have underpowered hardware, as you get a predictable, steady flow of income. Because these pools pay for submitted work, they have to absorb the risk of bad luck periods. Thats when the pool doesn’t find as many blocks as it statistically should. Because of that, they naturally need to collect higher fees.

The eligius pool has an entirely different strategy. As happened to 50btc, the pools above accumulate funds for payouts, and are thus exposed to hacks. You don’t have to register for eligius. Instead, you just provide your payout address as user name. When a block is found, it is split amongst the miners, and no funds are kept on the server. This manifested in a different action in my bitcoin client. Rather than an usual transaction with an originating address, it showed two hammers, indicating that this came directly from mining. Though not vulnerable to hacks as the other pools, it is still attackable by DDoS. And yes, the BitCoin world is more hostile than the broader OpenSource community. That’s what money does to people.

Then I found what I consider much more in line with the bitcoin spirit: p2pool. It is decentrally organized as peer to peer network, just as bitcoin itself. Having no single point of failure, it is save from both hacking and DDoS attacks. It is very clever how it works: Continue reading “BitCoin mining pools”

revisiting enable_if

It was roughly 2008, when I wanted to make a template function for serialization, only available to container types. Template stuff can become complicated at times, and from reading the documentation boost::enable_if seemed to be just what I needed. I didn’t get it to work, and I blamed Microsoft Visual Studio 2005 for not being standards compatible enough. And somehow I remembered enable_if as being difficult and hard to get to work, despite highly desirable if it would work. I ended up providing explicit template overloads for all the supported container types.

Fast forward to five years later, enable_if made it into the C++11 standard, and I didn’t even notice until reading “The C++ programming language” by Barne Strousup. In the book the facility is presented as a concise template that is easy to use and even to implement. To understand it’s value, let’s start with an example. Suppose, I want to implement a template function to stream the contents of containers to stdout.

#include <iostream>
#include <vector>
#include <list>

template<class ContainerT, class StreamT>
StreamT& operator<<(StreamT& strm, const ContainerT& cont)
{
	strm << '{';
	for(const auto& element : cont)
		strm << element << " ";
	strm << "} ";
        return strm;
}

int main()
{
	std::vector<int> ints{8, 45, 87, 90, 99999};
	std::list<float> floats{3.14159, 2.71828, 0.57721, 1.618033};
	std::cout << ints << floats;

	return 0;
}

So far so good, this does the trick. And the output is just what we expected: {8 45 87 90 99999 } {3.14159 2.71828 0.57721 1.61803 } But now we also write an output stream operator for some user defined interface type. Continue reading “revisiting enable_if”

trading agents

I always considered finance and accounting as the most boring things you can do with a computer. And while you can earn big bucks, working for a Swiss bank, I have always preferred topics with a more physical background.

But BitCoin got me interested in how some aspects of the established financial systems work. Looking at the bitcoin price fluctuations, I long suspected that it should be possible to write a trading agent to exploit the volatility. It could follow some fix pre-programmed rules, or find the rules by itself using machine learning. All the data it would need to work on, is easily available.

Last summer started btcrobot, a service that promised just that. They have a subscription model, and I’m sure, if it doesn’t work out, they still gain and the users loose. I didn’t really want to pay hundreds of dollars just to find out if it works. And to be honest, the whole site smelled like a scam.

So I completed the Coursera class “Computational Investing 1“. It was more about portfolio management and algorithmic trading of stocks. But a lot of the material can be applied to currency trading and in special to bitcoin as well. In the homeworks we built a small trading agent and portfolio optimizer. The main metric we used was the Bollinger Bands technical indicator.

So I started implementing a bitcoin trading agent that would use bollinger bands. I didn’t want to start completely from scratch, so I skimmed through github and sourceforge for a starting point. I selected funny-bot, and started extending it. But soon, my interest switched to other projects. Remember, finance is not my primary interest. In the last months I had an eye on the exchange rates, trying to see how such an agent might perform. And I think it would be very difficult to tune, at least without experience in that field.

Last week I found out again that I suck at trading. The bitcoin price started rising like cracy. I thought if it goes up so fast, it must come down again. In a rush, I sold some of my bitcoins. I wanted to buy again after the price would crash. But the price kept rising, and I would have gotten a lot more if I sold them just two days later. Apparently I was not alone with my false prediction.