Presentation is loading. Please wait.

Presentation is loading. Please wait.

Post-Lab 1 Quiz Digital Thermometer Digital Storage Oscilloscope

Similar presentations


Presentation on theme: "Post-Lab 1 Quiz Digital Thermometer Digital Storage Oscilloscope"— Presentation transcript:

1 Post-Lab 1 Quiz Digital Thermometer Digital Storage Oscilloscope
M. Smith, Electrical and Computer Engineering, University of Calgary, Canada ucalgary.ca

2 Modeling an audio channel using an ADSP21061 processor
Typical DSP algorithms Many memory fetches for data Many memory fetches for instructions Loop – often very tight Extensive multiplications and additions Real-time requirement – meaning must finish between successive interrupts or else lose samples (audio fidelity) 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

3 Modeling an audio channel using an ADSP21061 processor
11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

4 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Post. Lab 1 Quiz Digital oscilloscope display Essentially the code from Lab. 0 but using a 40 Hz audio signal generated using Analog Devices TMP03 – digital thermometer “Oscilloscope” display using a modified TCL capability Digital thermometer Essentially the code from Lab. 1, but using a 40 Hz audio signal generated using Analog Devices TMP03 – digital thermometer Synchronized (stable) digital oscilloscope Combination of first two parts of the quiz and assignment 2 Timing report required Looking at relative code efficiency between “C++” and your assembly language routine 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

5 Needed for Post Lab 1 Quiz
All the files required from Lab. 0 clanguage_register_defines.i -- Changes ADSP21O6X register names to something more readable – get the updated version from the web All the files required for Lab. 1 Your IIR filter must be modified to run using “real-time” points rather than an “off-line” predetermined array You will also need the ON-LINE library (from Lab. 1 link) Ear-phones Analog Devices TMP03 digital thermometer + documentation Some of this quiz is done with your laboratory partner – some done on your own 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

