Update project MCU real-time clock DS1307 S52 +89!

Display time clock circuit moments, potentially saving hours of power. Suitable for those who want to make your own hand, or give your friends.
MCU real-time clock DS1307 S52 +89!



Circuit chip using DS 1307 real-time operation at frequencies 32768kHZ fed by redundant power 3V can operate in 5 years time when k is power 
I, speaking via the standard I2C interface 
Priority communication protocol followed was developed by Philips Semiconductor and is called the I2C bus. Because the source is designed to control the inter-IC (Inter-Integrated Circuit), it was named the I2C. All of the chip is integrated and compatible with I2C interface has a built-in chip for direct communication with other I2C compatible devices. The serial data transfer in two 8 bit was implemented in three modes: Standard (Standard) -100 Kbits / sec Fast (Fast) -400 Kbits / sec high speed (High speed) -3.4 Mbits / sec implement bus I2C serial communications are two-way serial data line SDA and transmission rate serial clock SCL. Because the mechanism of action is synchronous, so it needs a synchronous clock signal. The device supports I2C has a predefined address, in which several low-bit address is configurable. Unit or device to initiate the communication process is the owner and also the generated clock synchronization, control that allows the transmission end. If the unit owner wants to communicate with other units it may send the address information of the unit where it wants to transmit the transmission data. Unit I is assigned and addressed through the unit owner can establish communication and data exchange. Data Bus is designed to allow implementation of multi-unit owners at the top and I Bus. I2C communication process begins with the start signal generated by the unit owners. The unit will then transmit 7 data bits contain the address of the unit that I want to communicate, the order is the biggest bit of weight will be transmitted MSB first. The next eight bits contain information to identify the unit will perform the role I get (0) or send (a) data. Next will be a bit ACK receive confirmation by the unit has received a previous byte or not. Transmission unit (sending) will transmit a data byte started by MSB. At the end of the byte transmission units received will generate a new ACK bit certified. Mould 9 bits (8 bits of data validation and a bit) will be repeated if the next byte to be transmitted again. When the unit owners were required data exchange is complete it will observe the final ACK bit confirmation will then generate a stop signal STOP to end the communication process.I2C is a communication interface is particularly suitable for applications of communication between units on the same motherboard with short distances and low speeds. For example, communication between the CPU with the function block on the same motherboard as EEPROM, sensors, creating real-time clock ... Most I2C devices support operation at speeds of 400kbps, some allow operation at high speed a few Mbps. I2C is simple to implement multi-unit connectivity as it supports mechanisms that identify the address. 
II, Summary Ds1307 chip real-time 
The chip DS1307 real time clock (RTC: Real-time clock), real-time concept is used here to mean absolute time that people are using, in seconds, minutes, hours ... DS1307 is a product of Dallas Semiconductor (a subsidiary of Maxim Integrated Products). The sensor has seven 8-bit register contains the time: seconds, minutes, hours, second (in weeks), day, month and year. Also DS1307 also has a control output registers and 56 sub spec sheet can be used as RAM.Appears in the second DS1307 SOIC and DIP packages have 8 legs 

Highslide JS

The legs of the DS1307 is described as follows: • X1 and X2: the two input connected to a 32.768kHz crystal oscillator as the source for the chip. • VBAT: positive culture of a 3V battery chip. • GND: ground truth for both 3V and Vcc pin. • Vcc: power to the I2C interface, and is often used with 5V microcontrollers. Note that if the power supply Vcc is not granted, the DS1307 but VBAT is still active (but not write and read). • SQW / OUT: an auxiliary input square pulse (Square Wave / Output Driver), the frequency of the pulse is generated that can be programmed. Thus the fact is hardly relevant to the functions of the DS1307 real time clock, we vacate the circuit pins. • SCL and SDA are two roads of the data clock and I2C interface. • DS1307 can be connected by a simple circuit as follows:

Highslide JS

Components inside the DS1307 include several components such as power circuits, oscillator circuits, logic controller, I2C interface circuit, and the address pointer register (or RAM). Using the DS1307 is primarily written to and read the registers of this chip. So have two basic problems which are structured and how to register to access the registers through the I2C interface. As shown, the memory contains all 64 DS1307 8-bit registers are addressed from 0 to 63 (from 00H to 3FH the hexadecimal system). However, actually only the first eight registers is used for the "clock" (RTC) register the remaining 56 vacant can be used as RAM contains temporary variable if desired. The first seven registers contain information about the time of the clock including: seconds (SECONDS), minutes (minuets), hours (HOURS), secondary (DAY), date (DATE), month (MONTH) and year (YEAR ). The values ​​recorded in the register 7 is equivalent to the "install" boot time for the RTC. The read register values ​​are read from 7 real-time chip created. For example, at launch, we recorded in the register "seconds" value 42, then the 12s we read this register, we obtain the value 54.Registers 8 (CONTROL) is the control register outputs SQW / OUT (pin 6). However, because we are not using foot SQW / OUT it can skip the first 8 registers. Organization of the DS1307 memory is presented in Figure 3. For the first seven registers are most important in the operation of the DS1307, we will examine this register in detail. First observation held each bit of this register as shown in Figure

Highslide JS

Highslide JS

Holding Registers timeline seconds (SECONDS): This register is the first register in the memory of the DS1307, its address is 0x00. Lower four bits of this register contains the 4-bit BCD digits of the seconds value. Since the highest value of the tens digit is five (non-sec 60) should only need three bits (bits SECONDS 6:4) that can be encrypted (some 5 = 101, 3 bits). The highest bit, bit 7, of this register is a control named CH (clock halt - hanging clock), if this bit is set by an oscillator in the chip is disabled, the clock does not work. So necessarily reset this bit to 0 at the beginning.Registers minutes (MINUTES): 01h address, containing the minutes of the clock value. Similarly register SECONDS, only 7 bits of this register is used to save the minute BCD code, bit 7 is always equal to 0. Registers hours (HOURS): have to say this is the most complex registers of DS1307. This register address 02h. First of all four low-bits of this register is used for filling the unit of time. Do DS1307 system supports two types of display time (called the mode) is 12h (1h to 12h) and 24h (1h to 24h) hours bit6 (Figure 4) establishing the system now. If bit6 = 0, the system 24 is selected, then 2 bits 5 and 4 digits encoded using dozens of valuable hours. Because the maximum value of tens digit in this case is 2 (= 10, binary) to 2 bits 5 and 4 are sufficient to encode. If bit6 = 1, the system 12 hours was chosen, in this case only 4 bit encryption using tens of hours digit, bit 5 (colored orange in Figure 4) only session of the day, AM or PM. Bit5 = 0 is AM and the PM Bit5 = 1. Bit 7 is always equal to 0. Second register (DAY - day of week): located at address 03H.DAY registry value only from 1 to 7, respectively, from Monday to Friday 7 in a week. Thus, only three low bit in this register means. The register also has a similar structure, DATE contains the date of the month (1 to 31), MONTH contains the month (1 to 12) contains vaYEAR years (00 to 99). Note, DS1307 is only for 100 years, the value in only two digits, the first part of the year added by the user (eg 20XX). In addition to the registers in the memory, the DS1307 also has a separate register called the other pointer is the address or address register (Address Register). The value of this register is the address of the register in memory that the user wants to access.

Highslide JS

III, AT89S52: Block diagram and pinouts

Intel 8051 microcontroller was launched in 1980 under the first microcontroller their MCS-51. Currently many manufacturers such as Siemens, Advanced Micro Devices, Philips Fusisu and focus on developing products based on 8051.Atmel the makers released the chip 89C51, 52, 55 and then improved further, company launched 89S51, 89S52, 89S52 89S8252 ... Configuration: + 8 KB of program memory. + External oscillator with quartz <24MHz. Typically, VDK 89S52 run with 12MHz quartz. + 256 Byte internal RAM. + 4 Port entry. + 3 Timer / Counter Timer 16 bit 0,1,2. Timer 2 has the function of Capture / Compare. + 8 interrupt sources. + Load program parallel or serial loading via SPI

