Pic Ringtones
This Project started as an attempt to create a system for creating and using Ringtones with a microcontroller in a simillar way to  mobile phone.  I quickly found that there wasn't enough EEPROM space in a 16F84 and decided to continue anyway and create a way editing 'chimes' to give a bit of variety to the humble beeps which can be quite dull.  The plan was to have a separate microcontroller for making sounds which could function as an 'add on' for other projects.  So far, eight of the control lines are used as follows:

A4--While low, this pin will trigger the playback cycle.  The cycle will repeat indefinately.  By setting the last note to 0 and the duration to 255, it can be made to wait for a long time so the controller asserting this pin can hold it low long enough for one repetition and allow some extra time to prevent part of the tune being cut off or having it make a partial repeat before being stopped.  As soon as this pin goes high, the playback stops. Don't forget to use a Pull-up resister on this line.
A3--Connects to ground through a Piezo
A2--Connects to an optional LED which was used for testing but I decided to leave it in because it was quite usefull.  When the data is sent to the PIC from the PC, it blinks when the data is being written to EEPROM.  It doesn't blink while the header is being confirmed in the data frame so it doesn't start blinking immediately.
B0--Sending this line low makes a one-off warble sound.  To make it repeat again, you will need to send it high then low again.  It is intended that this line be toggled to trigger the response.  It should be held low for at least 15 to 20 instruction cycles to avoid it being missed then taken high again. Don't forget to use a pull-up resister on this line.
B1--Same as B0, but makes a Low-High beep.
B2--Same as B0, but makes a Low-Medium-High beep.
B3--Same as B0, but makes a High-Medium-Low beep.
B5--This line should be connected to the Serial port of the PC (TX) through a suitable buffer, such as a MAX232.  There are some simple transistor / resister / diode circuits on the internet which should also work but I haven't tried any of them.  The data is recieved only if all the other input lines are high. If this pin is not being used, it should be tied to VCC through a Pull-Up Resister. Because the tone is stored in EEPROM, programming can be done as a one-off if the project doesn't have a serial port.

The format is 2400-N-8-1.  I am providing a copy of the simple utility I wrote which allows ringtones to be composed on a PC.  It is really simple but does the trick.  The data frame starts with "PIC_TONE_V1.0" and ends with a note value of 0xFF so that the bus to the RS232 interface can be shared by other devices.  Data will only be written to EEPROM after the header has been accepted.  When this happens and it starts writing, you will see the LED flash (if used).  Other devices sharing the bus can also use their own headers and thus, whatever the PC sends, should be able to find it's correct target. This allows the chip to be connected to the serial port on it's host device and share the same connection as the host.

By sharing the serial connection with a host, this chip should be able to co-exist with it's host and other devices without the added complexity of a separate serial port.  The inputs for triggering it have had the internal pull-up's disabled so it should be able to sit on a bus shared by multiple hosts.  The inputs are mutually exclusive, that is, while one is low, the other inputs won't be checked until the line has gone back high and the beep has finished.  This project is only about two days of work and so far, hasn't failed although my testing hasn't been extensive.

Using the Editor:
Download Editor
Download HEX file
Download Sample Tones
Using it it pretty straightforward:

The notes are numbers from 0 to 255 in increments of 5, ie: 0,5,10,15,20 etc.  0 is a pause or silent note and 255 is used to signify the end of the melody.  a 255 must be put at the end or it may have unpredictable noises at the end. 5 is the highest pitch and 250 is the lowest.

The Durations are numbers from 1 to 15.  0 is not valid and any number above 15 is not valid except for 255.  255 is used for long delay.

The Download button copies the file to the pic using COM1.
The rest of the buttons are pretty self explanatory.
The files use the extension .RTN, try some of the sample tones, nothing fancy but they will make a starting point..

If you find any bugs, please E-Mail them to me and I'll endeavour to rectify them.  If this software or the PIC code are going to be used in any commercial project, please contact me first.

If you come up with any interresting melodies, E-Mail them to me and I'll include any good ones on my website including credit to the author.
Return to Pic Page
Hosting by WebRing.