3-Embedded Software Development-10-08-2023
3-Embedded Software Development-10-08-2023
K Selvakumar
Assistant Professor
Department of Instrumentation and Control Systems Engineering
PSG College of Technology
• Immunity to Noise
7→ Analog signals are allowed to take any value within a particular range and
noise can easily alter the magnitude
7→ Digital signals take binary values and for altering a 1 to 0 and vice versa
a noise voltage of large magnitude is required
• Reprogrammable capability
7→ In analog case rewiring/ resoldering is required
• No performance drift in the field
• Takes an analog voltage as its input and produces a digital number representing
that voltage as output
• The output of ADC is a stream of sampled fixed word length values
• Number of samples is determined by the ADCs clock
• To calculate the input voltage from the output code
VFullRange
Vin = (1)
2N − 1
where N is number of bits used in ADC output
• The resolution of these samples is limited to the output data word width of the
ADC (Example: 8-bit ADC, 10-bit ADC)
• 125µs are available to perform all the processing necessary before next sample
arrives
• Samples are arriving on a continuos basis and we can’t fall behind
• This is a common constaint for any real time systems
• Helps to determine the processor speed to keep up with this sampling rate
T
Number of Instructions per sample=
Insruction cycle time
• Q4: If a 100MHz processor executes one instruction per cycle, how many instruc-
tions can be executed in 125µs?
• If the signal is not sampled often enough,the information will not be the represen-
tative of true signal and it causes an aliasing problem
• Over sampling leads to huge cost:memory,computation,power consumption
• Nyquist crieria sets a lower bound for the sampling rate
• Anti-aliasing analog filter helps to achieve this!
fs
Cut-off frequency=Nyquist frequency [ ]
2
• Sampling frequency helps to select ADC’s clock
• Q5: What is the sampling rate of a music signal?
• int:Integer data type is used represent positive and negative whole numbers in 16
bits
• char :Generally used to store ASCII values in 8-bit
• float: It is used to store positive and negatve real numbers in 32 bits
• double: Stores real numbers using 64 bits
• Q6: How much memory is required to store 10 seconds of ECG data using float
and double data types?
• Number systems refers to the format usd to store and manipulate numeric
representation of data
• Fixed point numbers are represented with a fixed number of digits after the
decimal point Examples: 123.45,1234.56,12345.67
• In fixed point representation the gap between adjacent numbers are equal
• In base2, binary point is the equivalent of a decimal point and it seperates integer
and fraction
• Various ways of 16 bit fixed point representations are
{-1 to 1;0 to 1;0 to 65,535;-32,768 to 32,767 }
• Q7: How signed -1 is stored in the memory?
• In floating point representation, the placement of the decimal point can float
Examples:1.23467,123456.7,0.00001234567,1234567000000000
• The gaps between adjacent numbers are not uniformly spaced
• It assures much larger dynamic range and greater precision
• Approximately, the gap between two consecutive numbers is 1 part in 10 million
• Fixed point microprocessors (ex. x86) are designed to understand only integers
• Q8: How real numbers are stored in the memory?
• Bits 0 through 22 form the mantissa, bits 23 through 30 form the exponent, and
bit 31 is the sign bit
• The 24 bit mantissa is used for precision while the exponent is for extending the
dynamic range
• Using these bits, the floating point number N is formed by
7→ 101001001.011001
7→ 1.01001001011001 × 28
• The sign bit is positive, so s = 0
• The exponent is 135 (8+127), so e = 10000111
• The mantissa field m is 01001001011001 (leading 1 is not included since its
implied)
• The 32 bit representation is
0 10000111 010 0100 1011 0010 0000 0000
spacing=0.00000000000091
01000100000111110000001000000010 7→ 636.0313110
01000100000111110000001000000011 7→ 636.0313720
spacing=0.0000610
01001101010011110000001000000000 7→ 217063424.0
01001101010011110000001000100001 7→ 217063440.0
spacing=16.0
• In double precision format 11 bits are used for exponent and 52 bits are used for
mantissa
• Smallest value:±1.0 × 2−1022 ≈ 2.2 × 10−308
• Largest value: ±2.0 × 2+1023 ≈ 1.8 × 10+308
• Approximately, 16 decimal digits of precision
• Mainly used to maintain accuracy over many iterative calculations, manipulaing
very large and very small values
• In general a real number may have infinite information content, but it can’t be
stored and processed in the computer
• OF flag indicates if signed value exceeds +127 or less than -128, CF indicates if
result exceeds 255, and SF indicate that if result goes below 0.
September 12, 2015 DSP Workshop 23
Saturation
• The round-off error from each of the arithmetic operations causes the result value
to drift away from the desired value
• If the error is predominately of the same sign, the value of the variable drift away
much more rapidly
1: c=1;
2: for i=1:10000
3: a=rand(1);
4: b=rand(1);
5: c=c+a;c=c+b;c=c-a;c=c-b;
6: end
• Q13: Plot the variable c for each iteration and observe the results.
• Q14: Analyze the sum variable for each iteration for float and double datatypes.
• Q15:The typical fixed-point C54x Digital Signal Processor can execute a single
instruction in 10nsec. The user written L-tap FIR filter can execute in ≈ 38 + L
instruction cycles per input sample.
1. What is the maximum bandwidth of the signal that can be filtered with an FIR
filter of order L = 255?
2. If speech signal is sampled at 8KHz, what is the highest FIR filter order that
may be used in real time stream processing?
• Although 64-bit machines are available today, finite word length effects have to be
seriouly considered for resource constraint embedded systems
• In small microprocessors used in embedded systems, manual fixed point arithmetic
is used
• Awarness on finite word length effects is very useful in ADC, processor and data
type selection.
• It is a first step towards any real-time signal processing system design