Beeper driven by LED(0) the power LED

Objective
Allow someone at a remote browser to click on a link and cause various tones or beeps (perhaps in Morse code) to be output by a loudspeaker connected to a LED line via an audio amplifier.
Then allow the person who hears the beep to press one or more buttons that causes a messages to appear on the web page viewed by the remote user.

Example
One type of beep may mean "Harold here - please switch on your computer, I am on Skype"
The different buttons pressed may mean - "OK, wait a moment" or "I am busy at present"
The beep might also alert the user to a message on the 4x20 LCD display .

Method
I chose to use LED(0) (the power LED) since it is hard to connect the CPU line on this LED and this LED alone is wired one side to earth. I connected a wire to the live side of the LED (which connects to the CPU line via a 220 Ohm resistor)

The wire then connects to the input of an audio amplifier chip feeding a small loudspeaker .
The LM386M-1 amplifier shown below is a surface mount chip.
Pins 8/6/1/3 were bent up to allow the use of a 0.1 inch matrix board.
Flying leads connect to pins 6 and 3. Pins 1/8/7 marked X are unused.

Simply connecting to the LED line works for the beeper but for the WAV player (see below) the quality is much improved with the tone control shown below. The transistor gives a clean 5volt pulsewidth modulated signal independent of power bus noise coming from the Sweex. The 5volt supply feeds the amplifier and is derived from the 12volt wall power supply independently of the 5volt supply within the Sweex. Signal leads to the amplifier are screened.

The connections to the CPU lines for GPIO 8/9/ 11/12/ 14/15/ 17/18/ 20/21 are also shown.

(The capacitor connecting the 8 ohm speaker to the chip is 250 microfarad or more, plus side to the chip)

beeper

The beeper is given a square wave created by pulse_burst.c I tried to use usleep (delay in microseconds) but that cannot create short delays so I used a crude FOR loop.
The compiled code is pulse_burst that I put in folder /test on the USB stick that I boot my Sweex from
I drive this from the ash script beethoven.sh shown below (this creates a (tone deaf!) di di di daaaaaa)

#!/bin/sh

# beep parameters :-
# led number (0=power led)
# pulse on time
# pulse off time
# number of pulses

cd /

./test/pulse_burst 0 4242 4242 160
usleep 103000
./test/pulse_burst 0 4242 4242 160
usleep 103000
./test/pulse_burst 0 4242 4242 160
usleep 103000

./test/pulse_burst 0 5100 5100 1000

LCD message display with push buttons for reply

The remote user clicks on a prepared message or creates a new one by viewing a web page created by beeper1.txt (change .txt to .cgi - my server hates .cgi!). This uses for the top of the page beeper1.html and calls ash script pg-beeper1.sh which passes the strings from the webpage that the remote user selects to the Blassic basic program button_control.bas. See pull down menu item 14 and item 12 (page bottom) for an explanation of this procedure.

The reply can be one of three choices selected by one of three push buttons. When a push buttons is pressed it flips a flip-flop within a quad 2 input NOR chip (4001) and an led below the button comes on to confirm the press. Later the Sweex sends a pulse to the flip-flop to reset it ready for the next button press (and the led goes off).

The circuit is shown here

(The keypad and green display are connected by I2C and are for future developments.
The graphic display (top left) is for future use with a PIC micro)

Improved Message board with rolling long message display and beeper
(July 2007)

This is my backup of an improved set of files that let a remote user leave a message on the LCD on my router.
Blassic basic is used to parse a long message so that words are not split in half at line ends on the LCD display.
The long message is split into pages that cycle on the LCD display.
It is not perfect yet! email me if you do something similar.

The remote user calls up beeper1_pages.txt (change txt to cgi)
which displays beeper1_pages.htmlThis holds some fixed messages to click on and a message box. The data is taken by the cgi file which calls up
pg-beeper1_pages.sh and this in turn calls button_control_pages.bas to do the work of parsing and displaying etc

Make it talk!

A WAV file sampled at 8bits mono contains some header data and then a long series of 8bit byte (0-255) samples of the sound waveform. I use Audacity, a free program that lets you record in many formats at all speeds.

talk16.c (compiled as talk16) sends the data in test.wav to the led(0) line as a sequence of variable length pulses that average out in the loudspeaker as analog samples - see the notes in the c program.

The driver program determines the length of the WAV file and then reads the data into arrays in memory. If you know how to force an accurate very short delay please email me (machine code writer needed!) . You could then read the header data and make a real WAVE player.

Some WAV files that work for me - homer not die - make my day
- sunspot
( NB- they play better on the PC) - I had to use Audacity to get the speed right on the Sweex.

The pulse stretcher loop in the program can be removed and sample rates of about 30000 samples per sec give very good quality but big files.

The WAV files output by Audacity had long silences at the end - I removed them with Hexedit.

I recorded at 18k samples per second and saved as 8-bit Microsoft 8bit PCM in Audacity - these work for n=0 in the driver program but you need to experiment to get the speed right. Audacity lets you record a tone and you can compare the tone coming from the Sweex with the original from the PC.
I now use WAV files instead of RAW - the header is very short and can't be heard and you can play the files on a PC.
I find that big files play slower than small ones and need a different bit rate from Audacity.

You will notice that I do not know much about c coding - send me a corrected copy if you use it!

Here is a sample recoded on my Mac microphone from the loudspeaker in the box in the above photograph - click here
(it contains 2 speech samples and a Windows chime)

I record as loud as possible and just avoiding distortion (like TV adverts!) so as to mask buzzes and clicks from the Sweex. I wish I knew how to make the CPU give the WAV player all of it's time.

Allophone test - synthetic speech - new 30/12/07
The
SPO256 speech chip joined allophones together to build any word. It is no longer sold but the allophone set is available on the web.
The WAV player on the LED(0) line can give reasonable speech if the signal recorded is loud - the problem is that the delay loops change length when other kernel processes take over the CPU briefly - this makes clicks and noises.
I amplified the allophone set by 21dB in Audacity to drown the noise and used 8bit unsigned microsoft WAV at 8000 Hertz as above.
The allophones are joined together by simply playing them in sequence using an ash script. A more sophisticated joining of the allophones would be prefered but It is possible to build words that can be recognised!

I may try a D to A converter next using 8 LED lines and an R/2R network. That should not be troubled by clicks - other kernel processes will cause small delay errors that may not be a problem within a word . The raw unamplified allophone set would then give much less distortion.

My test files for back-up are here

 

These are my notes for my backup and future reference - if you do something similar please email me