Analyzing Low Frequencies

by jaimearavena in Circuits > Software

419 Views, 6 Favorites, 0 Comments

Analyzing Low Frequencies

ejemplo.jpg

Low-frequency electromagnetic signals, in this case below 14 Hertz, reveal interesting phenomena, the most notable being the Schumann resonance, which is believed to be generated by the excitation of lightning storms around the world on the resonant cavity formed by the ionosphere and the Earth's surface. Wikipedia explains this topic very well.

However, receiving these signals is challenging, as the wavelengths are several tens of kilometers long, making practical implementation difficult. In such cases, a magnetic field-sensitive antenna, typically a loop with a few turns, is used.

There are quite a few texts on this subject, and one of them inspired us ten years ago. It was written by Kurt Diedrich for *Elektor* magazine in 2014, issue 10, page 8: “ELF Receiver.” In addition to being an interesting circuit, Kurt provided a program for the 'Processing' language, which is free and serves as the basis for this tool.

Downloads

Supplies

Magnetometro.jpg


- Honeywell HMC5883L Magnetometer.

- ESP8266 Microcomputer.

- Laptop with Processing and the Arduino IDE.

You can see that the budget is very modest.

Analyzer Program

After many trials and errors, and building upon the work of Kurt Diedrich, we can now, ten years later, attempt to make some changes to the suggested program.

The first modification to consider is the advent of integrated magnetometers on a chip. We have used the well-known Honeywell HMC5883L, which can measure with a sampling rate of up to 75 Hertz and a scale from ±0.88 Gauss (88 microteslas). Since the sensor is 12-bit, the LSB (least significant bit) value is 0.4297 milligauss (42.97 nanoteslas), a relatively high value compared to fluxgate technology sensors.

(The Earth's magnetic field varies between approximately 25 and 65 microteslas.)

The new idea is to use the magnetometer as an “antenna.”

To read the magnetometer, we will use the ESP8266 microprocessor from Espressif, a very interesting and affordable chip. When sampled at 30 Hertz with an average of 8 samples, it can give us a sampling rate of about 28 Hertz, which is suitable for our purposes. This frequency is sufficiently far from the powerful 50 Hertz that the power grid heavily contaminates, and the ‘aliasing’ mirror frequencies are also outside our range of interest.

A second modification has been the simplification of Kurt Diedrich's brilliant program, also changing the Fourier analysis routine to an FFT algorithm. With a modern laptop, the power and speed provide much more flexibility than a desktop from 10 years ago.

It should be noted that the sound input of a laptop cannot be used for these analyses, as the frequency response of audio amplifiers is generally not good below twenty Hertz.

The analysis of this type of signal requires storing a large number of points over a long period of time, as these are slow phenomena. The graphical ‘waterfall’ presentation proposed by Kurt Diedrich is quite convenient for obtaining a synoptic view of several hours of recording.

Programs.

On the ESP8266, we have installed a program using the Arduino IDE (also available for free), a magnetometer reading routine provided by Korneliusz Jarzebski in a library available at:

https://github.com/jarzebski/Arduino-HMC5883L

The signal analyzer program itself is written in the interpreted language 'Processing' and can be obtained for free at:

https://processing.org

The magnetometer control code must be uploaded using the Arduino IDE, which is also free. This program reads the data provided by the ESP8266 in frames of 1024 data points and consists of the following routines:


- void setup(): Initializes the values and writes the fixed texts, including a color scale according to relative intensity.

- void draw(): Inputs the data and controls the flow of the process.

- void fft(float input, float real, float imag): FFT routine suggested by ChatGPT.

- void cascada(): Draws the waterfall display according to the color scale. It also shows the spectrum of the current frame and the accumulated spectrum graph filtered with an EMA filter with a coefficient of k=0.2. This can be changed on line 21 of the code in ‘Processing’.

- void resumen(): Creates graphs of the values: RMS, maximum, and minimum range in the two lower windows.

- void reescala(): Once the first frame is read, the corresponding parameters are calculated, some of which are recalculated in each frame.

- int gama(int i): Provides a color code according to the input value, which ranges between 0 and 255.

- void fecha(): Reads the system date and time at the start of the readings.

- void calibra(): Calculates all signal parameters using the first frame as a reference.

- void guarda(): Saves the screen image before restarting the recording.

Adaptation.

The ‘analysis program’ requires certain particular settings to work:

A) On line 52 there is the instruction:

serport = new Serial(this, "COM4", 115200); //<<<<<<<<< ADJUST

As indicated, the expression “COM4” must be set to the USB port to which the sensor is connected through the ESP8266. It is the same port with which the CPU was programmed with the Arduino IDE.

B) On lines 12 and 13 there are the assignments:

float ymax= -240.;//maximum value delivered by the Arduino. IT IS NECESSARY TO KNOW

float ymin= -300; // minimum value delivered by Arduino

These values ​​correspond to the ranges of values ​​that the sensor is actually delivering, which can be determined using the serial monitor of the Arduino IDE.

It is enough to put approximate values, since, as stated, after the first data reading, these values ​​are recalculated with a range of a few units. This should be modified if it is considered that the signal excursion in the next hours is large.

