Radioactivity meter (radiometer) with Glonass receiver and Wi-Fi data transfer

    The article describes a home-made device for measuring radioactivity, determining the GLONASS \ GPS coordinates and having a Wi-Fi channel. The software of the internal microprocessor and an external program (Visual Basic) for receiving, displaying data and writing them to log files are also described.





    In the past few years, I have been engaged in the design and practical manufacture of various devices for home automation, control and monitoring environmental parameters, in my spare time from my main job. Now I have a lot of free time and I got the opportunity to describe what was done.

    My devices are connected to the home network via Wi-Fi, a silent fanless control machine with a solid-state drive lives in the home network. This machine performs the functions of the kernel of the system, it runs programs for collecting data from a variety of sensors and control programs for external devices.

    The problem that I wanted to solve with a radiometer, I formulated as follows: "I want to have a device that will measure radiation in a general sense." The device must show the level of natural radiation background, respond to changes in this background, have measurement limits not less than the applied sensor and be able to transfer data to an external recorder. It would also be nice to have a search function in the device: when you can move the device near the "hot spot" and find it by changing the readings of the built-in indicators. It would also be nice to have autonomy in nutrition for a while, for example, walk around the cottage and check if everything is in order.

    The first question that needs to be decided is which sensor to use. Studying materials on measuring radioactivity gave me the understanding that the optimal sensor for my task is an ordinary Geiger-Muller sensor. It is traditional to call these devices "Geiger-Muller counter", although in reality they do not count anything, but give impulses to each particle that was able to start the process of avalanche breakdown in the measuring chamber. Therefore, I use the term "sensor." There are a lot of them, for different purposes. I wanted my device to be sensitive enough to beta radiation, and not just gamma. Widespread and cheap (in the range of 200 - 1000 r) SBM20 are insensitive to beta radiation, they do not have a window transparent to beta particles. SBM20 is primarily sensitive to gamma radiation, and to a sufficiently powerful one. It is clear why - they were made for military purposes. The use of such a sensor in a radiometer requires a long accumulation of data for a more or less adequate measurement of the natural background. For SBM20, this time is usually taken 46 seconds, while the number of accumulated pulses is equal to the current value of the gamma background in microroentgen per hour. But I wanted more sensitivity to beta radiation. I did not count on a cataclysm; I was interested in the everyday measurement of small values. If you want to be prepared for a cataclysm - you can search and buy some kind of DP5V from storage, replace three capacitors in it with good film ones and get a military-style device in a green box, foolproof, suitable for measuring radiation up to 200 x-rays per hour in extreme conditions. The use of such a sensor in a radiometer requires a long accumulation of data for a more or less adequate measurement of the natural background. For SBM20, this time is usually taken 46 seconds, while the number of accumulated pulses is equal to the current value of the gamma background in microroentgen per hour. But I wanted more sensitivity to beta radiation. I did not count on a cataclysm; I was interested in the everyday measurement of small values. If you want to be prepared for a cataclysm - you can search and buy some kind of DP5V from storage, replace three capacitors in it with good film ones and get a military-style device in a green box, foolproof, suitable for measuring radiation up to 200 x-rays per hour in extreme conditions. The use of such a sensor in a radiometer requires a long accumulation of data for a more or less adequate measurement of the natural background. For SBM20, this time is usually taken 46 seconds, while the number of accumulated pulses is equal to the current value of the gamma background in microroentgen per hour. But I wanted more sensitivity to beta radiation. I did not count on a cataclysm; I was interested in the everyday measurement of small values. If you want to be prepared for a cataclysm - you can search and buy some kind of DP5V from storage, replace three capacitors in it with good film ones and get a military-style device in a green box, foolproof, suitable for measuring radiation up to 200 x-rays per hour in extreme conditions. the number of accumulated pulses is equal to the current value of the gamma background in microroentgen per hour. But I wanted more sensitivity to beta radiation. I did not count on a cataclysm; I was interested in the everyday measurement of small values. If you want to be prepared for a cataclysm - you can search and buy some kind of DP5V from storage, replace three capacitors in it with good film ones and get a military-style device in a green box, foolproof, suitable for measuring radiation up to 200 x-rays per hour in extreme conditions. the number of accumulated pulses is equal to the current value of the gamma background in microroentgen per hour. But I wanted more sensitivity to beta radiation. I did not count on a cataclysm; I was interested in the everyday measurement of small values. If you want to be prepared for a cataclysm - you can search and buy some kind of DP5V from storage, replace three capacitors in it with good film ones and get a military-style device in a green box, foolproof, suitable for measuring radiation up to 200 x-rays per hour in extreme conditions.

    I also note that there are other methods for recording charged particles, for example, based on scintillation crystals and PMTs. These measurement methods allow you to measure the distribution of the power spectrum of the radiation flux, but for my purpose it is redundant and very expensive.

    So, I need a Geiger-Muller counter with beta sensitivity. Fortunately, these sensors are manufactured in Russia. I chose the Beta sensors. They are produced by NPF Consensus. A very kind and client attitude of the plant employees played a certain role in the decision to buy just such a sensor. I tormented them with silly Dummies and got quite adequate answers to them. To buy a sensor, I had to go to Zaprudnya. This is about 100 km along Dmitrovka, almost reaching Dubna. The desire to see new places also played a role in making the trip decision :)

    The BETA-2 sensor I chose has a mica window of 13.8 cm2 and is sensitive to beta radiation.

    To work, he needs 400v. An important sensor parameter is recovery time. The essence of the sensor is gas ionization in the chamber during the passage of a charged particle and subsequent avalanche breakdown, then additives in the gas come into play and quench the discharge. After quenching, the sensor takes some time to restore sensitivity. This time (the term "dead time") is indicated in the specifications and for Beta-2 specifically is at least 140 microseconds. Recalculation into frequency gives us the maximum frequency of pulses from the sensor in the region of 8 kHz.

    Passport scan:



    There are two methods for collecting data from a Geiger-Muller counter. First, a resistor in the region of 10 megohms is placed in series with the anode and a negative pulse is applied to the registration circuits through a capacitor with a capacity of picofarads and an operating voltage of about 500 volts. The pulse is suitable for direct control of the CMOS chip input.
    The second - a resistor is placed in the cathode circuit and a positive pulse is generated on it, which is applied to the base of the transistor. With this inclusion, a high voltage capacitor is not required.
    The standard method recommended by the manufacturer is to remove the signal from the anode. Specialists of NPF Consensus could not answer why such inclusion is correct. I received an answer later from the author of the PN400 power converter — he believes that a large cathode surrounds the anode and acts as a screen for the anode, and this inclusion reduces interference and the number of false positives.

    Schematic diagram of a radiometer



    Construction photo:



    The signal from the sensor through the forming protective circuits can be directly fed to the microprocessor inputs. But I decided to put an additional forming element on a dual 564AG1 single vibrator. The first one-shot generates a pulse with a duration of 50 μs, and the second –2.5 ms for feeding to the LED. The LED serves as an indicator of operation and allows you to search for a hot spot by the intensity of the blinking of the diode. Initially, I wanted to put two counters - one on beta, the other on gamma. Therefore, a two-channel timer was used and the indicator SMD LED HL2 was put on the output of the first channel of the single-shot.



    After launching the first channel, I was convinced that Beta-2 responds perfectly to the natural background (1), the cost of the second sensor is still high (2) and I also wanted to install a navigation sensor (3). Of these three reasons, a decision arose to change the plan, not to put a second gamma sensor, but to put a navigation sensor.

    Therefore, the SMD LED remained in place, the timing circuits of the second channel AG1 were changed (the resistor was increased from 2 to 100 k) and the output of the second channel was output to a large bright red matte LED on the front panel. A pulse with a duration of 50 μs is clearly visible, but a pulse of 2.5 ms is perfectly visible:



    This hardware solution will work even when Arduino Nano fails, allowing you to navigate in the situation by the frequency of the LED blinking.
    I didn’t make any sound accompaniment, since the main application of the device is the measurement of background activity.

    As the processor of the radiometer, I chose Arduino Nano. The reasons for this choice are the price (200 rubles from China), the small size, the huge number of ready-made solutions and the experience already gained from using such boards in home-made products. The main question was - is there enough processor speed to process pulses quickly following each other? From the study of such devices and descriptions of programs, it became clear that the supply of pulses from the counter to the input of the processor and software testing of the interrupt requires high processor speed and serious programming efforts. However, fortunately, the processor used has three timer counters, two of which can be included in the external pulse counting mode from the external processor foot. This radically simplifies the task. It is enough to reset the counter at the beginning of the measurement cycle and read the number of pulses at the end. The account is executed at the hardware level, without requiring the attention of the processor. The processor resource can be used to exchange data and render the device screen.

    The algorithm for recalculating the number of accumulated pulses for a certain time is based on the nameplate characteristic of the meter:

    Sensitivity to 60 Co imp / μR: 160 ÷ 240

    Ie To calculate the microroentgen per hour, you need to know the number of pulses, the time interval and the sensitivity of the counter. The calculation formula for sensitivity 200 looks like this:

    R = CT / DELTA_T * 18

    Where CT is the number of pulses for the DELTA_T interval in seconds, and R is the current radiation value in microroentgen per hour.

    Those who wish can derive the formula on their own, it’s not difficult at all :)

    A radioactivity measurement is a measurement of the parameters of a stationary random process. The random process is characterized by expectation and standard deviation. The smaller the standard deviation, the more accurately we measured the parameters of the random process. RMSD decreases to a stationary value with increasing number of pulses. Those. the more accurate we want the result, the longer we must take the measurement.

    From a practical point of view, this means that for measuring the background and small fluctuations of this background, the measurement time should be large - a couple of minutes. If we want to use the device to search for a “hot spot”, it is advisable to minimize the time.

    To satisfy both requirements I made an adaptive measurement algorithm. To do this, in the process of counting pulses, the sketch checks the contents of the counter at each pass, and if it is more than a predetermined setting (100), then an early exit from the cycle occurs. If there is no excess, then the count of pulses goes until the time elapses in 120 seconds. Thus, in the background measurement mode, the measurement takes 120 seconds, which gives a standard deviation of 1.3.

    Screenshot of Radiometer, background value measurement:



    If the situation changes dramatically, the count ends much earlier and the readings of both the built-in display and the external receiver are updated much faster. The “100” setting is selected from monitoring the background measurements; in 2 minutes the number of pulses is usually in the range of 50-80. When measuring the activity of the compass, the counting cycle is about 10 seconds, the standard deviation is 17.6:
    Radiometer screenshot, measuring the radioactivity of the old compass:



    Here is this compass:



    Here is a photo of the usual situation, the measured background is 11 mcr / h, which is close to normal for Moscow.



    To supply a Geiger-Muller counter, a stable voltage source of 400 V is required.
    I used the finished PN3-400-0.1M converter, purchased for 750 r. These converters can be purchased via ebay (search for “Geiger counter power supply module dosimeter NEW 1 HV 400V high voltage” or “Adjustable HV high voltage supply module for geiger tube counter and dosimeter”).
    I didn’t want to wait and I found the author of the product (it turned out to be Moscow Region), he recommended one of his representatives in Moscow to me and they brought me to the nearest metro station for cash. There were no problems with the product, it worked right away and does not cause any questions.

    I used a rather large case for the device: Gainta 413, measuring 150 by 80 by 30, bought in Brown Bear. At first I thought of two Geiger-Muller counters - one for beta, the second for gamma. It would be possible in one measurement cycle to obtain data immediately for gamma and beta separately. Space for a second counter was provided above the first. However, after starting the system, I saw that with one sensor the radiometer does what I wanted - it reacts vigorously to background radiation, to an old compass, to crystal objects, to welding electrodes with thorium and to a bag of potassium fertilizers. Therefore, I refused to install a second sensor on the gamut and switched to a backup plan - the deployment of the Glonass \ GPS navigator. The practical benefit was thought like this - found a "hot spot" (for example, at the cottage), wrote down the coordinates, and transferred them to the Ministry for Emergencies for disinfection.

    Beta particles are characterized by low penetration. Even a sheet of paper is a serious obstacle, not to mention the case with a thickness of about 5 mm. To take full advantage of the Beta 2 sensor, I provided an opening round hatch to give beta radiation direct access to the sensor. The round hole in the case is made by a band circular saw on a tree. The cover is made based on the launcher of domestic intercontinental ballistic missiles. On the reverse side are attached flat stoppers from the fragments of a clerical knife, reduced to a rectangular shape on a sharpener. To fix the cover, a magnet from the terminal client kit was used. In this terminal client, such magnets are used as legs. When working with a magnet, you need to remember





    The device of the lower part of the housing with an opening cover for the passage of beta particles:







    Beta-2 sensor is placed on the lower board in the hole slightly larger than the diameter of the counter. Self-adhesive felt circles are installed under the counter, acting as spacers between the bottom surface of the sensor and the body. The mica window of the sensor is very thin and requires careful handling. At the final assembly after debugging, I aligned the sensor with a hole in the case and secured the sensor with hot glue.

    The window must be opened if it is necessary to measure activity or search for a weak beta emitter.
    For example: an old compass with a composition glowing in the dark. With the lid closed - 70 microroentgen per hour. With an open lid - 200 microroentgen per hour.





    Crystal Glass Radioactivity Measurements:





    Navigation module.

    At first I found on ebay GPS \ Glonass a receiver based on UBLOX7m. This device looks like this: It






    connects simply - it is enough to apply power to it (+ 3.3V) and connect the 3.3-volt interface through the series. I used a FT232-based converter:





    The proprietary program allows you to play with the module - get the coordinates of the place, look at the satellites, etc.

    Ublox program screenshot:



    Unfortunately, the module, although it can work with the constellation Glonass, is truncated. Firstly, the module is single-channel - i.e. he can only work with one constellation at a particular moment in time. Constellation switching requires a reboot of the module. Secondly, when the Glonass constellation is turned on, the module stops working with data from the differential correction satellite.

    I wanted the module to work simultaneously with Glonass and GPS. There are such modules, in particular ML8088 of the St. Petersburg company Navia. Unfortunately, I did not find a ready-to-use module suitable for installation in a home-made device. There are ready-made devices on the ML8088, but they were not suitable for my device either in price or in size. And I decided to make my module :). I bought the antenna B35-3556920-AMT03 [GPS / GLONASS] and the ML8088se module in DESSY.RU . A two-system antenna is needed - Glonass and GPS have slightly different carrier frequencies.

    According to the instructions of the manufacturer of the antenna, it should be installed on a conductive base measuring 7 by 7 cm in the center. It was very successful - a 7 by 7 cm square was precisely placed in my case. When designing the GLONASS module, I had to decide how to connect the antenna to the input of the ML8088 module. According to the manual, you must use a microstrip or coplanar line with an impedance of 50 ohms. Such a line requires sufficiently precise conductive stripes on the PCB. It is difficult to make this my favorite method of teething tracks on the board with a clerical knife. Having carefully considered the situation, I decided to do without a microstrip line at all and connect the antenna directly to the receiver input. The manual says - the shorter the transmission line from the antenna to the entrance, the better. So, zero length is optimal. We had to develop the board accordingly from the place of installation of the antenna. However, with a board size of 7 by 7 cm, the displacement of the micromodule does not cause any problems.



    This design required a certain sequence of installation of elements. First you had to glue the antenna, then fit the ML8088 so that the antenna leg went into the recess of terminal 21 and grab the ML8088 in that position. Then mark the position of the ML8088 terminals, remove the micromodule, cut through the tracks. And solder the legs of the chip, taking breaks for cooling. Unfortunately, I was mistaken and did not tin down the deepening of the antenna output before soldering the antenna. The soldering did not work, the system caught a couple of satellites after an hour of work ... After thinking about the situation, I decided to remove the antenna, irradiate the output and solder the antenna back. The difficulty is that you need to simultaneously unstick the antenna from the base and solder the output. But I was lucky - I put the diagnosis “do not drink” correctly and the antenna bounced off the leg as soon as I slightly peeled the antenna off the base.



    When breeding the antenna connection, it is imperative to take into account the requirement from the documentation - the antenna ground must be connected to terminals 20 and 22 and no longer have contact with the common ground. This is necessary to prevent the formation of earthen loops and reduce noise immunity. Pins 20 and 22 of the ML8088 are connected to ground inside the micromodule.

    It turned out that in the factory supply in ML8088sE firmware was flashed that did not support the slow blinking of the output "there is a solution." I contacted the manufacturer and received a new firmware and detailed flashing instructions. Did, everything worked out.

    I want to thank Vladimir Osadchiy (Technical Director of Navia ), who kindly and patiently answered my questions.

    Failed to convert the signal "there is a solution to the navigation problem (GNSS)." This is a signal that flashes with a frequency of half a Hz if the module has solved the navigation problem and the data it provides is correct. The signal amplitude is 1.8 volts and the load capacity of this output is about 2 mA. But the diagram from the manual (ML8088sE inclusion of AppNote 1_1.pdf) did not work.



    It seems - there was not enough load-bearing ability of the output to confidently open the transistor. The effect was strange - if the system did not start correctly - a signal of sufficient level was generated at this output to control the conversion circuit, and the control LED blinked happily at the morse code. And when the system started correctly, the signal amplitude was less and the transistor did not open. According to the developer, the signal should be enough. He brought an oscilloscope from the balcony and made sure that there is a signal, but the level is low, only 0.4 volts ... Vladimir Osadchiy named a specific model of the transistor, which definitely works for him, but I went my own way and applied another garbage comparator LM393 :). I used the second channel of this comparator to indicate the PPS signal. Along the way, I changed the parameters of the 1PPS signal, made a signal with a length of 200 μs.

    The final version of the Glonass \ GPS module looks like this:



    and placed in the case: The



    upper unconnected connector is designed to fill the firmware into the module.
    Yellow rectangle made of soft plastic - remote laying, abuts against Beta-2 when closing the case.

    The ML8088sE module has two serial communication channels. Navigation data goes one by one, debug information or firmware goes by the second. By default, the channels are configured at a speed of 115200. I switched them to 57600. I had to do this because of the speed limits of the second channel of the Wi-Fi module HI-LINK HLK-RM04. Details about it are somewhat lower.

    I used an external backup battery like CR2032. With it, the start of the module is much faster, since everything necessary for quick calculation of satellite positions and from capture to tracking mode is already in memory. In this mode, resetting the module is usually not required. Reset is needed the first time you turn it on or if the module did not start correctly. If the module did not start correctly, the LED for the presence of a solution will cyclically repeat a certain code. Reset brings the module to normal. In my case, a reset was required after soldering the parts. I implemented two independent module reset mechanisms. The first is an ordinary button, recessed in the case, so as not to interfere and so that it is not accidentally pressed. The second is software. At startup, the sketch waits five seconds, then starts receiving data from the ML8088sE. If there is no data for the timeout interval, the sketch resets the module with a negative pulse from pin A0. Important - when starting the module, it is necessary that the reset pin be in a high-impedance third state. Therefore, after issuing a reset command, I put the output of A0 into input mode. The Arduino button and output are connected in the "mounting or" mode.

    My device exchanges with the outside world through the HI-LINK HLK-RM04 Serial Port-Ethernet-Wi-Fi Adapter Module module , which is essentially a mini-router with great features. I use it in the converter mode serial port to Wi-Fi. The device has two ports, one can operate at speeds up to 115200, the second up to 57600. The Glonass navigator is connected to the second port and therefore the exchange rate of ML8088 had to be reduced to 57600. Unfortunately, this module comes from China without an internal antenna and is configured to an external the antenna. In the photo in the store there is an internal chip antenna. I had to buy external antennas such as ANT 2.4 ESG-2400-12 UFL-F in DESSY.RU and demand a comparable price reduction from DX. Similar antennasthere is in DX, it is probably worth buying them immediately when buying a Wi-Fi module. I tried to connect two different whip antennas to the module from some router and a PCI card - it works, but the signal level is about 10 dB lower compared to a flat antenna. Plus, it is much more convenient when placed inside the case.

    The Wi-Fi module has a 3.3 volt output from the internal stabilizer. It is enough to power the Glonass module ML8088sE.

    The first channel is used to work with Arduino. The data generated in the Arduino program (from the radiometer) is sent to the first channel of the Wi-Fi module and transmitted to the home network. They can be received by any program of the PUTTY type, which can be connected to the specified IP address and port. The navigator is connected to the second serial port. Data from the navigator also arrives at the serial port Arduino, the program processes the data from the navigator and displays it on the screen.
    I investigated the issue of using the software serial port, but decided that it would not work reliably and would require programming with a lot of labor. So I came up with a hardware hack :).

    First, let me remind you how the transmission of information on the serial port is arranged. The series signal is transmitted by negative drops from +5 V to 0. In the initial, inactive state, the signal has a high level (+ 5V). Inside the Arduino Nano, the signal from the FT232 output is transmitted to the ATMEGA328P serial input through a 1 kilo ohm protective resistor. Here is a piece of the circuit diagram:



    The top diagram shows the connection of the RX and TX pins inside the Arduino board. The RX Atmega328P pin is directly connected to the leg of the Arduino connector and simultaneously through a 1k resistor to the TX pin of the USB-serial FT232RL converter. This makes it possible to transfer the serial data to the connector leg and the signal will go directly to the desired microprocessor output and be correctly processed if the FT232 output is at a high level. This condition is met when the computer does not send anything to Arduino or Arduino works autonomously without connecting to a computer. In this case, the Atmega328P series input is actually pulled up to 5 volts through a 1 kΩ resistor, as shown in the bottom diagram. In order not to interfere with the regular data transfer from a computer via FT232, you must use an open collector transmitter and put it in a closed state, when it is necessary to ensure full-time operation of the channel series. I just had a certain number of two-channel comparators like LM393, which have an open collector type output.

    The signal from the series port of the Glonass module is transmitted through a comparator with an open collector type output. When the processor is reset, pin A1 rises to the third state. The inverting input of the comparator is actually connected to ground through resistor R11. At the non-inverting input of the comparator there is a positive voltage in the range from 0.4 to 3.3 V. The output of the comparator is in a completely closed state and does not affect the operation of the Arduino. Exchange of a microprocessor with a computer, loading a sketch into memory - everything happens as usual. After starting the sketch, the A1 output is switched to the output mode and a high level of +5 V is set on it. The voltage at the inverting input becomes 1.65 V (half of 3.3 V). The comparator begins to work as a repeater of the signal series from the Glonass module. A sketch reads data from a standard serial port and processes incoming data. When you start downloading a sketch to Arduino, FT232 first generates a processor reset, pin A1 goes into the third state, and the output of the comparator goes into the closed state and ceases to affect the series input of Arduino. Data transfer from the GLONASS module is terminated and the sketch is loaded normally.

    The LM393 comparator was used simply because there were a lot of them in the box on the table, where they got after dismantling from the gas sensor modules. Naturally, to implement such a hack, you can apply another logic element with an output such as an open collector or a control input to translate the output into a third state.
    This method of connecting information flows is called "editing OR".

    Through the second channel of the Wi-Fi module, full communication with the ML8088 module is organized for the Navia Viewer program supplied by Navia. The program can communicate with the module connected via the serial port. I used the Tibbo program to organize a virtual serial port. Tibbo, unlike similar programs, automatically starts and organizes the channel without the need for manual intervention. I also tried Virtual serial port driver from HWGroup . It works, but requires manual manipulation after starting the computer>, this is inconvenient.

    Here are a couple of screenshots:





    Another screenshot, interesting in the presence of a differential correction satellite, is in a blue circle:



    I run this complex in a virtual machine running VMware workstation.
    From the screenshots it can be seen that TIBBO established a connection with 192.168.1.155:8081 and presented it as a virtual serial port COM3. COM3 communication port is set in Navia GLONASS and all this economy automatically takes off steadily when the virtual computer starts.

    Perhaps the authors of Navia GLONASS will be interested in finalizing the program so that it can communicate directly not only with the serial port, but also with the TCPIP channel. Display used

    in the devicewas bought at dilekstrima for about 300 p. The display uses the ILI9341 controller, about which almost everything is known, there are libraries and extensive experience in use. The only subtlety is that the display is powered by +5 volts, and the inputs are rated at 3.3v. If you directly connect nano to Arduino, it will not work, but it will not burn. I used the simplest converter 5 -> 3.3 - sequentially connected 2.7 k resistors. The MOSI signal does not require a resistor - it goes from the display to the processor. The LED signal also does not require conversion.

    To work with the display, the standard TFT v2 library with minor modifications was used. In the standard library, the symbol output highlights the desired points, but does not erase the unlit ones. The first time after erasing the screen, everything will be correct, but the second and subsequent ones will not. Matrix points will only turn on, but not turn off, and after a dozen iterations, a rectangle fully illuminated by the color of the symbol will appear on the screen. I added a slice to the library code that displays the background color at points not used in the symbol.

    Changes to the library code
    old:

    void TFT :: drawChar (INT8U ascii, INT16U poX, INT16U poY, INT16U size, INT16U fgcolor)
    {
    if ((ascii> = 32) && (ascii <= 127))
    {
    ;
    }
    else
    {
    ascii = '?' - 32;
    }
    for (int i = 0; i INT8U temp = pgm_read_byte (& simpleFont [ascii-0x20] [i]);
    for (INT8U f = 0; f <8; f ++)
    {
    if ((temp >> f) & 0x01)
    {
    fillRectangle (poX + i * size, poY + f * size, size, size, fgcolor);
    }

    }

    }
    }

    new:

    void TFT :: drawChar (INT8U ascii, INT16U poX, INT16U poY, INT16U size, INT16U fgcolor)
    {
    if ((ascii> = 32) && (ascii <= 127))
    {
    ;
    }
    else
    {
    ascii = '?' - 32;
    }
    for (int i = 0; i INT8U temp = pgm_read_byte (& simpleFont [ascii-0x20] [i]);
    for (INT8U f = 0; f <8; f ++)
    {
    if ((temp >> f) & 0x01)
    {
    fillRectangle (poX + i * size, poY + f * size, size, size, fgcolor);
    }
    else
    {
    fillRectangle (poX + i * size, poY + f * size, size, size, BLACK);
    }

    }

    }
    }


    I also had to change the pieces of code responsible for kicking the RESET and CS. The library is designed to use pins D4 and D5, and I needed them to work with timers. Therefore, the display pins are connected to pins D8 (Reset) and D9 (CS) and the following changes are made to the code:

    Changes to the library code
    old:

    #define TFT_RST_LOW {DDRD | = 0x10; PORTD & = ~ 0x10;} // Added by Vassilis Serasidis (18 Oct 2013)
    #define TFT_RST_HIGH {DDRD | = 0x10; PORTD | = 0x10;} // Added by Vassilis Serasidis (18 Oct 2013)
    #define TFT_CS_LOW {DDRD | = 0x20; PORTD & = ~ 0x20;}
    #define TFT_CS_HIGH {DDRD | = 0x20; PORTD | = 0x20;}

    new:

    #define TFT_RST_LOW {DDRB | = 0x01; PORTB & = ~ 0x01;} // changed by Sergey Dronsky 26 dec 2013
    #define TFT_RST_HIGH {DDRB | = 0x01; PORTB | = 0x01;} // changed by Sergey Dronsky 26 dec 2013
    #define TFT_CS_LOW {DDRB | = 0x02; PORTB & = ~ 0x02;} // changed by Sergey Dronsky Dec 26, 2013
    #define TFT_CS_HIGH {DDRB | = 0x02; PORTB | = 0x02;} // changed by Sergey Dronsky Dec 26 2013


    The full program text and modified libraries can be taken here.

    In the final version of the device, only the T1 counter is used, which counts pulses from the output of D5. Conclusion D4 remained unused.

    Since the device is designed for use in 24 by 7 mode, I took measures against the effect of screen burnout. All elements displayed on the screen change color randomly and move around the screen a bit randomly too. I can’t say that it is very necessary for proper operation, but it was fun to program :)

    The device is powered through the mini usb connector on the Arduino. An internal battery was not provided, but to ensure the ability to work autonomously - for example, to check the garden plot, a power bank with a capacity of 4000 mah was purchased. Measurements showed that the actual capacity of about 3000 mah, but this capacity is enough for the radiometer to work for more than 10 hours. Walking in the country is enough in excess.
    To receive and process data, use the Radiometer program written in Visual Basic in the Visual StudioExpress 2012 environment.

    The program receives data from the radiometer in the background stream, displays the received data in the form of text and graph:



    The program implements a connection recovery mechanism in the event of a signal loss. If the channel crashes and there is no data after the specified timeout expires, the program will close the channel, clean the “tails” and open the channel again. And it will do so until the connection is restored. In the case of a radiometer, a timeout of 3 minutes is set. The normal interval for receiving data is 2 minutes. The program correctly executes and shuts down - turning on the transmitting module, Wi-Fi access point or any connected equipment along the path of the data stream.
    Channel opening and closing events are logged. A program start and stop event is also noted.
    Data and events are written separately in two separate text files.
    When the timer is activated, once every 10 minutes the program for writing statistics to the log file is executed.

    Upon receipt of data from the channel, they are placed in a buffer, and upon reaching certain conditions, this buffer is sent to the input data processing program. In this program, the condition is that the last bytes of the string are vbCrLf (that is, Hex (0D0A), they are the characters "carriage return" "return line").

    The processing routine checks the input string for formal validity using the regular expression mechanism. If the line has an invalid format, this is noted in the log file. If the string has a valid format, the program splits the string into elements using the regular expression mechanism, resulting in an array of elements.

    Further processing consists in entering the necessary elements into arrays of the “FIFO queue” type (QUEUE).

    The QUEUE array calculates the maximum, minimum, average and standard deviation. To calculate the maximum, minimum and average, the ready-made methods of the queue are used. The calculation of the standard deviation is made by outputting the elements of the queue to the array and processing this array. As far as I was able to understand from the documentation - you can make your own method, but it didn’t work out quickly and I left it for the future :).

    The length of the queue is chosen to be 2400 elements, which, when the interval of data is two minutes, gives about 80 hours ago displaying the background of radioactivity.



    The peak on the graph is the result of presenting the compass.

    The program can be downloaded here

    Description of the sketch in Arduino.

    Block diagram of the sketch:

    Run the program
    Initialize the display
    Initialization of the T1 timer, transferring it to the pulse counting mode from the external input.
    Initialization of the serial exchange at a speed of 57600
    The main cycle of the sketch
    Zeroing the counter
    Remembering the start time
    Receive data from the serial port, search for message 1 ("$ GPRMC")
    Receive data from the serial port, search for message 2 ("$ GPGGA")
    Receive data from the serial port, search posts 3 ( «$ GPVTG»)
    Parsing and displaying data from GLONASS \ GPS
    display current counter status T1
    Checking ending conditions - the time has expired or the counter has counted more than 100 pulses
    Fixing meter readings and timer
    calculation of radioactivity
    display
    Output serial channel

    Description of the output to the integrated display.



    The first line shows the number of detected pulses during the measurement of radioactivity. The number changes approximately once a second.

    The second line shows the calculated value of the radioactivity in the previous cycle.

    Next comes a block of four lines. This is the output of information from the Glonass \ GPS module.

    The first line is the UTC time, date, the number of satellites, the data from which were used in calculating the solution, a sign of a solution (letter A or V)
    095623 140514 08 A - 9:56:23 UTC 05/14/2014 8 satellites and there is a solution.

    The second line is latitude and speed in km \ h.
    5545.13119 N means 55 degrees 45.13119 minutes north latitude

    third line longitude
    03739.20397 E means 37 degrees 39.20397 minutes of east longitude.

    Fourth - speed in miles per hour, angle of movement in degrees and height in meters.

    The output of GLONASS \ GPS data is simplified - parts of character strings are simply displayed without any conversion.

    Next, the maximum value of radioactivity during the observation is displayed.
    A running graph shows the change in radioactivity over time. The graph automatically adjusts to the maximum value in the ring buffer. When presenting the compass, we get the following picture:



    I will be glad to answer questions.

    Also popular now: