Calendar Digital-ras

  • Uploaded by: sujay pujari
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Calendar Digital-ras as PDF for free.

More details

  • Words: 3,206
  • Pages: 32
15313424.doc

TE MINI PROJECT DIGITAL CALENDER WITH TEMPERATURE

BY: ROHIT JADHAV (T2-25) AVADHOOT KUMTHEKAR (T3-35) SUJAY PUJARI (T3-48)

PVG’s COLLEGE OF ENGINEERING& TECHNOLOGY 1

15313424.doc

CERTIFICATE

This is to certify that the Mini Project entitled DIGITAL CALENDER WITH TEMPERATURE Has been completed in Academic year 2007-2008 by 1. ROHIT JADHAV (T2-25) 2. AVADHOOT KUMTHEKAR 3. SUJAY PUJARI (T3-48)

In fulfillment of Third Year Engineering in the E&TC Engineering as prescribed by the University of Pune, Pune.

DATE: ___________ ___________ Project guide

________________ Head of Department

2

15313424.doc

INDEX OF CONTENTS SR NO.

TITLE

PAGE NO

1

ACKNOWLEDGEMENT

2

INTRODUCTION

3

SPECIFICATIONS

4

BLOCK DIAGRAM

5

CIRCUIT DIAGRAM AND WORKING

6

ALGORITHM

7

FLOWCHART

8

CODE

9

PCB LAYOUT

10

DEBUGGING AND TESTING

11

MECHANICAL DESIGN

12

FUTURE DEVELOPMENTS

13

LIST AND BILL OF COMPONENTS

3

15313424.doc

ACKNOWLEDGEMENT We wish to express our profound thanks to Prof Mr. R.W. Pattarkine (HOD of Electronics and Telecommunication dept) for giving us this opportunity to present our “DIGITAL CALENDER WITH TEMPERATURE”. Project initiative was from and by Prof. C.B. Joshi.Whole concept of project and implementation of AVR controller was all due to him. We would like to express our sincere gratitude to Prof Mr. R.G. Kaduskar for his able guidance and unfailing support. Without his constructive criticism and co-operation, we would have never overcome the difficulties and hardships faced during the course of the project work. To our parents who have been the constant source of inspiration for us. Last but not the least, we are grateful to all those who have extended their cooperation directly or indirectly during the implementation of this project.

-ROHIT JADHAV -AVADHOOT KUMTHEKAR -SUJAY PUJARI

4

15313424.doc

INTRODUCTION Digital calendar with temperature is the device that displays current time, date, day and current temperature in degree Celsius. Every one can use it in day to day life. It is ATMEGA 32 (AVR Family) controller based devise. It uses LM 35 as a temperature sensor, DS1307 as R.T.C. and JHD162Aas a LCD module. SPECIFICATIONS CIRCUIT SPECIFICATIONS Sensor module: • No of sensors: 1 • Type of sensors: Temperature • I/P voltage: 5V • O/P of sensor module: 0V or 5V Controller: • Atmega32 • Total current requirement: 500mA Display: • JHD162A • 16x2 line LCD

MECHANICAL SPECIFICATIONS •

PCB size : 17 x 11 cm Controller board 1 x 1 cm Sensor board 5 x 3 cm RTC board 5

15313424.doc

ELECTRICAL SPECIFICATIONS Input Supply : 9V DC • Input current: 500 mA •

BLOCK DIAGRAM

Sensors

Controller

R.T.C.

Display unit

6

15313424.doc

CIRCUIT DIAGRAM

Controller Board

7

15313424.doc

CIRCUIT WORKING



SENSOR MODULE (Temp Reading):

Connection:

pin2 i.e. o/p of LM35 to portA.0

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 is rated to operate over a -55 to +150C temperature.LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. • Linear a 10.0 mV/˚C scale factor For inbuilt ADC section of controller; we set • Reference voltage=2.56v. • 8-bit resolution mode For ADC. This mean, step voltage=2.56/ (2^8) =2.56/256=10mV As and when temp changes by a single ˚c (degree).o/p of LM35 wil differ (alter) by 10mV.which results in 1 bit change in digital representation of o/p of ADC, which come out in ADCH register of controller.

