2014-15 ieee embedded projects list,ieee projects for embedded,ieee projects in embedded
embedded sys14
-
Upload
shubham-kaushik -
Category
Documents
-
view
212 -
download
0
description
Transcript of embedded sys14
![Page 1: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/1.jpg)
Exam
zone
![Page 2: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/2.jpg)
ATtiny2313 Timers/Counters
CS-423 Dick Steflik
![Page 3: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/3.jpg)
What Do You Use Timers For?
Timing of events (internal or external)
Scheduling Events
Measuring the width of a pulse
Speed control of motors (PWM)
Generation of complex waveforms
Frequency generation (sounds)
![Page 4: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/4.jpg)
The concept of using a timer/counter
Counters run asynchronously to your code
Can be setup to start based on an internal or external event
Can generate interrupts
Can signal to a pin
![Page 5: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/5.jpg)
Example
To time a piece of code:
Initial the counter to 0, have it interrupt on overflow
Interrupt handler should count overflows
Start the counter
Run your code
At end of code read counter and add to number of overflows to get total time
![Page 6: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/6.jpg)
Example
To time an incoming pulse/event:
Setup interrupts on rising and falling edge of pulse and overflow of counter
In handler for rising edge start counter
In handler for overflow, count the overflows
In handler for falling edge read counter and add overflows to get time of pulse/event
![Page 7: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/7.jpg)
Example
Motor control:
Use counter to generate a pulse train to control speed of DC motors
Full speed = full power (infinitely wide pulse
Low speed = narrow pulses with wide down time
50% speed = equal up and down times
Can only control very small motoers directly, must use high power transistors to drive bigger motors
This is came idea as intermittent wipers on a car
![Page 8: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/8.jpg)
2 Timer/Counter Units
8-bit Timer/Counter0 w/PWM
16-bit Timer/Counter1
Timer/Counter1 and Timer/Counter0 prescalers
![Page 9: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/9.jpg)
8-bit Timer/Counter0
Single channel counter
Frequency Generator
External Event Counter
10-bit clock prescaler
Only used with internal clock
Scale by: 1, 8, 64, 256, 1024
![Page 10: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/10.jpg)
8-bit Timer/Counter0
![Page 11: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/11.jpg)
8-bit Timer/Counter0
Sample code can be found at: http://winavr.scienceprog.com/avr-gcc-tutorial/control-avr-8-bit-timer-counter0-using-avr-
gcc.html
![Page 12: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/12.jpg)
16-bit Timer/Counter1
![Page 13: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/13.jpg)
Modes of Operation
Normal Mode – always counts up, no clear, counter just overruns
Clear Timer on Compare match (CTC mode)
Fast PWM Mode
Phase Correct PWM mode
Phase and Frequence Correct PWM mode
![Page 14: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/14.jpg)
16-bit Timer/Counter1
Sample code can be found at: http://winavr.scienceprog.com/avr-gcc-tutorial/program-16-bit-avr-timer-with-
winavr.html
![Page 15: embedded sys14](https://reader030.fdocuments.in/reader030/viewer/2022020503/568c4bd81a28ab49169dccf7/html5/thumbnails/15.jpg)
Prescaler