PIC Projects
WiFi, Ethernet
Doorbell with SD / EEPROM
SD FAT16/32 for .bmp
LCD TFT Egg Timer
LCD TFT Oscilloscope
SD Talking Clock
SD Sound Recorder,
    FAT32 wav Player
LED Thermometer
LED Egg Timer
LCD Egg Timer

Frequency Counters
TFT 10MHz
100KHz For PC
1MHz For PC
8 Digits LED 50 MHz
Scope Screen Display
LCD Module 10MHz
6MHz for Android
USB PIC18F2550
USB TFT display BMP
USB DS18B20 Sensor
USB Thermometer
USB Counter
USB Meter
USB Oscilloscope
USB Input-Output
USB 16x2 LCD

COM & LPT Ports
MCP3201 on LPT
Serial TFT Text
Serial Inputs Outputs
Serial Port LCD
Analogue Signal to LPT
MCP3201 on Serial Port
Serial Thermometer
Analogue Signal to Serial
LCD Display on LPT
Serial Thermostat

Others
Water Softener
HP Stream 7 docking
3.7V to 5V
Solar Charger

Infrared Decoder
PIC Music

Code Lock
Code Lock with LCD
HOME MOBILE Technical Tips

ARDUINO TALKING CLOCK

The clock tells the time by playing back tracks from the SD. The SD is FAT32 formatted. The tracks are wave (.wav) files of 22.050 KHz, 8 bits, mono. SD card interface the PIC in SPI mode.
The LCD module is 2 lines 16 characters.
The ATMEGA328P generates audio using PWM.

Sound tracks can be any sound. The code doesn't read the file name, it goes to the file number in the list of 27 files. The code plays tracks in this order: tens of hours, hours, "hours", tens of minutes, minutes, "minutes" and then a message, for example; "have a nice day".
The SD card has to be prepared this way:
Files have to be 22.050 KHz, 8 bits, mono. With short names (max 8 characters).
Format the card with FAT32. No folders or subfolders.
Copy to the root folder the files one at a time and in this order; 0 to 19 (20 files),20,30,40,50,"hours","minutes","good day" (or any other message). Totally 27 files. If you make a mistake while copying the files to the SD it isn't good enough to delete a file, you must start again with formatting the SD. The reason for loading the files one at a time is that if you load them together the PC sends them to the card in the order it finds fit, and when the code plays them it picks up the files without searching for their name. The software includes wave files in English.
 

PIC and DFPlayer TALKING CLOCK

The pic drives the LCD to display hours and minutes. Time base is set by dividing 4MHz using CCP1, CCP2, TMR1, TMR2.
Pressing TALK requests relevant tracks of hours and minutes to be played. Tracks can be changed to any language, wav or mp3, you can also record your own voice. 
The SD card in the player must be formatted to FAT32. The player reads the tracks in the order they are written (not by the names), as an example track 53msg.mp3 is read by the dfplayer . Tracks files must be copied to the SD one track at a time and in the order they are in the computer folder. No other files or folders should be on the card. If you wish to change any of the tracks you need to reformate the SD first and then copy the new files.
Datasheet for the DFPlayer:  http://www.picaxe.com/docs/spe033.pdf
The LCD module is HD44780 compatible, most modules on sale are. It can be 1 or 2 lines. 

 

PIC and SD Card TALKING CLOCK

The clock tells the time by playing back recording of sound by the user. The user record saying "one", "two"... till 59. these short recorded tracks are played by the PIC following the hours and the minutes on the display. There are 60 tracks for minutes and 24 tracks for hours. Each track is 1.6 second long. Total memory for the 84 tracks is 4.5 MB.
The Menu has the options of setting hours and minutes, recording and playing the minutes and hours tracks.
The LCD module is 1 line 16 characters. 2 lines module or 20 character modules can be used too.
The PIC16F876A's ADC
digitizes the sound and store it in the SD card (not SDHC). The PIC's CCP is used as a DAC to convert the digital data back to audio. The sound is converted to 20KHz 8 bits mono in a format similar to .wav files. The quality of the audio is reasonable.
SD card interface the PIC in SPI mode. Reading and writing data is in multi-blocks. Memory is used at the rate of 20KB/s. The SD error display indicates error sent by the SD card. The software doesn't use any file system, it just uses absolute memory addresses (raw).
Audio input is 1Vp-p , you can use the mic circuit or other source. The CCP in PWM mode gives 20KHz wave with duty cycle modulated to the audio amplitude. A low pass filter removes the 20KHz component. I added a simple 2 transistors amplifier to boost the power to drive 32 Ohm speaker.
Good free specifications for SD can be found in SanDisk PDF: http://alumni.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf
You are free to use the circuit diagram and software with no limitations.

Circuit Description
See also Technical Tips

