# The Godot Machine

17,544

91

21

## Introduction: The Godot Machine

What is a Godot Machine?

It is part of the human experience that we can find ourselves in a state of waiting for something that might eventually happen after a long time of waiting, or not at all.

The Godot Machine is a solar-powered piece of electro-"art" that tries to capture the desperate emotion that accompanies possibly pointless waiting.

The name is from Samuel Beckett's famous play Waiting for Godot, in which two men wait for the coming of a certain Godot, who might arrive tomorrow, the day after, or never.

So what does the Godot Machine do?

1. 1. Given some sunshine, a Joule Thief circuit starts charging a bank of capacitors.
2. 2. Once charged to about 5V, the Arduino Nano is powered.
3. 3. The Arduino generates a 20-bit true random number, which is shown on a 4-bit LED bar.
4. 4. This number is compared to another random number, unknown to all, that was stored in eeprom the first time the circuit booted.
5. 5. If equal, the wait is over, the machine stores this fact in eeprom and from now on the green LED and piezo beeper are activated (if there is enough energy).
6. 6. If not equal, hope, despair, repeat.

...also, once in a while the generated number is made audible by the beeper, so you don't actually forget that you have a Godot Machine.

Given that the probability to hit the Godot number is 1 over 2^20 or about one in a million, and the machine is not very fast, especially in winter and autumn, it could take years to find it. Your Godot Machine might even become part of your inheritance. While waiting for it to test the next number, you can fantasize about how your distant great great grandchildren may finally see it come to its conclusion. In short: it's the ideal present for the upcoming holiday season!

## Step 1: The Schematic

The Godot Machine consists of:

-A Joule Thief energy harvester (Q1) that charges 9x2200uF capacitors. For those who suffer from helixaphobia (an irrational angst of inductors, while capacitors and resistors pose no such problem), fear not as no manual winding is required: the coupling is created by placing standard coaxial inductors in each other's vicinity as shown here in the 2nd pic. Awesome trick!

-A discrete transistor power switch (Q2, Q3, Q4), which switches on at 5V1 about and off at around 3.0V. You might want to tune R2-R4 a bit if you use different (general purpose) transistor types.

-An entropy generator (Q6, Q7, Q8). This circuit amplifies the electronic noise present in the environment from microvolts to volts levels. That signal is then sampled to seed a chaos-based (read on) random number generator. A piece of guitar string acts as an antenna.

-A LED-bar with 4 LEDs or 4 red separate LEDs, a piezo beeper and a green LED.

Note that the output of the power switch (collector of Q4) is connected to the 5V pin of the Arduino Nano, NOT to the VIN pin!

## Step 2: Building the Godot Machine

I built the circuit on a piece of perfboard. Nothing special there. The 2V/200mA solar panel is a leftover from another project. The brand is Velleman. It's easy to pry it open using an sharp knife, to drill holes for screws etc. Circuit board and solar panel are screwed on to two pieces of plywood, as shown in the picture. The idea is that the solar panel can be positioned towards the sun on a window still.

## Step 3: The Code: Random Numbers From Chaos?

How are the random numbers made? Well, they are Made With Math!

Instead of using the Arduino random number generator function random(), I decided to write my own Random Number Generator (RNG), just for fun.

It is based on the logistic map, which is the simplest example of deterministic chaos. Here's how it works:

Suppose x is some real value between 0 and 1, then calculate: x*r*(1-x), where r=3.9. The result is your next 'x'. Repeat ad infinitum. This will give you a series of numbers between 0 and 1, as in the first picture, where this process is started for the initial value of x=0.1 (red) and also x=0.1001 (blue).

Now here's the cool part: no matter how close you choose two different initial conditions, if they are not exactly equal, the resulting series of numbers will eventually diverge. This is called 'Sensitive dependence on initial conditions'.

Mathematically, the map equation x*r*(1-x) is a parabola. As shown in the 2nd figure, you can graphically determine the x-series using what is known as a cobweb construction: start from x on the horizontal axis, find the function value on the y-axis, then reflect against a straight line at 45 degrees angle going through the origin. Repeat. As shown for the red and blue series, even if close initially, they completely diverge after about 30 iterations.

Now, where does the 'r=3.9' number come from? It turns out that for low values of r, we get only two alternating x-values. Increasing the r-parameter will then at some point switch to an oscillation between 4, 8, 16 values etc. These branchings or bifurcations come more and more rapidly as r is increased, in what is called a 'period doubling route to chaos'. A plot with r on the horizontal axis and many x-iterates overlapped vertically will result in what is known as a bifurcation plot (3rd figure). For r=3.9, the map is fully chaotic.

So if we calculate many x-updates and sample from them, we get a random number? Well no, at this point it would be a Pseudo Random Number generator (PRNG), since if we always start from the same initial value (after coming out of reset), we would always get the same sequence; aka deterministic chaos. This is where the entropy-generator comes in, which seeds the logistic map with a number created from electric noise found in the environment.

In words, the random number generator code does this:

- Measure the voltage from the entropy generator on pin A0. Keep only the 4 least significant bits.

- Shift these 4 bits into a 'seed' value, repeat 8 times to get a 32-bit floating point seed.

- Rescale the seed between 0 and 1.

- Calculate the average of this seed and x, the current state of the logistic map.

- Advance the logistic map many (64) steps.

- Extract a single bit from the logistic map state x by checking some insignificant decimal.

- Shift that bit into the final result.

- Repeat all steps above 20 times.

Note: In the code, the Serial.println and Serial.begin are outcommented. Remove the // to check the generated random numbers on the serial monitor.

To be fair, I haven't statistically checked the quality of the random numbers (e.g. NIST test suite) but they seem to be OK.

## Step 4: Marvel at Your Godot Machine!

Enjoy your Godot Machine and please share, comment and/or ask if anything unclear.

While you're waiting for the Godot number to be found, please vote for this Instructable in the Made With Math contest! Thanks! Runner Up in the
Made with Math Contest

## Recommendations

I cannot merely stage here how I enjoyed this project. A statue would be the least to give to you. Finally a project that has the possibility to span the generations. You sir, have all my kindest regards!

Cool device but a better name: "The Vampire device" - It sucks the life force (time) from its creator, stays asleep for a century, and when it wakes it again steals the life force of the next person it encounters. Should have made it in the shape of Count Dracula. Oh no, I think it's sucking my life force, too!!!! aaaaaaaaaargh. :)

While writing a reply to your question, I noticed I made another mistake in copying the circuit from my lab notebook. Extremely sorry for that :-/ (bashes head into keyboard). Edited schematic.

So here goes for the explanation:

The transistors Q6-Q8 are DC coupled and all in common-emitter configuration (emitters to supply for PNP, to gnd for NPN). DC biasing is provided by R20-R22. Now, imagine the base voltage of Q8 rises a little bit, then its collector voltage and thus Q7's base voltage will decrease. This increases the collector voltage of Q7 and thus the base of Q6. In turn, the collector voltage of Q6 will decrease. Thus the amplifier is inverting. R21 and R22 divide the collector voltage of Q6 by about 3 and feed this back to Q8's base for the biasing. So if the base voltage of Q8 is about 0.6V, expect the collector voltage of Q6 to be around 3x that or 1.8V. This is assuming the drop across R20, who's job it is to isolate C6 from the base of Q8, is zero, which it isn't due to base current of Q8, so DC voltage at the output will be a somewhat higher than 1.8V. C6 together with R21 and R22 form a low pass filter, so no high frequencies get negative feedback, or stated otherwise, high frequencies are not suppressed by negative feedback.

Total gain is very high: Collector of Q8 sits at 0.6V below supply. Likewise for Q7 (above ground), so both Q8 and Q7 have around 0.6V/4.7k=0.13mA running through them (ignoring base current of next transistor). This gives a transconductance of gm= 5.2 mA/V (recall you get about 40mA/V of transconductance per mA collector current). This gives Q8 and Q6 an unloaded gain of about 5.2mA/V*4.7kohm = 24, give or take. Similarly, for Q6, assuming 2V across R19, the collector resistor of the last stage, we get a gain of 80. Total gain of the 3 stages, should they not load each other, would be a whopping 24*24*80> 46000, for in total 0.63mA of supply current (measured at 4V supply). However the stages load each other a bit, so total gain is going to be lower, but still enough to pick up all kinds of noise from the environment, using a short open lead antenna.

The oscilloscope screenshot shows the collector voltage of Q6 at 4V supply.

Now hope I didn't make any errors here! :-/
Cheers!