ALGORITHM 1.

Initialize ADC (a) RFS1 and RFS0 are for Internal Reference voltage of 2.56V AND 8 BIT CONVERSION

8

15313424.doc

ADLAR bit set to get o/p in ADCH register Select A0 channel

(b) 1MHz/32 = 31 kHz & Normal conversion without interrupt

2. Read ADC (a) Start conversion: set bit ADSC from ADCSRA. (b) Bit 4 – ADIF: ADC Interrupt Flag This bit is set when an ADC conversion completes and the Data Registers are updated. The ADC Conversion Complete Interrupt is executed if the ADIE bit and the I-bit in SREG are set. ADIF is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ADIF is cleared by writing a logical one to the flag. Wait for that interrupt.

3. Display temp on LCD The byte stored in ADCH is nothing but HEX format of temperature .As 0 ˚C corresponds to 0in ADCH and any 1˚C change in temperature will change content of ADCH by one. Therefore the situation is like ADCH= (TEMP) hex. 9

15313424.doc

Convert hex to 3 digits BCD no. (b)And again each BCD no to ASCII forms. (c) Then send each no. one by one to data ports of using appropriate function. (a)



RTC (time ,date ,day read)

Connections: 10

15313424.doc

For ATMEGA32 (master):

TWI Control Register – TWCR The TWCR is used to control the operation of the TWI. It is used to enable the TWI, to initiate a master access by applying a START condition to the bus, to generate a receiver acknowledge, to generate a stop condition, and to control halting of the bus while the data to be written to the bus are written to the TWDR.

• Bit 7 – TWINT: TWI Interrupt Flag The TWINT Flag must be cleared by software by writing a logic one to it.  Note that this flag is not automatically cleared by hardware when  executing the interrupt routine. Also note that clearing this flag starts the  operation of the TWI, so all accesses to the TWI Address Register  (TWAR), TWI Status Register (TWSR), and TWI Data Register (TWDR)  must be complete before clearing this flag. • Bit 2 – TWEN: TWI Enable Bit The TWEN bit enables TWI operation and activates the TWI interface. When TWEN is written to one, the TWI takes control over the I/O pins connected to the SCL and SDA pins, enabling the slew-rate limiters and spike filters.

A STOP condition is generated by writing the following value to TWCR:

11

15313424.doc

For DS1307(slave):

For RTC part DS1307, as ‘TWI base RTC (I2C protocol) ‘is used.

12

15313424.doc

ALGORITHM NOTE: Controller is master always.For RTC operation there are two mode. 1. Controller transmitting mode1 2. Controller receiving mode2 Product requires 2 source codes 1. Before user access(administrator code) 2. For user dedicated (client code) There is some common part of initialization in both Algo –common) a. set global interrupt flag so interrupts can be used b. set hardware i2c to 28khz rate operation(ref: doc2564) c. set internal pull-ups on SDA and SCL pins Apart from above, Administrator code uses algorithm to initialize RTC timekeeper register. ( i.e. set mode) & to test read it.->ALGO-a) .Client code uses algorithm to read RTC timekeeper register. ( i.e. set mode) ALGO-b) ALGO-a) a. Initialize register address; b. initialize Register data; c. write(); //mode 1 only d. read(); //mode 1 & 2 e. go to d. c) write() 1. send START condition 2. wait until TWINT is set by hardware 3. check TWSR with 0x08(starts successfully) 4. send SLAVE address .TWDR=0xD0 5. wait until TWINT is set by hardware 6. check TWSR with 0x18 (device Acknowledge successfully) 7. Send actual register address.TWDR=registeradd. 8. wait until TWINT is set by hardware 9. check TWSR with 0x28 ( data Acknowledge successfully) 13