LCD supply is 5V. The SD Card supply is only 3.3V (3-3.6V) The 3.3V and 5V are generated on the Arduino board.
The PWM output is boosted by 2 transistors push-pull. The signal to the speaker is PWM of 62 KHz and the speaker outputs the modulated audio only. The speaker should be 8 ohms or higher.
Digital outputs from the Arduino to the SD card use 1K and 2K resistors to reduce the 5V signals to 3.3V. SD output at pin 7 is 3.3V but is enough to drive the input.
The pins number are for ordinary SD card, for MicroSD the pins are different.
Link between Arduino pins 3 and 5 connect 1000 Hz clock from timer 2 to timer 1, these timers generate 1 minute time base.
LCD display and driver has 14 way connector, 10 connections are used, 4 bits data bus is selected. 10K pot adjusts the contrast. Use 16 x 2 LCD module.



Circuit Description
See also Technical Tips

DFPlayer mini module is sold as MP3 player for Arduino. https://www.ebay.co.uk/sch/i.html?_from=R40&_trksid=p2060353.m570.l1313.TR2.TRC0.A0.H0.Xdfplayer.TRS0&_nkw=dfplayer&_sacat=0
1K resistor is to reduce the 5V output of the PIC to 3.3V input of the DFPlayer.
Volume can be controlled by pushbuttons connected to pins 9, 11 of the DFPlayer, see the datasheet.
LCD display is 1 or 2 lines 16 characters module.
Link between pins 11 and 12 connects output of CCP2 to the input of TIMER1.

 

Circuit Description
See also Technical Tips

PIC and LCD supply is 5V. The SD Card supply is only 3.3V (3-3.6V) The 3.3V is generated by dropping the 5V with 2 diodes.
Audio input at pin 2 is 1Vp-p max. Voltage over 2Vp-p can damage the PIC input protection. 100K and 12K resistors give 0.6V DC input which is the middle of 1.25V range of the ADC.
One option is to boost the pic output by the Simple Audio Amp. You can use a 32 Ohm speaker. For use with another amplifier connect via the low pass filter.
8MHz crystal is a time base for the audio recording. 32768Hz crystal is a time base for the clock. Capacitors may need to be changed depending on the type of crystal used.
Digital outputs from the PIC to the SD card use 1K and 2K resistors to reduce the 5V signals to 3.3V. SD output at pin 7 is 3.3V but is enough to drive the PIC's input.
Stop, Rec, Pause and Play are pushbuttons.
LCD display and driver has 14 way connector, 10 connections are used, 4 bits data bus is selected. There is a big selection of LCD modules, and they are very similar in characteristics i.e. DM1601, ACM1601.
Vss - Supply GRD.
Vdd - Supply 5V
Vo - Contrast Adjust
RS - Register Select
R/W - Data Read/Write
E - Enable
D4-D7 - Data Bus Lines
LCD module is 20K pot is the LCD contrast, make sure it is set.
Talk PB is also the PB for Record and Play.

TIMER1 OSCILLATOR LAYOUT
CONSIDERATIONS
The Timer1 oscillator circuit draws very little power
during operation. Due to the low-power nature of the
oscillator, it may also be sensitive to rapidly changing
signals in close proximity.
The oscillator circuit, shown in Figure 12-3, should be
located as close as possible to the microcontroller.
There should be no circuits passing within the oscillator
circuit boundaries other than VSS or VDD.
If a high-speed circuit must be located near the oscillator
(such as the CCP1 pin in Output Compare or PWM
mode, or the primary oscillator using the OSC2 pin), a
grounded guard ring around the oscillator circuit, as
shown in Figure 12-4, may be helpful when used on a
single-sided PCB or in addition to a ground plane.




Name:

Comments and questions

Copy the number from the picture It stops net-robots from adding comments.



