Close
0%
0%

GPS Talking Clock

Accurate time without a display

Similar projects worth following
I was inspired to start this project by listening to the USNO Master Clock telephone feed on New Year's Eve 2017/2018. My wife complained that it was the wrong timezone, but there are no time-talkers left in Pacific time. I glanced over at one of my GPS clocks at midnight and it struck me that there was no reason I couldn't make my own talking clock for either live use with a speaker or perhaps even as a dialup service.

The timekeeping aspect of this project is going to be very simple. While the GPS clock project had granularity down to the 10th-of-a-second, which required some interpolation, this clock will only require one second granularity. There will be a need to keep a sub-second timer, but we'll get to that later. Getting time from a GPS receiver requires handling the serial I/O as well as the PPS output from the receiver. We can use the PPS as an interrupt to create the leading edge of the tick and beep sounds (so that they're as accurate as possible) as well as marking the second-start for synchronizing the software activities.

Like all of the time-talkers that have come before, we want to use sampled audio rather than attempting to use voice synthesis. The limited vocabulary of the clock makes that the path of least resistance. 8 kHz 12 bit PCM audio will provide "telephone" quality level for the audio. The bad news is that the 32 kB of flash available is obviously insufficient for the number of samples required. Storing the audio on an SD card not only gives us a nearly infinite (for our purposes) amount of storage, but by using FAT storage, we can configure the card quite easily. This also potentially allows field replacement of the samples, so that people could customize the voice (even the language) however they like.

We're going to use the same XMega32E5 controller we used in the v5 variant of the GPS clock. The XMega32E5 has a 2 channel DAC that we can use to play back the audio samples from the SD card. We can use one of the timers configured for 8 kHz as a clock for the DMA controller to trigger updating the current DAC value so that playback can be done largely in the background (we will have to double-buffer SD card reads to insure the playback remains seamless, but that's only 1k of RAM out of the 4k available).

The actual audio format is going to be 10 second blocks. Every second will be marked by a 10 ms "tick" and every 10 seconds there will be a 3/4 second beep. The leading edges of these will be synchronized to the PPS of the GPS receiver using the PPS ISR. We will configure one of the timers to output a 1 kHz square wave on one of the pins of the controller, and we will simply turn that output on early in the PPS ISR and in the outer loop turn it off either 10 ms or 750 ms after the second.

The audio circuitry will take the 1 kHz square wave output and run it through an RC low-pass filter. Then it will be mixed with the output of the DAC and the sum fed into an audio amplifier and speaker.

The SD card slot will be simply connected to the SPI interface. The directory layout will be top level directories "ZONE" "HOUR" "MINUTE" "SECOND". Inside of each of the hour, minute and second directory will be files named 0-60 (0-24 for hours, and only every 10 for seconds), each of which will be an audio snippet. Inside of "ZONE" will be files with two letter names, the first of which is a timezone (Pacific, Mountain, Central, Eastern, Alaskan, Hawaiian), the second of which is either S for standard or D for daylight. There will also be a "U" for UTC. Every 10 seconds, the playback will consist of the appropriate ZONE file, then hour, minute and second. The intended scripting is "At the tone, Coordinated Universal time will be 23 hours, 59 minutes, 50 seconds." The first second of each 10 second block will be reserved for the previous block's mark tone. Seconds 2 through 6 are for the "ZONE" file, then one second for each of the time files, which means the whole thing should end just before the 9th second.

There will be a simple set of DIP switches on the board to configure the desired timezone. The system will simply continuously generate the audio stream, and the speaker turned on with a momentary push-button. The push-button will be an input to the controller and the firmware will toggle an enable pin on the audio amplifier. This design allows for autonomous audio...

Read more »

gps_voice_clock_1_2.pdf

PDF Schematic

Adobe Portable Document Format - 74.60 kB - 02/06/2018 at 01:45

Preview
Download

gps_voice_clock_1_2.sch

EAGLE Schematic

sch - 461.88 kB - 02/06/2018 at 01:46

See BOM
Download

gps_voice_clock_1_2.brd

EAGLE Board file

