Jeff Epler's blog

25 July 2011, 13:41 UTC

wwvbpy: WWVB timecode generator in python


A few weeks ago, I posted about a WWVB timecode generator written in C. Unfortunately, this timecode generator did not have a clear license permitting modification or redistribution, so I felt I was unable to incorporate it into a project of my own.

Thus was born my own timecode generator, called wwvbpy. Its primary output mode is compatible with the "wwvb2.c" that inspired it. It also has a few features that wwvb2.c didn't: automatic handling of DST, DUT1, and leap seconds. DST is handled according to the operating system's rules for Denver. DUT1 and leap seconds are handled using data from IERS (As a result, my program's DUT1 does not exactly match past broadcast data on WWVB, as the data NIST broadcasts is "an average value for an extended range of dates").

It also has a set of tests of interesting times, such as the first and second days after a DST change, the last and last-but-one days of leap and non-leap years, a historical leap second, etc. (where possible, these test vectors were originally generated by wwvb2; however, some of the tests—such as the DST tests—had to be hand-generated, as wwvb2 couldn't generate them; besides this limitation, I also uncovered a bug in wwvb2 where non-leap years were treated as having 364 days and leap-years were treated as having 365!)

An option to output the timecode data to a serial device is contemplated but not finished; ultimately, this would work together with an Arduino/AVR firmware to produce a logic-level and/or 60kHz modulated version of the signal for testing hardware devices.

wwvbpy is covered by the GNU GPL v2+. It can be obtained from my public git repository: http://git.unpy.net/view?p=wwvbpy.git;a=summary.

[permalink]

23 June 2011, 21:38 UTC

Side track: wwvb links


Chris asks what advantage GPS has over WWVB for my clock project. I don't have a good answer for that (except that having enough controls to select one of 4 mainland US timezones and whether to apply DST is undesirable). However, this did prompt me to do some googling about WWVB. I found some interesting links about generating WWVB signals at home.

read more…

22 June 2011, 20:19 UTC

Towards my GPS LED Light Clock


A few years ago, I made a CCFL light clock using an Arduino with a custom shield containing a transformer (to get a reliable 60Hz timebase) and a triac (for solid-state switching of the lamp). By having a simple 7-day alarm calendar (set at compile time), the clock seldom requires interaction except for the reading lamp function.

However, the design has two main problems:

read more…

29 June 2009, 12:19 UTC

at90usb162 single-sided board


I got an e-mail request for this board. You may use this eagle (4.x) library, schematic, and board under the GNU GPL version 2 or later, or CC-BY-SA.

read more…

5 May 2009, 1:43 UTC

qq: quick & dirty terminal


qq is a quick and dirty terminal application for beagleboard. It's written in Python and requires python-serial. I didn't like cu (no CLOCAL that I could find) or minicom (terminal emulation, keyboard shortcuts and configuration got in the way of real work)

Except for tilde-specials (similar to rsh, ssh and cu), qq just copies data between the local terminal and the given tty. Two tilde specials are defined:

    <CR>~.: quit
    <CR>~b: send break (useful for "alt-sysrq" actions on beagleboard)

Files currently attached to this page:

qq4.0kB

Copyright © 2009 Jeff Epler <jepler@unpythonic.net>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

[permalink]

13 March 2009, 1:33 UTC

Facepalm of the day


I wrote this code for my red alert box and tested it using a shorter timeout than 60 seconds--it worked fine with a 10-second timeout. Just today I realized that the 60s timeout wasn't working; even after several minutes without communication, the globe was still showing green. The cause of the bug is left to the reader, but a hint is available if you click "more inside".

void loop()
{
    unsigned long now = millis(); // time since boot in milliseconds

    if(Serial.available()) {
        level = Serial.read() % 4;
        last_message = now;
    } else if(now - last_message > 60*1000 && level < 3) {
        // if no message received after 60*1000 ms, increase alert level
        last_message = now; // well, sorta
        level ++;
    }

    if(level != oldlevel) {
        set_led_color(level);
        oldlevel = level;
    }
    delay(50);
}

read more…

31 January 2009, 16:29 UTC

Red Alert Box


Every morning I get up too late, and then I think to myself "I'll just check real quick to see that everything on my home network is running". 45 minutes later I've browsed all the new lolcats and read a few personal trainwreck posts on askme, and now I'm running really late.

This is the kind of problem we can solve with technology!

read more…

4 October 2008, 12:54 UTC

Autoreprogram for DFU devices


It's a bit of an annoyance to first have to press a combination of two buttons on my at90usb162 board, then run a sequence of 4 dfu-programmer commands.

Thanks to the magic of the freedesktop 'hal', though, I've written a program that waits for the dfu device to appear. It then erases and flashes the device, finally restarting into the newly uploaded firmware.

Modify the program to name your .hex file (and avr partnumber if it's different), then leave it running in the background. It's still necessary to tickle the RESET and HWB buttons in the proper way after rebuilding your firmware, but it does shorten the process.

Files currently attached to this page:

autoprogram.py1.5kB

[permalink]

4 October 2008, 3:05 UTC

at90usb162 gotcha: PC0 vs XTAL2

24 December 2006, 21:08 UTC

Pluto_Servo has landed

18 December 2006, 3:20 UTC

Pluto-Servo: EMC2 Servo Controller

6 December 2006, 19:36 UTC

Do not buy: PCI-8255

All older entries
Website Copyright © 2004-2017 Jeff Epler