SlideShare a Scribd company logo
1 of 15
Download to read offline
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Time
Measurement
Dr. Tomy Abuzairi
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Why should measure time ?
2
Most embedded applications (discrete system)
are related to time
• Auto power off
• How much elapsed time remaining before
sleep/shutdown
• Playing music / video (Hz/bps)
• Recorded music/video has specification on
Hz/bps, playing with different specification
make it annoying
• Smart watch (Ex: Mi-Band) for measuring
heart rate, deep sleep, step walk/bike
• Measurement shall be compared with
elapsed time
Real-time Issue
• Missile control
• A mistake in time measurement will
explode not in the right time / place
• Autonomous system (ex. Plane, tesla)
• Real-time action on each consecutive time
is required to make it autonomous
30/08/23 3
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Real Time System
• There are systems that need to respond to a service request within a certain amount
of time: they are called real-time system.
• To a real-time system, each incoming service request imposes a task (job) that is
typically associated with a real-time computing constraint, or simply called its timing
constraint.
3
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Timing Constraint
• The timing constraint of a task is normally specified in terms of its deadline, which is the time
instant by which its execution (or service) is required to be completed.
• A timing constraint is hard if the consequence of a missed deadline is fatal. A late response
(completion of the requested task) is useless, and sometimes totally unacceptable.
• A timing constraint is soft if the consequence of a missed deadline is undesirable but tolerable. A
late response is still useful as long as it is within some acceptable range (say, it occurs
occasionally with some acceptably low probability).
• Actual systems may have both hard and soft timing constraints. A system in which all tasks have
soft timing constraints is a soft real-time system. A system is a hard real-time system if its key
tasks have hard timing constraints.
4
30/08/23 5
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Soft Real-Time System
A soft real-time system offers
best-effort services; its
service of a request is
almost always completed
within a known finite time
(deadline)
Soft timing constraints are
typically expressed in
probabilistic or statistical
terms, such as average
performance and standard
deviation
5
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Study Case – Radar System
6
Silahkan Baca Textbook 1
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Radar System Discussion
7
Bagaimana konsep
realtimenya ?
01
Apa saja yang
harus di atur
secara real-time ?
02
Sejauh mana
kebutuhannya
bisa diakomodasi
oleh embedded
system ?
03
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Time Measurement in Embedded System
8
• Arduino, ESP, etc
• millis()
• micros()
• C/C++ (PC)
• gethrtime();
• Python
• from timeit import default_timer as timer
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Delay on Consecutive Commands
9
• Arithmetic/dummy operation in the loop (based on
execution clock)
• for(i=0; i<maxCount; i++) {}
• Internal timer
• Arduino, ESP, etc : delay(), delayMicroseconds()
• C/C++ : sleep(), usleep()
30/08/23 10
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Delay on Action for Repeated Task
while(true) {
// your program
delay
}
10
Bermasalah jika program anda membutuhkan
waktu lama sehingga total waktu setiap loop
lebih dari waktu delay
mis :
- eksekusi program 20ms, delay 50ms
- total waktu setiap loop 20+50ms
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Solusi Mengatasi Konsumsi Waktu Program
yang Berubah-ubah
11
t = hitung waktu
while(true) {
// your program
delay(hitung waktu - t)
t =hitung waktu
}
Delay hanya berdasarkan waktu
tersisa
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Timer Interrupt on Arduino
• Basically millis is based on timer
• Timer with interrupt based on timer overflow (sudah mencapai
counter yg diinginkan)
• Initialization
• Timer1.initialize(PERIODE);
• Timer1.attachInterrupt(repeated_task);
• Repeated task declaration
• void repeatedtask() {
• // your program
• }
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Timer Interrupt on ESP32
• The ESP32 contains two groups of hardware timers.
• Each group has two general purpose hardware timers
• ESP32 has a total of 4 timers which are numbered 0-3. These are all generic 64-bit based timers.
• Each Timer has a 16-bit Prescaler (from 2 to 65536)
• The Timer uses the processor clock to calculate the elapsed time. It is different for each microcontroller. The quartz frequency
of the ESP32 is 80MHz.
• The prescaler is used to divide the frequency of the base signal (80 MHz for an ESP32), which is then used to increment or
decrement the timer counter
• The timer simply counts the number of Tic generated by the quartz. With a quartz clocked at 80MHz, we will have 80,000,000
Tics
• By dividing the frequency of the quartz by the prescaler, we obtain the number of Tics per second
• 80,000,000 / 80 = 1,000,000 tics / sec
• timer = timerBegin(0, 80, true);
• timerAttachInterrupt(timer, &repeated_task, true);
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Tugas
1. Berikan contoh cuplikan program untuk mengukur seberapa lama waktu telah terlewati
setelah mengeksekusi satu/beberapa perintah
ü Arduino : perintah kirim serial dengan minimal 200 karakter
ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter
2. Berikan contoh cuplikan program untuk membuat sebuah perintah/program
tereksekusi setiap 1 detik dengan DELAY
ü Arduino : perintah kirim serial dengan minimal 200 karakter
ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter
3. Berikan contoh cuplikan program untuk membuat sebuah perintah/program
tereksekusi setiap 1 detik dengan INTERRUPT
ü Arduino : perintah kirim serial dengan minimal 200 karakter
ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter
30/08/23 15
D E P A R T E M E N
TEKNIK ELEKTRO
Universitas
Indonesia
Selamat Belajar
15

