DNA - this is the Nature's way to serialize life

Posts from: December '12

Chinese precision FTW!


More importantly, I only ordered one of these (the one on the right), but the chinese figured out they can just ship me a second one, just in case. And they didn't charge me for the second one. Talk about precision!

Posted in category Images -- clock 14 Dec 2012, 13:34, 5 comments


Hardware random generator

I'm getting better at electronics :) When I decide to build something, it now takes me around six hours to complete it. This weekend was in a I'm-somewhat-sick-n-bored mood, so I decided to build a random generator.

And not just a random generator, but an arcade monster! With ridiculously big indicators and buttons! Blinking brightly and stuff...
It would be utilized in board games like The Settlers Of Catan, where you need to throw a pair of dice and sum their roll. In fact, the generator just "rolls two dice", and a jumper determines what to do with the outcomes.

Hardware random generator

Computers usually employ algorithms like LCPRNG (or more sophisticated), with the side effect that whenever a "supposedly random" lottery draw is done on a computer, you'd have a very hard time convincing the average joe that the drawing isn't manipulated :) Luckily, having a more close-to-the-metal access to the hardware allows you to code something like this:

	while not keypressed() {
	return (counter MOD 36);

What do we have here? A counter is incremented extremely fast (thousands and millions times per second). When the button is depressed, the counter immediately freezes at its last value, which is used to determine how did "the dice roll".

Now, imagine highway driving. And in additional to the usual per-kilometre signs, the asphalt is ruled finely, into metres and centimetres. Each centimetre tick has a number associated, and the numbers increase cyclically: 0, 1, 2, 3, ..., 34, 35, 0, 1, 2, ... While driving, you throw a steel ball out of the car. The ball lands somewhere and you take the number, associated with the closest centimetre tick. This is roughly what the code above does - the outcome is essentially random. Then one has to apply some 1:1 mapping between the 36 possible pair-of-six-sided-dice rolls and the numbers, and we're ready.


Here I'm testing some possible layout configurations. I got the huge button from SparkFun.
Image Image


The mandatory breadboard design phase:

Here I put a miniature counterpart of the big red button:


I swore that I'd never use a perfboard again, right? But this project would've been an overkill to do with a PCB, so I used something simpler: a stripboard (a.k.a. Veroboard). This is a prototyping board, which has parallel copper-clad strips. The elements are usually placed perpendicular to the strips, which leads to a characteristic order in the design - all paths are straight (in coherence with the inner peace of someone who grew up in Manhattan or Stara Zagora!).

My first job was to drill four holes with my new toy:

In retrospection, I wonder how I'd lived without a Dremel :)

Soldered some sockets:
Image Image

The strips in these these boards are very long, but are easily teared with a simple tool, so one horizontal may be used to connect several different groups of components. Here: we have to isolate the two sides of the MCU pins, and same for the indicators:


On the plus side for stripboards are: less soldering, very few custom connections, and error tolerance. If you mess up something, it can usually be fixed without desoldering. Run the tool to isolate the wrong part and reroute it somewhere else. On the other side: be careful with soldering, it's easy to introduce tiny "whiskers" of solder, that inadvertently connect neighbouring strips. I had two errors of this kind and debugged them for quite some time...

Filling up with resistors:

...and elements:

Please, install software:

Visibly progresses to near-finished:
Image Image

I decided to put the 7-segment indicators on sockets - they could be soldered directly, too, but that would make the huge space below them unusable.

Finishing touches

Test blink on the segments...:

... and some test digits...:

I imagined the finished thing to be like this:

However, I didn't like the power switch. It's big, and accessing it conveniently would've required drilling a big hole, and would need some redesign due to space constraints. However, I had these cute toggle switches...

So I put into action the other new toy:

Seemed like the drill bit was rotating lazily, but it drilled into the plastic as if it was butter...

Image Image


The timer is at 6 hours and a half after the first photo. Here's how it looks like with the lid closed:

Please, press the button:

Here, you're lucky:

And an useless sign:
something like the electrical equivalent of the code i++; /* incrementing i by one */

Here's it in action: YouTube

In the end, I wanted to make a random generator, but it turned like a lot like a timer-activated bomb (or probably has the looks that Hollywood formed in my imagination).

In conclusion



The C source code is available here.

I'm looking forward to the upcoming holyday season, there would be a lot of Catan, and I'm impatient to test my generator :)

Posted in category Hardware -- clock 9 Dec 2012, 16:09, 3 comments




Open source


+ 2008 (9)
March '08 (2)
April '08 (2)
May '08 (2)
October '08 (1)
December '08 (2)
+ 2009 (8)
January '09 (2)
March '09 (1)
August '09 (2)
September '09 (1)
November '09 (1)
December '09 (1)
+ 2010 (9)
January '10 (1)
April '10 (2)
June '10 (1)
July '10 (1)
September '10 (1)
November '10 (1)
December '10 (2)
+ 2011 (10)
January '11 (3)
February '11 (1)
August '11 (2)
September '11 (2)
October '11 (2)
+ 2012 (14)
January '12 (3)
March '12 (1)
April '12 (2)
May '12 (3)
August '12 (1)
September '12 (1)
November '12 (1)
December '12 (2)
+ 2013 (1)
March '13 (1)
+ 2014 (3)
September '14 (3)
+ 2015 (5)
January '15 (1)
March '15 (3)
May '15 (1)
+ 2016 (4)
June '16 (1)
July '16 (1)
November '16 (1)
December '16 (1)

Last comments:

30 Mar 2017, 13:59 by antfarmer
26 Dec 2016, 17:52 by Private
19 Dec 2016, 23:01 by ицаци
16 Dec 2016, 19:50 by Антон
8 Dec 2016, 01:23 by anrieff
8 Dec 2016, 01:06 by Николай

Valid XHTML 1.0 Strict


linkJoel on Software
linkRidiculous Fish
linkXKCD blag