Loading...

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

Saturday, August 30, 2014

LM35 Simple Thermometer Circuit with LCD - 16F818

Thermometer
Thermometer

In modern world, analog equipment and device are converting in to digital format. To do this mostly used sensors. There are many cool sensors available now days, ranging from IR distance sensor modules, accelerometers, humidity sensors, temperature sensors etc. but many of these sensors are analog in nature. That means they give a voltage output that varies directly (and linearly) with the sensed quantity. For example in LM35 temperature sensor, the output voltage is 10mV per degree centigrade. That means if output is 300mV then the temperature is 30 degrees. Or else, if the temperature changed one degree then its output voltage varied by 10mv.

In this post, I show you how to build temperature sensor (Thermometer) circuit easily. It uses the PIC 16F818 micro-controller, LM35 temperature sensor and a 16x2 LCD.

LM35 Temperature Sensor Schematic Diagram
Schematic Diagram

LM35

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ' Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 1/4°C at room temperature and 3/4°C over a full -55 to +150°C temperature range. It can be used with single power supplies, or with plus and minus supplies.

Features
  • Calibrated directly in Celsius (Centigrade)
  • Linear + 10.0 mV/°C scale factor
  • 0.5'C accuracy guarantee-able (at +25°C)
  • Rated for full -55° to +150°C range
  • Operates from 4 to 30 volts

Operation


The LM35 outputs an analog voltage proportional to the temperature. This analog voltage then read by the PIC and processed to display the corresponding temperature value on the LCD. The PIC ADC module does the analog to digital conversion. The PIC MCU’s ADC gives us the value between 0-1023 for input voltage of 0 to 5v. So if the reading is 0 then input is 0v, if reading is 1023 then input is 5v.In the code, I have used the mikroC library function for ADC.

The temperature range for this circuit is 0°C to 150°C.
You can download project files form below and it used MikroC

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

    LM35 Temperature Sensor
    Copyright (C) 2015 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.  If not, see <http://www.gnu.org/licenses/>.

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

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

char temp;

void main()
{
OSCCON= 0x70; // 8MHz internal osc
ADCON0=1;
ADCON1=0b10001110;
TRISA = 0x01; // AN0 input
TRISB = 0x00;
PORTA = 0;
PORTB = 0;

Lcd_Init(&PORTB);

Lcd_Cmd(Lcd_CLEAR);
Lcd_Cmd(Lcd_CURSOR_OFF);
Delay_ms(10);

Lcd_Out(1, 3, ".:SCORPIONZ:.");
Delay_ms(1000);
Lcd_Out(2, 2, "Temp is 000.0ßC");

while(1) {

temp = Adc_Read(0)/2.048;

Lcd_Chr(2, 10, ((temp/100)%10 +48));
Lcd_Chr(2, 11, ((temp/10)%10  +48));
Lcd_Chr(2, 12, ( temp%10      +48));
Delay_ms(100);
}
}


Friday, August 29, 2014

Simple LCD Spectrum Analizer Demo Circuit - 16F628



Spectrum analyzers are widely used within the electronics industry for analyzing the frequency spectrum of radio frequency, RF and audio signals. Looking at the spectrum of a signal, they are able to reveal elements of the signal, and the performance of the circuit producing them that would not be possible using other means.

Audio spectrum analyzer shows you a detailed picture of what you are hearing in real-time, that is, as it happens. You can easily built very cheap spectrum analyzer circuit using below diagram. However, this is not a real-time and it is just a visualizing model. But this work as real one and you can add this to your audio projects to get a nice appearance and add extra value for it.

You can able to download MikroC source and other files from the below link

Simple Spectrum Analizer circuit
Schematic Diagram of Analyzer

Thursday, August 28, 2014

Digital Combination Lock Circuit with Keypad and LCD - 16F628

Digital Lock
Digital Lock

Now day’s ordinary locks are replace with digital locks. Those have very advanced features such as digital display, keypad, fingerprint recognized etc. Therefore, I decided to build basic digital lock with LCD display and keypad.

This is a micro-controller based digital lock circuit and it used PIC16F628A. 16x2 LCD is used for the display information and keypad is used for enter the code. (#) will clear the code and (*) will enter the code to initialize process.

Default code for this lock is 2468 and this code was stored in device Eeprom memory. You can change the default code by changing value of device Eeprom memory. Address 1 for first number, Address 2 for 2nd number, so on. You can change Eeprom value from zero to nine.

Digital Lock circuit
Schematic Diagram of Digital Lock

Lock code = Eeprom Address 1 & …. & Eeprom Address 4

Ex:
Eeprom Address 1=3,  Address 2=1,  Address 3=0,  Address 4=7 then,
Lock code  =>  3 & 1 & 0 & 7  => 3107

Eeprom Address and lock code
Eeprom Address and lock code

Wednesday, August 27, 2014

Scrolling Seven Segment Display Circuit - 16F628

Scrolling Seven Segment Display preview
Preview

Many electronic hobbyists are very much interested about build scrolling displays. Most of the time this circuits used matrix displays. However, its cost is high and almost complex to build. Therefore, I try to build a scrolling displays circuit using the seven segments displays because these are cheaper than matrix displays and we can be easily build circuit. This circuit is very simple.

To build this circuit I used PIC16F628A micro-controller and four common cathode seven segment displays. To save micro controller's pin and reduce the cost I used internal oscillator. Massage on ‘scrl_txt’ array will run continuously. You can change the length by changing the value of ‘scrl_len’ according to your text.

A seven-segment LED display is an special arrangement of 7 LED elements to form a rectangular shape using two vertical segments on each side with one horizontal segment on the top, middle, and bottom. By individually turning the segments on or off, numbers from zero to nine and some letters can be display, but we cannot display all characters. However, it is possible to display all the numbers and many characters. See below picture to recognized how seven segment displayed characters.

Seven Segment Characters
Seven Segment Characters

In this picture, you can see some characters like K, M, V, W, X and Z cannot displayed properly. If you need to display all the characters then you need to use 14 or 16 segment displays instead of seven segments. To use this type of display you need to modify the firmware and circuit.

Scrolling Seven Segment Display circuit
Schematic Diagram of Circuit

In Proteus diagram, I used NOT gates to connect the Seven Segment and micro controller. However, in practical you have to use NPN transistor such as 2SC1815 or transistor array IC such as ULN2003 instead of NOT gates. When you are using transistor do not forget to add resistor 1k-10k between micro-controller and base of transistor.

 

on line

Labels

Recent comment

Visitors

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