Saturday, February 20, 2021

YATPGPSDO - Yet Another TruePosition GPSDO - Part 3: the firmware

 In the previous part I described the hardware. So now it is time to write about the software.

First let's summarize what the software needs to do. The TruePosition board implements practically all function of the GPSDO, so we don't have to deal with processing GPS messages or implementing frequency counting or anything else like that. Except for one thing, the TruePosition board would only need power to operate. The one thing is that it won't boot without getting the $PROCEED command via its serial interface. So the bare minimum software is something that send this command and stops. But, of course that is not enough. I want a cool instrument with blinkenlights!

I have to admit that the firmware for this instrument was developed/evolved during some time, while simultaneously learning TruePosition, STM32-Arduino and the u8g2 graphics library. As a result, the code quality is far from best.

Design goals and features

I came up with some design goals and required features for the software:

  • Implement basic functions to drive the TruePosition board. Sent the startup command and any additional configuration command. Monitor status of the board.
  • Provide a usable, concise and aesthetic user interface. Provide means to get detailed data but also have a 'quick glance' way to see the current state.
  • Provide configurable option for timezone, display backlight and position.
  • Be robust. The instrument should tolerate and if possible recover from any issue and notify the user on them.

Basic structure

The development environment was the Arduino implementation for STM32. I initially though that the simple Arduino structure of setup() and loop() was not going to be enough, and I would need to step up to some more complex solution such FreeRTOS, but eventually it turned out to be sufficient. 

The basic structure of the firmware actually very much follows this pattern. After setting up the display, serial lines, etc. it goes into a loop, where it reads character from the GPSDO, detects key presses, handles timing and updates the display and LEDs if required. If enough character is read so that a complete message is received then it is processed. Same for the key presses.

The main loop checks if messages are received from the TruePosition. If they do not appear for a length of time, then the GPS lost message is displayed and the Fail LED is lit. This should not happen in normal operation unless the board stops working or the serial connection is disconnected.

If the boot message is received, the firmware send the $PROCEED command to initiate the booting and waits for the first $STATUS message at which time the GPSDO is considered initialized. 

The User Interface

For main user interface there is a 128x64 pixel bitmap LCD. Obviously a much simpler display would also work, but it looks cool. Incidentally the bulk of the code is about creating the pages for this LCD.

There are two buttons, the Mode and the Select. The Mode button cycles between the pages. On some of these pages the short press of the Select will chose between options and the long press will activate that option. Finally, there are four LEDs. One is for power, on the left side of the front panel, which is always green as long as the device is switched on. The other leds are on the right to the display. The green LED indicates the Locked state. So if there are two green then he GPSDO is locked and operating properly.  The next LED is yellow, which is on if the GPSDO is in Holdover. Finally the red LED indicates fault condition, like disconnected antenna. Additionally there are other states and transitions, like startup or acquisition indicated by blinking and/or combinations of the LEDs.

These are the display pages.

1 - General status page. This is the default page. The status bar shown the current status (such as locked, holdover, etc.). There is an icon to indicate whether the TruePosition is in normal or survey mode. An antenna symbol shown that an antenna is detected and finally there are two indicators for the operation of the 10Mhz and 1PPS output. Although I have never seen the GPSDO board indicate that these are not operational. 

The current time is displayed, as well as how long the device has been locked or in holdover.

Finally at the bottom the number of satellites tracked, the DOP value, the control voltage for the oscillator and the temperature is shown. 

2 - The next page is the clock page. Current time and date and the quality of the timing is shown as well as an analog clock.


3 - Then comes the satellites page. The left shows the constellation and on the right the list of satellites. SNR is a small bargraph in front of each satellite data row in the list. 

4 - The position page comes next. Latitude, longitude, elevation and number of satellites are displayed. Pressing the Select button increases the survey time while long press of the same button initiates a survey.

5 - The final page is the configuration page. Short press of select cycles trough the lines and long press changes that line. Yes, it is not the most ergonomic solution.


The first line sets the time-offset from -12 to +12 hours. The next sets the backlight to always on, always off and automatic.  These settings are not persistent, unless saved using the Save config line. The last line is 'Load last position'. When the configuration is saved, the current position is saved. However, as opposed to backlight and timezone offset it is not automatically reloaded at startup. Instead this menu can be used to load the position, to speed up acquisition.

The source code and the KiCAD files are available under GPL V3 on Github: https://github.com/szigix/YATPGPSDO



Sunday, February 7, 2021

YATPGPSDO - Yet Another TruePosition GPSDO - Part 2: the hardware

The hardware for the GPSDO is very simple. There are two main parts: the power supply and the microcontroller.
All the design was done with KiCAD, design files will be shared in the last part of this series. 

The Power Supply

The power supply is nothing special. The TruePosition board needs 12V, with a peak current of 0.5A, which will decrease somewhat once the oven is warm and the heater switches off. The microcontroller and the display needs 5V with less than 100mA.

This does not need anything extraordinary. I already had nearly everything for the power supply, a 230V/12V transformer, bridge rectifier, capacitors and a 7812 and 7805 regulator. The only component i had to get was the connector/fuse holder/switch to the back.


The microcontroller

The controller part is similarly simple. There is a socket for the STM32 and there isn't much else. Two pushbuttons, four LEDs, three of them connected to the controller. There is also a transistor to switch the LCD backlight and one pot for the LCD contrast voltage. And a couple of headers for connecting all this.