15313424.doc

10. send

actual register data.TWDR = registerdata 11.wait until TWINT is set by hardware 12. check TWSR with 0x28 ( data Acknowledge successfully) 13. send STOP condition 14.return d)read ()

mode1 1. Send STOP condition. 2. send START condition 3. wait until TWINT is set by hardware 4. check START complete 5. Send Slave address 6. loop until TWINT is set 7. check SLAVR ADDRESS complete 8. Send DS1307 RAM address. TWDR = registeradd 9. loop until TWINT is set 10.check Data Send complete mode2 11.SECOND START CONDITION to go into writing mode 12.loop until TWINT is set 13.check RESTART complete 14.Send Address and write bit 15.loop until TWINT is set 16.check receive complete 17.loop until TWINT is set 18.TWDR will contain actual content of desired register. 19.return ALGO-b) a. Int k=read(int regaddress) b. K will contain actual reading a) Int read (int regaddress) 14

15313424.doc

mode1 1. Send STOP condition. 2. send START condition 3. wait until TWINT is set by hardware 4. check START complete 5. Send Slave address 6. loop until TWINT is set 7. check SLAVR ADDRESS complete 8. Send DS1307 RAM address. TWDR = regaddress. 9. loop until TWINT is set 10.check Data Send complete mode2 11.SECOND START CONDITION to go into writing mode 12.loop until TWINT is set 13. check RESTART complete 14.Send Address and write bit 15.loop until TWINT is set 16.check receive complete 17.loop until TWINT is set 18.TWDR will contain actual content of desired register. 19.return TWDR

LCD MODULE: LCD operates in 8 bit and 2*16 character mode. Port D is taken as data port& Port C.7=RS (register select) Port C.6=R/w Port C.5=ale (address latch enable)

15

15313424.doc

CODE: Codes are classified in 2 part 1. User dedicated a) Client code 2. Debugging purpose a) Administrator code for RTC b) LCD Test

1a)client code #include "mega32_ds1307.c" int main(void) { char temp[]="Temp="; char arrr[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"}; int i; init(); Init_Ports(); Init_Lcd(); Init_ADC(); Select_InstructionRegister; Write_Lcd; Data_Lcd(0xC8); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); Lcd_Send('^'); Lcd_Send('c'); Select_InstructionRegister; Write_Lcd; Data_Lcd(0xC0); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); for(i=0;i<5;i++) { Lcd_Send(temp[i]); } 16

15313424.doc

//call the read function in a loop to update second's value to the screen for(;;) { Select_InstructionRegister; Write_Lcd; Data_Lcd(0x80); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); Ouptut_Display(read2(2)); Lcd_Send(':'); Ouptut_Display(read2(1)); Select_InstructionRegister; Write_Lcd; Data_Lcd(0x87); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); Ouptut_Display(read2(4)); Lcd_Send('/'); Ouptut_Display(read2(5)); Lcd_Send('/'); Ouptut_Display(read2(6)); Select_InstructionRegister; Write_Lcd; Data_Lcd(0xc5); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); Ouptut_Display2(Read_ADC()); Select_InstructionRegister; Write_Lcd; Data_Lcd(0xcB); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); Lcd_Send(arrr[read2(3)-1][0]); Lcd_Send(arrr[read2(3)-1][1]); Lcd_Send(arrr[read2(3)-1][2]); 17

15313424.doc

} return 0; }

2a)Administrator code: #include "mega32_ds1307.c" int main(void) { init(); Init_Ports(); Init_Lcd(); registeradd=0x3; registerdata=0x5; write(); for(;;) read(); return 0; }

