MSFduino – A clock using the MSF 60kHz time signal

Introduction

Why do it?

There are many reasons to start a project. If I’m really honest I don’t really know why I decided to do this. I do have a bit of a thing for having accurate time and this looked like a nice thing to get me more involved with Arduino. This is where it all started to go wrong, not because it is a particularly complex project but personally it took me up quite a steep learning curve on a number of different aspects of electrical and electronic design. Being a Mechanical engineer and project manager by profession you can see why it is ‘challenging’ for someone like me. The good thing about this is that if I can do then so can just about anyone else.

Why not a shield?

Again, no real clear answer. One of the drivers for this project was learning. Ham radio is often called a ‘self-learning’ hobby. This was just one of those extensions. There is no reason why this shouldn’t be a shield, in fact I may get round to designing one that allows all the various bits on to it but space was definitely a concern when I started out so it didn’t take long to decide to design my own PCB. Anyway that was half the fun.

What actually is it?

Ok so what is MSFduino? The short answer is that it is a clock. Just an accurate clock that uses the time signal, broadcast from Anthorn in Cumbria by the National Physical Laboratory. The signal is transmitted on a low frequency of 60 kHz and consists of a code that constantly tells you the right time and date. The signal comes from a bunch of atomic clocks that are always accurate as you would imagine. The internet can do the same thing but, it’s just not radio.

The ‘circuit’ consists of an Arduino, a receiver for the time signal and an LCD module to display the time on. There are a few simple components such as a voltage regulator, trimmers to vary the brightness and contrast of the LCD and some small passives. The whole design is such that it copies what the Arduino Uno does but takes away a lot of the extras that just aren’t required and that makes it a fairly stress free set up.

Just one note – you need to be aware that there will be some soldering regardless of the route you take. The MSF receiver needs the antenna soldering to a couple of tags as a minimum but needless to say it isn’t onerous.

OK let’s get started

Before we do I’ll explain one thing. There are many ways of constructing this. I will be showing you how I did it is a risk averse way. This means I did things in a step by step way so I could make sure that everything works. You don’t have to follow this process, it just helped me as a novice. It went something like this:

1. Build up the simplest circuit and display the output on the serial monitor that comes with the Arduino IDE

2. As above but displaying it on the LCD instead of the serial monitor

3. Breadboard the whole lot and output on the LCD

4. Build up the PCB

You do not need to follow this lead if you are as ease with this sort of thing but it will make sense if you take a step by step approach if this is new to you. If you make a mistake at any stage the step by step process reduces the number of changes made so narrows down where to look.

Design & Build

Parts lists / BOM / Shopping list

Depending on which method you use depends on which bits you’ll need. The simplest is with the Arduino only the most complex is as the stand alone PCB. None of it is particularly difficult and you may find that the work is well below your capability so don’t be put off if you need to get the soldering iron out¦..what’s the worst that could happen? Don’t answer that.

Stuff you’ll need

  • 1 off Arduino Uno
  • 1 off MSF Receiver (mine came from PV electronics)
  • 1 off Barebones Arduino – kit comes from Hobbytronics (Don’t forget you need the one with the bootloader)
  • 2 off 10k Trimmer pot – e.g. Bournes 3306 or similar
  • 4off 22nF capacitors
  • 1 off Resistor
  • 1 off LCD Module – 16×2 standard LCD module
  • 1 off push button reset switch

Additional hardware odds and sods

  • Breadboard
  • Hook up wires
  • Soldering iron & Solder
  • Solder sucker and/or braid – useful for mistakes
  • Emery cloth
  • USB Cable for programming the Arduino

Software

The only really complex decision you need to make is how you are going to programme the Arduino. My method may not be the most ideal solution but I used the Arduino Uno microprocessor (the one supplied with the Arduino) as the basis. When it came to switching over to the ’empty’ one I simply swapped the two over, taking care of course.

Note: Some suppliers offer ‘kits’ for building up breadboards and come with various parts. Some of these might be suitable. I bought a job lot from eBay a while ago but I forget who the seller was

Preparing the receiver

My MSF receiver came in 2 parts. The antenna was separate to the board and there were holes and pads where the remaining connections were placed. What we need to do is make up the connections to the various parts and this will allow us to build up the project. So, to wire up the receiver first we are going to attach the PCB connections and then the Antenna. The reason for doing it this way round is that the antenna wire is very thin and is easily broken.

I used hook up wire to solder a 10cm length of wire to the VDD, TCON and GND connections as a minimum. I didn’t use PON as the Arduino wouldn’t be on without the receiver being on.

Take a small piece of emery cloth or a scotch brite pad and rub it on the thin antenna wires to remove some of the coating. Solder them to A1 & A2. It doesn’t matter which one goes where.

clip_image002

Note: Yours may not be the same as mine so check the connections!

To make things easier I used the Arduino Uno and just fed the hookup wire into the various pins. It also reduces the need for an external 5V power supply. Very handy and simple.

Step By Step Build

clip_image004

Arduino & Serial Monitor output

Uses:

  • Arduino
  • Receiver
  • Your PC and the Arduino IDE

The simplest way to construct the circuit. This will output the time through the serial output that comes with the Arduino IDE. I’ll also assume that you’ve prepared the receiver. There are only 3 connections to be made VDD, GND and TCON. The latter goes to Pin7 on the Arduino. That’s it!

Well nearly. You have to put the software that decodes the incoming signals onto the Arduino. This is where a few hours can be wasted if you don’t pay attention to how the Arduino likes to see things.

The software comprises of the following

Decoding software –

Libraries –

Put the software into the following directories:

  • MSFTime.h
  • MSFTime.cpp
  • Time.h
  • Time.cpp

Into….

  • A folder called ‘Time’ in the Arduino libraries folder (C/Program File/…./Arduino/libraries

If you do not follow the protocol with location of the various directories then there will be problems. The IDE likes to know where things are and if they aren’t where they are expected then you can expect a few compiling errors.

Assuming you’ve followed the instructions then the Arduino will accept the code and start running. If you have the same receiver that I have then it will start blinking as soon as the voltage is applied. The signals will be received through to the Arduino and it will start to ‘settle’. It will need to read the incoming data and make sense of it. Depending on the way the wind was blowing this has taken up to 2 minutes for me in the past and occasionally a bit longer.

The Arduino IDE has an in built serial monitor. We will be using this to monitor the incoming signals and hopefully telling the time, albeit not in a very handy form. This gives us the benefit of confirming that everything is working with the simplest set up.

Serial Monitor

Once the signals are starting to come through nicely the LED will blink regularly and data will come back through the serial monitor and look like this

ArduinoTimecrop

Arduino Uno with LCD

Now we are going to replace the serial monitor with an LCD. A standard connection for the LCD is used. Don’t forget the library that needs to be put into the right place. There is a minor software modification to make from SerialPrint to LCDPrint. These are on lines..x..y..z.. but we’ll come to that

The LCD pinout is very well documented but in simple terms the connections are as follows

clip_image006.png

Pin Reference Function Arduino Uno Header
Pin 1 VSS GND Pin 1
Pin 2 VDD +5v Pin 2
Pin 3 V0 Contrast Adjustment GND
Pin 4 RS H/L Register Select Signal Pin 12
Pin 5 R/W H/L Read / Write Signal Pin 11
Pin 6 E H/L Enable Signal Pin 10
Pin 7 DB0 H/L Data Bus Line Not connected
Pin 8 DB1 H/L Data Bus Line Not connected
Pin 9 DB2 H/L Data Bus Line Not connected
Pin 10 DB3 H/L Data Bus Line Not connected
Pin 11 DB4 H/L Data Bus Line Pin 5
Pin 12 DB5 H/L Data Bus Line Pin 4
Pin 13 DB6 H/L Data Bus Line Pin 3
Pin 14 DB7 H/L Data Bus Line Pin 2
Pin 15 A +4.2V for LED 10k pot then pin 13
Pin 16 K Power Supply for Backlight (0V) GND

Breadboard

The breadboard version needs a bit of careful placement of parts onto the board. There is scope for confusion and getting wires crossed etc. Its a good idea to give yourself plenty of space and come up with a colour code that suits you.

What we will be doing is using the discrete components to build up an Arduino on the breadboard and adding in the receiver and LCD module just as we did previously. The only difference is the Arduino is on the breadboard and not the blue(ish) PCB.

I used a regulated 5V supply from a USB charger that gave exactly 5v all the time. If you are going to use anything that is a bit more variable then you must use a voltage regulator. If you’ve bought the kit from Hobbytonics then you’re quite likely to already had one in a little bag. Mine is a 7805, a fairly standard device.

 

IMAG0018

 

If you’ve wired it all up correctly then you will get the same results as before. The receiver will output the time and date on the screen. Voila!

PCB

We will now be going into the realms of collecting together a load of components, throwing them together onto a breadboard and all of a sudden the system will work. Well that’s the plan anyway. If you’re happy with that then you can build up your own PCB or use my design as a starter and make it better.

Taking it further and designing your own PCB

Eagle

Eagle is a piece of design software (CAD) that can be used in these types of jobs to design the schematic and layout a PCB. It is very versatile and is well supported with libraries of parts and components that come from 3rd parties. There is a free version that comes with some limitations but these shouldn’t affect what you do from a hobbyists perspective.

I used this mainly because the libraries are very well supported, which makes putting parts in easier. I have tried other software packages like Fritzing kiCAD and DIP Trace. They all do a similar job to varying degrees and it really is a choice you’ll have to make. There are plenty of tutorials available to get started and if you fancy having a go then use your friend Google. Sparkfun gave me what I needed but there are loads of other suppliers that may be.

The reason I mention this is that the schematic and PCB’s were drawn in this package. They are available to you to look at, play around with and modify, feel free to use and abuse them. I have no commercial interest in this project. It’s just a piece of fun and if they can save you a bit of time then all well and good. If you can add something to them then please go ahead and improve them. Remember that I am a novice and this is new to me. You old hands will no doubt spot some common mistakes quite quickly.

These two screen shots are from an earlier attempt, actually my first with Eagle and these weren’t too successful. Spot the mistakes!

Shack-clock-P4

 

Shack-clock-board-P4

 

PCB Fabrication and Assembly

If you are going to fabricate your own board then you’ll need to create an output that the various machines can read. This is generally called a Gerber file (there are actually a number of files that contain all the layer information and things like the drill files). Again there are loads of tutorials on how to do this so it shouldn’t be too hard to use your friend Google again to find out how to do it. I suggest Sparkfun as a good source again.

Fabrication of the boards and getting all the parts can be done in a variety of ways and it depends on your geography really but I used SEEEDStudio. Not lightning quick but they came recommended. Follow their process and you won’t go too far wrong.

PCB Assembly

Assembling the PCB is very straightforward. I would suggest using a print out of the schematic and mark off the parts as you put them in. If you’ve used the process above then the ATMEGA328 microprocessor can be gentle removed from your Arduino and used in the circuit. If you’ve dived straight in here then you’ll have to write the software to it which means either using an existing Arduino or directly using a FT232RL USB to Serial breakout board. If you try and programme an ATMEG328 directly then you will kill it. If you decide to go this route then you obviously know what you’re doing. If you aren’t then I suggest you do some reading up or you may end up with some useless parts.

Other Useful Design Tools

Google Trimble SketchUp

A 3D CAD programme that is nice and basic with none of bells and whistles of Solidworks or AutoCAD Inventor but enough to be able to get you drawing simple 3D parts. Again has a load of libraries and parts available through its own warehouse or through specific vendors. One of the add on parts is a tool that will take the PCB you designed in Eagle and render it into SketchUp without too many issues (I tend to get scaling issues that are quickly resolved). The add on is called ‘Eagle Up’ is and has parts which sit in Eagle and SketchUp as well as other requirements. Best advice is to follow what is on the website and you can produce nice renderings that can be used to design laser cut cases.

Front

Viewplot

Viewplot is handy for looking at Gerber files and checking that the design is as intended. Not much to add to this other than it was recommended to me, there are plenty of other Gerber viewers about and some online versions as well.

Finishing it off.

I used a PCB layout by Dangerous Prototypes called Sick of Beige. There is a case design that is based on that layout and it looked nice and clean and simple. The case is a simple acrylic case with stand offs. I used Google SketchUp to create the look and feel of the finished product. You can output an SVG file from SketchUp that can be used by a laser cutting service like SEEEDstudio (Who incidentally fabricate PCB’s). Ultimately how you go about boxing things up is down to you. Prefer a clean look and like to see the PCB as well as the case.

 

Update:

The newer IDE’s don’t like the older libraries so use IDEv0023 from here or rewrite the libraries so they are compatible

My sketch looks a little like this if you want to pinch it (As well…thanks Jarkman)

// MSFduino based on MSFTime samples program 
// Jarkman, 01/2011 
// http://www.jarkman.co.uk/catalog/robots/msftime.htm 
// Prerequisites: 
// An MSF time receiver, wired to analogue pin 0, like this: http://www.pvelectronics.co.uk/index.php?main_page=product_info&cPath=9&products_id=2 
// Time library: http://www.arduino.cc/playground/Code/Time 
// Library compatible with Arduino IDE 0023
#include <Time.h> // from http://www.arduino.cc/playground/Code/Time
#include "MSFTime.h"
#include <LiquidCrystal.h>
MSFTime MSF;// = MSFTime();
 time_t prevDisplay = 0; // when the digital clock was displayed
 byte prevStatus = 255;
 time_t msfTimeSync();
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 void setup()
 {
 lcd.begin(16, 2);
MSF.init( 255 ); // LED pin for status - pass 13 for the built-in LED on the Arduino, or 255 for no led at all
 // For reasons I do not understand, you cannot use this when running with USE_AVR_INTERRUPTS
lcd.println("MSFduino............");
 setSyncProvider(msfTimeSync); // tell the Time library to ask for a new time value
}
void loop()
 {
 byte currStatus = MSF.getStatus();
if(currStatus != prevStatus || currStatus & MSF_STATUS_FIX)
 {
 if( currStatus != prevStatus )
 {
 if( currStatus & MSF_STATUS_CARRIER)
 lcd.println("Got carrier ");
 if( (currStatus & MSF_STATUS_WAITING))
 lcd.println("Waiting for sync");
 if( (currStatus & MSF_STATUS_READING))
 lcd.println("Reading fix");
 prevStatus = currStatus;
 }
now();
if( timeStatus()!= timeNotSet )
 {
 if( now() != prevDisplay) //update the display only if the time has changed
 {
 prevDisplay = now();
 digitalClockDisplay();
 }
 }
 }
 }
 void printDigits(int digits){
 // utility function for digital clock display: prints preceding colon and leading 0
 lcd.print(":");
 if(digits < 10)
 lcd.print('0');
 lcd.print(digits);
 }
 void digitalClockDisplay(){
 // digital clock display of the time
 lcd.print(hour());
 printDigits(minute());
 printDigits(second());
 lcd.print(" ");
 lcd.print(day());
 lcd.print(" ");
 lcd.print(month());
 lcd.print(" ");
 lcd.print(year());
 lcd.println();
 }
 time_t msfTimeSync() // called periodically by Time library to syncronise itself
 {
 return MSF.getTime();
 }
 /***************************************************************************************/

13 thoughts on “MSFduino – A clock using the MSF 60kHz time signal

  1. D Haines

    Hi there.
    I have been playing around (unsuccessfully) with the MSF clock board of the same type that you have utilised.
    I started trying to work with the sketch

    Reply
  2. D Haines

    Whoops sorry I got a bit quick with the return key.

    Hi there.
    I have been playing around (unsuccessfully) with the MSF clock board of the same type that you have utilised.
    I started trying to work with the sketch using the info from Jarkman’s site but have no success at all with a multitude of compile errors, mostly “not declared in this scope” errors and things like pinMode not declared.
    I have put the library in the library folders as MSFTime and this has got me completely foxed.
    Was there anything major you needed to do to Jarkman’s original sketch to make it work.?

    All the best

    Dale H G4IPZ

    Reply
    1. Alex

      Hi Dale,

      No major changes. Just making sure things were in the right folders.

      I tried uploading the sketch to an Arduino Nano the other day with a newer IDE and it chucked up some errors, presumably similar. The sketch worked perfectly on a Uno with pre v1.00 IDE so I think I’ll have to do some figuring out as to why it didn’t work in exactly the same way with the newer IDE. I assumed the cheapo Nano was on the fritz but maybe not.

      If I get the chance I’ll have a look this evening

      73

      Alex

      Reply
      1. D Haines

        Hi Alex
        .

        Thanks for that.

        I’ve not had a chance to take another look today as, due to my own stupidity, I’ve been going around in circles on another project.

        I’d updated a GPS sketch of mine then found it wouldn’t run when uploaded to my bare-board Uno.
        So I rolled back to the previous version of the sketch and found that wouldn’t run either.

        After several prolonged head scratching hours I finally remembered that I’d changed the I2C address between versions of the thing that I’d built.

        The first version board used a commercial I2C display driver board (address 0x27) but the later version I had built using an on board PCF8574AP chip directly.

        The AP chip comes with a different bank of I2C addresses to the commercial driver board which uses an SMT device and so it needed 0x3F in the initialisation string instead.

        DOH!

        The joys of technology

        73

        Dale (Slim) Haines G4IPZ

        Reply
  3. Alex

    Don’t you just love it. I’ve spent too many hours moving stuff about in files and folders for this project only to find I’d not even uploaded the sketch to the board!

    Reply
  4. D Haines

    That rings more than a slight bell. And of course the good old Arduino IDE doesn’t prompt for a save when you click exit. I’ve lost a few bits of stuff that way desperately hoping that I didn’t click exit before I’d saved the sketch and, of course, knowing full well they’d gone down the proverbial pan.

    Reply
  5. Alex

    I’ve had a prod about with mine and tried both the new and older IDE’s and I’m thinking the older libraries are not compatible with the new IDE as it works with v 0023 IDE. As long as the libraries are in the right place then it compiles , uploads and runs successfully.

    Reply
  6. August Ackley

    Hi, I’m having a bit of trouble with building the connections. Is there any way that you have a circuit diagram or a clearer picture of the arduino connections? Thanks

    Reply
  7. August Ackley

    I’m struggling with where basically every wire should be. Is the first screenshot the circuit diagram of the original project?

    Reply
    1. Alex Post author

      Ah, I see. There are two parts to it. One bit is to wire up the LCD, of which there are plenty of wires. The other is the receiver, this is much easier as there are only really 3.

      The LCD needs quite a few. There are power connections, signal connections and light / contrast. It might be worth getting your head round the arduino LCD ‘hello world’ first (https://www.arduino.cc/en/Tutorial/HelloWorld). Once you’ve got that sorted it’ll be simple to add the receiver

      Reply
      1. August Ackley

        Thank you! I’ve figured out the LCD connections. For the the receiver, does TCON connect to analog 0?

        Reply
        1. Alex Post author

          Good stuff. It is A0 if I remember right. Its been a while. Don’t forget about the libraries and the compatibility. I used version 0023 of the ide and it compiled and uploaded ok. I’ve not tried it with later versions

          Reply

Leave a Reply