More Related Content

Similar to Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf

Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05Rajesh Gupta
 
Real-Time Systems Intro.pptx
Real-Time Systems Intro.pptxReal-Time Systems Intro.pptx
Real-Time Systems Intro.pptx20EUEE018DEEPAKM
 
Energy power efficient real time systems
Energy power efficient real time systemsEnergy power efficient real time systems
Energy power efficient real time systemspragya arya
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfRakibul Rakib
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Anne Nicolas
 
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksAccurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksDesign World
 
multiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.pptmultiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.pptnaghamallella
 
Domino Effect and Analysis | Gaurav Singh Rajput
Domino Effect and Analysis | Gaurav Singh RajputDomino Effect and Analysis | Gaurav Singh Rajput
Domino Effect and Analysis | Gaurav Singh RajputGaurav Singh Rajput
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating SystemsRohit Joshi
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
Domino Effect and Analysis | Relaibility Analysis | Unavailability Analysis
Domino Effect and Analysis | Relaibility Analysis | Unavailability AnalysisDomino Effect and Analysis | Relaibility Analysis | Unavailability Analysis
Domino Effect and Analysis | Relaibility Analysis | Unavailability AnalysisGaurav Singh Rajput
 
MODULE IV embedded (1).pptx
MODULE IV embedded (1).pptxMODULE IV embedded (1).pptx
MODULE IV embedded (1).pptxSajinvs4
 

Similar to Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf (20)

Embedded Intro India05
Embedded Intro India05Embedded Intro India05
Embedded Intro India05
 
02 performance
02 performance02 performance
02 performance
 
Timers
TimersTimers
Timers
 
Timer
TimerTimer
Timer
 
Real-Time Systems Intro.pptx
Real-Time Systems Intro.pptxReal-Time Systems Intro.pptx
Real-Time Systems Intro.pptx
 
Energy power efficient real time systems
Energy power efficient real time systemsEnergy power efficient real time systems
Energy power efficient real time systems
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
 
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
Embedded Recipes 2018 - Finding sources of Latency In your system - Steven Ro...
 
synchonization PTP
synchonization PTP synchonization PTP
synchonization PTP
 
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed ClocksAccurate Synchronization of EtherCAT Systems Using Distributed Clocks
Accurate Synchronization of EtherCAT Systems Using Distributed Clocks
 
multiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.pptmultiprocessor real_ time scheduling.ppt
multiprocessor real_ time scheduling.ppt
 
Domino Effect and Analysis | Gaurav Singh Rajput
Domino Effect and Analysis | Gaurav Singh RajputDomino Effect and Analysis | Gaurav Singh Rajput
Domino Effect and Analysis | Gaurav Singh Rajput
 