brd - 155.32 kB - 02/06/2018 at 01:46

Download

  • 1 × Assembled board
  • 1 × Laser cut wood case part set
  • 2 × feet of 22 gauge hookup wire
  • 1 × PR144C1900 Big Red Button
  • 1 × CSS-66668N Speaker

View all 11 components

  • Laser cut wood case

    Nick Sayer02/20/2018 at 06:59 1 comment

    My friends at Steamy Tech helped me finalize the design for the laser cut and engraved wood case that's coming soon to the store. It's 4" x 4" x 2", and by housing the speaker in a cavity that size, the bass is really accentuated and the whole thing just sounds a whole lot better.

    The DIP Switches are accessible through a cutout on the back panel (you mount the DIP switches on the opposite side as the components for using the case), and the big red button on the top has the obvious function.

    They've got a few pressing items on their schedule, so it'll be a week or so before the inventory of cases is available, but I think it'll be worth the wait.

    EDIT: The case doesn’t have any viewports for the LEDs, but it turns out you can see the FIX LED through the speaker cone. If it’s not blinking, then GPS isn’t working. That’s the number two reason (after the speaker being turned off) that the clock would be silent. 

  • Chimes and configuration

    Nick Sayer02/06/2018 at 17:27 0 comments

    I've added support to for optional chimes and hour-strokes at the top of the hour.

    That sort of begs the question as to how to enable/disable the chimes temporarily when you don't want them.

    The DIP switches would seem the natural mechanism, but there are only four of them, and I don't want to just keep piling them on.

    It occurred to me this morning that I could simply add a config file to the top level of the SD card. That would allow configuration of, say, 8 different timezone/DST settings with the DIP switches and set one switch aside to turn the chimes on and off.

    EDIT: The chimes now can actually be on any minute you like, with optional per-hour STROKES at the top of the hour. The SD card now comes programmed to perform full-on Westminster Quarters.

  • Second build report

    Nick Sayer02/06/2018 at 01:45 0 comments

    The second prototype boards came today and they're almost ideal.

    As I mentioned in the last log, I do think I'll back down from a buck converter to an LDO to make the 3.3v power for the controller and GPS, but the addition of the preamp improved the range of output loudnesses available - making more of the range of the adjustment pots usable.

    I am going to change a pair of component values, however. The preamp only needs to have 5x gain instead of 10, so that means dropping the feedback resistor from 200kΩ to 100kΩ. The audio (to my ears anyway) sounds a bit less tinny changing the LPF feedback cap on the final amp from 2200pF to 0.01µF.

    But that's about it. With the larger speaker, I wouldn't call the volume "room filling" in the same sense as a stereo, but it's certainly loud enough to serve the purpose. If I did a better job recording the audio samples, that would probably help quite a bit too.

  • Buck -> LDO

    Nick Sayer01/31/2018 at 15:52 0 comments

    It occurred to me today that the combined draw of the Xmega and the GPS chip isn't likely more than 75 mA or so, so the buck converter is a bit of a waste. The final version will have a simple LDO instead. There should still be plenty of capacity left over to power a 3.3v antenna if it's jumper that way (the default, however, is 5v antenna power).

    The only other question for that version is whether the preamp will be kept or not. We'll get the answer to that when the 2nd prototype boards arrive, probably early next week.

  • Accuracy

    Nick Sayer01/28/2018 at 19:58 0 comments

    The old saw is, "measure with a micrometer, mark with chalk, cut with an axe."

    Using GPS to provide a source of time signaling directly through human senses is always going to be swatting a fly with a hydrogen bomb. Humans just aren't very accurate preceptors without lots of technological assistance. The visual GPS clock that presaged this project wound up with an accuracy of ~180 µs, but the granularity is only 100 ms. The speed of light has essentially no bearing on the accuracy.

    Unfortunately, I don't have any information about the latency of human perception.

    The talking clock has a granularity of only 1 second. But how accurate is it?

    Because the tick/beeps of the talking clock are 1 kHz and the oscillator for them is free-running, the accuracy spec starts at ±1 ms, but there's also the PPS ISR's latency to consider, which is probably a few microseconds (that ISR has little to do other than enable the tone output). Depending on where you are in the room relative to the clock will also have an impact because of the speed of sound - probably adding another 2-3 ms of latency if you're ~1 meter away.

  • Mystery solved

    Nick Sayer01/27/2018 at 16:53 0 comments

    Thanks to Ted Yapo for responding in the comments to a previous log. He solved the mystery.

    He said that the LM4871 LPF feedback cap (C20) was the problem. That got me to recalculate LPF rolloff and it was 24 Hz. Way, way too low. I had wanted something more like 2.4 kHz.

    First I removed the cap entirely and it really did jump right up.

    I had replaced the 20kΩ feedback resistor (R9) with 56kΩ, so the LM4871 gain is now officially 7 dB instead of 3 dB. I added back in 1000pF just to give it some pro-forma rolloff, but I can't really hear a difference.

    When the next boards come, I can experiment a bit. I can replace the pre-amp's feedback resistor with 0Ω and leave off the rest of the preamp components and it will be as if nothing is there. Or I can populate the pre-amp and see which way is better.

    As for the speakers, the little tiny ones I originally bought won't cut it. Trying to get enough gain for the voice output to sound decent makes it clip badly. The larger speakers, unsurprisingly, sound a lot better. If there's a downside, it's that the case will wind up having to be much larger (still not at all sure what I'm going to do there).

    It turns out that a new board rev was going to be necessary anyway because of the previously noted errors. In addition, I swapped the poles of the two gain trimmers so that the directionality correctly matches ordinary expectations (CW for higher gain).

  • Next prototype ordered

    Nick Sayer01/27/2018 at 06:17 0 comments

    I've added an op amp preamp configured for 10 dB of gain and ordered a set of boards. 10 dB is ostensibly too much gain, but the way things are now, the two gain pots are all the way up. With 10 dB of intermediate gain, the hope is that the "sweet spot" for the output will have those pots further down in their ranges. The most likely explanation I can come up with is that the maximum amplitude of the output from the controller is 1.65Vpeak. Doubling this yields 3.3Vpeak. If you calculate the average power (P = Vpeak^2 / 2R) into 8Ω, you get a little more than 0.5W. If instead you look at the power from 5Vpeak, it's over 1.5W.

    Configuring an OP Amp for a single supply voltage to amplify an audio signal isn't too hard. You use an inverting configuration (because audio doesn't care if it's inverse - that just means the speaker pulls instead of pushes, but it sounds the same) with a Vcc/2 virtual ground (classically the non-inverting input is grounded) made with a two resistor divider (and a decoupling cap). The input and output are both AC coupled. The LM4871 generates differential output power with 3 dB of gain, so if the output of the pre-amp is maxed out, it will max out the output of the power amp.

    I've now got two choices for speakers. One is smaller, but it's low frequency performance is much poorer (as you might expect). It's also a couple of dB less efficient overall.

    If the result still isn't loud enough, then the audio amp will need to be ramped up, probably to something running on a higher voltage supply.

  • The audio mystery

    Nick Sayer01/21/2018 at 16:45 5 comments

    I'm going to have to take the clock back to the workbench and check some stuff out on the scope. It just doesn't seem completely reasonable that given input levels that are ~3Vpp that the LM4871 can't generate enough output. At the same time, given that the specifications of the speaker are something like 98 dBA 1W/0.1M I can't quite square that with "hold it next to your ear" levels of audio. The input levels ought to be making easily 1W of output, and 1W of output ought to be making far more sound unless I'm misunderstanding something badly.

  • First hardware report

    Nick Sayer01/19/2018 at 00:57 0 comments

    The first boards came back from OSHPark. There were a couple of bugs and improvements in the firmware that came out of it, but at the moment there are two hardware bugs that I'm going to have to fix.

    The first is that I reversed the differential inputs on the LM4871 audio amplifier input. I was able to work around this on the prototype by lifting the pins and air-wiring them. The v1.1 board design has already been fixed for this.

    The other issue is that the audio output is just way too quiet. You can hear it if you hold the speaker right up to your ear, but it's not nearly loud enough to actually use. I'm not sure if it's because the speaker is too puny or if the input levels aren't high enough. What you can hear, however, is definitely good enough in terms of audio quality. The tick/beep output has just a little bit of shrillness (the low-pass filter isn't quite sharp enough to really make it a pure sine output), but that's not out of place. Even increasing the feedback resistor (and thus increasing the amplifier's gain) from 20k to 56k wasn't a significant increase in output volume.

    Another correction v1.1 will have is that I've decided to put a MOSFET in to properly level-shift the audio !SHUTDOWN pin. The current design has a 5v pull-up resistor, but that still winds up feeding some current into the output pin of the controller when it's off (since the off level is 3.3 volts). It's not fatal, but it's not ideal.

    I'm not going to order the next version of the board, though, until I decide what I need to to do get more audio out.

  • First cut at firmware complete

    Nick Sayer01/08/2018 at 07:54 0 comments

    I spent most of this evening writing the first cut of the firmware. I don't think I'll be sufficiently inspired to breadboard the whole thing before the boards come back from the fab, and even if I did, I don't have any of the requisite audio files created. I'll have to spend an evening this week sometime dictating those.

    The top level directories on the card are ZONE, HOUR, MINUTE and SECOND. Inside of zone will be files named with two letter names (with the exception of just "U" for UTC) with the first letter being one of 6 for the timezone (P, M, C, E, A, H) and the second letter being S or D for standard or daylight savings time.

    Inside of the other directories will be numeric filenames for 0-23 hours, 0-59 minutes and 0, 10, 20, 30, 40 and 50 seconds.

    All of the audio files will be little endian 16 bit 8 kHz mono raw audio files (though the files are 16 bit, the DAC will truncate them to 12 bits. In the grand scheme of things, this probably won't be noticeable). Each intro file must be no longer than 4 seconds, and each of the other files must be no longer than one second.

    The ticks and beeps will have their leading edges synchronized with GPS time via the PPS pin ISR. Given that the frequency is 1 kHz, that implies up to 1 ms of jitter, though exactly how meaningful that is to human hearing is questionable. It still will wind up being far more accurate than any "time talker" telephone line you can use today given the lack of latency and jitter guarantees of the telephone network.

View all 12 project logs

  • 1
    Usage instructions

    Install a CR1220 battery in the backup battery bail. This battery is optional, but if present will help the GPS receiver by preserving the satellite almanac across power cycling.

    Insure a properly formatted and loaded µSD card is installed in the slot.

    Adjust the two trimpots on the board to the center of their range to start with. The pot closest to the button controls the gain of the ticks and beeps, the other controls the gain of the sampled audio (chimes and speaking).

    Connect a GPS antenna to the SMA jack and plug a 2.1mm barrel connector with 5 VDC center positive to the power jack. The FIX LED (LED3) near the corner of the board and the GPS diagnostic light (LED1) should come on. As soon as the GPS receiver gets a fix, the FIX LED should start blinking at 1/2 Hz and the GPS diagnostic LED should go out. At some time a few seconds later, the clock should begin playing the audible timecode.

    You can push the button any time (except during chiming) to turn the audible timecode on or off.

    At any time, you can change the DIP switches to select the desired timezone. You can also turn switch 3 on or off to enable or disable the chimes. The chimes will only sound when the audible timecode is muted.

    The default time zones available:

    • 0 - UTC
    • 1 - Pacific Time
    • 2 - Mountain Standard Time (no DST - Arizona)
    • 3 - Mountain Time
    • 4 - Central Time
    • 5 - Eastern Time
    • 6 - Hawaii Standard Time (no DST)
    • 7 - Alaska Time

    If at any time LED2 lights, that indicates an error accessing the µSD card. Remove power and try reseating the card. If the error is persistent, it indicates an error in the content of the card. The best suggestion is to reformat and reload the correct sample files into the card.

  • 2
    Assembly instructions

    The board comes as a "quick kit" with the DIP switches unattached. If you're installing the clock in the laser-cut case, then install the DIP switches on the bottom of the board (opposite the components). Otherwise, it's up to you which side. If you prefer, you can connect some other switching mechanism up. The top 4 holes (nearest the center) are the switched pins. Shorting any of these to ground turns the switch "on."

    For mounting in a case, you can connect a remote switch up to the 2 pin terminal near the on-board switch.

    The speaker jack should be connected directly to a 4Ω or 8Ω speaker. The speaker terminals are a bridge output configuration - do not connect one to ground. The bottom terminal is positive (but it doesn't really matter in practice).

    For faster restarts after power outages, install a CR1220 battery under the battery bail on the board. This battery will likely last many years, as it is not used except when the board is unpowered (and even then the draw is very, very small).

  • 3
    Laser-cut wood case assembly

    Attach the speaker loosely to the front panel with 4 3/8" screws, lock washers and nuts. Once all 4 screws are loosely attached, tighten them using a figure X pattern.

    Solder 4 wires to the speaker and button terminals. Use 22 gauge wire 6 inches long (to facilitate easier case assembly).

    Attach the board to the back panel with 4 5/8" screws, 1/4" spacers, lock washers and nuts. Orient the board so that the DIP switches are visible through the cut-out with the switch numbers immediately above. The components should be facing upwards.

    Insert the button firmly through the hole in the top panel (the top panel doesn't have a front or back side).

    Solder the speaker wires to the speaker terminals.

    Solder the two switch wires to the switch terminals, then bend those terminals down to about a 60 degree angle against the switch body.

    Now is a good time to test the circuitry. Connect an antenna and apply power. Wait until the FIX LED (bottom left corner) begins to blink and the GPS LED (bottom of the two paired near the top middle of the board) goes out. Within a few seconds of that, the voice announcements should commence. Push the button to silence them and again to resume. Change the DIP switches to verify they function. Disconnect power and antenna for remaining assembly steps.

View all 4 instructions

Enjoy this project?

Share

Discussions

NobodyYouKnow wrote 01/21/2018 at 19:00 point

Ah. Thanks. That explains why I was not finding it from the usual sources. Of course, it is a BGA device. I haven't tried to push my SMT skills that far yet. :-)

  Are you sure? yes | no

Nick Sayer wrote 01/21/2018 at 19:49 point

it’s actually an LGA - there are no balls. So you just paste and place it the same as if it were a QFN - there are just more pads underneath. 

  Are you sure? yes | no

NobodyYouKnow wrote 01/22/2018 at 13:25 point

Thanks for the correction. That might not be so bad, then. An LGA I can handle. Are you aware of a commercial source that sells in the onesie-twosie range?

  Are you sure? yes | no

Nick Sayer wrote 01/22/2018 at 16:11 point

SkyTraq will sell in small quantities. I just buy large ones for the quantity pricing and to better amortize shipping cost.

  Are you sure? yes | no

NobodyYouKnow wrote 01/21/2018 at 18:49 point

What is your source for the Skytraq / Venus 838LPx-T? I'm having a bit of trouble finding it as a bare chip. Thanks!

  Are you sure? yes | no

Nick Sayer wrote 01/21/2018 at 18:51 point

I buy them a tray at a time from SkyTraq in Taiwan. 

  Are you sure? yes | no

Dan Maloney wrote 01/19/2018 at 19:37 point

Hey, this looks pretty cool. I'd like to write it up for the blog -- do you think you'll get the audio problem sorted out soon? A video of the clock in action would be a big bonus, too. 

  Are you sure? yes | no

Nick Sayer wrote 01/21/2018 at 19:28 point

Absolutely. 

I will say that in this case the video looks almost identical to the picture. 😁 (but the video can carry the audio - I get that).

The audio problem at the moment is a quandary. There shouldn’t be any reason it’s so low, which suggests I’ve just made some other dumb error.

I’m fairly sure I’ll be ordering a second prototype board run this week and I’m confident that one will be correct. 

  Are you sure? yes | no

Nick Sayer wrote 01/28/2018 at 06:12 point

I've added a YouTube video with the improved audio (now that that mystery has been solved).

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates