Month: December 2014

Marx generators

As you may have noticed we were not able to maintain our post rate during the holidays. We have thus decided to add a workaround for this to our internal rules, so no posts during official holidays in Bulgaria, England and Norway.

Today I would like to introduce you to a very popular High Voltage (HV) generation circuit. Named after its inventor Erwin Marx the Marx generator utilizes a very simple yet efficient high voltage switching scheme without any moving parts or solid-state switches. A circuit diagram describing a Marx generator is shown below:

A Marx generator

A Marx generator

Through the resistors Rc all capacitors are initially charged to V_{in}, when a higher potential is applied on the trigger terminal the first in chain spark gap ignites. The latter process triggers uncontrollable chain reaction which causes all spark gaps to ignite. When all gaps ionise we can ideally (neglecting the spark gap arc’s resistance and Rc) draw the following equivalent circuit:

Marx generator equivalent circuit diagram during ignition

Marx generator equivalent circuit diagram during ignition

Connecting all capacitors in series would mean we have boosted the voltage N times, while using the same (low) dielectric strength of each capacitor. Let’s draw some conclusions out of this as this is my primary motivation for this post, there are a few disadvantages with such schemes which should be noted,

– The circuit operates in a very short transient mode, not usable for constant HV supplies, however this scheme is an excellent dirac function generator
– It has to be loaded, i.e. can not work with very high impedance or no loads
– The spark gap firing voltage (ionisation) depends on the surrounding atmospheric gases i.e. would have a completely different behaviour under vacuum.
– High voltage regulation can not be utilized due to its transient mode of operation (unless an infinitely fast feedback look regulator can be designed in practice)
– Makes an excellent lightning bolt simulator, making it suitable for dielectric strength testing and various physical phenomenon experiments.

To illustrate a bit, here is a picture of an abandoned Marx generator, presumably used for dielectric material (high voltage porcelain insulator) testing.

Abandoned Marx generator, source: photorator.com

Abandoned Marx generator, source: photorator.com

I really want to try out this circuit one day, but hey, maybe you have some caps and resistors lying around the desk? Why not spend an hour time playing with Mr. Marx‘s invention.

Advertisements

Christmastime Number Problem

As we are steadily approaching the Holidays, I’ve decided to contribute a post in the spirit of Christmas!

Before we jump in though, I think a quick introduction to who it is that is writing this is in order:
To start, I was born and raised in Montreal, Canada and I currently work/research on a regular basis with Deyan. My background is in electrical engineering, but that doesn’t mean that’s where my only interests are!  There are so many fascinating topics to explore in this world and limiting ourselves to just one is a shame. Neuroscience, Biology, Physics, Computer Science, Financial Markets – these are all interesting areas and fields which I believe could greatly benefit from increased interaction between one another.  Anyway, so what am I doing here? Simply put, I like the concept of contributing information on a regular basis. As such, I’ve decided to pitch in occasionally as a guest blogger to this 365 day journey of continuous blogging – quite the feat!

Now, back to the problem.

Image by Kris Wilson (http://explosm.net/comics/390)

Image by Kris Wilson (http://explosm.net/comics/390)

As those bright colorful lights start appearing everywhere, it is a telltale sign that it is that family-time of the year again where I’m sure retailers notice a nice bump in sales. Indeed, it is Christmas time, and with that come Christmas carols. This is where our journey begins:

“The Twelve Days of Christmas” is one of those Christmas time songs that is hard to miss. If you have never heard or don’t remember which I’m referring to, give it a quick listen here. From Wikipedia, it is “an English Christmas carol that enumerates in the manner of a cumulative song a series of increasingly grand gifts given on each of the twelve days of Christmas”. Knowing that and having heard the song, the question now is,

What is the sum total of gifts given?

Now, even with just a quick read through Wikipedia, we can find that the answer is 364. However, without manually going through each day and tediously summing everything up, how can we get to that answer? What if the song lasted for 212 days? How many gifts would we get in total then?

Using a computer

If you were going to write a program to do this sum, you could easily implement the calculation using a recursive function. It would look something like this (pseudo-code):

 function GiftCalculator (integer Days) {
if Days = 1 then
    return 1
else
    return (Days + GiftCalculator(Days - 1))
end if
} 

Very simple, very effective, but start plugging in big values and this method will start taking up a lot of time (and memory!). Also, this is essentially the same as doing it tediously by hand, but having a computer do the grunt of the work. This does not TRULY simplify obtaining the answer.

What we are looking for is to obtain a one line function expression. A secret formula that, when supplied with a value of “x”, spits out a resulting value for “f(x)” which corresponds to the total number of gifts given. Something of the form

f(x) = a_{1}x^n + a_{2}x^{n-1} + {...} + a_{n}x + C

Where is the pattern?

Listening to the Twelve Days of Christmas, it is very easy to detect that there is a pattern embedded into the song. It is this same pattern that makes it possible for our brains to predict the progression of the song thus making it possible to jump in and sing along with the carolers (provided you are in the mood – I’m looking at you Ebenezer Scrooge). So, how can we formulate this?

First thing’s first, it’s definitely a sum. Everyday of the song, you receive an amount of gifts that is equivalent to that day’s position (relative to the initial day) plus the amount of gifts received on the previous day. So, on day 4, you would receive 4+(3+2+1) = 10 gifts. What we are then doing is adding up all the gifts received on everyday to obtain a value for the total amount of gifts. Thus, it is a sum and will require the use of the good old \Sigma symbol.

Let’s start of by finding the value of gifts obtained on any given day. As we saw earlier, Day 4 was 4+3+2+1. Following this, Day 5 would be 5+4+3+2+1, which is the same as 1+2+3+4+5. Examining this, we can see that the amount of gifts received on any given day is equivalent to the sum of all the “day numbers” up to and including the day in question. This can be formulated as:

\sum_{i=1}^d i

where “d” refers to the day for which we want to know the amount of gifts and “i” range of integers between 1 and “d”.

This may look a little intimidating if you’ve never worked with sums before, but if you have, you will recognize that this is a geometric series whose result is \frac{d(d+1)}{2}. Just to double check, plugging in with a value of 4 for “d”, we obtain \frac{4(5)}{2} = \frac{20}{2} = 10 which is what we found before. Great!

Next, we want the sum of ALL the gifts over the twelve day period. So, we want the value obtained for Day 1 + Day 2 + Day 3 + … + Day 12. Once again, this is similar to the sum we did above and can be written as:

\sum_{d=1}^t f(d)

where “t” refers to the total amount of days (which in our case is 12), “d” refers to the range of days between 1 and “t” and where f(d) corresponds to the number of gifts received on day “d”.

Now, we already know what f(d) is, we found it previously. It is: f(d)=\sum_{i=1}^d i So let’s go ahead and replace that into our above equation. Doing that we will obtain the following double-sum:

\sum_{d=1}^t(\sum_{i=1}^d i)

As we know what the formula is for the inner sum, this can also be written as:

\sum_{d=1}^t(\frac{d(d+1)}{2})

Further simple simplification gives us:

\frac{1}{2}\sum_{d=1}^t(d^{2}+d)

Which we can then break up as a sum of two sums:

\frac{1}{2}\sum_{d=1}^t d^{2}+ \frac{1}{2}\sum_{d=1}^t d

Looking at the above equation, we are familiar with the term on the right and know that it is equivalent to \frac{t(t+1)}{2} as we did above. However, what about the n^2 term? Well, to our delight this is also a geometric series which can be expressed as \frac{t(t+1)(2t+1)}{6}. Knowing this, we can return to our above equation and replace the sums by their corresponding algebraic expressions:

\frac{1}{2}\frac{t(t+1)(2t+1)}{6}+\frac{1}{2} \frac{t(t+1)}{2}

Finally, the last step is to simplify to obtain a nicer looking algebraic equation:

f(t)= t^3/6 + t^2/2 + t/3

Now, for the moment of truth, let’s plug in a value of 12 for “t”

f(12) = 12^3/6 + 12^2/2 + 12/3
f(12) = 288 + 72 +4
f(12) = 364

…and voila! 364, as expected!

A more creative approach

Great, we have found the answer we are looking for, but was there a different, easier or maybe more intuitive manner to get to this result? Whether the following approach will fulfill those criteria, I can’t claim for sure. When presented to me, it seemed more intuitive for my way of thinking, but that may not apply the same way for others.

Either way, here it is.

Let’s start by making a picture representation of what is indeed happening in the song:

xmas

As we can see, as we progress through the days, the row values increase by 1, but the row lengths decrease by 1. This leads to a sum of the form 12*1 + 11*2 + 10*3 + ... + 1*12, which with a bit of pondering can be formulated as:

f(d) = \sum_{n=1}^d n(d+1 - n)

This is then simplified as follows,

f(d) = \sum_{n=1}^d n(d+1) - n^2

f(d) = (d+1)\sum_{n=1}^d n - \sum_{n=1}^d n^2

f(d) =(d+1)\frac{d(d+1)}{2} - \frac{d(d+1)(2d+1)}{6}

f(d) =\frac{d^3+2d^2+d}{2}-\frac{2d^3+3d^2+d}{6}

f(d)=\frac{d^3+3d^2+2d}{6}

f(d) =\frac{d^3}{6}+\frac{d^2}{2}+\frac{d}{3}

which is what we obtained previously!

And that is it, there you have it. You can now calculate the total amount of gifts given for any variation to the song’s length in days with a quick and simple formula!

**A little additional interesting tangent to this, the sum total of the COST of all the gifts in the “Twelve Days of Christmas” has been used as a tongue-in-cheek economic index. This year’s calculated cost is 27,673.22 USD. Check out how it compares to other years here.

Dithering and is no noise a good noise? – Part one.

The technique which I will try to briefly describe in this post is often referred to as dithering. The term according to Wikipedia comes from the old English word “didder”, meaning to shiver, shake.

During continuous to discrete-time signal conversion a so called quantizer component is used. Quantization in signal processing is a process of converting the information from a fine continuous-time (analog) signal to one represented in finite amplitude steps by sampling. It is important to mention that time sampling (ideally w/o quantization) does not generate noise and if one ensures that the sampling frequency exceeds the Nyquist rate, then a smooth signal is again obtained and no information is lost. In reality however in a sampled system we can not save each sample with its exact value, but instead we often need to quantize (digitize) it and store it with a limited number representation (bits). Having a limited set of numbers means that in reality there would be a discrepancy between the real analog signal and the quantized (digitized) one. Here is a quick sketch showing what I actually mean:

An analog signal and its quantization

An analog signal and its quantization

The analog signal is quantized in a finite set of steps and the error between the real sampled and the converted (quantized) values is shown in the hatched area. Now, it has been shown that with the help of oversampling techniques one can statistically increase the resolution of a quantizer by generally speaking accumulation and averaging.

My post aims to show how the effect of oversampling and therefore Signal to Noise (SNR) ratio can be increased by injecting even more noise into the system. At first glance one might say – no way! However, that’s not always the case. If the quantizer is coarse (so that no circuit thermal noise would influence it much) and if the injected noise (dither) has the right magnitude we can gain a lot. Let’s have a look at a simple and intuitive example. Here is an overview of our system consisting of a signal source x random uniform noise source d and a quantizer (2-bit) to ease-up our drawings later-on.

 

Analog additive dither and a quantizer

Analog additive dither and a quantizer

 

Let’s apply a sinewave x as our input signal and skip adding a dither signal d , then the input and output of the quantizer would look like this:

An ideal quantized sinewave

An ideal quantized sinewave

 

Now if we inject random uniform (a key role, to be discussed in Part 2 of this post) noise d with an amplitude of one least-significant bit (LSB) we can observe the following picture:

A quantized sinewave with additive dither

A quantized sinewave with additive dither

It comes to ones intuition that if we try to average the samples we might actually have done a higher resolution quantization. Think low-pass filtering. However to give a very clear illustration I’ll introduce a numerical example. Consider a DC signal of 2.5 Volts and an ideal quantizer of 2 bits:

An example of DC signal oversampling with and without dither injection.

An example of DC signal oversampling with and without dither injection.

We can see that without any dither the average conversion value is still 3, while by adding dither we randomize the error and after averaging we have gained additional resolution. Obviously my 2.5V example is a bit too idealistic and there is an awful lot more to this, but I just wanted to make my trial at introducing this concept here. Some other day I will write some about analog additive and digital subtractive dither, as well as its impact on images.

Laser rays, beams and divergence

I guess no one says “laser rays” in English, but in Bulgarian the two words for ray (infinitely narrow) and beam (as a shaft or bundle) of light are frequently interchanged. This purely linguistic difference could actually teach us a bit how divergence works.

One of the most well-known and fascinating properties of laser light is that it’s collimated. The beam stays narrow as it propagates in space, unlike the light emitted from the Sun, the lamps at home or any other typical source of light. A truly unique and very useful quality that I will write about in detail some other time.

Now, there is no such thing as perfect collimation and sooner or later every laser beam starts to diverge due to diffraction of light. It is very important to know the divergence of a laser and what is needed for certain applications. This is because, obviously, you cannot have minimal divergence without sacrificing something else. And here comes the ray/beam difference.

divergence

We have a collimated light beam that passes through an aperture with width D. Imagine that’s where the beam leaves the resonator. When it’s free to go, it would slowly start spreading out (divergence) and we could estimate the angle alfa (half the angle of the spread) as seen above. In this case k is a positive constant with value near 1, so we could ignore it. So let’s look at D. If it was indeed a laser ray, that implies that D is zero. But as D approaches zero, alfa approaches infinity which means we get a huuuuge divergence and lasers are supposed to have small(er) divergence angles. That’s why it’s called a laser beam with finite width and the bigger D, the smaller the angle, the better the collimation. But we get a big laser spot. So it’s either a narrowly focused beam with big divergence, or a wide beam with small divergence angle.

Also note that alfa is proportional to the wavelength lambda. Then, if we have a constant width, the laser with the shorter wavelength will have weaker divergence. That’s why there’s an interest in blue lasers: with them more information could be recorded.

More in-depth info awaits in my future post on Gaussian beams.

A short follow-up on RTL-SDR

I am currently at the airport in Zürich and I am waiting for my flight back home. Modern planes are equipped with something called ADS-B (Automatic Dependent Surveillance-Broadcast) transponder which periodically broadcasts location and altitude information to air traffic controllers. The latter system uses the 1.09 GHz band and this frequency luckily happens to be within the range of my SDR receiver. A quick search in Google suggested that the community has developed a set of ADS-B decoders so I decided to try out something called dump1090.

The source code is maintained at github and what you only need to do is fetch the repository and compile the C++ code.

Some quick commands for the lazy ones:

git clone https://github.com/MalcolmRobb/dump1090.git
cd dump1090
make
sudo modprobe -r dvb_usb_rtl28xxu
./dump1090

Not too surprisingly I had excellent signal reception and managed to decode and locate quite a number of airplanes.

Flight number and airplane positions, Snapshot 1

Flight number and airplane positions, Snapshot 1

Flight number and airplane positions, Snapshot 3

Flight number and airplane positions, Snapshot 2

Flight number and airplane positions, Snapshot 2

Flight number and airplane positions, Snapshot 3

 

Isn’t that fantastic? Now by keeping a small receiver in your bag’s side pocket, every time you get to the airport you can not only get live and real information about whether your plane has landed or not, but you can also track its position on the map and judge for yourself whether the airport staff is lying to you or not. In addition, one doesn’t even need to sit close to the information screens as you have your own in front of you.

That was my brief burst of excitement, SDR is very very addictive… off to security check now 🙂

Reception and decoding of POCSAG Emergency Service messages

Lately I have been scanning the frequency spectrum with an R820T and Realtek RTL2832U DVB-T tuner. Scanning the spectrum for mysterious signals and hunting decryption schemes gives me an immense pleasure. With such a module I am able to do frequency sweeps from 24MHz up to 1.8GHz and a few nights ago I spotted some strange Frequency Shift Keying (FSK) bursts at around 153-154 MHz.

POCSAG FSK Signal Reception

POCSAG FSK Signal Reception

 

An initial thought was that these are traffic light or possibly train radio relaying signals as I live close to the train station. I was clearly able to distinguish the FSK modulation but the encoding/encryption schemes used were still a mystery. An initial guess was RTTY, however after spending some time on the problem it appeared that this was the so called POCSAG protocol and the messages transmitted were clearly coming from the ambulance/emergency services.

I found about Elias Oenal / Tom Sailer’s multimon-ng decoder and decided to give it a try. Aaah, it’s so great when you can use things ready made by someone else, although a joke-saying we used to often repeat with colleagues during my bachelor studies in Ruse read “You are not a man if you aren’t writing your hardware drivers on your own!”… After some listening I tuned my receiver on 153.345 MHz and started decoding. (offtopic/public non-encrypted messaage: Simon, if you are reading this, ok, yes, no, agreed, this is not a bravery at all).

A quick command for the enthusiasts: “rtl_fm -g 47.2 -E dc -E edge -f 153.345M -M fm -s 22050 | multimon-ng -t raw -i -p -u -e -f alpha /dev/stdin | grep –line-buffered -i POCSAG > pocsaggrep.txt”

I spotted some quite frightening messages and could not believe that so many accidents are actually happening in right now. Here are some examples of what one can hear/read on these bands. It might not be very politically correct to publish such information, but as there are no names in the messages I am more reliant that is should be OK, for the name of science 😉

POCSAG1200: Address: 432795 Function: 2 Alpha: 22:39-11 11/12/2014 22:38:28 INC 11703852 27D03S 2 SLAIDBURN PLACE, RIBBLETON PRESTON, PR2 6JY Male 30 Years MALE – STABBED GRD 357053 430858<NUL>

POCSAG1200: Address: 640324 Function: 2 Alpha: 22:37-78 11/12/2014 22:35:21 INC 11703843 17D03 PENNY FARTHING THEATRE BAR, 89 ROE STREET, LIVERPOOL CITY CENTRE L1, L1 1EP Female 45 Years fem been on drugs and alcohol/ fallen

POCSAG1200: Address: 40078 Function: 2 Alpha: 22:35-39 11/12/2014 22:34:13 INC 11703838 10C02 BROOK COURT – FLAT 45, MOOR LANE, SALFORD 7 SALFORD, M7 3NF Female 85 Years FEMALE CHEST PAIN GRD 382144 402077

POCSAG1200: Address: 1565498 Function: 2 Alpha: 22:31-32 11/12/2014 22:30:12 INC 11703827 01D01 132 SHEAR BROW, BLACKBURN, BB1 8DZ Female 34 Years Pt condition has worsend- Upper stomach and lower back pain GRD 367963 429071<NUL>

POCSAG1200: Address: 1259918 Function: 2 Alpha: 22:31-70 11/12/2014 22:28:52 INC 11703821 19C03 THE VENUS BUILDING, G4 SECURITY, OLD PARK LANE, TRAFFORD PARK MANCHESTER, M41 7HA Male 55 Years Q ANGINA ATTACK GRD 376491 396927

POCSAG1200: Address: 432795 Function: 2 Alpha: 22:30-10 11/12/2014 22:26:49 INC 11703812 11D02 86 YEWTREE AVENUE, GRANGE/RIBBLETON PRESTON, PR2 6QA Male 1 Months BABY NOT BREATHING GRD 357222 431741

POCSAG1200: Address: 432477 Function: 2 Alpha: 22:29-85 11/12/2014 22:28:40 INC 11703820 09E01 45 BEECHWOOD ROAD, BROMBOROUGH WIRRAL CH62, CH62 7BQ Male 79 Years MALE FALLEN GRD 334376 381540<NUL>

POCSAG1200: Address: 16127 Function: 2 Alpha: 22:27-43 11/12/2014 22:25:05 INC 11703810 30D01 (BLUE ANCHOR, AINTREE LANE, AINTREE L10, L10 2JJ Female 67 Years M F HEAD INJ GRD 337376 398861<NUL><NUL>

POCSAG1200: Address: 134937 Function: 2 Alpha: 22:11-02 FOR YOUR INFORMATION **** ****** HAS LEFT THE INCIDENT SCENE AT SHILBOTTLE NOW, IT APPEARS THAT THE 80 YEAR OLD FEMALE OCCUPANT HAS TRIED TO SET A FIRE IN AN AREA OTHER THAN THE FIREPLACE, ALTHOUGH THERE WAS A FIRE IN THE FIREPLACE, THIS HAS SET FIRE TO CURTAINS WHICH SHE HAS REMOVED AND TRIED TO TAKE OUTSIDE WHICH PROBABLY RESULTED IN HER SETTING FIRE TO HER CLOTHING, SHE MAY BE SUFFERING FROM SOME DEMENTIA AS THERE WERE CORNFLAKES IN THE OVEN. PARAMEDICS INDICATE THAT ALTHOUGH SHE IS SUFFERING 45% BURNS THEY DO NOT APPEAR TO BE TOO DEEP BUT AT THIS STAGE IT IS DIFF

However, it seems like these messages are transmitted nationwide, or? Anyone, ideas? Some addresses listed are not even in the region I am…

POCSAG1200: Address: 14904 Function: 0 Alpha: 23:38-11 POLICE SERVICE OF NORTHERN IRELAND PLS CALL BACK 07989 970 160 RE FESABILITY CHECK
POCSAG1200: Address: 1039155 Function: 3 Alpha: <ACK>/
POCSAG1200: Address: 18743 Function: 2 Alpha: 23:39-15 PLS CALL CHILDRENS CDU ON 26876 – 2ND REQUEST<NUL><NUL>
POCSAG1200: Address: 49263 Function: 2 Alpha: 23:39-95 MEDICAL EMERGENCY – WARD 1 – UHND
POCSAG1200: Address: 311674 Function: 0 Alpha: 23:40-84 THIS IS A PAGER TEST PLS RESPOND VIA RADIO

Here is a short video on rtl_sdr and POCSAG decryption (you will note the discontinuity in the sound, it is due to CPU overload, sorry).

The next interesting miniproject would be live weather satellite multispectral image reception and reconstruction. Once I complete the latter I promise a proper post with more and interesting satellite images, hopefully, luckily, Christmas and New Year are approaching… 🙂

 

 

A very basic study of an optical fiber cable

Following in Deyan’s footsteps, I now present to you my first post. It will be short and simple, but I am just starting to accelerate… Our scientific adventure begins!

An optical fiber is essentially a waveguide for light. It consists of core and cladding and the refractive index of the core is larger than the refractive index of the cladding. Thus the light is confined inside the core due to total internal reflection. This simple concept can be observed here:

Image: Timwether, own work (via Wikipedia)

In order to transmit an image (or a signal in general) we need lots of fibers that, together with a protective tube, form a cable. The distribution of fibers inside the cable may be square or hexagonal. At the Faculty of Physics we studied a hexagonal distribution that we observed with a microscope: it looks like a honeycomb!

So, onwards to the results! Again using a microscope, I measured the diameter of separate fibers and the average is 24 micrometers. For comparison, a human hair’s minimum width is 17 micrometers.

Photo copyright: 1988 Paul Silverman - Fundamental Photographs

Photo copyright: 1988 Paul Silverman – Fundamental Photographs

The diameter of the whole cable turned out to be 3.1 mm and knowing the distribution, we can estimate the cable contains around 14 000 fibers.

Another important feature is the angular aperture of the cable. To measure it, one end of the cable was connected to a power meter and the other end was placed on a special rotating table with a scale. Next, a laser beam was aimed directly at the front surface of the cable and the power was recorded. Then the table was rotated and for every 3 degrees away from the center the power of the transmitted laser radiation was recorded. These are the results, neatly plotted:

power-angleIt is observed that around 10 degrees away from the central position (in each direction), the performance is pretty much the same. Further to the left/right, power drastically decreases.

Finally, a few words about the optical resolution of the cable. It is practically a raster optical system as each fiber transmits a certain part of the image, resulting in a grain structure, so the resolution depends on the diameter of the fibers. My estimate using an optical resolution test chart is 21 lines per mm. Is that enough? Well, considering the applications, maybe! Comparing it with the resolution of a typical diffraction grating though, it’s almost nothing. I will further explore this topic when I have the time.