Lect05
Lect05Lect05
Lect05
 
exp 3.docx
exp 3.docxexp 3.docx
exp 3.docx
 
UNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docxUNIT II - CPU SCHEDULING.docx
UNIT II - CPU SCHEDULING.docx
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Domino Effect and Analysis | Relaibility Analysis | Unavailability Analysis
Domino Effect and Analysis | Relaibility Analysis | Unavailability AnalysisDomino Effect and Analysis | Relaibility Analysis | Unavailability Analysis
Domino Effect and Analysis | Relaibility Analysis | Unavailability Analysis
 
MODULE IV embedded (1).pptx
MODULE IV embedded (1).pptxMODULE IV embedded (1).pptx
MODULE IV embedded (1).pptx
 

Recently uploaded

萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程1k98h0e1
 
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurSuhani Kapoor
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsappssapnasaifi408
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service ThanePooja Nehwal
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一Fi sss
 
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一ss ss
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsPooja Nehwal
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...Authentic No 1 Amil Baba In Pakistan
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...Suhani Kapoor
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberMs Riya
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 

Recently uploaded (20)

萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程萨斯喀彻温大学毕业证学位证成绩单-购买流程
萨斯喀彻温大学毕业证学位证成绩单-购买流程
 
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /WhatsappsBeautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
Beautiful Sapna Call Girls CP 9711199012 ☎ Call /Whatsapps
 
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311  Call Girls in Thane , Independent Escort Service ThanePallawi 9167673311  Call Girls in Thane , Independent Escort Service Thane
Pallawi 9167673311 Call Girls in Thane , Independent Escort Service Thane
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
(ZARA) Call Girls Jejuri ( 7001035870 ) HI-Fi Pune Escorts Service
 
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一
(办理学位证)加州州立大学北岭分校毕业证成绩单原版一比一
 
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
定制(Salford学位证)索尔福德大学毕业证成绩单原版一比一
 
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
如何办理(UCLA毕业证书)加州大学洛杉矶分校毕业证成绩单留信学历认证原版一比一
 
Thane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call GirlsThane Escorts, (Pooja 09892124323), Thane Call Girls
Thane Escorts, (Pooja 09892124323), Thane Call Girls
 
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...Papular No 1 Online Istikhara Amil Baba Pakistan  Amil Baba In Karachi Amil B...
Papular No 1 Online Istikhara Amil Baba Pakistan Amil Baba In Karachi Amil B...
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565
 
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
VIP Call Girls Hitech City ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With R...
 
CIVIL ENGINEERING
CIVIL ENGINEERINGCIVIL ENGINEERING
CIVIL ENGINEERING
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
 