The PCB

The PCB was designed to fit the available space in the instrument case. The transformer and the line voltage parts are on the left, carefully spaced for safety. The power supply is in the middle. Initially I wanted the regulators to go on the backside of the instrument for cooling, so they are both on the edge of the board, but later decided to use a heatsink, so they are connected via wires from their original place. Finally the right side hosts the controller the other small parts and the headers for the display, LEDs, etc. 


Manufacturing was done by JLCPCB, This is the finished board.

Assembly

For such a simple circuit, there wasn't much to get it working. I first populated the power supply part, and made sure that it works as intended. Getting into the case was easy, since the PCB was designed to fit perfectly. There was some fiddly work to get al the wires to the LCD, LEDs and switches, but eventually everything was there. I was considering putting pin headers everywhere, but then decided to simply solder the wires in place. I don't think I ever want to disassemble it and everything is accessible from above as well as from below.
I plugged in the STM32 and tested that it runs and drives the LCD properly. Then finally I connected the power and serial lead to the GPSDO.

It worked without any issues, although the software was far from completed at that time. The BluePill can be programmed in circuit, so I could now concentrate ot the firmware, it was actually easier to do testing in the assembled instrument instead of some breadboard state of completion. I used ST-link V2 to program, but the serial pins are also there on the PCB if someone uses serial programming. 
The next part will describe the software.




Friday, February 5, 2021

YATPGPSDO - Yet Another TruePosition GPSDO - Part 1.

Introduction

As promised in the teaser I am giving a detailed description on my version of the TruePosition GPSDO and releasing the design files.

This is the first part of a series, with the general description of the project, concentrating on the mechanical design. The next part will contain the electronics hardware and the third part the software component.

Why another GPSDO?

First let me give some justification for the project. There are already a ton of GPSDO projects on the net, and one can buy ready made units from all price segments. There are versions specifically for hobbyists, such as Leo Bodnar's unit or the BG7TBL frequency reference.  So why create a new one?

Well, first because it is a fun project, and second, because it is a fun project. I had a TruePosition boards hanging around. I got it years ago from eBay and they are still available for cheap. I did use it for adjusting counters, but by itself it is a pain to use, as it needs power and it needs some kind of a computer to control. Initially I looked around for designs, which there are plenty, but then I decided to spin my own. I wanted to use as many components from my drawer as I could, but I also had the goal to create a standalone unit, which only needs power to run. So after looking around of what I have and what I can use for this project, I came up with the following list of requirement.

  • Built in power supply. There are already more power bricks around than what I want, so let's not have even more. The case will be larger, and one needs to be careful with the line voltage, but that is OK. I already had a suitable transformer, voltage regulators and most important a case that seemed to be large enough to fit everything.
  • Have a simple, but informative user interface. I had a 128x64 pixel graphical LCD, which is probably an overkill for this, but hey, it doesn't really make anything more complex, except for the software. But that can even be updated later and it looks cool. However, I also wanted some status LEDs to check the status at a glance.
  • Be a standalone unit, it should just works without any external intervention or connection. 
  • Use an STM32 BluePill for controller. I have a bunch of these cheap units so why not use one. This looked to be a good learning project, as I have not really used the STM32 before.
  • No computer interface. I just don't need it right now, but I did keep in mind to have the possibility of maybe later adding it in the form of a serial or USB port.
  • No distribution amplifier. It would make sense, but I decided to build a separate amplifier once I need one. This is going to be a 10Mhz / 1PPS reference only.

General description

Let's go from outside to inside. Probably the hardest part of hobby projects is to have a nice casing for whatever one builds. At least for me it is definitely the case (no pun intended). I guess if I had a machine shop, this would make it easier, but I don't, so...

Not all is lost though, fortunately ready made cases can be bought in every shape and form or old instruments can be repurposed. I was lucky, I had an unused case, which was originally destined to host a small power supply, but it never happened. It is approximately a 20x20x8 cm size quite good quality aluminium case, so all components should fit comfortably.

It was important to find a case first, as it determines the PCB design so it is easiest to mount it inside.

The front contains the 10Mhz and 1 PPS outputs, two buttons for control and 4 LEDs for power (green), lock (green), holdover (yellow) and failure (red) and of course the LCD. Which required a lot of careful filing to fit. Sometime I will need to create labels for all of theses to have a really professional front panel.

The back has an IEC connector, switch and fuse and the MCA connector for the GPS antenna,

The inside contains the main components. The TruePosition board is front left. It's size is given, so everything else is based on it. The boards are supported by spacers on aluminium L profiles fastened to the side rails of the case.

The display, the LEDs, the buttons, and the connectors are all on the front pane.  I used ready made cables with the proper SMB connectors.

And finally, the main topic of this blog post: the power and controller board, which is placed aft in the case. It is one board with the power supply on the left. There is the large black transformer, and the STM32 on the right with some additional components. I designed the board to fit into the remaining place, so there wasn't really any problem with component placement. The display, buttons and LEDs are connected with pieces of ribbon cable.

The two voltage regulators were originally go onto the back, but I found a heatsink in my junk drawer that fit perfectly between the profiles holding the TruePosition board, so the regulators went to the front right. The heatsink is a bit overkill, but one can never go wrong with larger than required cooling.

So that is about the mechanical aspects of the unit. Of course everyone will need to adapt to whatever case and components they have.

In the next part I'll describe the design of the power / controller boards. See you soon in Part 2.