Highslide JS

Basically, the chip set on the same, just some more innovative features. The next version of the more special features than block. We see table compares some common types below.

Highslide JS

• 89S52 The function P0 pins, 1,2,3 a basic function import / export. • Particularly P0, P2 also features expandable memory connections, will be examined in the expanded memory. • P1: T2 and T2EX legs for timer / counter 2. These two functions will be examined in the Timer. Chan SS \, MOSI, MISO, SCK SPI data transfer standard and function circuit connected to the program. View

Highslide JS

Circuit:

Highslide JS

Truth ALE, PSEN, WR \, RD \ used to connect memory expansion. • Pin EA \ function selected program memory: EA \ = GND: Select external memory, EA \ = VCC choose internal memory. • Pin XTAL1 and XTAL2 associated with quartz

IV, the algorithm I2C COMMUNICATION WITH 89S52 Microcontroller

START and STOP conditions START and STOP conditions is required when a device wants to establish communication with a device in the I2C network. START is the starting conditions, signaling the start of communication, and STOP indicate the end of a communication. Figure 11 shows the START condition and STOP condition when the DS1307 I2C communication with the microcontroller.

Highslide JS

Initially implemented without communication process, both SDA and SCL lines are high (SDA = SCL = HIGH). Now I2C bus is "idle" ("bus free"), ready for a communication. Both START and STOP conditions are indispensable for communication between the I2C device, of course, in this communication is no exception. • START condition: a state transition from high to low on the SDA line while SCL is high (high = 1; low = 0) signals a condition START • STOP Condition: A transition state from low to high on the SDA line while SCL is high. • Both START and STOPdeu conditions created by the host device. After the START signal, I2C bus is regarded as working status (busy). I2C Bus will be free, ready for a new communication after STOP signal from the host device. • Following a START condition, the communication process, when a repeated START signal instead of a STOP signal, the I2C bus to continue in the busy state. Signal START and repeated START has the same function that initiates a communication.

Operating mode

Highslide JS

Mode of operation of I2C DS1307 can operate in two modes: • In slave receive mode (DS1307 write mode): sequence data and clock sequence to be received through SDA and SCL. After each byte is received, then an acknowledge bit is transmitted. The START and STOP conditions are recognized as the beginning and end of a chain transfer 1, address recognition is performed by hardware after adoption of the slave address and bit one dimensional. • develop slave mode (DS1307 read mode): the first byte received similar slave mode slave records. However in this mode, the bit line direction just the opposite way. The string data is transmitted on SDA by the DS1307 while on foot chain SCL clock

To work with the DS1307, we perform the following steps: • START I2C • Remember: 0DxH (This is the DS1307 address specified by the manufacturer in the I2C interface) with: x = 0: Write data to the DS1307 x = 1: Read the DS1307 • Record data on this parameter x, which means that they tag the next hi or read data from the DS1307, depending on the value x = 0 (write data) or x = 1 (read data). • Write the register address to write or to read (table maps registers of DS1307 wind had us in Figure 3 & Figure 4). • Write or read data. • I2C STOP

An illustrative example of reading the record • register address 01h Data contained in "minutes", to set the DS1307 minutes we follow the process: START → Record: 0D0H → Remember to: 01h → Remember to:
→ Remember to or STOP if you just want to set the time for minutes.

Highslide JS

