160 likes | 178 Views
EE 319K Introduction to Embedded Systems. Lecture 11: Data Acquisition, Numerical Fixed-Point Calculations, Lab 8. Agenda. Recap Sampling, Nyquist Analog to Digital Conversion Agenda Data acquisition Numerical fixed-point calculations Lab 8. Hardware Transducer Electronics ADC.
E N D
EE 319KIntroduction to Embedded Systems Lecture 11: Data Acquisition,Numerical Fixed-Point Calculations, Lab 8 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Agenda Recap Sampling, Nyquist Analog to Digital Conversion Agenda Data acquisition Numerical fixed-point calculations Lab 8 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Hardware Transducer Electronics ADC Software ADC device driver Timer routines Output compare interrupts LCD driver Measurement system How fast to update Fixed-point number system Algorithm to convert ADC into position Data Acquisition System (Lab 8) Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Analog Input Device • Transducer – A device actuated by power from one system that supplies power in the same or other form to another system. Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Transducer Circuit • Position to voltage Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
P o s i t i o n V o l t a g e S a m p l e 0 t o 2 c m 0 t o + 3.3V 0 t o 4 0 9 5 S a m p l e P o s i t i o n A D C 0 t o 4 0 9 5 A D C S e n s o r h a r d w a r e d r i v e r S y s T i c k I S R S y s T i c k M a i l b o x h a r d w a r e m a i n L C D L C D d i s p l a y F i x e d - p o i n t d r i v e r 0 t o 2 . 0 0 0 Data Acquisition System • Data flow graph ST7735 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Data Acquisition System • Call graph ST7735 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Thread Synchronization in Lab 8 Background thread Foreground thread • SysTick ISR • Sample ADC • Store in ADCmail • Set ADCstatus • Main loop • Wait for ADCstatus • Read ADCmail • Clear ADCstatus • Convert to distance • Display on LCD Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Sampling Jitter • Definition of time-jitter,δt: • LetnΔt be the time a task is scheduled to be run and tnthe time the task is actually run • Then δtn= tn – nΔt • Real time systems with periodic tasks, must have an upper bound,k, on the time-jitter • -k ≤ δtn≤ +k for alln Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Measurement • Resolution: Limiting factors • Transducer noise • Electrical noise • ADC precision • Software errors • Accuracy: Limiting factors • Resolution • Calibration • Transducer stability Average accuracy (with units of x) = Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Fixed-Point Revisited Why: express non-integer values no floating point hardware support (want it to run fast) When: range of values is known range of values is small How: 1) variable integer, called I. may be signed or unsigned may be 8, 16 or 32 bits (precision) 2) fixed constant, called (resolution) value is fixed, and can not be changed not stored in memory specify this fixed content using comments value integer• Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Fixed-Point Numbers The value of the fixed-point number: Fixed-point number I• Smallest value = Imin • D, where Imin is the smallest integer Largest value = Imax • D, where Imax is the largest integer Decimal fixed-point, =10m Decimal fixed-point number = I • 10m Nice for human input/output Binary fixed-point, =2m Binary fixed-point number = I • 2m Easier for computers to perform calculations Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Fixed-Point Math Example Consider the following calculation. C = 2**R The variables C, and R are integers 2p ≈ 6.283 C = (6283*R)/1000 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Fixed-Point Math Example Calculate the volume of a cylinder V = *R2 *L The variables are binary fixed-point R = I*2-4 cm L = J*2-4 cm V = K*2-8 cm3 2p ≈ 201*2-5 K = (201*I*I*J)>>9 Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Make a Voltmeter with ADC =0.001 V Vin = 3•N/4096 how ADC works Vin = I • 0.001 definition of fixed point I = (3000*N)/4096 substitution I = (m•N+b)/ 4096 calibrate to get m and b Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Lab 8 Calibration Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi