Home Brew Lightning Detector (HBLD)

Contents:
  1. Overview of the Wisdom-Beet or Homebrew Lightning Detector
  2. Capture Antenna Circuit
  3. STMicroelectronics STM32 NUCLEO F767ZI
  4. GPS Reciever - Ublox NEO-7M
  5. GPS active antenna - Generic
  6. Rpi3B for Monitoring and Logging
  7. Antenna Construction
  8. The USB Connection for Power and Communication
  9. ac6 - STMicroelectronics STM32System Eclipse Workbench
    1. Installation on a 32bit Raspberry Pi 3
    2. Installation on a 64bit Ubuntu Workstation
    3. General Documentation and Support for the STM32 IDE
  10. STM32Cube initialization code generator
  11. Setup the capture application
  12. FreeRTOS
    1. Light weight Internet Protocol (lwIP)
  13. Install the Github package
  14. Download the Source Code from Github
  15. Java Runtime
  16. STLink Open
  17. Building the CodeTyphon IDE
    1. MESA Computer Graphics
    2. A Side Note
    3. Pilot Logic's CodeTyphon
  18. Build the Data Relay Application "captofile1"
  19. The STM32CubeMX MicroXplorer Code Generator
  20. Editing the STM32 Include files
  21. Build the SMT32 Firmware using STM32SystemWorkbench
  22. Load the compiled firmware to the STM32 processor
  23. Configuring the Data Relay and Monitoring the System (Captofile)
  24. Loading the Binary Version
  25. Monitoring the Serial Port
  26. Viewing The Results
  27. MTU and the UDP Fragmentation Issue
  28. Frequently Aasked Questions

[Top][Home]

Note that as of October 2020 the Splat V1.0 daughter boards is available for the NECLEO STM32.
The Splat Board - NEW daughter board 2020

Image
My Version of the Homebrew Lightning Detector (HBLD)

Overview of the Wisdom-Beet or Homebrew Lightning Detector

Bob VK4YA and Paul VK4PLY from the Bayside District Amateur Radio Society have been doing some excellant experimental work on lightning ground strike detection making use of a STM32F7 processor. They have undertaken this work independantly of the Blitzortung Project. Their objective is to obtain more accurate location of local strikes rather than world wide perspective. It is based on the Nucleo-144 demoboard, STM32 F767ZI and the Neo7 GPS unit. The project is in the early stage of development but they are making significant advances.

Image
Lightning Detector


[Top][Home]

Capture Antenna Circuit

Image
Antenna Circuit - compoment values are not critical


The Antenna is not tuned to a frequency and is designed for broardband digital sampling.
Connection of Antenna circuit to the STM323 board: [Top][Home]

STMicroelectronics STM32 NUCLEO F767ZI

The Connector Layout is shown here: STMicroelectronics STM32 NUCLEO F767ZI

[Top][Home]

GPS Reciever - Ublox NEO-7M

The GPS reciever details can be found here: GPS Reciever - Ublox NEO-7M Connections to STM32 board:

[Top][Home]

GPS active antenna - Generic

GPS active antenna - Generic

[Top][Home]

Rpi3B for Monitoring and Logging

If monitoring and debugging is required then a Raspberry Pi is required to run a capture application with space on a sdcard to store data.

[Top][Home]


Antenna Construction

The antenna wire consists of a few meters of coax connected to the breadboard at one end as per the circuit diagram above, and then several meters of single wire. The unshielded part the antenna should be kept away from any source of electrical interference so false signal are not received.

[Top][Home]

The USB Connection for Power and Communication

A USB A to micro USB cable is required with the power and data lines connected. Some USB cables do not connect the data pins as they are designed for charging purposes only. So if the STM32 powers up but the USB device is not detected by the OS try swapping out the cable.

Insert the USB cable into the STM32 and the Workstation or Raspberry Pi that is going to power the STMM32. A filesystem should mount. The debug USB port is the micro port on the J-Tag part of the STM32 board at the opposite end to the RJ45 network port. My workstation detected the device in the system log as: "New USB device found, idVendor=0483, idProduct=374b" and mounted it in the Nautilus file manager as "NODE_F767ZI". It was 2.1Mbyte in size.

This usb port is also enabled as a modem serial port. It is seen as /dev/ttyACM0 on my Ubuntu workstation.

[Top][Home]


ac6 - STMicroelectronics STM32System Eclipse Workbench

Image
STM32Cube Initialization Code Generator
This an Eclipse based IDE for STM32 MCU's. It is best install on a linux workstation for performance reasons but will install on a Raspberry Pi.
Both 32 bit (Rpi) and 64bit (linux Workstation) can be downloaded from:
http://www.openstm32.org/Downloading%2Bthe%2BSystem%2BWorkbench%2Bfor%2BSTM32%2Binstaller

Installation on a 32bit Raspberry Pi 3

Install the 32bit version on the Rpi running Raspberian or Ubuntu MATE
The latest Installer is "install_sw4stm32_linux_32bits-v1.14.0.run"
Version v1.14.0, updated on Friday, March 10, 2017, is the last as the 32bit version is no longer maintained.
To launch the installer in GUI mode, JavaRE (v7 or higher) and gksudo must be installed.

Installation on a 64bit Ubuntu Workstation

On Ubuntu 18.04 gksudo is no longer available but it can be installed form two deb's:
http://security.ubuntu.com/ubuntu/pool/universe/libg/libgksu/libgksu2-0_2.0.13~pre1-9ubuntu2_amd64.deb
and
http://security.ubuntu.com/ubuntu/pool/universe/g/gksu/gksu_2.0.2-9ubuntu1_amd64.deb

These libaries as also required:




An Uninstaller program has been created in: /home/glenn/Ac6/SystemWorkbench
Note:
The udev rule 49-stlinkv1.rules will be installed into /etc/udev/rules.d
The udev rule 49-stlinkv2-1.rules will be installed into /etc/udev/rules.d
The udev rule 49-stlinkv2.rules will be installed into /etc/udev/rules.d
The udev rule 49-stlinkv3.rules will be installed into /etc/udev/rules.d

This script will create the the Folder ~/Ac6 which contains the eclipse executable, and place an icon on the desktop that runs the application, "~/Ac6/SystemWorkbench/eclipse". As an alternnative, to the desktop icon launcher, the ac6 SMT32 workbench can be run directly from the "eclipse" binary in the the "~/Ac6/SystemWorkbench" folder.

General Documentation and Support for the STM32 IDE

Image
The OpenSTM32 Community host the STM32 Systems Resource site

OpenSTM32 resources can be found here:
http://www.openstm32.org/tiki-login.php
The www.openstm32.org site requires registration and login.

The System Workbench toolchain, called SW4STM32, is a free multi-OS software development environment based on Eclipse, which supports the full range of STM32 microcontrollers and associated boards. Documentation can be found here: http://www.st.com/en/development-tools/sw4stm32.html

[Top][Home]


STM32Cube initialization code generator

Image
STM32Cube Initialization Code Generator
Download from: http://www.st.com/en/development-tools/stm32cubemx.html

Select the "Get Software" tab and accept the License Agreement. Scroll to the very bottom of the page. Sign in with youe email address and validate to start the download. Save the file, en.stm32cubemx.zip in ~/packages/stm32cubemx

Installation Notes for Ubuntu 18.04.1 LTS:



[Top][Home]

Setup the capture application

Create a desktop icon by copying an existing icon and right-click to edit it properties. Update the form as follows:

Name STM32CubeMX
Description STM32CubeMX for STM32 configuration and initialization C code generation
Command /usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/STM32CubeMX
Comment STM32CubeMX for STM32



Update the icon by click on icon in properties window. Use the icon file: "/usr/local/STMicroelectronics/STM32Cube/STM32CubeMX/help/STM32CubeMX.ico"

Run the STM32CubeMX and select File->New Project and select the file "~/packages/my9/my8.ioc". You will then be asked to Download missing components or Migrate. Select Download The application will then download selected software packages and automatically install them:

The installation of STM32CubeMX is now complete. See the Build Procedure Section of this document to build the Homebrew Lightning Detector project.

As background documentation here is a PDF titled "Data brief - STM32CubeMX - STM32 configuration and initialization C code generation":
http://www.st.com/content/ccc/resource/technical/document/data_brief/7a/81/a9/b5/72/99/4b/be/DM00103564.pdf/files/DM00103564.pdf/jcr:content/translations/en.DM00103564.pdf

[Top][Home]


FreeRTOS

Image

FreeRTOS is a Real Time Kernel (RTOS) for micro processors.

The FreRTOS Site's Home Page:
https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/index.html

Download the file "FreeRTOSv10.1.1.zip" from the Sourcefourge download site https://sourceforge.net/projects/freertos/files/latest/download?source=files and save it in to ~/packages/RTOS.

Light weight Internet Protocol (lwIP)

RTOS employees lwIP, a widely used open source TCP/IP stack designed for embedded systems. lwIP was originally developed by Adam Dunkels at the Swedish Institute of Computer Science and is now developed and maintained by a worldwide network of developers. lwIP is used by many manufacturers of embedded systems.
Source Wikipedia: https://en.wikipedia.org/wiki/LwIP

[Top][Home]


Install the Github package

Image

Installing the git package is the simplest of all the software require to support the Home Brew Lightning Detectors:



[Top][Home]


Download the Source Code from Github

Please ensure all the prerequisite software packages have been sucessfully installed as describle above in the Software Platforms. That is, The ac6 STM IDE, the STM32CubeMX code generator, FreeRTOS, and git utilites.

Firstly obtain the source code. The HBLD source code is archived at guthub site, in the my9 repository, and can be accessed with this link: https://github.com/bobwis/my9. Note that the source is case senitive on linux, and case insensetive on Windows. I installed the source in the ~/packages folder from the git repository using "git clone" or "git pull", Alternatively, copy the link and download full archive. The my9 respositary contains full source to the application that runs on the HBLD STM32.

If no changes have been made to the project code locally, or you are starting from scratch, download a fresh copy of the source. It is safer to remove the my9 folder and clone it from scratch, in case some intermediate files have not archived correctly.

NOTE: Do not delete my9 if you have made local changes to the source code.

Download the source:


Alternatively, update the source with the following github commands:


As a precaution, backup the project file my9.ioc:


[Top][Home]




Java Runtime

The STMM32MXCube will not compile with assistive technology classes so edit this file to remove them.



The java Runtime version I am using on Ubuntu 18.04.1:

[Top][Home]


Image

This is the Linux open source, command line version of the of the STMicroelectronics Stlink Tool. It is used to load firmware over the USB port to STM processor boards.

The install procedure can be found here: github Archive of the Open STM32 Firmware and Debug Tool (local).

This stand alone tool is not necessary as similar mechanisms are included in the Ac6 Eclipse Intergerated Development Enviorment (IDE).



[Top][Home]

Building the CodeTyphon IDE

Image

http://www.pilotlogic.com/sitejoom/index.php/codetyphon

http://www.pilotlogic.com/sitejoom/index.php/downloads/send/14-codetyphon/123-codetyphonins-zip

http://www.pilotlogic.com/sitejoom/index.php/downloads/send/16-linux/131-arm-linux-pi-7z

CodeTyphon has an extensive, multistage, and somewhat tiresome installation process. It begins with an character based installation, and a graphical build of the IDE. Finally, you get the IDE product to work with.



Select "0" to start the install process.
Select "0" again to download and "Install System Libraries". This install a lot of apt packages.
Keep repeating the install until all package required are downloaded and installed and you get
a message like this:

Option 11:
CodeTyphon Studio Unix Platform (widget) Setup
        Current Platform: gtk2
Option 12:
   CodeTyphon Studio Multi-Architecture Setup
      Current Multiarch Mode: 1

   0) NO  Multi-Architecture Mode (Multiarch=0)
   1) Use Multi-Architecture Mode (Multiarch=1)

I had difficulty running CodeTyphon from the icon as it would stall on most menu options. I assume this is a permission problem . There appears to be a problem in the ways the application nneds to gain sudo status or maybe permissions are not correct. The solution is to start CodeTyphon the "sudo ./install.sh" command, but warns against have "root" privledges.

Next, Select 1 to Run CodeTyphon Center (CTC) and Select Menu Item "Typhon-->Build BigIDE" to build the BigIDE. This can take a long time. Select the "CommandBox" tab to view the progress.

After all this processing CodeTyphon creates a new application IDE called "Typhon64" and a new desktop icon to go with it. Typhon's working directory is /usr/local/codetyphon/typhon/

Now refer to the build section to compile the data relay application "captofile1". Build the Data Relay Application "captofile1"

MESA Computer Graphics

CodeTyphon makes extensive use of MESA for its Graphical User Interface. Mesa, also called Mesa3D and The Mesa 3D Graphics Library, is an open source software implementation of OpenGL, Vulkan, and other graphics specifications. Mesa implements a cross-language, cross-platform, vendor-neutral standard API for translating these specifications to vendor-specific graphics hardware drivers.

Source Wikipedia: https://en.wikipedia.org/wiki/Mesa_(computer_graphics)

A Side Note

In Greek mythology, Typhon was a monstrous serpentine giant and the most deadly creature . According to Hesiod, Typhon was the son of Gaia and Tartarus. Typhon and his mate Echidna were the progenitors of many famous monsters. Typhon attempted to overthrow Zeus for the supremacy of the cosmos. The two fought a e cataclysmic battle, which Zeus finally won with the aid of his thunderbolts. Defeated, Typhon was cast into Tartarus, or buried underneath Mount Etna, or the island of Ischia. Hopefully, the software does not reflect it's namesake.

Source Wikipedia: https://en.wikipedia.org/wiki/Typhon - Wikipedia

Pilot Logic's CodeTyphon

Notes:

[Top][Home]

Build the Data Relay Application "captofile1"

Firstly make sure the Typho64 IDE is fully installed. See the section above: Building the CodeTyphon IDE

The Captofile CodeTyphon build requires ttf-mscorefonts for the screen layout to look well proportioned. The MS true type fonts can be install with the apt utility thus:


Copy the "Captofile1" source file into th3 ~/packages/captofile folder.

I had to change ownership of these folders to get typhon to run properly.
Note I had to remove "{$IFDEF WINDOWS}mmsystem{$ELSE}" condiftional from the source file.
The Linux do not support the Microsoft multimedia system libaries.

Typhon64 places the compiled executable in: /usr/local/codetyphon/typhon/Captofile1/lib/x86_64-linux/captofile1
and a ARM binary suitable for execution on the Raspberry Pi placed in: /home/glenn/packages/captofile/Captofile1/lib/arm-linux/captofile1

It is more convient to copy the executable to a local folder. The captofile1 program will create a captofile1.ini file the first time you attempt to save any configuration, so do not install it in "/usr/local/bin" as normal users do not have priveldges to create files in that folder. I chose to make a bin folder in my home folder.

[Top][Home]


The STM32CubeMX MicroXplorer Code Generator

Image
my9.ioc - MicroXplorer Configuration settings

If you wish to build the stock standard version of the HBLD skip this process. The chip level includes are already included in the my9 source code downloaded from the repository. It is only necessary to run the STM32CubeMX if you wish to make changes at the hardware level. EG interupts, DAC, ADC, etcera.

The second task to building the firmware is the STM32CubeMX code generator. Run up the STM32CubeMX IDE from the icon created on the desktop and open the .ioc project file.
Select File->Load Project and choose ~/packages/my9.

If the developemnt version in my9 is not the latest STM32cubeMX, you will be presented with this screen:
Image.
Th safest course is to select "Continue". "Migrating" is desirable but may lead to configuration issues.
The startup screen will take afew minutes to appear:
Image

The red labels indicated that those peripherals and pins have been allocated and are no longer available for use. They do not indicate an error condition.
Select the code generator option with the menu bar icon Image.

SMT32CubeMX automatically generates include files into the my9 project area, ~/packages/my9. Most of these are included into "main.c". STM32MX will then offer to start the STM32 Workbench. You can proceed directly to the workbench or exit The Code Generator and start the SMT32 workbench by executing "~/Ac6/SystemWorkbench/eclipse" binary.

Note that there are two files that do not automatically get included and have to be copied manually. They are:
Middlewares/Third_Party/LwIP/src/apps/httpd/fs.c
Middlewares/Third_Party/LwIP/src/apps/httpd/fsdata.c

If you forget to copy thess two files you will get fatal compiler error: fsdata.c: No such file or directory.

[Top][Home]




Editing the STM32 Include files

There are a couple of manual edits that are required to the my9 source. Start the SMT32 Workbench if it not already runing. If this is the first tiome it has been runing

In the STM32 System Workbench

In the STM32 System Workbench

Two file require manual editing.

Edit the version.h file and change
#define MY_UID "1099" to your serial number.
and change the testing flag
#if 1
#define TESTING
#endif

Make sure it is set to "1" if you wish to test or set to "0" for production.
Edit the udpstream.h file and change

#define SERVER_DESTINATION "lightning.vk4ya.space" to your local IP address if you wish to run the cptofile1 relay application instead of sending the packet data directly to the server.

[Top][Home]




Build the SMT32 Firmware using STM32SystemWorkbench

As an alternnative the ac6 SMT32 workbench can be run from the "eclipse" binary in the the "ac6" folder.

Image
Select ~packages/my9 and "Finish"

The source will load in to the Eclipse STM32 workbench.
Image The imported my9 source archive

Point it at the top directory where my9 is located. The my9 will display in the project explorer pane on the left hand side.

The STM32 Jtag USB port (which also powers the STM32 in normal cases) must be connected to a USB port on the same platform (Windows, Linux Workstation, or Raspberry Pi)

Use File-->Open to open the Project from File System in STM System Workbench,
Select "Build All"

[Top][Home]




Load the compiled firmware to the STM32 processor

If set up correctly the STM32SW will load the compile and load the firmware into the STM32 board.

In the STM32SW IDE navigate to:


Image

The second tab details the debugger tools to be used. Nothing needs to be changed. The GBD Command is set to use "arm-none-eabi-gdb" and the OpenOCD Command is set to use "OpenOCD"/ The "Open On-Chip Debugger" provides JTAG/SWD access from GDB (or directly with TCL scripts) to processors with ARM and MIPS based cores.
Source:http://openocd.org/

Image

In the STM32SW IDE navigate to:



Image

[Top][Home]

Configuring the Data Relay and Monitoring the System (Captofile)



My advice would be to change TESTING to 0, and to uncomment the SERVER_DESTINATION in udpsream.h which has "lightning.vk4ya.space" as the target. You will also have to comment out the existing entry in that 'else' clause. Recompile and run will update the STM board with the new firmware.

After that it should be running and sending to the server directly, with status packets every two minutes. You can open a serial terminal on the USB port to see the start-up messages and any subsequent errors:

To see the output data in the 'Capture' program on the RPi, just change that SERVER_DESTINATION entry to point to the local RPi IP address.

On the RPi run he Captofile program from a bash shell and and every two minutes you should see the status field update (and the sample packet field when it detects an event).

The Options tab in the Sample program lets you relay the packets on to the server as well. (see Screenshot below), so you can run Capture and still send the data to the Server.

The Captofile program will eventually fill up a file Raw3.bin on the RPi, (but it should take weeks to break the filesystem). The Raw3.bin file can be read into another program named 'Anal1' to display the samples, waveforms etc and the captured packets. Its very CPU intensive so it is not ported to the RPi. It compiles on Windows and Ubuntu PC's using Typhon.

Image Relay Configuration Screen - Relay data to lightning.vk4ya.space (112.213.32.44)

Image Packet Capture Monitor and GPS Status Screen

[Top][Home]

Loading the Binary Version

As an alterntive to compiling the source code a binary can be downloaded and installed. There is a binary of my9.bin on github. This binary version can loaded directly onto to the STM32 lightning server.

Downloaded the binary from github: https://github.com/bobwis/my9/blob/master/Debug/my9.bin

Insert the USB cable into the Ubuntu workstation and a filesystem should mount. The debug USB is the micro port at the opposite end to the network port My workstation detected the device in the system log as: "New USB device found, idVendor=0483, idProduct=374b" and mounted it in the Nautilus file manager as "NODE_F767ZI" and was 2.1Mbyte in size.

Copy the my9.bin file into the shared 2MByte drive offered by the STM32 and initate a reboot to load the binary.

[Top][Home]


Monitoring the Serial Port

Make sure the USB cable is correctly plugged into the Ubuntu workstation and the STM323 as described in the hardware Section of the document: The USB Connection for Power and Communication

Remember, The debug USB is the micro port at the opposite end to the network port.

You will need a serial port communications program. Cutecom is a graphical serial port communications program, similar to the character based Minicom. It can be loaded with the apt utility:


The system log, dmesg shows that /dev/ttyACM0, the USB ACM device, is active. Open the serial console to the STM32 in cutecom to see the startup dialogue.

Add Cutecom to the favourites menu.

Configure Cutecom:

Once this is done press the black reset button on the STM3 to load the binary and output the strtup dialogue to the serial port.

The startup dialogue will display serial numbers and IP addresses as it boots. You can now assume you have a live lightning detector that sending packets to the server. Note that this dialogue is only active during the startup process.

[Top][Home]


Viewing The Results

http://s7.slashdit.com:8080/detectors

Note:



[Top][Home]


MTU and the UDP Fragmentation Issue

Some moden do not allow for the resetting of the Maximium Transfer Unit, MTU.

https://support.microsoft.com/en-au/help/314496/the-default-mtu-sizes-for-different-network-topologies
I've confirmed that the STM LwIP fragmenting the packets is too much for its little brain,
 and it can't keep up with the ADC. So after much googling I think I've found a solution
to keep your detector sending full size packets without any new software (so use the last
version you built).

The trick is to point your detector at the RPi as per normal, run the Capture program to
relay the packets to the server, but firstly run this command on the RPi:-

ip route add 112.213.32.44 via  dev eth0 mtu lock 576

(assuming you have eth0 as your network interface on the RPi).

It forces IP of no larger than 576 (in the case above) to be used when sending to the
lightning server via your modem.


[Top][Home]


Frequently Aasked Questions

  1. How do you reload the firmware on to the STM32?

    Either copy over shared usb drive or use the compile and run option in the IDE - as long as USB is connected to your PC Its the 'Run' option in the IDE menu. Also the Green Right Arrow Icon when its learned it after the first go. The 'bug' icon is 'run' and debug.

  2. How does the RTOS and lwIP get included inti the source code?

    To building the target software for the STM, you do not need to download LWIP or FreeRTOS. They were installed by the STM build system. I'm guessing it was the STM32CubeMX 'front-end' code generator that brought it in (but it could have been the STM32SW IDE). There is a my9.ioc file that the STM32CubeMX generates into the my9 project folder that show all the dependencies.

  3. What does TESTING mode do that normal mode does not.

    On the STM32SW IDE, the version.h file contains a directive for TESTING or not. All this does is set the status packet rate to once a second rather than once every two minutes, also, it also sets the IP Address (or DNS name) afrogots defined in a conditional test found in udpstream.h.

  4. What do the flashing LED's on the STM32 board indicate?

    The green LED on the STM32 should flash every second when the GPS is sending the one pulse per second (1PPS).
    The Red LED and Blue LED flash when a detection event occurs. An event can be simulated by ckicking a pizo lighter (or placing a finger on the antenna/ADC input pin).

  5. Can the STM32 be reset?

    The black button on the STM board is the reset.



[Top][Home]
Glenn Lyons VK4PK
glenn@LyonsComputer.com.au
Ver:gnl20180914 - pre published v0.9