If you want to write the next address 01h and 04h Remember to address such we must START from the beginning → Remember to 0D0H (Remember to identify the DS1307 will communicate the direction _ Remember to) → Remember to 04h → Recording of data registers to be installed → STOP I2C. • Similarly, if we are to read, first we have to write to the address should read: that is, continue to conduct three procedures 0D0H → START → Remember Remember the address (the address of the register that we want read data). Then I recorded the new START 0D1H (this new notice will read from the DS1307), followed by any normal reading (read register is the register address written to me recently), followed need to read the read address is automatically increased until I2C STOP.

V, general block diagram of clock circuit

Highslide JS

Based on the block diagram of the interface above, it is essential that we have to initialize the DS1307 software, actually I2C communication program, read the value stored in the RAM of the DS1307 into the Ram's temporary 89S52 . Then write a software to read the contents of this Ram offers displayed by scanning method. For simplicity, the read data stored in the RAM of the DS1307 and displaying gio_phut_giay 89S52, is divided into two small subprograms, if any key press will jump to subroutine processing separate keystrokes.

Map principles:

Highslide JS

Circuitry in:

Highslide JS

Highslide JS

VI, DESIGN SOFTWARE

As described in the algorithm and rice to a general block diagram, the MAIN program will include our three main sections are described in detail flowchart of the MAIN program in the

Highslide JS

Interpretation of this flowchart: Start, the program will call the subroutine reading data from the DS1307 I2C to communicate with standard methods have been presented in detail in section 4 (communication algorithms), then, will call the subroutine for scanning 7 segment LED display 6 No. 2 showing the values ​​of hours, two numbers show the value of the minutes, 2 seconds to display the value of. If the MODE key (chosen settings) is not pressed, the loop of this program will run indefinitely. If the MODE key is pressed, it will jump to subroutine set hours or minutes depending on the number of press MODE. Here we go into the details of the small block parts:

Reading data from DS1307 stored in RAM'S 89S52 See flowchart program as shown below. Here, the smaller programs, such as: CTC SEND_START, SEND_STOP, SEND_BYTE, etc. have been discussed in section 4 (communication algorithms mentioned above).

Highslide JS

VII, DISPLAY WITH PARAGRAPH 7 LED SCAN METHOD

Highslide JS

VIII, INSTALLATION TIME
In the flow chart on the above algorithm Highslide JS , Shows us, the loop of the program will run endlessly until the keys are set to MODE. Then, it jumps to the CTC to address installation time. CTC algorithm flowchart of processing key settings are shown in Figure

Highslide JS

Flowchart install CTC CTC installed minute now also the same principle as setting time should not be told here. Looking at the flow chart we can see, ThanhGhi = 02h, the address bar grille in the DS1307, thus, the purpose of defining ThanhGhi memory address is to determine changes in the value of RAM memory the DS1307. CTC installed will loop endless hours and CTC hours will be displayed only 2 Led 7-segment display, only visible during the installation time, all the remaining LEDs are turned off. While CTC installation is running endlessly, if any INC or DEC key is pressed, it will jump to the CTC to increase or decrease depending on the key is pressed. CTC increased hours are shown in Figure 22 below, the principle of CTC reduction is always the same.

Highslide JS

Flowchart CTC increased hours if hit up the 23, the program will set the time value is 00h.

and the!

Video products:



Reference code:
 (Pass: chipkool.tk)

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Can u pls send me the source code jito79@gmail.com

    ReplyDelete
  3. When tollfree numbers were not yet available, collect calls provided people with a means to make a call charged to the receiver. This was introduced in the UK by the post office as "transferred charge service".

    ReplyDelete
  4. Dear sir, Could you please send me the source code tharakaxe@gmail.com

    ReplyDelete
  5. Can u pls send me the source code nawafabdfathi@gmail.com

    ReplyDelete
  6. Dear sir, Could you please send me the source code luthfan_55091@yahoo.co.id

    ReplyDelete

Post a Comment

Popular posts from this blog

Using the TLP250 Isolated MOSFET Driver - Explanation and Example Circuits

N-Channel MOSFET High-Side Drive: When, Why and How?

Using the high-low side driver IR2110 - explanation and plenty of example circuits