To do this, the following will be modified:

void rescale(){

ymax=max+10;

ymin=min-10;

Data Storage

When 512 frames of 1024 data each have been received, a snapshot of the image is recorded in the form of a BMP drawing, which is saved in the same directory as the program. Since the start date and time are set, it is possible to deduce the exact time of any event, and the analysis can continue for many hours. The name of the saved file is equal to the recording date. The amount of data that has been analyzed in each full screen is 512 * 1024 = 524,288 data. If the reading time of each frame is 36 seconds, we will have 18,400 seconds = 306 minutes = approximately 5 hours and 6 minutes. The size of the captured image file is on the order of 3.2 megabytes.

Naturally, there are “dead times” between each frame and between each data recording, but they are short periods, depending on the type of laptop.

A scale at the bottom of the waterfall graph shows the frame number that has been analyzed, and a green number to the right of the top window indicates the index of the last frame that was completely read.

The recording time depends on the delay with which the sensor measurements are made. A delay on line 132 of the program in the Arduino IDE determines the value. If the delay is increased, the analysis will cover lower frequencies. It should be noted that lower frequencies have a larger margin of error due to the limited size of the measurement span, which is always 1024 data. Therefore, values ​​for frequencies close to zero have been removed from the graphs.

Results.

The laptop screen will show us a set of six boxes, as we see in the initial figure. The first one shows us the captured signal as the values ​​are read in the USB port up to a maximum of 1024 values, that is, a frame.

Then, going down to the left, we have the presentation of the Fourier spectrum of this signal in the format known as “cascade”, in which the relative intensity of each frequency component is encoded according to an arbitrary color scale. This chromatic scale is shown as a line on the far right. This window is very interesting, as it gives us a global and historical view of what was measured.

Below this window is another one that shows us in white the RMS value of the signal for each frame of 1024 values. Similarly, the lower right window shows the signal excursion in each frame, in yellow, i.e. minimum and maximum, as well as the respective average value in red.

Also on the right side, two other windows can be seen: the lower one shows the spectrum of the last frame in blue and the filtered spectrum according to the exponential moving average (EMA) for all the frames already read is superimposed. This filtered spectrum is shown in orange. The units are arbitrary since they depend on the units used in the sensor. The coefficient that governs the EMA filter can be modified in the line:

21 float a=0.2;

The smaller the value of this parameter, the less importance the last measurement has with respect to the previous accumulated history. In this way, the noises tend to remain at a constant and low level but the frequency of a present signal becomes more prominent as more frames are examined. This EMA filter is of the low-pass type so it also helps to dampen aliasing frequencies. There is also an interesting article on EMA filters on Wikipedia.

On the upper right side there is a window that informs us about the value of the maximum frequency found in each sample, in orange.

We must recognize that the program is somewhat intricate as it was modified through trial and error. Any improvement is welcome.

Example.

In the example we presented, we focused on examining the vertical component of the magnetic field in my environment. To do this, in the ESP8266 program, only the following expression was used in line 126:

126 Serial.print(raw.ZAxis);

By changing this section of the program, it is possible to analyze different components of the field or the field as a whole.

The installation we used is in an apartment building in the middle of Santiago, a few hundred meters from the subway and on an intermediate floor, so it is a very adverse environment. However, the results are interesting as we observed a frequency around seven and eight Hertz. We do not dare to claim that this is the Schumann resonance, but we like to believe that it is, although further analysis of more examples and testing in other environments will be necessary.

We currently do not have an explanation for the presence of these frequencies as they could be of human or natural origin. This is part of the charm of low-frequency signal analysis, and any determined explanation will be very welcome.

Improvements to Be Made

The reading method is based on the asynchronous capture of each data point that the ESP8266 delivers to the COM port. Therefore, there may be lost data, and more importantly, there is no guarantee that the data is read at an exact rate. In this case, for example, data is estimated to be read every 33 milliseconds, but every so often, approximately every six or seven readings, there is a 50-millisecond delay in a single reading. This is due to the capture method and the fact that we are using machines that do not operate on a 'real-time' operating system, but rather on the usual ones.

Naturally, there is a limit to the ability to analyze measurements at high speed, so the tool is more useful only for low sampling rates. It seems that below 17 milliseconds, the sensor does not respond well.

To improve the accuracy of the measurements, a better solution could involve capturing the data by generating interrupts directly from the COM port.

Another interesting improvement would be to communicate the sensor with the laptop via WiFi, taking advantage of the wireless capability of the ESP8266. This would allow the sensor to be conveniently placed in locations outside the house.

Conclusion.

Specifically, the tool allows us to analyze a signal both in its low-frequency components and in its amplitude and power in the corresponding windows. The units are somewhat arbitrary since they will depend on the values ​​delivered by the sensor.

It is also possible to analyze other types of signals such as the signals from a seismometer in order to determine the resonance frequency of the building in which it is located or other sensors that may be of interest such as accelerometers, low-frequency barometric pressure waves (infrasound) or environmental variables, considering the delays necessary for the measurement to be significant.

We leave these tools for the entertainment of those interested.