Loading...
Showing posts with label I2C. Show all posts
Showing posts with label I2C. Show all posts

Sunday, November 1, 2020

AN7223 LM7001 PLL FM Stereo Tuner, JQ8400 USB MP3, Bluetooth Audio Player - 16F690

FM USB MP3 Player
Audio Player

This is my new project, 3 in 1 audio player that design for my amplifier. It built in FM radio, USB player and Bluetooth module. Also include a simple mixer with op-amp.

Bottom PCB
Bottom PCB

Top PCB
Top PCB

Side View
Side View

For tuner section I used AN7223 and TA7343 and for PLL here I used LM7001 low cost IC. JQ8400 used for USB function and it controlled by a PIC16F690 microcontroller. U can use any Bluetooth audio module for this. I used MH-M18 Bluetooth module for this.

JQ8400 Module
JQ8400 Module

Bluetooth Module
Bluetooth Module


Please read my previous post for detailed information about PLL FM tuner and jq8400. I wrote a small sample program for control this unit and u can modify it according to your need. Don’t use relay. Just connect I2C directly to R37 & R39.

Control Circuit
Control Circuit

Usage of usb command

// --------- commands ----------------- Write_Df(0x06,0,0); // mp3 next Write_Df(0x05,0,0); // mp3 prev Write_Df(0x02,0,0); // mp3 play Write_Df(0x03,0,0); // mp3 pause Write_Df(0x04,0,0); // mp3 stop Write_Df(0x21,0,0); // mp3 random Write_Df(0xA3,0,5); // mp3 ff 5s Write_Df(0xA2,0,5); // mp3 fr 5s write_Df(0x87,Cur_Tr>>8,Cur_Tr); // mp3 track play (max 9999)

Mikro c source code for Control circuit, source code for PLL FM, Hex file for jq8400 controller and PCB file and circuit are in download section. Hope you like it.


Saturday, November 4, 2017

DS3231 RTC Clock mikro C Demo Code - 16F648A


LCD Clock
LCD Clock

Introduction:

The DS323x is a low-cost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line. The DS323x is available in commercial and industrial temperature ranges, and is offered in a 16-pin, 300-mil SO package.

DS3231 Block Diagram
DS3231 Block Diagram
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an active-low AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially through an I²C bidirectional bus.

Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw. And that’s all well and good, but those crystals have slight drift, particularly when the temperature changes (the temperature changes the oscillation frequency very very very slightly but it does add up!) This RTC is in a beefy package because the crystal is inside the chip! And right next to the integrated crystal is a temperature sensor. That sensor compensates for the frequency changes by adding or removing clock ticks so that the timekeeping stays on schedule.

DS3231 module
DS3231 module

This is the finest RTC you can get, and now it in a compact, breadboard-friendly breakout. With a coin cell plugged into the back, you can get years of precision timekeeping, even when main power is lost. Great for data-logging and clocks, or anything where you need to really know the time.

The Circuit:

The circuit is very simple. It used PIC16F648A Pic micro, 16x2 LCD and DS3231 RTC module. The PIC used it's internal oscillator and run at 4MHz. Proteus and Hex file can download from the bottom of the page.

DS323x RTC Clock Circuit
DS323x RTC Clock Circuit


MikroC PRO Source Code:

