Вы находитесь на странице: 1из 9

Using the I2C Bus ELP 305 : Design and System Laboratory

Samarth Mohan: 2016EE30516

Naman Upadhyaya: 2016EE30507

1. Objective :​ ​Using I2C protocol - Interfacing a Real-Time Clock chip

1.1 Problem Statement:​ ​Using a RTC chip to get the time input, we will have to write the
necessary software to display the time on a LCD display. Alarm will be set using push buttons
Padj,P+ and P-. Press Padj ONCE activates the Alarm Setting mode. The second press of Padj
sets the hour setting, the third press of Padj sets the minute setting, the fourth press of Padj sets
seconds setting and pressing Padj a fifth time ends the Alarm Setting mode. P+/P- will
increment/decrement the time unit .We will sound an alarm (buzzer) when the current time
matches the set alarm time.

1.2 Going Further :

a. Alarm based motor switch-on / switch-off control - Using one additional pin and a current / voltage
buffer, switch on a water pump when the water supply comes on. Switch off the pump after 1
hour or 1 second after the water supply stops.

b. Alarm based temperature recording for temperature prediction - using a LM35 as a


temperature sensor, record a log of ambient temperature at 15 minutes intervals
starting at 00:00 AM. Arrange to have these values transferred to your laptop using
either a USB or a serial port.

2. Apparatus:​We used the following equipments and machine

3 Challenges Faced
a. Like every other computer clock, this clock also showed clock drift over
time i.e. the system time gradually deviates from accurate or ?true? time.
In this case, the RTC module didn’t show any time drift because of shorter
time period. The time drift varies for different RTC depending upon con-
ditions such as temperature, time it is remained on, etc. Drift is normally
around 3-5 sec per day.

b. Another challenge we faced was initialisation error in Arduino where we


needed to remove 2 pins and then upload our
code.

c. We also had a tough time syncing the rtc with the arduino, by that we
mean synchronising the
connections.

4 Block Diagram for Interfacing


For block diagram refer figure 1 on page
3

5 Circuit Diagram
For circuit diagram to connect RTC to Arduino refer figure 2 on page 4 (5)

Figure 1: Block Diagram


3
6 Flowchart for Code
Figure 2: Circuit Diagram
4

7 Observations
RTC displays the current time. User can set an alarm depending upon the
user needs.

a. In the figure 3 on page 5, is the physical circuit.

b. In the figure 4 on page 6, is the display of setting up of alarm.

c. In the figure 5 on page 7, is the display of alarm ON.

Figure 3: Physical Circuit

8 Conclusion & Result


We used library of DS1302 to set an initial time. Then once the clock starts
running, user can give input as to when it wants to set the alarm. The push
but- tons facilitate this communication between user and clock. There are
different push buttons to switch mode, set hours, set minutes and set
seconds. All computer systems show clock drift over time - the system time
gradually deviates from accurate or ?true? time. Note that this time drift is just
3-5 seconds a day so we cannot make a direct observation of the time drift in
our lab hours. Various methods have been devised to correct drift. The
simplest and most reliable way to do so is to implement Network Time
Protocol and receive accurate time signals from a server that is dedicated to
that task and maintained to a very high standard of accuracy. (3)

5
We also learned that 2C is a serial protocol for two-wire interface to connect
low- speed devices like micro-controllers, EEPROMs, A/D and D/A
converters, I/O interfaces and other similar peripherals in embedded systems.
It was invented by Philips and now it is used by almost all major IC
manufacturers. Each I2C slave device needs an address ? they must still be
obtained from NXP (formerly Philips semiconductors). I2C bus is popular
because it is simple to use, there can be more than one master, only upper
bus speed is defined and only two wires with pull-up resistors are needed to
connect almost unlimited number of I2C devices. I2C can use even slower
microcontrollers with general-purpose I/O pins since they only need to
generate correct Start and Stop conditions in addition to functions for reading
and writing a byte. (4) In conclusion we succeeded in using Arduino and RTC
to create and alarm clock.

References
[1] Tutorial on DS1307. Available at
http://datasheets.maximintegrated.
com/en/ds/DS1307.
pdf

[2] Tutorial on LCD. Available at ​http://www.itron.com.cn/PDF_file/


JHD162A%20SERIES.
pdf

[3] Network Time Protocol. Available at


http://cloudhsm-safenet-docs.s3.
amazonaws.com/007-011136-002_lunasa_5-1_webhelp_rev-a/Cont
ent/ administration/drift_and_correction_non-ntp.htm

[4] I2C Bus. Available at


http://i2c.info/

6
Figure 4: Set Alarm

[5] Circuit Diagram. This diagram is available on the internet we made direct
connections in physical
world.

9 Link to Code Repository


https://docs.google.com/document/d/1ccNMh9FQeCh9Wl9OeeMDTddb-o6mQyjyXxo
5NuDdXS4/ edit?usp=sharing
7
Figure 5: Alarm Ringing

Вам также может понравиться