Week 1 Time_measuremenjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjt.pdf

  • 1. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Time Measurement Dr. Tomy Abuzairi
  • 2. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Why should measure time ? 2 Most embedded applications (discrete system) are related to time • Auto power off • How much elapsed time remaining before sleep/shutdown • Playing music / video (Hz/bps) • Recorded music/video has specification on Hz/bps, playing with different specification make it annoying • Smart watch (Ex: Mi-Band) for measuring heart rate, deep sleep, step walk/bike • Measurement shall be compared with elapsed time Real-time Issue • Missile control • A mistake in time measurement will explode not in the right time / place • Autonomous system (ex. Plane, tesla) • Real-time action on each consecutive time is required to make it autonomous
  • 3. 30/08/23 3 D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Real Time System • There are systems that need to respond to a service request within a certain amount of time: they are called real-time system. • To a real-time system, each incoming service request imposes a task (job) that is typically associated with a real-time computing constraint, or simply called its timing constraint. 3
  • 4. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Timing Constraint • The timing constraint of a task is normally specified in terms of its deadline, which is the time instant by which its execution (or service) is required to be completed. • A timing constraint is hard if the consequence of a missed deadline is fatal. A late response (completion of the requested task) is useless, and sometimes totally unacceptable. • A timing constraint is soft if the consequence of a missed deadline is undesirable but tolerable. A late response is still useful as long as it is within some acceptable range (say, it occurs occasionally with some acceptably low probability). • Actual systems may have both hard and soft timing constraints. A system in which all tasks have soft timing constraints is a soft real-time system. A system is a hard real-time system if its key tasks have hard timing constraints. 4
  • 5. 30/08/23 5 D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Soft Real-Time System A soft real-time system offers best-effort services; its service of a request is almost always completed within a known finite time (deadline) Soft timing constraints are typically expressed in probabilistic or statistical terms, such as average performance and standard deviation 5
  • 6. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Study Case – Radar System 6 Silahkan Baca Textbook 1
  • 7. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Radar System Discussion 7 Bagaimana konsep realtimenya ? 01 Apa saja yang harus di atur secara real-time ? 02 Sejauh mana kebutuhannya bisa diakomodasi oleh embedded system ? 03
  • 8. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Time Measurement in Embedded System 8 • Arduino, ESP, etc • millis() • micros() • C/C++ (PC) • gethrtime(); • Python • from timeit import default_timer as timer
  • 9. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Delay on Consecutive Commands 9 • Arithmetic/dummy operation in the loop (based on execution clock) • for(i=0; i<maxCount; i++) {} • Internal timer • Arduino, ESP, etc : delay(), delayMicroseconds() • C/C++ : sleep(), usleep()
  • 10. 30/08/23 10 D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Delay on Action for Repeated Task while(true) { // your program delay } 10 Bermasalah jika program anda membutuhkan waktu lama sehingga total waktu setiap loop lebih dari waktu delay mis : - eksekusi program 20ms, delay 50ms - total waktu setiap loop 20+50ms
  • 11. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Solusi Mengatasi Konsumsi Waktu Program yang Berubah-ubah 11 t = hitung waktu while(true) { // your program delay(hitung waktu - t) t =hitung waktu } Delay hanya berdasarkan waktu tersisa
  • 12. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Timer Interrupt on Arduino • Basically millis is based on timer • Timer with interrupt based on timer overflow (sudah mencapai counter yg diinginkan) • Initialization • Timer1.initialize(PERIODE); • Timer1.attachInterrupt(repeated_task); • Repeated task declaration • void repeatedtask() { • // your program • }
  • 13. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Timer Interrupt on ESP32 • The ESP32 contains two groups of hardware timers. • Each group has two general purpose hardware timers • ESP32 has a total of 4 timers which are numbered 0-3. These are all generic 64-bit based timers. • Each Timer has a 16-bit Prescaler (from 2 to 65536) • The Timer uses the processor clock to calculate the elapsed time. It is different for each microcontroller. The quartz frequency of the ESP32 is 80MHz. • The prescaler is used to divide the frequency of the base signal (80 MHz for an ESP32), which is then used to increment or decrement the timer counter • The timer simply counts the number of Tic generated by the quartz. With a quartz clocked at 80MHz, we will have 80,000,000 Tics • By dividing the frequency of the quartz by the prescaler, we obtain the number of Tics per second • 80,000,000 / 80 = 1,000,000 tics / sec • timer = timerBegin(0, 80, true); • timerAttachInterrupt(timer, &repeated_task, true);
  • 14. D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Tugas 1. Berikan contoh cuplikan program untuk mengukur seberapa lama waktu telah terlewati setelah mengeksekusi satu/beberapa perintah ü Arduino : perintah kirim serial dengan minimal 200 karakter ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter 2. Berikan contoh cuplikan program untuk membuat sebuah perintah/program tereksekusi setiap 1 detik dengan DELAY ü Arduino : perintah kirim serial dengan minimal 200 karakter ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter 3. Berikan contoh cuplikan program untuk membuat sebuah perintah/program tereksekusi setiap 1 detik dengan INTERRUPT ü Arduino : perintah kirim serial dengan minimal 200 karakter ü C/C++ : perintah kirim tulisan ke layer dengan minimal 200 karakter
  • 15. 30/08/23 15 D E P A R T E M E N TEKNIK ELEKTRO Universitas Indonesia Selamat Belajar 15