Jam LCD Dengan RTC

download Jam LCD Dengan RTC

of 6

Transcript of Jam LCD Dengan RTC

  • 8/20/2019 Jam LCD Dengan RTC

    1/13

    This time I will be showing you how to make a module for letting the Arduino find out the time.Although there are many tutorials for the Real Time Clock module I wanted to make my version

    of this module entirely focused on the step by step soldering. The Instructable will also try to

    include as much example code as possible so that the reader will get more than the basicknowledge of this module.

    This module has the integrated time keeping system using a crystal oscillator. So the timing is

    accurate with multiple applications. This module also has a battery backup with which the

    module can keep track of the time even when the Arduino is programmed or turned off. ets startoff with the stuff you will learn and the applications of this module.

    Stuff You Will Learn:

    • The code re!uired to access the module and get the current time.

    • The code for setting the time.

    • A simple program with which the user can interact with the module.

    Uses of The Project:

  • 8/20/2019 Jam LCD Dengan RTC

    2/13

    • "nce you are done with this Instructable you will be able to make your own #igital

    Clock.

    • $ou can build on the idea and make an Alarm Clock.

    • This %odule is the timekeeper for many pro&ects like The 'ropeller Clock( The )ixieClock( etc.

    Components Required:

    Component for the Module:

    • #S *+,-.

    • /'in #I' Socket.

    • CR 0,+0 1utton Cell. 

    • 1utton 1attery 2older. 

    • 3/'in Connector .

    • *,k Resistor *43 5att. 

    • +0.-6k27 "scillator Crystals.

    • 'rototype 1oard.

    Additional Components:

    • Solder 5ire. 

    • Soldering Iron. 

    • Arduino 8)". 

    •*6x0 C# Character #isplay.

    • 9umper 5ires :;emale to ;emale

  • 8/20/2019 Jam LCD Dengan RTC

    3/13

    Apart from the arduino the #S*+,- Integrated Circuit is the core of this pro&ect since it acts as

    the timekeeper and tells the arduino when it should leave the appliance on. The #S *+,- is

    specifically designed for timekeeping( The time is fairly accurate with an error :time drift< of

    about * minute per month. If u want to eliminate this u can go for the #S+0+3 which has a time

    drift of only * minute per year. ;or our particular application we can settle for the #S*+,- itself.

    The beauty of the #S*+,- is that it has this backup coin cell. This Coin Cell is commonly the

    CR0,+0. This battery is more than enough for the IC since the #S*+,- has a fairly low power

    consumption the backup battery life of the cell is about a minimum of > years of usage.

    So now that the specs have been discussed lets talk about the communication. The #S *+,-

    communicates with the arduino using I?C communication. Simply put the chip sends data in

    decimal form such that each decimal form is 3 bits of binary data also known as 1inary Coded

    #ecimal System.

    Important Pins:

    ! Pin: 5hen this pin is high then the ds*+,- sends the data and when it is low it runs on the

     backup button cell.

    "#$: This is the ground pin for the module. 1oth the ground of the battery and the power

    supply are tied together.

    SCL: It is the i0c clock pin / 5hich communicates with the RTC.

    S$A: It is the i0c data pin / 5hich communicates with the RTC.

    http://www.ebay.com/itm/25pc-GENUINE-MAXELL-CR2032-2032-LITHIUM-BUTTON-COIN-CELLS-BATTERIES-Battery-3V-/290755065751?pt=US_Single_Use_Batteries&hash=item43b25a3797http://en.wikipedia.org/wiki/I%C2%B2Chttp://en.wikipedia.org/wiki/Binary-coded_decimalhttp://en.wikipedia.org/wiki/Binary-coded_decimalhttp://en.wikipedia.org/wiki/Binary-coded_decimalhttp://www.ebay.com/itm/25pc-GENUINE-MAXELL-CR2032-2032-LITHIUM-BUTTON-COIN-CELLS-BATTERIES-Battery-3V-/290755065751?pt=US_Single_Use_Batteries&hash=item43b25a3797http://en.wikipedia.org/wiki/I%C2%B2Chttp://en.wikipedia.org/wiki/Binary-coded_decimalhttp://en.wikipedia.org/wiki/Binary-coded_decimal

  • 8/20/2019 Jam LCD Dengan RTC

    4/13

    So now that the introductions are done lets get to actually making the module. The instructable

    has steps of the soldering and the places of the components in the board. 2ope this method is

     better to understand than &ust providing the circuit diagram.

    Step 2: Assembly and Soldering - 1

    So the module is only 0 x + cm in si7e( which is pretty compact. The module has a wire

    connector but you can also use a male or female header so that it can be directly plugged into the

    Arduino. Anyway apart from the s!uare wave pin not soldered the module has all the functional

    features.

    Making The Module:

    Step %:

    Cut the prototype board to the si7e mentioned above and insert the coin cell holder. Then solder

    the bottom end to hold the cell in its place.

  • 8/20/2019 Jam LCD Dengan RTC

    5/13

    Step &:

    Insert the #I' socket right next to the cell holder but leave space for the crystal oscillator like in

    the diagram. Solder some pins to hold the socket in place.

    Step ':

     )ow insert the crystal "scillator near the first and second pin of the #I' Socket as shown in the

    figure. Then solder it as shown.

     Note 1:

    This note is for showing the colour code for my 3 pin connector for reference( since yours may

    vary please double check that the proper connections are made.

    #ote &:

     )ow we need to connect the battery terminals using the tracks as shown in the diagram. These

    connections provide the backup power.

    Step 3: Assembly and Soldering - 2

  • 8/20/2019 Jam LCD Dengan RTC

    6/13

    tep :

     )ow insert the power pins coming from the Arduino. The positive pin goes to the eighth pin of

    the #S *+,-. Then the ground is common for the IC and the button cell.

    Step (:

    In this step we connect the other two data pins coming from the Arduino as shown in the figure.

    I=m sorry because I made the module a little small so there was no hole for the *,k resistor. I

    inserted both the resistor and the wire in the same pin and then soldered.

    Step ):

    So after you inserted the wires next we need to insert *,k resistors each into the two pins. Theother ends of the two resistors goes to the power pin eight of the #S *+,-. Then solder up the

    wires( a diagram is provided for reference.

    Step *:

    Since I use a connector in this module fre!uent usage will lead to wear and tear of the wires. So imade a &oint using the cut of wire from the resistors. ;irst insert the wire into one end and solder

    it to make it sturdy. Then make a 8/bend and pass the wires through this 8/bend and tighten the

    8/bend for a good grip and then solder the other end too to make a &oint. The diagram explains

    the method better than words.

    The module is finally finished so insert both the battery and the #S*+,- IC into their sockets.

    The final diagram shows the completed module with all intact.

    Step 4: Checking and Setting The Module

  • 8/20/2019 Jam LCD Dengan RTC

    7/13

    "nce you are done assembling the module. Connect the module to the Arduino( so that the pins

    are inserted properly into the Arduino. The program for testing the module is given below. The

    code constantly updates the time through the serial port.

    In/order to run the module we need two libraries we need two libraries into the Arduinosoftware. The following steps set up the Arduino software with the libraries needed and the code.

    +mportin, The Li-raries:

    • #ownload the library @ RealTimeClockDS1307 @ and save it in the desktop.

    • "pen the Arduino and go to S.etch B +mport Li-rar/ B Add Li-rar/.

    • Then select the library saved in the desktop and click add.

    •  )ow paste the sample code given below and click compile. If it compiles successfullythen skip the remaining steps.

    • If it doesn=t import the second library @Wire@ and repeat the same procedure and compile

    the code and it will work.

    Code Wor.in,:

  • 8/20/2019 Jam LCD Dengan RTC

    8/13

    The code is written by @#avid 2. 1rown@ I merely use it to give you an introduction to the

    #S*+,-. Anyway the Arduino communicates with the RTC %odule and updates the time for

    every second through the Serial Monitor. The creator has given us a option to set the time whenwe send the command @0@. The following menu appears.

    Try these: h## - set Hours [range 1..12 or 0..24] i## - set mInutes [range 0..59] s## - set Secons [range 0..59] ## - set !ate [range 1.."1] m## - set onth [range 1..12] y## - set $ear [range 0..99] %## - set ar&itrary ay o' (ee) [range 1..*] t - togg+e 24-hour moe a - set , - set

     / - start c+oc) - sto c+oc)  - S(3T 6 1H/ - sto S(3T

     This code will help you to set the time as well as check if the module's backupbattery supply works properly. In the next tutorial I will show you how to setup a

    LCD Display and display the time from the TC module. !ere is the code for testin"

    the module and an attached #le of the same.

    #inc+ue 7(ire.h8#inc+ue 7ea+Time+oc)!S1"0*.h8

    33ea+Time+oc) T;336ne% ea+Time+oc)ShortHe+>?@ery>A>Secons B0 33 n.secs to sho% hint 'orhe+33#e'ine T?ST>Suare%a@e33#e'ine T?ST>StoStart33#e'ine T?ST>1224S%itch

    int count60;char 'ormatte[] 6 C00-00-00 00:00:00DC;

    @oi setu

  • 8/20/2019 Jam LCD Dengan RTC

    9/13

      33GGG ,na+og in settings to o%er T mou+e GGGJ @oi +oo?@ery>A>Secons 66 0=E  Seria+.rint

  • 8/20/2019 Jam LCD Dengan RTC

    10/13

    #eni'

    #i'e' T?ST>StoStarti'

  • 8/20/2019 Jam LCD Dengan RTC

    11/13

      T.set+oc)

  • 8/20/2019 Jam LCD Dengan RTC

    12/13

      T.set+oc)

  • 8/20/2019 Jam LCD Dengan RTC

    13/13

      Seria+.rint