tachometer - indian institute of technology...
TRANSCRIPT
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/1.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/2.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/3.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/4.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/5.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/6.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/7.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/8.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/9.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/10.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/11.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/12.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/13.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/14.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/15.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/16.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/17.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/18.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/19.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/20.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/21.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/22.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/23.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/24.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/25.jpg)
![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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/26.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/27.jpg)
• 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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/28.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/29.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/30.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/31.jpg)
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)](https://reader035.vdocuments.net/reader035/viewer/2022071104/5fddaad09eb414111857badf/html5/thumbnails/32.jpg)
• Downloading the Software • Components distribution (When and where )• Prelims (when , where & what to show )