6 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Essence of “main.c” void main ( ) { int channel1_in, channel2_in; // Input channels int leftchannel_out, rightchannel_out; // Output channels int processor = PROCESSOR; // Auto defined #define SOURCE_DESCRIPTION OFFLINE_AUDIOSOURCE | IMPULSE | MONO; int which_soundsource = SOURCE_DESCRIPTION; ADISoundSource sounddemo (processor, which_soundsource, processing_options); // Get the sound samples while(sounddemo.ReadSource(&channel1_in, &channel2_in)) { sounddemo.Stop_AudioInterrupts(); // Don't forget to turn interrupts back on KnownLocationForBreakPoint(); // Needed for running some TCL tools VolumeControl(&channel1_in, &channel2_in, &sounddemo); // Checks to see if button FLAG 1 is pressed on the board. if (!sounddemo.DoNotProcess()) ProcessSound(channel1_in, channel2_in, &leftchannel_out, ……. else { leftchannel_out = channel1_in; rightchannel_out = channel2_in; } sounddemo.Start_AudioInterrupts( ); // Restart the interrupts // Write the sound samples sounddemo.WriteSource(leftchannel_out, rightchannel_out); } 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

7 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Essence of “main.c” // Get the sound samples while(sounddemo.ReadSource(&channel1_in, &channel2_in)) { sounddemo.Stop_AudioInterrupts(); KnownLocationForBreakPoint(); VolumeControl(&channel1_in, &channel2_in, &sounddemo); // Checks to see if button FLAG 1 is pressed on the board. if (!sounddemo.DoNotProcess()) ProcessSound(channel1_in, channel2_in, &leftchannel_out, ……. else { leftchannel_out = channel1_in; rightchannel_out = channel2_in; } sounddemo.Start_AudioInterrupts( ); // Write the sound samples sounddemo.WriteSource(leftchannel_out, rightchannel_out); } 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

8 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Arrays available Input_channels 1 and 2 used to provide known signals to the ReadSource( ) method – both offline and on-line libraries Left_channel and Right_channel used to provide a location to store WriteSource ( ) method output – offline only Embedded systems – typical memory poor – so re-use arrays when possible 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

9 Essence of ProcessSound( )
void MemoryMove_Delay_CPP(int *channel1_in, int *channel2_in, ……); extern "C" void MemoryMove_Delay_ASM(int *channel1_in, int *channel2_in, …); void OverSimpleIIR_CPP( float iir_coeff, int *channel1_in, int *channel2_in); extern "C" void OverSimpleIIR_ASM( float iir_coeff, int *channel1_in, ….); #warning "All audio processing algorithms currently performed in High Level language" #define OverSimpleIIR(PAR1,PAR2,PAR3) OverSimpleIIR_CPP(PAR1,PAR2,PAR3) #define MemoryMove_Delay(PAR1,PAR2,PAR3) MemoryMove_Delay_CPP(PAR1,PAR2,PAR3) void ProcessSound(int channel1_in, int channel2_in, int *leftchannel_out, int *rightchannel_out, ADISoundSource *sounddemo ) { if (sounddemo->Getprocessoroptions() & OVERSIMPLEIIR) OverSimpleIIR(/* IIR_COEFF = */ 0.1, &channel1_in, &channel2_in); if ((sounddemo->Getprocessoroptions() & MOVEDELAY) == MOVEDELAY) { MemoryMove_Delay(&channel1_in, &channel2_in, sounddemo); *leftchannel_out = channel1_in; *rightchannel_out = channel2_in; } 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

10 Essence of audio algorithm
static float left_delayline[FIFO_LENGTH] = {0}; static float right_delayline[FIFO_LENGTH] = {0}; void MemoryMove_Delay_CPP(int *channel1_in, int *channel2_in, ADISoundSource *sounddemo) { int count; // Insert new value into the back of the FIFO delay line left_delayline[0 + LEFT_DELAY_VALUE] = *channel1_in; // Grab delayed value from the front of the FIFO delay line *channel1_in = left_delayline[0]; // Update the FIFO delay line using inefficient memory to memory moves for (count = 0; count < LEFT_DELAY_VALUE; count++) left_delayline[count] = left_delayline[count + 1]; } IIR Filter is your code from Lab. 1 modified for single point real-time operation 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

11 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Test 1 – IIR filter test Design and test your “OFF-LINE” code – offline.dlb NOTE: “OFF-LINE” means that you are linking with the offline library using a known signal It does not necessarily mean that you are running with the simulator. You can run with the real-board if you want and can get access to the lab. Required test Show that your IIR low pass and IIR high pass filter works using the SQUARE-WAVE off-line source IIR low pass output into left channel IIR high pass output into right channel De-activate delay at this time Display on plot routine – capture onto clip board using “Print-screen” key and paste into .doc file Provide code for your low pass and high pass filters High pass filter should be implemented by calling low-pass filter routine and then subtracting low pass output from original signal 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

12 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Sample test result 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

13 Test 2 – Impulse the High-pass signal
Once the processing of the input array has stopped Write a routine that checks for the maximum and minimum values of an array Call the routine to determine maximum and minimum values of IIR high pass output Write a routine that uses the maximum and minimum values as follows For each point in array if value < 98% of max and value > 98% of min then value is 0 else value is unchanged unless the previous value is not 0 The output of this routine is a series of positive and negative pulses that correspond to the sharp rising and falling edges of the input signal Display on plot routine – capture onto clip board using “Print-screen” key and paste into .doc file Provide code for determine max / min and “impulsification” routines 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

14 Temperature Calculation
Centigrade = A1 – B1 T1 / T2 Fahrenheit = A2 – B2 T1 / T2 T1 essentially constant – check formula from chip documentation T T2 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

15 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Test 3 Using the impulse version of the IIR filter calculate an average of five T1 and T2 values Calculate the temperature (to an accuracy of 0.25 degrees) in both Centigrade and Fahrenheit Store in external variables Modify the TCL file so that you have a menu item that will allow you to display these memory values Capture onto clip board using “Print-screen” key and paste into .doc file Provide code for determining average AND TCL changes 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

16 Code developed during Assignment 2
void FindMaxMin (long int *array_IN, long int num_points_array_IN, long int *max_value, long int *min_value) Returns the largest and smallest value in the array_IN void BinarizeSignal (long int *array_IN, long int *array_OUT, long int num_points_array_IN, long int min_amplitude) e.g input -1, 2, -4, 3, 5 with min amplitude of 4 becomes 0, 0, -4, 0, 5 long int FindFirst (long int *array_IN, long int num_points_array_IN) returns the array position of the first non-zero element of the array array_IN void RepositionArray (long int *array_IN, long int *array_OUT, long int num_points_array_IN, long int postion) Returns the array array_OUT where array_OUT[N] = array_IN[N + position] 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

17 Test 4 – Positioning the signal
You have Low-pass filter signal in left-channel array High-pass filter signal in right-channel array Impulse signal in input2 channel array Write a routine to identify when the first negative signal appears in the impulse signal channel Use that information to reposition the low-pass filter signal so that the first negative value of the low-pass signal is at location 10 in the array Capture before and after onto clip board using “Print-screen” key and paste into .doc file Provide code for determining identification and repositioning algorithm Developing and testing this code (In C and assembly code) is going to form assignment 2 This code will also be used during Laboratory 2 and 3 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

18 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Real-time code We have the following routines – and are going to use them for a real-time digital oscilloscope 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

19 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Quick Test of TMP03 Basically – 3 pins +5V GND Output These are new I/O boards and have not been tested – voltage wise Hook up the boards – and connect output to oscilloscope and check that output voltage is no more than 1 V peak-to-peak with small DC offset If too far from this, check with Warren Warning the “potentiometer” on the board is very fragile – self destructs after 10 changes – leave it to Warren +5V GND SIGNAL 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

20 Temperature Calculation
Test by warming with your hands – examine on the scope Centigrade = A1 – B1 T1 / T2 Fahrenheit = A2 – B2 T1 / T2 T1 essentially constant – check formula’s accuracy from chip documentation T T2 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

21 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
ICE hardware TAKE CARE -- THESE ARE VERY EXPENSIVE PROBES -- I want to use them for a number of years! Look at the set-up for Lab. 1 for the care and handling of the ICE hardware 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

22 Quick test of ONLINE.DLB
Using project and files from Lab. 0 Link project with on-line.dlb rather than off-line.dlb Recompile with –D LOCAL_AUDIOTEST compiler option Test – you should hear an audio tune with the sound source “placed” nearer your right ear because of “audio delay” Press the FLAG1 button on the board to remove processing 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

23 Quick test of ONLINE.DLB
Recompile with –D CODEC_AUDIOTEST compiler option Test – Use a radio or CD input you should hear an audio tune with the sound source “placed” nearer your right ear because of “audio delay” Press the FLAG1 button on the board to remove processing Proceed -- provided TMP03 volume (amplitude) is not too large Use the TMP03 as an audio signal (around 40 Hz) Display both the left and right output channel on an oscilloscope Expect some minor distortion in the square wave as the audio input is AC, rather than DC, coupled to the CODEC. However watch out for overload as this will cause the algorithms to fail. Volume adjust on output? The left channel output should be delayed by 40 sample periods 44 kHz) 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

24 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Digital Thermometer You will need to run with the CODEC source activated You will need to capture 1/10 s of the square-wave signal from the digital thermometer output to guarantee that you get at least two full cycles You can’t store that amount of information – assume that the maximum available array size is 512 points Calculate the input decimation rate (down-sampling) necessary so that you can store the required signal Report on your calculation 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

25 Real-time temperature guage
In a loop Capture two cycles of the digital thermometer signal Apply the high pass filter, and “impulsify” the signal using the routines you have developed Calculate and display the temperature Warm the temperature gauge with your hands to check that it works This is a “batch” style of operation – see Assignment 2 for more details 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

26 Real time oscilloscope
In a loop Capture two cycles of the digital thermometer signal Apply the high pass filter, and “impulsify” the signal using the routines you have developed Use your adjusting subroutine so that the “digital thermometer” signal is placed in the same position in the array Show the stable signal in a plot window, and demonstrate that the oscilloscope works by warming the thermometer and see the changes in pulse width (or is the resolution too small?) 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --

27 ENCM515 -- Post Lab1 Details Copyright M. Smith -- smithmr@ucalgary,ca
Final documentation All the required code previously discussed Together with ethics statements, the final working code and screen dumps from the plot and temperature windows running in real time Some of the routines should be running in assembly code – see assignment 2 Due at the start of the lecture on the Friday when you have your Lab. 2 start – but will accept up to 1 week later if you have time constraints but have participated in class discussions 11/20/2018 ENCM Post Lab1 Details Copyright M. Smith --


Download ppt "Post-Lab 1 Quiz Digital Thermometer Digital Storage Oscilloscope"

Similar presentations


Ads by Google