?>

Hard Copy World

HCW

Sensor

Home > Info >

Sensor

DS1302 Real Time Clock

페이지 정보

작성자 최고관리자 쪽지보내기 메일보내기 홈페이지 자기소개 아이디로 검색 전체게시물 작성일14-10-05 00:36 조회5,487회 댓글0건

본문

1. DS1302 Real Time Clock

DS1302 특징:

  • Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100
  • Serial I/O for Minimum Pin Count
  • 2.0V to 5.5V Full Operation
  • Uses Less than 300nA at 2.0V
  • Single-Byte or Multiple-Byte (Burst Mode) Data Transfer for Read or Write of Clock or RAM Data
  • Board Size: 44mm x 24mm

 

Time 라이브러리를 이용한 시간 데이터 사용은 아래와 같은 하드웨어를 지원합니다.

  • Time library for dates and times that can be used with and without external hardware
  • DCF77
  • DS1302
    • DS1302 Information and a basic sketch for the DS1302.
    • DS1302 RTC (23-wire interface with supercap backup) library
  • DS1306
  • DS1307
  • Use the CMax CMMR-6P WWVB Receiver with Arduino
  • Sleep and Watchdog functions for battery operated equipment Nightingale example
  • Interface to IBM AT RTC bq3287 and compatable with 8bit bi-directional bus code and description
  • Interface to a Maxim-IC DS3231 I2C chip
  • Guide for beginners to using the DS1302 RTC in the nuelectronics.com datalogging shield. Could help other users of the DS1302 also.
  • Library for the DS1340Z RTC with sample sketch to read and write time code. (Low voltage operation supported). For more information please check out the DS1340Z Inmojo Arduino Shield product page.
  • PCF8563 RTC Library with examples.
  • MicroCLK: A stand alone RTC controlled clock with LCD display
  • DS3234
    • The libary creates software interface to communicate with DS3234 RTC.
    • It allows for using any pins as MOSI, MISO, CLK and SS, for communication with the DS3234, thus conflicts with SD and Ethernet libraries are no longer a problem.
    • The libary is based on the example offered by Sparkfun.
    • Library offers reading date and time, setting it, and also as a bonus it allows to read the temperature.
  • PCF8563
  • R4571 (ETM21E-02)
    • R4571 Epson Toyocom R4571 RTC Library and documentation

 

2. 연결 방법

얼핏 비슷해 보이지만 I2C, SPI 와는 다른 Simple 3-wire interface 를 사용합니다.  디지털 핀 3개를 사용하며 임의로 변경할 수 있습니다.

MODULE  ->  ARDUINO
GND            -> GND
VCC             -> +5V
SCK             -> D4
I/O              -> D3
RST(CS)    -> D2

 

3. 소스 코드 (스케치) 

/* FILE:    ARD_1302_RTC_Example_Sketch_HCMODU0035
   DATE:    03/09/13
   VERSION: 0.1

REVISIONS:

20/09/13 Created version 0.1

This is an example of how to use the Hobby Components 1302 Real Time Clock
module (HCMODU0035). This example uses the RTC library written by Henning Karlsen 
(http://www.henningkarlsen.com/electronics/). This example sketch demonstrates 
how to read and write to the RTC module. To connect the module to your Arduino 
please see the following pinout:

PINOUT:

MODULE    ARDUINO
GND       GND             
VCC       +5V              
SCK       D4
I/O       D3
RST(CS)   D2

You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of premoting or selling products 
that directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */

/* Define the DIO pins used for the RTC module */
#define SCK_PIN 4
#define IO_PIN 3
#define RST_PIN 2

/* Include the DS1302 library */
#include <DS1302.h>

/* Initialise the DS1302 library */
DS1302 rtc(RST_PIN, IO_PIN, SCK_PIN);

void setup()
{
  /* Clear the 1302's halt flag */
  rtc.halt(false);
  /* And disable write protection */
  rtc.writeProtect(false);

  /* Initialise the serial port */
  Serial.begin(9600);
}

/* Main program */
void loop()
{

  /* Set the time and date to 16:30 on the 3rd of September 2013 */
  rtc.setDOW(MONDAY);
  rtc.setTime(16,30,0);
  rtc.setDate(3, 9, 2013); 

  /* Read the time and date once every second */
  while(1)
  {
    Serial.print("It is ");
    Serial.print(rtc.getDOWStr());
    Serial.print(" ");
    Serial.print(rtc.getDateStr());
    Serial.print(" ");
    Serial.print("and the time is: ");
    Serial.println(rtc.getTimeStr());

    /* Wait before reading again */
    delay (1000);
  }
}

Arduino DS1302 RTC library written by Henning Karlsen (http://www.henningkarlsen.com/electronics/)

 

추천 0
  • 페이스북으로 보내기
  • 트위터로 보내기
  • 구글플러스로 보내기

댓글목록

등록된 댓글이 없습니다.