06.05.2019 - 22:36
Name: Moty
Comment: Sorry I was misleading you with the term RS232, the pic and the player communicate serially at TTL levels so their UART are connected directly' no max232 needed.  http://www.picaxe.com/docs/spe033.pdf http://www.picbasic.co.uk/forum/attachment.php?s=4d33b151492596d92735014e4094ffd7&attachmentid=8726&d=1530090274 Are the datasheet, you can google for more docs. https://github.com/Indo-Ware/dfplayer-mini-mp3 is a sample for interfacing arduino, it will be similar with pic. To play a track (0 to 2999) you send a command of 9 bytes. I've never written a code for the player. I may find some free time to try some code, I have a pic16f876a and a DFplayer. My project has a disadvantage, when the cpu plays the SD it can't run the clock, so it can't display seconds. With the player or the TTS this can be overcome. Please send me a link to the source of the TTS module, maybe I can buy one to play with (if it's up to $10). It needs assessing how much memory is needed to store all the words in the pic.

06.05.2019 - 17:18
Name: coding4fun
Comment: I forgot to add my name on the last post. Anyways, I imagine if you have to use RS232, then you must connect a MAX232 via the pic16f876a to the Dfplayer module. am i on the right track? idk, since I don't have a sample dfplayer module in my hand yet. do you have a link to the datasheet??

06.05.2019 - 17:10
Name:
Comment: Thank you for the great input. If you want to work on TTS with me then leave me your email address and I will send you a TTS module and PIC16F876A for FREE. I'm working on interfacing the module by UART, since the manual is in Chinese I am having trouble. You can join this project with me if you like. In regards to the "DFPlay" THANK YOU. Do you have any PIC16F876A sample code and schematic using this successfully, if so I would love to try it. I've been following your work and I would love to see the new code for PIC16F876A for this project. Keep up the good work! Thank you.

05.05.2019 - 19:41
Name: Moty
Comment: I have on my list to modify the pic project to work like the arduino. the pic's PWM isn't very clever and it gives reduced sound quality in compare to the arduino. Some new pic include DAC that will give better sound. The interference between the crystals is also a problem. Your idea to add a TTS module (text to sound) is a good one but the cost of existing TTS is high. Another option is to use MP3 player that has SD card and you call a track using RS232. https://www.ebay.co.uk/itm/TF-Card-U-Disk-DFPlay-Mini-MP3-Player-Audio-Voice-Module-For-Arduino-Red-Black/332191775209?hash=item4d582c39e9:m:mipJiSTcU06odSU7dsEBqGA

05.05.2019 - 18:18
Name:
Comment: Oops, I was wrong. These .wav files are only for Arduino. Wow! For Pic, you actually have to record your own files. Is there any other way? Especially for those who don't want to record their files. I presume not because of the reading style. Have you ever used any text to speech modules? I would love to chat with you about those. Thanks.

05.05.2019 - 17:23
Name: coding4fun
Comment: Never mind, I found the .wav files in the ARDUINO folder, I'm using a PIC16F876A so I had no interest in ARDUINO. Had I never checked I would be lost.

05.05.2019 - 17:19
Name: coding4fun
Comment: Where can I download the .wav files you used to make this project? I find it hard trying to create my own. It would be easier if you could provide the same ones that you used, please. Thank you.

26.02.2019 - 23:16
Name: Thanh Tung
Comment: Hello

22.05.2018 - 23:03
Name: Moty
Comment: Hi Sangatee, Click the button 'download software' add the c file to your project in MPLAB or MPLAB X and you can edit the code if you need to. You can also load the hex file directly to your pic.

22.05.2018 - 08:30
Name: sangatee david
Comment: please i mean the programing software

22.05.2018 - 08:28
Name: sangatee david
Comment: how can i get the peogramming software

13.01.2018 - 20:16
Name: Moty
Comment: Hi Konstantyn, These clocks tell the time only when you press the button. It is easy to add to the code to talk when the hour changes. To add alarm is a big change. The Arduino clock gives better sound.

13.01.2018 - 19:02
Name: Konstantyn545
Comment: Is there an alarm clock here?

13.01.2018 - 19:02
Name: Konstantyn545
Comment: Is there an alarm clock here?

13.01.2018 - 09:08
Name: Konstantyn545
Comment: Hello, I want to collect this watch, please tell me they say time every hour?

21.12.2017 - 17:19
Name: Dmitry
Comment: Hi friend please we are too soft pic16f876 , please bin file nice day

21.12.2017 - 17:17
Name: Dmitry
Comment: Hi friend please we are too soft pic16f876 , please bin file nice day

15.10.2017 - 22:49
Name: Moty
Comment: Hi Omar, I know too little about simulators to be any help.

15.10.2017 - 19:31
Name: Omar
Comment: Hi, I simulated your clock but unfortunately, time is not moving. We will be grateful if you help us. omarfaruksaritas@gmail.com

15.10.2017 - 15:49
Name: Moty
Comment: Hi Mr Ozgur, Yes, when you set the time by pressing the buttons the internal registers (RAM) update. The LCD and the Talk read the time from those registers.

15.10.2017 - 11:56
Name: mr. özgür
Comment: Greatings, I couldn't quite understand how clock states the real time. Does it set the time after i increase or decrease the numbers on lcd display?

15.10.2017 - 11:56
Name: mr. özgür
Comment: Greatings, I couldn't quite understand how clock states the real time. Does it set the time after i increase or decrease the numbers on lcd display?

15.10.2017 - 11:41
Name: mr. özgür
Comment: Greatings, I couldn't quite understand how clock states the real time. Does it set the time after i increase or decrease the numbers on lcd display?

02.05.2017 - 15:47
Name: Moty
Comment: Hi Sangatee, Click button DOWNLOAD SOFTWARE , If it doesn't work send your email address and I'll send you the code.

02.05.2017 - 10:57
Name: Sangatee
Comment: Please can I get program code

12.09.2016 - 21:51
Name: mike
Comment: i find this very useful, thanx pls

19.04.2016 - 08:47
Name: dipen
Comment: while simulating on proteus,clock doesnot advances

12.10.2014 - 10:33
Name: Moty
Comment: Hi Abraham. My full name is Moty Santos Jelahlibahd.

11.10.2014 - 15:32
Name: Abraham
Comment: can I get your name? I want to reference u you I my Project.

02.06.2014 - 12:08
Name: Moty
Comment: Hi Yusa. 2 GB SD allows for about 20 minutes for each track. The clock doesn't advance during playing the tracks so for the clock showing the right time a track has to be limited to 2 seconds.

02.06.2014 - 02:09
Name: Yusa
Comment: How many seconds can a track be.