/**************************************************************************

DS323x RTC Clock Demo
Copyright (C) 2017 Scorpionz

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 3 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.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/


// Software I2C connections
sbit Soft_I2C_Scl at RB2_bit;
sbit Soft_I2C_Sda at RB1_bit;
sbit Soft_I2C_Scl_Direction at TRISB2_bit;
sbit Soft_I2C_Sda_Direction at TRISB1_bit;
// End Software I2C connections

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

char seconds, minutes, hours, day, date, month, year, tem_l, tem_h; // Global variables

//--------------------- Reads time and date information from RTC (DS3231)
void Read_Time()
{
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xD0); // Address DS3231, see DS3231 datasheet
Soft_I2C_Write(0); // Start from address 0
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xD1); // Address DS3231 for reading R/W=1

seconds = Bcd2Dec(Soft_I2C_Read(1)); // Read seconds byte
minutes = Bcd2Dec(Soft_I2C_Read(1)); // Read minutes byte
hours = Bcd2Dec(Soft_I2C_Read(1)); // Read hours byte
day = Bcd2Dec(Soft_I2C_Read(1)); // Read day byte
date = Bcd2Dec(Soft_I2C_Read(1)); // Read date byte
month = Bcd2Dec(Soft_I2C_Read(1)); // Read month byte
year = Bcd2Dec(Soft_I2C_Read(1)); // Read year byte

Bcd2Dec(Soft_I2C_Read(1)); // Alarm
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1)); // Data
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1));

tem_h = Bcd2Dec(Soft_I2C_Read(1)); // Temp
tem_l = Bcd2Dec(Soft_I2C_Read(0));

Soft_I2C_Stop(); // Issue stop signal
}

void write_data(char address, char w_data)
{
Soft_I2C_Start(); // issue I2C start signal
Soft_I2C_Write(0xD0); // send byte via I2C (device address + W)
Soft_I2C_Write(address); // send byte (address of DS3231 location)
Soft_I2C_Write(w_data); // send data (data to be written)
Soft_I2C_Stop(); // issue I2C stop signal
delay_ms(50);
}

//-------------------- Output values to LCD
void Display_Time()
{
Lcd_Chr(2, 7, (hours / 10) + 48);
Lcd_Chr(2, 8, (hours % 10) + 48);
Lcd_Chr(2,10, (minutes / 10) + 48);
Lcd_Chr(2,11, (minutes % 10) + 48);
Lcd_Chr(2,13, (seconds / 10) + 48);
Lcd_Chr(2,14, (seconds % 10) + 48);

Lcd_Chr(2,16, (day % 10) + 48); // day
}

void Display_Date()
{
Lcd_Out(1,1,"Date: "); // Prepare and output static text on LCD
Lcd_Chr(1,9,'-');
Lcd_Chr(1,12,'-');
Lcd_Out(1,13,"20"); // start from year 2000

Lcd_Chr(1, 7, (date / 10) + 48);
Lcd_Chr(1, 8, (date % 10) + 48);
Lcd_Chr(1,10, (month / 10) + 48);
Lcd_Chr(1,11, (month % 10) + 48);
Lcd_Chr(1,15, (year / 10) + 48);
Lcd_Chr(1,16, (year % 10) + 48);
}
void Display_Temp()
{
Lcd_Out(1, 1,"Temp: +");
Lcd_Out(1,13,"ßC ");
Lcd_Chr(1,10,'.');

tem_l=tem_l*25;

Lcd_Chr(1, 8, ((tem_h & 127) / 10) + 48);
Lcd_Chr(1, 9, ((tem_h & 127) % 10) + 48);
Lcd_Chr(1, 11, (tem_l / 10) + 48);
Lcd_Chr(1, 12, (tem_l % 10) + 48);

if(tem_h & 128) Lcd_Chr(1, 7, '-');
}

//------------------ Performs project
void Init_Main()
{
PCON.OSCF = 1; //4MHz
CMCON |= 0x07; // Disable Comparators CMCON |= 7;
OPTION_REG = 0;

Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off

Lcd_Out(1,3,".:Scorpionz:.");
Delay_ms(500);
Lcd_Out(2,1,"Ds3231 RTC Clock");
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,1,"Time: ");
Lcd_Chr(2,9,':');
Lcd_Chr(2,12,':');

write_data(14,0x40); //SQWE output at 1 Hz
}

//----------------- Main procedure
void main() {
Delay_ms(500);

Init_Main(); // Perform initialization

while (1) { // Endless loop
Read_Time(); // Read time from RTC(DS3231)
Display_Time(); // Prepare and display on LCD
Display_Date(); Delay_ms(450);
Display_Temp();
Delay_ms(450);
}
}

Monday, June 15, 2015

I2C FM Receiver Circuit with LCD - 16F88 BK1080

Digital FM Receiver
Digital FM Receiver


This is a simple stereo FM radio receiver circuit that can scan with 87.5 MHz and 108 MHz seamlessly between 100 kHz step and it use BK1080 as a receiver IC.

Main components of this receiver are a PIC16F88 micro-controller, 16x2 LCD and BK1080 FM receiver chip. This system is design to work with 5V DC power supply. User interface of this system consist with 6 push buttons and a 16×2 character LCD module. All the functions of this receiver can control by this buttons and necessary information displayed on the LCD.

Specifications of this receiver

  • Easy to build
  • Standby mode
  • Automatic gain control
  • Automatic frequency control
  • Automatic noise suppression
  • Preset memory stations up to 250 (default 20)

Schematic of BK1080 I2C FM Receiver
Schematic of BK1080

BK1080

The BK1080 FM receiver employs a low-IF architecture, mixed signal image rejection and all digital demodulation technology. The stations scan of BK1080 searches radio stations based on both the channel RSSI estimation and signal quality assessment, increases the number of receivable stations while avoids false stops. BK1080 enables FM radio reception with low power, small board space and minimum number of external components. All functions controlled through an I2C serial interface. See datasheet for more details.

Numbers of memory locations are determine by the value of Eeprom 1 (default value 0x14).
You can connect an earphone directly with BK1080’s output. However, do not connect speakers directly with IC. I recommended you to use amplifier if you wish to get more sound. In addition, be carefully when soldering BK1080. Because this IC more sensitive to electrostatic. Use DC soldering Iron to solder this IC or unplug your iron when solder. Micro-controller runs using its internal oscillator. RA0 and RA1 are configuring as SCL and SDA. RA2 is not connected. RA6 pin can directly connect with background light of LCD display. As well as it is also can used for the controlling another device like mute pin of power amp.

Selecting the station:
When we are in the power on mode, on the screen we can see "Frq:107.5 Ch:12" - tuned frequency of the station and then the number of the cell where the recorded frequency of the station. Pressing ‘CH_UP’ and ‘CH_DN’ we can move the recorded stations. Pressing ‘FR_UP’ and ‘FR_DN’ we can change the frequency. ‘STORE’ stored the current frequency to the current station and ‘PWR’ used to toggle standby mode and power on mode

Firmware of this system was written by using MikroC for PIC and schematic, hex and Proteus files are available for download.

Thursday, May 28, 2015

10 Band I2C Graphic Equalizer Circuit - 16F628 TEA6360

Updated:
  • 2016-08-17 - Added small application for calculate frequencies and parts.

10 Band Equalizer
10 Band Equalizer

A graphic equalizer is a high-fidelity audio control that allows the user to see graphically and control individually a number of different frequency bands in a stereophonic system. A typical graphic equalizer consists of several audio filter/amplifiers, each centered at a specific frequency in the audio range. Most graphic equalizers have two identical sets of filter/amplifiers, one for each channel in a stereophonic system.

The gain controls in most graphic equalizers are slide potentiometers that are adjusted by moving a controller up or down. Gain is increased by sliding the upwards. The slide potentiometers for each channel are placed side-by-side, with the lowest-frequency unit at the left and the highest-frequency unit at the right. In this way, the positions of the buttons appear to follow a graphical curve that represents the gain as a function of frequency for each channel.

By using following circuit you can build a 10 band stereo graphic equalizer that can be controlled via I2C system. For this circuit I used two of TEA6360 ICs. Each IC contains two serial five bands equalizer blocks. Therefore, we need two ICs for 10 bands. We can reduce the size of circuit because all the function can be drive via i2C. So that, we do not need connect potentiometers to control the gain of frequency bands like an ordinary equalizer. In addition, we can reduce cost and complexity of circuit using this IC.

10 Band Equalizer circuit
Schematic

10 Band Equalizer pcb
Circuit on PCB

In my demo code, I used 16F628A micro-controller and single button to set equalizer modes. The modes are ‘Flat’, ’Rock‘, ’Pop‘, ’Jazz‘ and ’Party’. The status will indicate by five LEDs those connected to PORTA. In addition, selected mode saved to device Eeprom and load to ICs when start up. However, according to your choice you can able to change the code.

For example if you need to set gain for each frequency manually, then you can add 1 button to each channel and total 10 buttons. For another example, you can add 3 buttons. One button to raise the gain and other to lower and 3rd one for select desired frequency.

The center frequency of each bands are 31Hz, 62Hz, 125Hz, 250Hz, 500Hz, 1KHz, 2KHz, 4KHz, 8KHz and 16KHz. the Q (quality) factor is 1 to 1.2 and PCB, full schematic and sample code can be downloading in below.

Part List

  • C04, 07, 08, 09 = 0.37uF
  • C10, 11, 12, 13 = 0.18uF
  • C14, 15, 16, 17 = 0.01uF
  • C18, 19, 20, 21 = 0.047uF
  • C22, 23, 24, 25 = 0.022uF
  • C27, 28, 30, 31 = 0.01uF
  • C32, 33, 34, 35 = 0.0052uF
  • C36, 37, 38, 39 = 0.0027uF
  • C40, 41, 42, 43 = 0.0015uF
  • C44, 45, 46, 47 = 720pF

TEA6360

The 5-band stereo equalizer is a 12C-bus controlled tone processor for application in car radio sets, TV sets and music centers. It offers the possibility of sound control as well as equalization of sound pressure behavior of different rooms or loudspeakers, especially in cars.

FEATURES
  • Monolithic integrated 5-band stereo equalizer circuit
  • Five filters for each channel
  • Center frequency, bandwidth and maximum boost/cut defined by external components
  • Choice for variable or constant Q-factor via I2C software
  • Defeat mode
  • All stages are DC-coupled
  • I2C-bus control for all functions
  • Two different module addresses programmable.

Saturday, November 8, 2014

DS1307 Real Time Seven Segment Alarm Clock Circuit - 16F88

Updates
  • 31/01/2016 - Added: Hourly chime restriction function
  • 27/10/2019 - Fixed: Hourly chime delay error (v3)
  • 27/10/2019 - Fixed: Auto mode data showing time increased (v3)

DS1307 Alarm Clock
Alarm Clock

This is the newest clock I made using DS1307 real time clock IC. Not like other clock circuits I posted, this clock circuit built in all necessary function such as hourly chime, alarm, time drift correction, etc. In addition, it also include temperature sensor as optional function.

This clock has eight display modes (including standby mode).
  • Mode 1 – Display Seconds
  • Mode 2 – Display Time
  • Mode 3 – Display Date
  • Mode 4 – Display Year
  • Mode 5 – Display Alarm
  • Mode 6 – Display Temperature
  • Mode 7 – Show Time, Date and Temperature continuously
  • Mode 8 – Stand By Mode

DS1307 Alarm Clock
DS1307 Alarm Clock

This PIC project uses PIC16F88 micro-controller, DS1307 Real Time Clock, LM35 temperature sensor, and SSD-5461AG common cathode seven segment display. (If you cannot find that display then use four common cathode seven segment displays).

The PIC16F88 used its internal oscillator and it runs at 8MHz. We can reduce cost and complexity of circuit and can save micro-controller’s pin by using internal oscillator.RA0 and RA1 configured as digital and analogue alternatively to drive seven segment and read voltage of LM35.

The DS1307 (RTC) Real Time Clock is an 8-pin device using an I2C interface. It has eight read/write registers that store the information. This IC will do the timekeeping and it not only keeps track of time but also the date and the day of the week. DS1307 RTC is fully Binary Coded Decimal (BCD) clock/calendar. Therefore, the data read from DS1307 should be converted to BCD format. The most important is the Clock Halt Bit (CH), which is, bit 7 of address 0. This is the register that controls 'seconds' and the CH bit has to be preserved otherwise the chip stops the clock. Writing zero to this bit resets the CH bit so that the clock runs. So when the first usage we must set ‘seconds’. Otherwise clock fail to run.

DS1307 Alarm Clock circuit
Alarm Clock's Internal

Time Setting

Using MODE button you can change the display mode and the current status will save to Eeprom.
SET button can be used for edit the time, date, alarm etc. When you pressed the SET button, clock entered to the Edit mode and two displays will turn off. You can be able to edit values on other display by pressing UP and DOWN buttons. To edit turn off displays value pressed SET button again. Press the SET button again to return clock to normal mode. If the clock is in normal mode UP button also can used to change the time format (12hr or 24hr) and DOWN button can used to turn on or off alarm.

When time changed to 12hr mode LED will indicate the AM/PM status. Alarm on will indicated by the decimal point of last seven segment display. If you wish, you can also connect separate LED for it.

Error correction

Surprisingly making an accurate 32kHz oscillator is a difficult. This is because low speed oscillator drivers are designed for low power operation. That means high impedance and therefore low current, which makes the driver extremely sensitive to noise (or any nearby signals, which can capacitive couple to the crystal wire). Because that when using DS1307 we cannot get accurate time. Therefore, I added simple error correction mechanism for this clock

First, set the clock to current time (time of computer or internet) and keep it run up-to 24 hours.
After 24 hours, check the time of clock with time of computer. If time is drift, check how many seconds are drifted..?  (Use clock mode 1 to view seconds)

E.g. 1:  PC time:  16:30:00 Clock time:  16:30:05
+5 seconds drifted. So we have to reduce time.

I used Eeprom (2) to store this values and default value is 30 (0x1E).  See the Eeprom figure.
Now simply overwrite it with 25 (0x19). You must use hex values for it.

E.g. 2:  PC time:  16:30:00 Clock time:  16:29:58
-2 seconds drifted. So we have to increase time.
Overwrite Eeprom (2) value with 32 (0x20).

Hourly Chime Restriction

You can able to stop hourly chime function for specific time period using this setting. Device Eeprom address 6 and 7 use for this. default values are 0x00 and 0x18 (0 and 24)

Eeprom(6) ≤ Chime Restriction < Eeprom(7)

Eg: Stop Chime from 21.00 to 6.00
Eeprom(6) = 0x06 and Eeprom(7) = 0x15
6 ≤ Chime Restriction < 21

Eeprom of 16F88
Eeprom of 16F88

Sunday, March 3, 2013

DS1307 Real Time Seven Segment Clock Circuit - 16F88

DS1307 IC
DS1307 is a low power serial real time clock with full binary coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM (Non Volatile Static Random Access Memory). Data and Address are transferred serially through a bidirectional I2C bus.

The RTC provides year, month, date, hour, minute and second information. The end date of months is automatically adjusted for months fewer than 31 days including leap year compensation up to year 2100. It can operate either in 24-hour format or 12-hour format with AM/PM indicator.

DS1307 comes with built-in power sensing circuit which senses power failures and automatically switches to back up supply. We can provide a 3V CMOS Battery for that. The DS1307 RTC uses an external 32.768 kHz Crystal Oscillator and it does not requires any external resistors or capacitors to operate.

DS1307 Block Diagram
DS1307 Block Diagram

In this project, I used ds1307 as real time clock ic and PIC16f88 as micro-controller. To save micro-controller pins there are four input keys which are all connected to a single analogue input pin. This pin also drives one of the seven segment display LEDs so it has to be switched between input (to read the analogue voltage) and output (to drive the led). Each key pulls the analogue input to a different voltage level which you can easily read using the ADC (RA0).

DS1307 Real Time Clock circuit
Circuit Diagram

Set Time

Mode : Pressing mode button cycles the display showing 3 different data.

Mode 1 : Time only
Mode 2 : Seconds only
Mode 3 : Stand-by


Set : To change the value, set button must be pressed.

Set 1 :  Edit mode, show Minute
Set 2 :  Edit mode, show Hour
Set 3 :  Return to clock mode


Up and Down : After Pressing set button, you can change the values indicated on clock by using this buttons.

UP :  Values ++
In clock mode it will also change the 12/24Hr format.

Down :  Values --
In clock mode it will do nothing.

Clock Accuracy:

The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error will be added by crystal frequency drift caused by temperature shifts. External circuit noise coupled into the oscillator circuit may result in the clock running fast.

To ensure the crystal oscillates correctly you must ensure that;
  • Crystal uses 12.7pf load capacitance (correct crystal type).
  • The crystal is close to the IC.
  • The tracks are short.
  • The chip supply has lots of decoupling (capacitors from +5V to GND). e.g. A 100n and a 10n
  • There are no signal tracks near to the crystal.
  • For a PCB: It has a guard ring and a ground plane and away from digital signals.

DS1307 Datasheet
PIC16F88 Datasheet

PIC16F88 pin
Pin Connection


I Used mikroC for compile this project.
Also you can get PCF8583 version from here.

Saturday, March 2, 2013

PCF8583 Real Time Seven Segment Clock Circuit - 16F88

Basic Connection of PCF8583
Basic Connection of PCF8583
The PCF8583 is a clock and calendar chip based on a 2048 bit static CMOS RAM organized as 256words by 8 bits. Addresses and data are transferred serially via the two-line bidirectional I2C-bus.

The built-in word address register is incremented automatically after each written or read data byte. Address pin A0 is used for programming the hardware address, allowing the connection of two devices to the bus without additional hardware.

The built-in 32.768 kHz oscillator circuit and the first 8 bytes of the RAM are used for the clock, calendar, and counter functions. The next 8 bytes can be programmed as alarm registers or used as free RAM space. The remaining 240 bytes are free RAM locations.

Block diagram of PCF8583
Block diagram of PCF8583

Features:

  • I2C-bus interface operating supply voltage: 2.5 V to 6 V
  • Clock operating supply voltage 1.0 V to 6.0 V at 0 °C to +70 °C
  • 240 × 8-bit low-voltage RAM
  • Data retention voltage: 1.0 V to 6.0 V
  • Operating current (at fSCL = 0 Hz): max 50 μA
  • Clock function with four year calendar
  • Universal timer with alarm and overflow indication
  • 24 hour or 12 hour format
  • 32.768 kHz or 50 Hz time base
  • Serial input and output bus (I2C-bus)
  • Automatic word address incrementing
  • Programmable alarm, timer, and interrupt function
  • Slave addresses: A1h or A3h for reading, A0h or A2h for writing

PCF8583 Real Time Clock circuit
Circuit Diagram

This clock circuit is same as DS1307 - Real Time Clock. The only different is here I used PCF8583 RTC clock ic and change firmware. Because registers of DS1307 and PCF8583 are different.

To save micro-controller pins there are four input keys which are all connected to a single analogue input pin. This pin also drives one of the seven segment display LEDs so it has to be switched between input (to read the analogue voltage) and output (to drive the led). Each key pulls the analogue input to a different voltage level which you can easily read using the ADC (RA0).


Set Time:

Mode : Pressing mode button cycles the display showing 3 different data.

Mode 1 : Time only
Mode 2 : Seconds only
Mode 3 : Stand-by


Set : To change the value, set button must be pressed.

Set 1 :  Edit mode, show Minute
Set 2 :  Edit mode, show Hour
Set 3 :  Return to clock mode


Up and Down : After Pressing set button, you can change the values indicated on clock by using this buttons.

UP :  Values ++
In clock mode it will also change the 12/24Hr format.

Down :  Values --
In clock mode it will do nothing.

Quartz Frequency Adjustment:

By evaluating the average capacitance necessary for the application layout, a fixed capacitor can be used. The frequency is measured using the 1Hz signal available after power-on at the interrupt output (pin 7). The frequency tolerance depends on the quartz crystal tolerance, the capacitor tolerance and the device-to-device tolerance. Average deviations of 5 minutes per year are possible. See data sheet for more detail.

Use mikroC for compile.

PCF8583 Datasheet

PIC16F88 Datasheet

PIC16F88 pin
PIC16F88 Pin Connection

 

on line

Labels

Recent comment

Visitors

Free counters!
Copyright © 2012 - Scorpionz™.,All rights reserved | Powered by Blogger