MONITORING LOCATION

Picture of mobile generator

The website measures the mains frequency at the rural village of Wybunbury in Cheshire.

Mains supply in this area is mostly by overhead line but when Scottish Power needs to undertake maintenance work on lines or transformers they sometimes provide a mobile generator for the day. The nearest transformer is in my garden and they park the generator in my yard and leave it running there. During these periods the frequency measured will be that of the generator and not the true mains.

SITE DESIGN

Screen shot of webpage

Creating a typical website usually involves a number of technologies: HTML, CSS, web server, etc. This website demands more than usual because of its combination of hardware and software and its animation. The following are used:

HOW IT WORKS AND CIRCUIT DIAGRAM

The underlying hardware that takes the mains supply and creates a signal that can be processed by a computer has been replaced entirely. The previous bespoke circuit, which required an Arduino, Pi and various electronic components, is superseded by an H11L1 combined opto-coupler and Schmitt trigger, two 82kΩ resistors and a diode. The Pi side of the H11L1 needs input power (3V3 and GND) and outputs a square wave to a GPIO pin on the Pi. The Pi polls the pin until a signal is received then time-stamps each pulse and records the data. It then calculates the elapsed time for 25 cycles, calculates the frequency and writes it to a shared file that's accessible by the web server. The measurement period is 25 cycles because the Pi has to complete all its calculations and I/O in the remaining half second if it's to measure the frequency every second. At the same time, the frequency is displayed on the Pi's console (if connected, otherwise to /dev/null) and on a 4-digit 7-segment display connected using I2C and mounted on the front of the equipment case.

Circuit diagram

The latest evolution of the hardware is based on that described above but uses a Raspberry Pi 3 B+ and includes some extra features:

ACKNOWLEDGMENT

The circuit was designed and prototyped by J. Thornton Lawrence, GW3JGA.

I would like to acknowledge the source of the PNG meter image - it was derived from an SVG image designed by Rones.

RASPBERRY PI

The Pi's connectivity to both I2C and Ethernet and its ample performance make it ideal as a small web server. It needs to run custom C programs to collect the frequency data, generate the last 10 minutes graph and to drive the animation of the frequency meter.

I2C

I2C was developed by Philips, now NXP, to support communication between integrated circuits but has been adopted by most manufacturers as an industry standard. It is based on a master-slave hierarchy and its advantage is that it uses only two wires, excluding Vcc and GND. Arduino and Pi both support I2C.

SVG

SVG is a sophisticated standard for creating scalable and animated images. Other websites use Flash for animation but Flash is not an open standard, and is not available natively on iOS devices and some non-Windows PCs. I had considered using a set of pre-created PNG images, one for each needle position but this seemed a bit lame and would not have resulted in a smooth movement. Animated GIFs would have been worse still and certainly more complicated. I use SVG a lot and for these reasons.

AJAX

AJAX is a technology that allows you to update parts of a webpage without reloading all of it. It provides a more efficient webpage and a more fluid display - no obvious page refreshes. While AJAX would usually receive data from the server in XML format, I chose to avoid the overhead of XML and use plain text instead. The webpage uses JavaScript to interface to the DOM model so that the content of individual elements, or their attributes, can be changed. In this particular case, it is the rotation of the needle that is changed during a 1s period.