Menu

Grid Frequency Meter. Measuring the load on the National Grid.

mkstevo
2020-06-20
2022-07-11
  • mkstevo

    mkstevo - 2020-06-20

    A few years ago I saw an article in Elektor Magazine written by Dieter Laues which showed how it was possible to determine the load on the National Grid electricity supply by measuring the frequency of the supply. To sum it up in a few words: The greater the load, the more it slows down the generators and so the lower the frequency of the supply.

    The National Grid is compelled in the UK to maintain the frequency of the supply to +/- 1% of the nominal frequency of 50Hz, the limits being 49.5Hz and 50.5Hz. However it aims to keep this to within +/- 0.2Hz normally (49.8Hz - 50.2Hz). A very large power cut across parts of the UK was caused by these limits being exceeded. Two large generating plants failed almost together and the sudden loss of supply caused the remaining power plants to become excessively loaded, lowering the frequency. To keep within the operating limits, large parts of the country were essentially unplugged to allow the remaining plants to continue to work. Reserve power was brought online and power was eventually returned.

    This meter can measure the frequency reasonably accurately, with a resolution on the bargraph display of 0.025Hz (25 mHz). I did an original design some years ago using PicAxe processors. This has worked well. I have one in the living room which has been running for over five years. Due to limitations in the mathematics abilities of the PicAxe, the maths was rather compromised, very convoluted and untidy. It did work though. I have finally rewritten the code using Great Cow Basic.

    The new design is (not surprisingly!) based almost entirely on the hardware used for the original. I've added a few minor tweaks, but it is very close to the original. The new model in the pictures uses one of the original PCBs, this only "needs" a solder link to be added to make it work. I have redesigned an entirely new PCB which I've ordered.

    The software is a grounds-up rebuild. A few of the constant values are the same as the original but not much else. Given the horrid maths I needed to make the PicAxe calculate frequency from a time period, I felt it was not really worth trying to alter it, but to start again. The frequency is also able to be averaged over 20 samples now which adds some much needed stability to the display. The voltage can also now be averaged and shows the voltage to 0.1V The PicAxe original did have this option, but the jitter between readings was too much for it to be useable so I removed it.

    As a basis for the frequency measurement, I used the example that William Roth provided back in 2015. At the time, I was looking at using that example to build this meter and thanked him for that example. It's only taken me five years to actually do it!
    (original post and the example code: https://sourceforge.net/p/gcbasic/discussion/629990/thread/a02288e0/#2238 )

    A video of the meter can be found here: https://youtu.be/-t6Cmd7ytLk

    The circuit diagram is included as a PDF. The circuit shows alternate locations for LCD displays. One is for a standard 1602 type, the other is to accomodate a large digit type I have a few of. These have pin 16 and 15 on the lower left of the displays, with pin 1 next to pin 15 and pin 14 on the extreme right. This circuit is the basis of my PCB, I deleted the two displays not relevant for my board.

    There are pictures of the original (PicAxe) version. Two of the new PIC version, the new ones have a white label on the Volts calibration potentiometer to remind me which way decreases the voltage reading from where I was calibrating this yesterday.

    One of the pictures of the new version is showing a power failure event. The event flag at the top of the display is showing an event took place, the down arrow indicates that the voltage fell below 5% of the nominal voltage and in the empty side of the bargraph, every 60 seconds or so, for 10 seconds, the time in hours and minutes since the event took place (or since power resumed) is shown. After 1 day, this time is displayed in days and hours. After 7 days, this is cleared unless another event took place in the meantime. The events are stored in EeProm, and assuming there was enough time to write to EeProm before the supply went totally, the event will be displayed when power returns. As this will store the time that the meter was unplugged, events can be cleared by tapping on the "calibrate" button for less than 500 mS.

    The event timing uses Chris Roper's millis() function. I only limited it to 7 days as I thought that power failures more than a week ago were not relevant to me any more.

     

    Last edit: mkstevo 2020-06-20
  • stan cartwright

    stan cartwright - 2020-06-20

    Interesting project. What do you use the info for?
    Kent is very knowledgeable and posted a frequency counter to me to.

     
    • mkstevo

      mkstevo - 2020-06-21

      I don't use it as such for anything. It is fascinating to watch though. Really therapeutic. It drifts up, down, hangs about in the middle for a while, drifts down, up, up some more, down, back up...

      It's like watching the waves roll in and out down on the beach.

      I originally made one for the Further Education College I worked at for five years, as part of a demonstration piece for the supply of electricity across the UK. I found it fascinating and would find myself transfixed by it. I wanted to build my own version once I left, but hadn't got the facilities to program the Atmel chip that was used in it. I decided to make my own version using the processors I was working with at the time, PicAxe. After some time we had the need to program some Atmel devices at work so I made myself a programmer/adapter. I realised I could now program a processor to build the "original" as published in Elektor. We had a few of the correct devices in some scrapped PCBs so I set to and made one. This spurred me on to make some changes to the original software.

      Then finding myself with some spare time at weekends during lockdown (I've been able to work throughout) I finally got round to creating a new version, in Great Cow Basic.

       
  • Anobium

    Anobium - 2020-06-21

    Very impressive! I love it.

     
    • mkstevo

      mkstevo - 2020-06-21

      Thanks. I'm hoping that once the PCB arrives it will look rather more impressive.
      I've only got one project left that still uses a PicAxe. Hopefully it won't take five years for me to re-write that one in Great Cow Basic.

       
  • stan cartwright

    stan cartwright - 2020-06-21

    I thought you were planning to sue your supplier :)
    I remember asynchronous motors used in lp record turntables in the 70's
    that used the mains frequency to make the motor drive at what made the turntable spin at
    33 and 1/3 rpm or 45 rpm.
    edit ps In retrospect.. I think picaxe was carp...and I don't mean fishy...with it being "compiled" but even assembler is interpreted...and it's basic is ... unique. Yet people still use it. Same people as when I used it. I tried to lure a few to gcb. Hope I did.

     

    Last edit: stan cartwright 2020-06-21
    • mkstevo

      mkstevo - 2020-06-22

      A 1% difference in mains frequency isn't likely to give "much" difference in the playback of 45s,or even 78rpm records!

      I liked, and still like PicAxe. Apart from one particular project which needed the extra speed of a fully compiled language I rarely need the speed. The maths can usually be worked around - as I did. I found the shortage of variables rather limiting, but the reduction in available program space was more limiting. The simulation capabilities of the IDE was fabulous though, if PC only, not macOS.

      By far and away, without doubt, Great Cow Basic is superior in every way. So thanks again to all at GCB for such a superb tool.

       
      • stan cartwright

        stan cartwright - 2020-06-22

        The manufacturers stuck strobe lines around the turn table and a bright neon so when the lines where stationary it was running at correct speed.
        Hi-Fi was a load of sales hype in the 70's/80's...and I bought into it.
        I still think picaxe was a rip off system. Saying it was compiled when it was interpreted.
        Variables..what a joke. Peek and poke was normal.
        I never used the simulator but people thought it was cool.
        What annoys me is when I bought into picaxe, gcb was available but I didn't know about it,
        hence I have youtube videos of gcb projects and try to promote gcb when I can...especially to picaxe users. They don't know what they are missing.
        A mega328 uno/nano is better than a picaxe 28X2 pic 18f25k22.
        You would never get glcd to work like gcb with picaxe. Drawing lines would take ages.
        A uno/nano is a nice populated board with sockets for everything, cost £5 and you don't need to buy a ttl converter to use the terminal a la pic. It's great with gcb.
        Unlike you I sometimes need to squeeze every bit of speed from my code. Usually for graphics on glcd as it needs to look smooth so erasing and replotting need speed or it looks flickery.

         

        Last edit: stan cartwright 2020-06-22
        • mkstevo

          mkstevo - 2020-06-22

          As the neon was also strobing at the mains frequency, if the mains frequency was "off" so would the strobe and so the turntable would indicate it was running at the correct speed.

          I wouldn't go so far as to call PicAxe a rip off. It has many things which make it really simple to use. Many programs could be up, running, simulated, tested and programed into the device far quicker than any other processor. Certainly it has it's limits, speed and variables being the main ones. But they are aiming for the educational market, not the hobbyist or commercial ones. For that, the simple programming interface and the in built macros (such as beep and PWM) make things really easy. I recently posted some code here for generating some ramped, low frequency PWM. This was from a work project originally built using PicAxe. The PicAxe version took days less time to write. For the Great Cow Basic replacement version, I had to build everything from scratch. By contrast, the Frequency meter here, took many, many, many hours of work for the PicAxe, most of which was taken up getting the maths right and getting the display all built into the "upper memory block" using poke, before peeking it all out again and then writing it to the display. The Great Cow Basic version took less than a day to get working, then another day to refine the interrupts which stop lost frequency pulses from locking up the entire program. Two projects. One far easier in PicAxe, one vastly quicker to develop in Great Cow Basic.

          I liked PicAxe. I still do. For what it is, it's great. It is however, surpassed in almost every single way by Great Cow Basic.

          I too try my hardest to promote Great Cow Basic, hopefully you'll notice my videos on YouTube all state that the software was written in Great Cow Basic, my websites mention it repeatedly, my postings on the Elektor Labs also do their best to promote Great Cow Basic.

           
          • Anobium

            Anobium - 2020-06-22

            Thank you. And, keep it up!!

             
          • stan cartwright

            stan cartwright - 2020-06-22

            As the neon was also strobing at the mains frequency, if the mains frequency was "off" so would the strobe and so the turntable would indicate it was running at the correct speed.

            Wow.never thought of that. What mugs we were for new tech in those days.

            As for picaxe being educational well...
            The first basic I learnt was sinclair and that's not what basic should be but it stuck and I translated what I learnt to other basics.
            I wish I could have afforded a bbc micro but they hadn't been invented then.
            gcb is more "standard" basic than picaxe and it has the graphic programmer mode
            like picaxe so it would be better for educational use..free, no licence

             
  • mkstevo

    mkstevo - 2020-07-07

    The PCBs have been delivered and I've built two of the boards.

    The LCD fits behind the PCB with a cut out allowing the LCD to be viewed through the front of the board. The dimensions of the board were made so that it fitted directly into the case that I put my original (PicAxe) design in.

    The PCB has been made to suit a rather specific type of large character LCD 16 x 2 display, a CCM-1624CSL. These have a lovely large 8mm x 5mm character size , but an unusual arrangement for the pins. If you imagine the "standard" arrangement on this type of display, pin 1 is positioned to the left, with pin 16 close to the centre of the display. On these displays pins 15 and 16 are close to the centre, with pin 1 next to pin 15 and then run "backwards" (right to left) ending up with pin 14 on the lower left edge.

    I had two of these displays salvaged from scrap machines, which is why I built two up. Anyone is welcome to have a board whilst I still have some, for no more than the cost of postage, but be aware that without the correct display some jiggling of the wires will be needed.

    The close up picture shows the display better, this is fitted into the case using the PCB as the front panel. The angled picture shows the PCB better but due to the angle the LCD looks faded, this is a free standing version using stiff wire in the corners to create an angled support to allow it to stand at an angle.

     

    Last edit: mkstevo 2020-07-07
  • stan cartwright

    stan cartwright - 2020-07-08

    nice looking kit. I tried cutting rectangular holes and it needs the right tools or a lot of filing.

     
  • mkstevo

    mkstevo - 2020-07-09

    That's why I "drew" the cut out on the PCB design and got JLCPCB to cut the hole for me. I've tried filing square holes like this before and it is really difficult to do well. A design I've just had delivered for work has a slot for an LCD and five square holes for the up, down, left, right and OK buttons to show through. This looks really good, I'm very pleased with it. It means we don't have to have a custom case manufactured too.

     
  • mkstevo

    mkstevo - 2020-07-12
     
  • mkstevo

    mkstevo - 2022-07-11

    Just a quick note to blow my own trumpet.

    I have written an article describing this design for Elektor Magazine, and it has been published in the July/August 2022 edition. GCB, promoted in print!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.