Modular DIY Geiger–Müller counter

The Geiger–Müller counter is a relatively simple tool to measure ionizing radiation. To increase sensitivity, construction presented here contains three (instead of one as usually) soviet STS-5 lamps. This is important for measurements of natural sources of (low) radiation like soil, rocks (an article about my trip with Geiger–Müller counter on Śnieżka mountain).

Principle of operation of a Geiger–Müller counter

When high voltage (typically 380-420V) is applied to the Geiger–Müller tube, the tube doesn't conducts electricity, but it does conducts for a short period, when radiation particle is observed. Those pulses are observed by the detector. The level of ionizing radiation is proportional to the amount of pulses detected in a constant interval of time (typically from 20s to 2,5min).

Geiger–Müller tube behavior can be described as a "button", that is "pushed" by an ionizing particle.

Homemade Geiger–Müller simplified circuit

Let's go further into the details. Geiger–Müller tube is made of two electrodes, ionizing particle creates a spark gap between them, to reduce amount of current that flows in this situation, a resistor is put in series with the tube. Marked as R1 on above circuit, R6 on below. Typically it's in a range 1-10M, acceptable values are listed in documentation of the GM tube.

There are a different ways to obtain a signal from the tube, in presented here, a resistor is connected in series between the tube and ground, changes of the voltage on the resistor are measured by the detector. This resistor is marked as R2 on above diagram, R7 on below. Typically it's in a range 10-220k.

Similarly to diode, a Geiger–Müller tube has its polarity, when connected in the opposite direction it will work incorrectly.

Below is shown a signal from GM tube when a particle is detected.

The electronic circuit of a Geiger–Müller counter

MC34063 is a DC/DC converter used to produce required high voltage, one of it's advantage over a simple NE555 or similar generators in this circuit is that it can monitor the output voltage and adjusts parameters to make it stable (R3, R4, R5, C3).

IC1A, R8, R9 are used as a comparator to filter out noises and produce binary signal (low=no pulse at this moment, high=pulse is currently being observed). R10, R11, R12 and a bunch of transistors drives LED, a speaker and (as an option) external digital devices, e.g. Arduino, or other evaluation board.

Waring! The device uses high voltage and can lead to unpleasant shock, injury or death. Don't touch the PCB or tubes when power is on.

Deobfuscation JavaScript code - how to start?

The easiest way to obfuscate code is to remove white-spaces that are not necessary and to shorten the names of variables and functions. A couple of years ago a made this simple tool to parse such obfuscated JavaScript code.

An example how the code can look after obfuscation and before passing it to a more readable form is presented below.

