32
Tachometer

Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Tachometer

Page 2: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Hardware Design

-=

Page 3: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Recall

Atmega

Interrupts

internal

External

LCD

Page 4: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

TSOP operates on 38 khz

Internal interrup

ts

CTC MODE 38 Khz

Page 5: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

LCD Circuit Diagram

Page 6: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Circuit is ready . What next ?

Circuit is ready . What next ?

Running Lcd through Code

Running Lcd through Code

Page 7: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

4 Simple Commands• Lcd_putsf(“Eclub welcomes u ”); // prints

constant string

• Lcd_putchar(‘a’); // character to be printed

• Lcd_puts(c); // c is a variable string

Page 8: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

What about integers ?

Problem

Page 9: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Solution• Convert Integer to strings • Use two simple Commands• Itoa(i,c) & ftoa(f,3,c)

Page 10: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Using Itoa

int a = 10 ;

char c[10]; itoa (i,c); lcd_puts(

c);

Page 11: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Result

Page 12: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Using ftoa

float a = 10.123 ;

Char c[10];

ftoa (i,3,c);

Lcd_puts(c);

Page 13: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Result

Page 14: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Using LCD in CVCAVR

Page 15: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 16: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 17: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Select any Port

Use the 4 magical

Functions

Page 18: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

External Interrupt• Triggered externally • Not at regular intervals of time

Detects

Rising Edge

Falling edge

Page 19: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Using Ext Interrupt in CVAVR

Page 20: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Open CVAV

R

Go to File New Proje

ct

Page 21: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 22: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 23: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 24: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 25: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)
Page 26: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Place your code here

Page 27: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

• So Now we are able to know when the obstacle attached to the shaft comes in way

• Able to display on LCD

Page 28: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

What remains ?• Calculate time at which external interrupt occurs • HOW ???

Page 29: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

HINT• Use one more Internal interrupt to get time

Page 30: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Pit Falls• TSOP frequency 38 Khz and frequency of IR= 405

THz (10^12) - 300 GHz (10^9) . So 38 khz is frequency is Blinking frequency

Page 31: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

Pit Falls

• Internal Interrupts functions call themselves after specific intervals of time . Its not like C Programming that to use a function you need to call it in main program .But here time calls the function itself after time interval set by you . You need to mention anything inside main function to call interrupt after specific interval of time

• Declare variables global if declaring them inside main block results in error

Pit Falls

Page 32: Tachometer - Indian Institute of Technology Kanpurstudents.iitk.ac.in/eclub/assets/lectures/techkriti12/...Solution • Convert Integer to strings • Use two simple Commands • Itoa(i,c)

• Downloading the Software • Components distribution (When and where )• Prelims (when , where & what to show )