Linux Talking Alarm Clock

So alarm clocks will probably be running Linux! (What! yours already does?)

Recently I found out that in 2007, AT&T pulled the POPCORN dial up time service since its decline of use. Cell phones and computers were now used for setting dumb clocks and dialing for time was rarely needed. I know I haven’t called it in a long time.

So Raspberry PI or Beagleboards which run a nice implementation of Linux can make a P1010841decent alarm clock. But being an alarm clock, it has to make waking sounds and should say the time and other interesting things. For this, I used the BeagleBone Black running Debian Linux. It is a TI Sitara AM335X Cortex A8 processor, 512MB DDR3 Memory, and 2GB Flash Storage.  It supports Ethernet, HDMI, USB Host/Client and two 46 pin dual row headers.

Getting the time is pretty straightforward, an NTP Daemon can set universal time (UTC) over Ethernet with pool.ntp.org or local NTP server.  The time zone data base is updated automatically through Debian package auto update.

For audio, the BeagleBone Black HDMI has an I2S interface for 48KHz 16 bit stereo audio. The Sitara processor has a superset of I2S called the McASP peripheral. The I2S signals from the Cortex A8 ARM are available on the 46 pin headers including the bit clock.

P1010833I wanted to try the deep throw 1” speakers which need about 2 or 3 watts. I designed a two layer board (called a cape) to add the audio DAC and amplifiers to the BeagleBone Black. There are a lot of cheap audio DACs out there – I used the NXP UDA1330ATS in a SSOP-16 package. This would take the I2S and convert it to two analog outputs. The analog outputs would each go to a 3 watt mono bridged audio amplifier chip TI LM4991 in an SOIC-8 package. I chose the UDA1330 DAC because it had both L3 serial control interface or simple DIP switch to set certain parameters.

I added other “experiments” to the board to save on board cost, so the PC layout files P1010844won’t be of much use.  The capes have complex PCB edge routing to clear the Ethernet connector that I had to piece together from a variety of sources. I’ll release a measured drawing in pdf for the outline and connector placements. The BeagleBone Black, DAC and power amplifiers are powered from 5V.  I used a pair of 5V LDOs to help keep the digital noise away from the audio analog sections and moved the power jack from the BeagleBone to the cape and power it from 6V. It does have the CAT24C256 I2C EEPROM although haven’t used it.. The L3 control signals were wired to the BeagleBone’s GPIO lines; however, a quad DIP switch was enough to program it to get it to work.  The advantage of the L3 over DIP switch is adjusting volume levels.  To use L3, No load R6/SW1 and load 0 ohm resistors (jumpers) to R9, R11,R12, and R13.

Another blog reported that I2S_BCK was inverted. This looks to be the case so a 74LVC1G04 was added and powered from BeagleBone’s 3.3V power to match 3.3V logic levels. I2S signals to the DAC are BCK, LRCK, DATA and SCK – all inputs to the DAC. The 5V DAC has  VIH minimum of 2.2V and can be easily driven by 3.3V logic. The digital side power has 0.1uF and 10uF ceramic bypass capacitors. The analog side has 0.1uF ceramic and 10uF tantalum with a ferrite bead. The tantalums have higher ESR than ceramics and less likely to create unwanted resonance peaks that a 10uF ceramic would.. Note that the output of the DAC is 1.0Vrms at 3.3V power supply and 1.45Vrms at 5V. That is, it is 3.2dbV higher output at 5V while the amplifiers are still looking for a 1.0Vrms input. I probably should have put an attenuator between the DAC and amplifiers but the amplitude of the sampled signals can be reduced or the volume reduced from L3 interface. The C4/R1 (C12/R8) form a high pass single pole filter with -3db cutoff at about 4Hz. The C7/R2 (C15/R10) form a low pass filter with a -3db cutoff  of 20KHz.  If improved high frequency response is needed then decrease C7/C15 to 270pF. The bridged output drives a 20mm deep throw CUI CMS0201KLX 8 ohm 2 watt loud speaker.

I made an acrylic enclosure based on the builtospec case on thingiverse. modified to hold P1010751both the little speakers and the audio cape. This case is available as dxf scaled to millimeters. It is cut out of 1/8″ acrylic plastic (280mm x 175mm min). The drawing has three layers, 0 (base layer) is cut, engrave (red) is engrave only and nomen (blue) is nomenclature and is not cut or engraved.

Hardware needed is:

  • 4 M3 x 0.5 x 15mm allen hex screws
  • 4 M3 x 0.5 x 20mm allen hex screws
  • 4 1/2″ Standoffs
  • 8 M3 nuts

The board was assembled using a hot plate and mylar paste mask stencil cut on a laser engraver.

Downloads:

Like my Voxclock, I used tracks found inside of Half Life video game. The instructions for extracting those files can be found here. The BeagleBone will need alsa-utils, if they haven’t already been installed.  Also, to run sound apps from user, you have to add username to group audio. (usermod  -a  -G audio <username>) The files need to be converted to 48KHz 16bit stereo. SoX can be used in batch mode to convert all files with simple bash script.  If files extracted are in src directory and processed files go into dest directory then:

for file in *
do
    sox --norm=-3 src/$file -c 2 -b 16 -e signed -r 48k dest/$file
done

File can be verified by running:

soxi dest/alert.wav

File can be played with:

aplay dest/alert.wav

HDMI would turn off if there was no keyboard/mouse. I’m not sure if this is still there but if this is the case, it can be fixed by editing /boot/uboot/uEnv.txt and adding optargs=”consoleblank=0″ after commented lines:

##BeagleBone Black:
##Disable HDMI/eMMC
#optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMMC-2G
optargs="consoleblank=0"

It does work! Speech is very clear and can be heard across the room. Music sounds like internal smartphone speakers – recognizable but not great. I don’t detect any hum or noise while it’s quiet. It is not a high fidelity system but will work well as an alarm clock.

 

2 thoughts on “Linux Talking Alarm Clock

  1. mark

    I liked your clock write-up!
    The UDA1330ATS is now a very cheap access to a filter and DAC. I liked your clock write-up.
    I want to use this chip, confused by RS-Online saying it is SPI serial, then data sheet has i2c and then modes of MSB/LSB first ‘alternative’ to i2c. Timing looks SPI.
    Where is the blog about a possible inverted input pin, would that be an issue if SPI works?
    Many thanks, not sure how far back you put this project up.

    Reply

Leave a Reply to Bob Cancel reply

Your email address will not be published.

Enter correct number to post comment *