(function(){var s=true,t=false,aa=window,u=undefined,v=Math,ba="push",fa="slice",ga="cookie",y="charAt",z="indexOf",A="gaGlobal",ha="getTime",ja="toString",B="window",D="length",E="document",F="split",G="location",ka="href",H="substring",I="join",L="toLowerCase";var la="_gat",ma="_gaq",na="4.8.6",oa="_gaUserPrefs",pa="ioo",M="&",N="=",O="__utma=",qa="__utmb=",ra="__utmc=",sa="__utmk=",ta="__utmv=",ua="__utmz=",va="__utmx=",wa="GASO=";var xa=function(){var j=this,h=[],k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";j.uc=function(m){h[m]=s};j.Nb=function()

[...]

After parsing it to more friendly form, we can spot functions, variables, loops and other things. Although the code still is far from being beautiful, it looks much better.

(function()
{
 var s = true,t = false,aa = window,u = undefined,v = Math,ba = "push",fa = "slice",ga = "cookie",y = "charAt",z = "indexOf",A = "gaGlobal",ha = "getTime",ja = "toString",B = "window",D = "length",E = "document",F = "split",G = "location",ka = "href",H = "substring",I = "join",L = "toLowerCase";
 var la = "_gat",ma = "_gaq",na = "4.8.6",oa = "_gaUserPrefs",pa = "ioo",M = "&",N = " = ",O = "__utma = ",qa = "__utmb = ",ra = "__utmc = ",sa = "__utmk = ",ta = "__utmv = ",ua = "__utmz = ",va = "__utmx = ",wa = "GASO = ";
 var xa = function()
 {
  var j = this,h = [],k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
  j.uc = function(m)
  {
   h[m] = s
   }
  ;
  j.Nb = function()
  {
   for(var m = [],i = 0;
   i<h[D];
   i++)if(h[i])m[v.floor(i/6)]^ = 1<<i%6;
   for(i = 0;
   i<m[D];
   i++)m[i] = k[y](m[i]||0);
   return m[I]("")
   }
  
  }
 ,ya = new xa;
 function Q(j)
 {
  ya.uc(j)
  }
 ;
       [...] 

USB powered thermometer with an interesting data display

Almost each person interested in building electronic devices has built at least one thermometer and power supply in his life. I'm not different, to add to this, today I will present one of my thermometers.

Original concept was different, I wanted to use it as a weather station, wake up, go to my balcony, smoke a cigarette and check what on this device what is the temperature, humidity and air pressure. At the end I decided to build a small thermometer (in future with all mentioned features), that I could plug to my computer and check conditions in my home.

What is nice here is that the data is displayed original way, there are two rows of nine LEDs, if on the upper row second diode is on, and on the bottom row fifth diode is on, then the value presented by the device is 2*10 + 5 = 25. It can sounds complicated at first, but in practice it's fast and intuitive. Below is an example, value presented on the display is 25:

Popularne pytania z rozmów wstępnych dla programisty C/C++

W tym wpisie podzielę się zbiorem pytań, które często powtarzają się na różnych rozmowach wstępnych na stanowisko programisty C/C++. Są to pytania techniczne - nie opisałem tu żadnych pytań miękkich (HR'owych). Spotkałem się z nimi sam (już prawie 10 lat pracy, jak ten czas leci..), a niektóre zadawałem osobiście, gdy byłem po drugiej stronie stołu. Mam nadzieję, że taka lista okaże się pomocna podczas przygotowań do rozmowy.

Na początek pytania związane stricte z C/C++. Kolejność losowa.

  • Czym jest język obiektowy? Czy C++ jest językiem obiektowym (odpowiedź na to, czy jest może się różnić w zależności od tego, jak definiujemy język obiektowy)?
  • Napisz program, który jest poprawny składniowo w C, a nie jest w C++.
  • Czym są słowa kluczowe (w kontekście zmiennej, w kontekście metody) static i const? Co oznacza słowo kluczowe volatile?
  • Czym różni się alokacja pamięci na stosie od alokacji pamięci na stercie? Jak zmienną na oba sposoby? Kiedy stosować jedno, a kiedy drugie?
  • Czym jest smart pointer? Kiedy go stosować? Jakie są rodzaje?

USB sound card made from a broken USB headphones

If you have old USB headphones you can easily transform them to a USB sound. This card can be helpful during testing of home built devices connected to the speaker or microphone ports on the PC (for example A proof of concept of a simple sonar and Constructing a homemade microphone).

I used broken Audio 655 DSP headphones with working electronic inside. They have below features:

  • Powered from USB.
  • Stereo output.
  • Built-in microphone.
  • Mute/unmute switch.
  • Volume up/down switches.
  • Power on LED indicator.

Thermocouple made from a nail and copper wire.

Thermocouple is a simple device to measure temperature by using Seebeck effect where a current is created in a heated conductor. The amount of current depends on temperature and the material from which the conductor was made. It's a common tool when measurement of relatively high temperatures is needed, also a lot of altimeters can measure temperature by using a thermocouple that usually is part of the multimeter set.

The thermocouple consist of two different conductors placed in the same temperature, because each one is made from a different material, the voltage that they produce differs. A thermocouple measure difference between those voltages.

In this post, I will present a simple version of a thermocouple, that I made by myself. If you like the idea of building your own sensors (even just for fun), you might be also interested in articles about home-made photo-element and DYI pressure sensor

I've tried built this sensor as simple as possible, so I used iron nail and a copper wire as parts of the thermocouple. I used a multimeter to measure voltage created by the thermocouple.

Is it possible to write a program in C without using semicolons?

Yes, it's possible! In this text I will show a set of tricks to do it. I will present this on a simple program that that reads two numbers from STDIN and prints theirs sum to the STDOUT.

Normally I would start this program from declaring two variables:

int a, b;

Unfortunately, there's a semicolon at the end of the line. It can be omitted by using variables already declared for the main function:

int main(int argc, char* argv[])

I will use argc as a and argv[0] as b. Normally, next thing would be reading two values from STDIN and placing them in a and b variables. It could be like this:

scanf("%d%d", &a, &b);

Once again, there's a semicolon! This one can be skipped by using 'if' statement:

if (scanf("%d%d", &a, &b)) {}

The same trick can be used for printing to STDOUT:

if( printf("%d", a + b ) ){}

Above code compiles and works correctly, but normally the main function should return zero if everything went OK:

return 0;

This semicolon can't be avoided by using the trick with 'if' statement, but we other construction can help here:

if(brk(0)){}

That's all, below is full source code:

#include <stdio.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
    if (scanf("%d%d", &argc, &argv[0])) {}
    if (printf("%d", argc+argv[0])) {}
    if (brk(0)) {}
}

Leave a comment, if you know other interesting riddles or tricks that can be used here!