Introduction to Embedded Microcomputer Systems Lecture 22.1 Recap Output compare interrupts Metrowerks Codewarrior Overview to Convertor Transducer: mechanical, electrical Using output compare interrupts to establish sampling Range(volts) = Precision(alternatives) Resolution(volts) 32 28 24 2 16 12 8 Discrete digital signal Continuous analog signal 4 1 2 3 4 5 6 7 8 9 1 Time (s) Figure 11.1. An analog signal is represented in the digital domain as discrete samples. 1-bit to digital Converter input V in +5 output ATDDR 123 Output is about 124*V in /5 or Output is about 123*V in /5 124 896 DAC Output 768 64 zoomed in 512 384 256 128 Outputs 1 2 3 4 5 signal (volts) Figure 11.2. /output functions of a DAC and an.
Introduction to Embedded Microcomputer Systems Lecture 22.2 256 224 DAC Output 192 16 zoomed in 128 96 64 32 Outputs 1 2 3 4 5 signal (volts) 8-bit to digital Converter input V in +5 output ATDDR 255 Output is about 256*V in /5 or Output is about 255*V in /5 Find the 16 analog inputs on the 9S12DG128 ATDCTL2=$8; set bit 7 to enable ATDCTL3=$8; sequence length=1 ATDCTL4 bit 7= for 1-bit, =1 for 8-bit Bits 4- internal clock (how fast the runs) Let m be the bottom 5 bits of ATDCTL4 Internal clock is ½E/(m+1) Internal clock can be between 5kHz and 2 MHz At 24 MHz 2 MHz make ATDCTL4=$5 ; m=5 (7us) 1 MHz make ATDCTL4=$B ; m=11(14us) ATDCTL5 write channel number to start channel number $8 to $87 ATDSTAT bit 7 SCF cleared by write to ATDCTL5 set when finished ATDDR first 1-bit result precision 1-bit, 124 alternatives range to +5V resolution (5-)/124 = 5 mv (V) Output. % $.5 %1 $1 1 2.5 %1 $2 512 3.75 %11 $3 768 5. %1111111111 $3FF 123 Table 11.6. Straight binary format used. ATDDR first 8-bit result precision 8-bit, 256 alternatives range to +5V resolution (5-)/256 = 19.5 mv
Introduction to Embedded Microcomputer Systems Lecture 22.3 (V) Output. % $.2 %1 $1 1 2.5 %1 $8 128 3.75 %11 $C 192 5. %11111111 $FF 255 Table 11.6. Straight binary format used. Lab 8 is real-time data acquisition system main Lab 8: Design a position meter Hardware Software Hardware Transducer Electronics Software device Timer routines Output compare interrupts Measurement system How fast to update Fixed-point number system Algorithm to convert into position A data flow graph is one of the first design steps Position Voltage to 1.5 cm to +5V Position Sensor display A transducer converts position into resistance ASCII ATDDR to 123 Sample to 123 Fixed-point to 1.5 ISR main Mailbox to 123
Introduction to Embedded Microcomputer Systems Lecture 22.4 Solder wires to pins 1,2,3 Glue transducer to a solid Position metric ruler (for calibration and testing) Create a hair-line cursor Question: what is R 12 + R 23 at all times? Question: what are R 12 and R 23 when cursor is at 1cm? An electrical circuit converts resistance in to a voltage Question: what is V in at 1cm? Question: what is ATDDR at 1cm? Question: what do you want to display on the at 1cm? 1) run Lab 8 starter file, first main program, write 2) see device 3) show _Init Turns it on Sets it to 1-bit mode 4) show _In write channel number to ATDCTL5 wait for SCF flag in ATDSTAT read 1-bit result from ATDDR 5) show Data complexity abstraction (what we want to do) divide a complex problem into simple subcomponents functional abstraction (how we do it) divide a problem into modules grouped by function draw a data flow graph Run solution to Lab 8, show how to prove real time DAS start at a regular rate (every 1ms) measure the jitter 1ms-δt < t n t n-1 < 1ms+δt
Introduction to Embedded Microcomputer Systems Lecture 22.5 15 Calibration Distance in.1 cm 1 5 y =.1726x - 1.75 R 2 =.9999 2 4 6 8 1 input Lab 8 Sample every.1s Map (Data is to 255) into (Position is to +16) Option A) use a linear function Position = (Constant1*Sample)/Constant2 + Constant3 Position = (65536*Sample)/Constant4 + Constant3 Option B) Use a paired calibration table (S[i],P[i]) S[i] are samples measured at corresponding positions P[i] Given sample, find i such that S[i]<=sample<S[i+1] Use linear interpolation (look up etbl in TExaS help) position = P[i]+((sample-S[i])*(P[i+1]-P[i]))/(S[i+1]-S[i]) Option C) Create a 256-entry calibration table (P[ATDDR]) Fixed-Point output (using Lab 6 code) 123 is displayed a 1.23 cm The bottom line converts analog to digital Controlling time is important