3)externally included ************************mega32_ds1307.C**************************** #include "global.h" // include our global settings #include #include "MYLCD.c" #include "ADC.c" #include "C:/Program Files/avrlib/timer.c" // include timer function library (timing, PWM, etc) //masks for different conditions on the TWI bus #define START 0x08 #define RESTART 0x10 #define MT_SLA_ACK 0x18 #define MT_SLA_NOACK 0x20 #define MT_DATA_ACK 0x28 #define MT_DATA_NOACK 0x30 #define MT_SLA_DATA_LOST 0x38 //Master Receive conditions #define MR_SLA_NOACK_LOST 0x38 #define MR_SLA_ACK 0x40 #define MR_SLA_NOACK 0x48 #define MR_DATA_ACK 0x50 #define MR_DATA_NOACK 0x58 #define TARGET_ADDR 0xD0 #define WRITE_FLAG 0x01 write to the DS1307

//Hardwired address of DS1307 (see datasheet) //bitmask to OR to TARGET_ADDR when attempting to

//prototypes of diferent functions to organise the code a little void init(void); void i2cInit(void); 18

15313424.doc

int read(int); //variable to store the value returned from the DS1307 void init(void) { timerInit(); i2cInit(); return;

//defined in timer.h //my personal function, defined in this file (see below)

} void i2cInit(void) { set global interrupt flag so interrupts can be used sei(); //set hardware i2c to 100khz rate operation TWBR = 10; //see appnote 315, page 5 //set internal pullups on SDA ans SCL pins PORTC = 0x03; //see Mega32 datasheet, page 63 return; } int read2(int reg) { //send STOP TWCR = (1<
15313424.doc

//;DATA1 //Send DS1307 RAM address 0x00 ($00) TWDR = reg; TWCR = (1<
and compare result against START mask (see top 20

15313424.doc

//see page 176 of the ATMEGA32 datasheet for explaination of TWSR register //else go on normally without msg //send SLAVE address TWDR = TARGET_ADDR; TWCR = (1<
//0xD0 //Change the TWCR

//Check slave address complete //;DATA1 //send address TWDR = registeradd; //load TWDR with DS1307 RAM address $00 TWCR = (1<
//Tell TWCR

15313424.doc

timerPause(200); //send START TWCR = (1<
15313424.doc

Ouptut_Display(TWDR); //NACK TWCR = (1<
return; }

********************************ADC.C************************** void Init_ADC(void) { ADMUX|=(_BV(ADLAR) | _BV(REFS1)| _BV(REFS0)) ; // RFS1 and RFS0 are for Internal Reference voltage of 2.56V AND 8 BIT CONVERSION ADMUX&=~(_BV(MUX0)|_BV(MUX1)|_BV(MUX2)|_BV(MUX3)|_BV(MUX4)); //SELECTING CHANNEL0 ADCSRA|=(_BV(ADEN) | _BV(ADPS2) | _BV(ADPS0)) ; //normal conversion without interrupt ADCSRA&=~(_BV(ADSC)|_BV(ADATE)|_BV(ADIF)|_BV(ADIE)| _BV(ADPS1));//clock/32 speed } int Read_ADC(void) { ADCSRA|=_BV(ADSC); //start conversion while(!((ADCSRA&_BV(ADIF))>>ADIF)); return ADCH; } ******************************MYLCD.C********************************** #include /*----------------------------------------------------------------------------CONNECTION BETWEEN LCD AND ATMEGA32---------------------------------------------------------------------------------*/ #define DATA_DDR DDRD #define DATA_PORT PORTD #define CONTROL_DDR DDRC #define CONTROL_PORT PORTC #define Enable_Pin 5 23

15313424.doc

#define RegSelect_Pin 7 #define ReadWrite_Pin 6 #define CONTROL_MASK 0XE0 /*----------------------------------------------------------------------------CONTROL BITS OF LCD ------------------------------------------------------------------------------------------------*/ #define Set_Enable #define Clear_Enable #define Write_Lcd #define Read_Lcd =_BV(ReadWrite_Pin) #define Select_InstructionRegister #define Select_DataRegister #define Data_Lcd(a) #define delay2(a)

CONTROL_PORT|=_BV(Enable_Pin) CONTROL_PORT&=~_BV(Enable_Pin) CONTROL_PORT&=~_BV(ReadWrite_Pin) CONTROL_PORT| CONTROL_PORT&=~_BV(RegSelect_Pin) CONTROL_PORT|=_BV(RegSelect_Pin) DATA_PORT=a delay_ms(a)

/*--------------------------------------------------------------------------------FUNCTIONS-------------------------------------------------------------------------------------------------------*/ void Init_Ports(void); void Init_Lcd(void); void delay_ms(unsigned char time_ms); void Lcd_Send(unsigned char a); int ka=15; /*-------------------------------------------------------------------------------MAIN FUNCTION------------------------------------------------------------------------------------------------------*/ /*int main() { Init_Ports(); Init_Lcd(); for(;;) Lcd_Send('f'); return 1; }*/ /*--------------------------------------------------------------------------------SEND A CHARACTER TO LCD-----------------------------------------------------------------------------------------*/ void Lcd_Send(unsigned char a) { Select_DataRegister; Write_Lcd; Data_Lcd(a); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); 24

15313424.doc

} /*--------------------------------------------------------------------------------FUNCTIONS TO INITIALIZE PORTS------------------------------------------------------------------------------------*/ void Init_Ports(void) { DATA_DDR=0XFF; //Setting data port for output CONTROL_DDR=CONTROL_MASK;//setting selected pins of control port for output CONTROL_PORT&=~(_BV(Enable_Pin)|_BV(RegSelect_Pin )|_BV(ReadWrite_Pin)); //setting values to 0 at starting }

/*---------------------------------------------------------------------------FUNCTION TO INITIATE LCD ---------------------------------------------------------------------------------------------*/ void Init_Lcd(void) { char init[10]; int i; init[0] = 0x01; init[1] = 0x38; init[2] = 0x0c; init[3] = 0x06; init[4] = 0x80; Select_InstructionRegister; Write_Lcd; for(i=0;i<5;i++) { Data_Lcd(init[i]); Set_Enable; delay2(ka); Clear_Enable; delay2(ka); } } /*-----------------------------------------------------------------------FUNCTION TO GENERATE DELAY IN MILLISECONDS--------------------------------------------------------------------------------*/ void delay_ms(unsigned char time_ms) { unsigned short delay_count = F_CPU / 400; unsigned short cnt; asm volatile ("\n" "L_dl1%=:\n\t" 25

15313424.doc

"mov %A0, %A2\n\t" "mov %B0, %B2\n" "L_dl2%=:\n\t" "sbiw %A0, 1\n\t" "brne L_dl2%=\n\t" "dec %1\n\t" "brne L_dl1%=\n\t":"=&w" (cnt) :"r"(time_ms), "r"((unsigned short) (delay_count)) ); } void Ouptut_Display(int h) {int k,j; k=h%16; j=h/16; Lcd_Send(j+'0'); Lcd_Send(k+'0'); } void Ouptut_Display2(int h) {int k,j,i,t; k=h%10; i=h/100; t=h/10; j=t%10; Lcd_Send(i+'0'); Lcd_Send(j+'0'); Lcd_Send(k+'0'); }

PCB LAYOUT 26

15313424.doc

Sensor board

R.T.C. BOARD

DEBUGGING AND TESTING 27

15313424.doc

Connect the external 9.0V dc supply with the correct polarity without switching on the circuit and follow these steps. 1. Check whether +5 V is available at output pin 3 of regulator IC 7805. 2. Now check the availability of +5 V at pin 10 of controller base before placing IC into the socket. 3. We have separate code namely administrator code for RTC and

testing code for LCD. 4. To check the LCD see the availability of 5V at pin2 of LCD. After

giving VCC the LCD should show matrices of black dots (5x7). The continuity check applies to all the components on board. 5. Apart from this always check connection twice.

HARDSHIPS FACED Due to unavailability of AVR general purpose board, we developed new AVR general purpose board. • Cold soldering points were found at a number of places. • Sensor was damaged because of wrong connections. •

MECHANICAL DESIGN 28

15313424.doc

FUTURE DEVELOPMENTS 29

15313424.doc

We can reduce the size of device by constructing our own PCB. We can make the device user friendly giving it more features like alarm circuitry, also can use keypad. We can also make the device compatible for AC mains.

LIMITATIONS: • This device does not give temperature reading below 0 degree. • Size of device is large. • Device is not user friendly. • It works on 9V battery only.

COMPONENT LIST AND BILL 30

15313424.doc

SR NO 1 2 4

COMPONENT

SPECIFICATIONS

12. 13 14 15 16

QTY COST (Rs) IC 7805 5V regulator 1 6 IC ATMEGA32 40-pin dipDIP 1 145 IC base 16 pin dip 1 2 40 pin dip 4 Relamet connector 6 pin 1 9 2 pin 3 6 3 pin 1 5 4 pin 2 12 Power jack(dc socket) 1 6 Transistor BC548 1 1 Toggle switch SPDT 1 8 BWR 1 6 Zener diode 5.1 V 2 2 Resistors 1000 ohm 0.25watt 2 0.5 10 kohm 0.25watt 2 0.5 15 Kohm 0.25watt 1 0.25 4.7 kohm 0.25 watts 2 0.5 Capacitors 1000uF,25V,electrolytic 1 6 100 uF,25V,electrolytic 1 2 10uF 25V, electrolytic 4 4 0.01 uF,ceramic 4 4 Bur strips 40 pin 3 18 2 pin push button 1 2 LCD 16x2 character LCD 1 130 LEDs 3mm 2 2 PCB 3 67 Serial cable Plug socket DB9 1 75

17 18 19 20 21 22

DB 9 socket LM 35 RTC CMOS Battery Crystal casing Max232

Female Temperature sensor DS 1307 3V 32.76Khz

5

6 7 8 9 10 11.

TOTAL Ref: 31

2 1 1 1 1 1 1

20 40 40 20 6 75 21 Rs.725

15313424.doc



MY EXPERIENCE IN PROGRAMMING AVR MICROCONTROLLER USING WINAVR/AVRGCC - By BIBIN JOHN Books are available on yahoo group-booksbybibin • Australian amateur robotics website

http://www.users.on.net/~symes/CwithAVR/IntrotoCwithAVR.htm http://www.users.on.net/~symes/Mega32/Mega32_ds1307.zip

AVR315: Using the TWI module as I2C master(application notes by ATMEL (doc2564.pdf) • DS1307 datasheet • ATMEGA32.pdf datasheet • Lm35 datasheet • FREE ISP from www.deccanrobots.com for downloading purpose • RTC PCB etching part done by Mr.Kadam from Dhankawadi. •

contact no:-9822851994 costs us 10/•

@rate 50p/cm2 (single sided)

Sensor PCB etching part done by Mr.Gurram from Bibvewadi. contact no:-02024269293

@rate ( 1/-)/cm2 (single sided)

Costs us 5/Controller PCB ( We are proud manufacturer of this testing board) Is now easily available named ‘R.A.S_ATMEGA’ in RAJIV Electronics-Pune contact no:02024477218 Costs us 52/• Apart from this all components were buy from RAJIV Electronics Pune • And serial cable from SEJUCTON-(house of networking product contact -02024459989 • For external casing purpose Tool used: • Winavr2007 compiler • Avr studio4-(debugging & simulation) • Free Isp- (free GNU for avr dude): downloader through spi bus. • Ext. Library: avrlib1.5 • avr-libc-user-manual-1.6.1.pdf •

32

Related Documents

Calendar
May 2020 5
Calendar
May 2020 7
Calendar
July 2020 5
Calendar
June 2020 4
Calendar
April 2020 11
Calendar
November 2019 23

More Documents from ""