Date post: | 21-Dec-2015 |
Category: |
Documents |
Upload: | veronica-alexis-bond |
View: | 225 times |
Download: | 2 times |
11-1Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
EE 319KIntroduction to Embedded Systems
Lecture 11: Data Acquisition,Numerical Fixed-Point Calculations,
Lab 8
11-2
Agenda
RecapSampling, NyquistAnalog to Digital Conversion
AgendaExam 2
o Pointers, arrays, strings, structures, FSMsData acquisitionNumerical fixed-point calculationsLab 8
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-3
Exam 2 review
0) Being able to quickly design, implement, and debug assembly software
1) Understanding differences between data and address, being able to use pointers and indices
2) Understanding differences between 8-bit, 16-bit data and 32-bit data
3) Understanding differences between signed and unsigned integers
4) Programming if-then if-then-else for-loops while-loops and do-while-loops in assembly
5) Processing a variable-length array or string, either size first or terminating code at end
6) Addition, subtraction, multiplication, division, shift, and, or, xor
http://users.ece.utexas.edu/~valvano/Volume1/Exam2thoughts.pdf
11-4
Exam 2 review
7) Structures 8) Call by value, call by reference, return by value 9) AAPCS Program conventions
Save and restore R4-R11,LR if you wish to modify Parameter passing in registers R0,R1,R2,R3 All input parameters promoted to 32 bits Return parameter in R0
10) Implementation of FSM using a table structure with an index Moore Not a real port, so no bit-specific addressing, no timer Read modify write sequences to be friendly (including
input pin) 11) Accessing arrays strings and structures using pointers and
indices Stepping through two or more arrays at a time 8/16/32-bit data, signed/unsigned numbers
No FSM Spring 2015
11-5
Exam 2 review
A) You may be given one or more variable length arrays of data, buf[i]The size may be the first entry There may be a termination codeThe data may be 8-bit ASCII characters or
integersThe integers may be 8 16 or 32 bitsIntegers may be signed or unsignedA pointer to this array may be passed in R0 You may be asked to deal with special cases:
size=0, size too big, overflow
11-6
Exam 2 Array problems Determine the size of the array Return the first element of the array Find the maximum or minimum element in an array Find the sum of all the elements Find the average of all the elements Find the mode of all the elements Find the range = maximum - minimum Find the maximum or minimum slope (buf[i+1]-buf[i]) Find the maximum or minimum absolute value Count the number of times a particular value occurs
(buf[i]==1000) Search for the occurrence of one string in another Concatenate two strings together Delete characters from a string Insert one string into another Move data from one place to another within an array or string Sort the array (we will give the steps)
11-7
Exam 2 FSM problems
Convert a FSM graph to a linked data structure or table with an index
Write a Mealy FSM controller (with or without timer wait)
Write a Moore FSM controller (with or without timer wait)
It also may involve accessing a linked structure like Lab 5
No FSM Spring 2015
11-8
Exam 2
Runs on your laptopKeil in simulation (no board)During exam: Keil, Keil help, PC calculatorNeeds internet to download and uploadBattery power
Written in assembly (no C)No SysTick, no interruptsOverall grade a combination of
Numerical score from graderProgram style (reviewed later)
Tricking the grader is considered dishonestHard-coding answers is considered dishonest
11-9
Data Acquisition System (Lab 8)
HardwareTransducerElectronicsADC
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
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-10
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
11-11
Transducer Circuit
Position to voltage
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-12
Data Acquisition System
Data flow graph
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
PositionSensor
Voltage0 to +3.3V
ADChardware
ADCdriver
Sample0 to 4095
SysTickISR
Sample0 to 4095
SysTickhardware
LCDdisplay
LCDdriver Fixed-point
0 to 2.000
Position0 to 2 cm
main
Mailbox
ST7735
11-13
Data Acquisition System
Call graph
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
main
SysTickhardware
SysTick
LCDhardware
LCDdriver
ADChardware
ADC driver
ISR
In
Init ST7735
11-14
Thread Synchronization in Lab 8
SysTick ISRSample ADCStore in ADCmailSet ADCstatus
Main loopWait for ADCstatusRead ADCmailClear ADCstatusConvert to distanceDisplay on LCD
Background thread Foreground thread
Other calculationsRead datafrom input
Full
Empty
Mainprogram
ISR
Process MailStatus = Empty
Status Mail = dataStatus = Full
a
bc
d
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-15
Sampling Jitter
Definition of time-jitter, δt:Let nΔt be the time a task is scheduled to be
run and tn the 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 all n
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-16
Measurement
Resolution: Limiting factorsTransducer noiseElectrical noiseADC precisionSoftware errors
Accuracy: Limiting factorsResolutionCalibrationTransducer stability
Measurement Output
100 measurements with Position = P1 100 measurements with
Position= P1+PP
Average accuracy (with units of x) =
n
imiti xx
n 0
1
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-17
Fixed-Point Revisited Why:
express non-integer valuesno floating point hardware support (want it to run fast)
When:range of values is knownrange of values is small
How:1) variable integer, called I.
may be signed or unsignedmay be 8, 16 or 32 bits (precision)
2) fixed constant, called (resolution)value is fixed, and can not be changednot stored in memoryspecify this fixed content using comments
value integer •
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-18
Fixed-Point Numbers
The value of the fixed-point number:Fixed-point number I•
Smallest value = Imin • , where Imin is the smallest integer
Largest value = Imax • , 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
b-1 b-2 b-3 b-4 b-5 b-6b9 b8 b7 b6 b5 b4 b3 b2 b1 b0
Fixed binary point
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-19
Fixed-Point Math Example
Consider the following calculation. C = 2**R
The variables C, and R are integers 2 ≈ 6.283
C = (6283*R)/1000
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-20
Fixed-Point Math Example
Calculate the volume of a cylinder V = *R2 * L
The variables are fixed-point R = I*2-4 cm L = J*2-4 cm
V = K*2-8 cm3 2 ≈ 201*2-5
K = (201*I*I*J)>>9
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
11-21
Vin (V)Analog in
N Digital out
I (1 mV)Variable part
LCD
0 0 0 0.000
0.75 1024 750 0.750
1.5 2048 1500 1.500
2.25 3072 2250 2.250
3 4096 3000 3.000
=0.001 V
Vin = 3•N/4096 how ADC worksVin = I • 0.001 definition of fixed pointI = (3000*N)/4096 substitution I = (m•N+b)/ 4096 calibrate to get m and b
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Make a Voltmeter with ADC
11-22
Lab 8 Calibration
Bard, Tiwari, Telang, Janapa Reddi, Gerstlauer, Valvano, Yerraballi
Position Analog input ADC sample Correct Fixed-point Measured Fixed-point Output 0.10 cm 0.432 538 100 84 0.40 cm 1.043 1295 400 421 0.80 cm 1.722 2140 800 797 1.20 cm 2.455 3050 1200 1202 1.40 cm 2.796 3474 1400 1391
n
imiti xx
n 0
1