EE 319K Introduction to Embedded Systems - PowerPoint PPT Presentation

About This Presentation
Title:

EE 319K Introduction to Embedded Systems

Description:

... write nibble to ADC_SSCTL3_R to disable temp measurement, ... Clear ADCstatus Convert to distance Display on LCD Background thread Foreground thread Bill ... – PowerPoint PPT presentation

Number of Views:118
Avg rating:3.0/5.0
Slides: 23
Provided by: BillBardA9
Category:

less

Transcript and Presenter's Notes

Title: EE 319K Introduction to Embedded Systems


1
EE 319KIntroduction to Embedded Systems
  • Lecture 11 Data Acquisition,Numerical
    Fixed-Point Calculations, Lab 8

2
Agenda
  • Recap
  • Sampling, Nyquist
  • Analog to Digital Conversion
  • Agenda
  • Exam 2
  • Pointers, Array and String Manipulation, FSMs
  • Data acquisition
  • Numerical fixed-point calculations
  • Lab 8

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 and
    division

4
Exam 2 review
  • 7) Shift left and right (signed and unsigned)
  • 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 linked data
    structure or using a table structure with an
    index
  • Mealy and Moore
  • Not a real port, so no bit-specific addressing
  • Read modify write sequences to be friendly
    (including input pin)
  • 11) Accessing arrays and strings using pointers
    and indices
  • Stepping through two or more arrays at a time
  • 8/16/32-bit data, signed/unsigned numbers

5
Exam 2 review
  • A) You may be given one or more variable length
    arrays of data, bufi
  • The size may be the first entry
  • There may be a termination code
  • The data may be 8-bit ASCII characters or
    integers
  • The integers may be 8 16 or 32 bits
  • Integers may be signed or unsigned
  • A pointer to this array may be passed in R0
  • You may be asked to deal with special cases
    size0, size too big, overflow

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
    (bufi1-bufi)
  • Find the maximum or minimum absolute value
  • Count the number of times a particular value
    occurs (bufi1000)
  • 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)

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

8
Exam 2
  • Runs on your laptop
  • Keil in simulation (no board)
  • During exam Keil, Keil help, PC calculator
  • Needs internet to download and upload
  • Battery power
  • Written in assembly (no C)
  • No SysTick, no interrupts
  • Overall grade a combination of
  • Numerical score from grader
  • Program style (reviewed later)
  • Tricking the grader is considered bad

9
Data Acquisition System (Lab 8)
  • 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

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.

11
Transducer Circuit
  • Position to voltage

12
Data Acquisition System
  • Data flow graph

13
Data Acquisition System
  • Call graph

14
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

15
Sampling Jitter
  • Definition of time-jitter, dt
  • Let n?t be the time a task is scheduled to be run
    and tn the time the task is actually run
  • Then dtn tn n?t
  • Real time systems with periodic tasks, must have
    an upper bound, k, on the time-jitter
  • -k dtn k for all n

16
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)
17
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 ?
18
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

19
Fixed-Point Math Example
  • Consider the following calculation.
  • C 2?R
  • The variables C, and R are integers
  • 2p 6.283
  • C (6283R)/1000

20
Fixed-Point Math Example
  • Calculate the volume of a cylinder
  • V ?R2 L
  • The variables are fixed-point
  • R I2-4 cm L J2-4 cm
  • V K2-8 cm3 2p 2012-5
  • K (201IIJ)gtgt9

21
Make a Voltmeter with ADC
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 3N/4096 how ADC works Vin I
0.001 definition of fixed point I
(3000N)/4096 substitution I (mNb)/ 4096
calibrate to get m and b
22
Lab 8 Calibration
Write a Comment
User Comments (0)
About PowerShow.com