This shows you the differences between two versions of the page.
milestone_3_task_3 [2023/03/02 17:58] scott [Source Code] |
milestone_3_task_3 [2024/03/09 16:18] (current) scott [Demonstration Videos and other Links] |
||
---|---|---|---|
Line 55: | Line 55: | ||
* [[https://www.youtube.com/watch?v=y_XvR_NCjQA|Video Demonstration of Shooter Mode]] | * [[https://www.youtube.com/watch?v=y_XvR_NCjQA|Video Demonstration of Shooter Mode]] | ||
* [[https://www.youtube.com/watch?v=s7QPsCfhY-w|Video Demonstration of Continuous Mode]] | * [[https://www.youtube.com/watch?v=s7QPsCfhY-w|Video Demonstration of Continuous Mode]] | ||
- | * [[https://en.wikipedia.org/wiki/Insertion_sort| Wikipedia page on insertion sort.]] | + | * [[https://en.wikipedia.org/wiki/Insertion_sort|Wikipedia page on insertion sort.]] |
- | * [[https://courses.cs.vt.edu/~csonline/Algorithms/Lessons/InsertionCardSort/index.html|Tutorial of insertion sort using cards.]] | + | |
* [[https://en.wikipedia.org/wiki/Selection_sort|Wikipedia page on selection sort.]] | * [[https://en.wikipedia.org/wiki/Selection_sort|Wikipedia page on selection sort.]] | ||
- | * [[https://courses.cs.vt.edu/csonline/Algorithms/Lessons/SelectionCardSort/selectioncardsort.swf|Tutorial of selection sort using cards.]] | ||
---- | ---- | ||
Line 65: | Line 63: | ||
Note that the following files are provided in your ecen390 project directory. Refer to the comments above each function for more details. | Note that the following files are provided in your ecen390 project directory. Refer to the comments above each function for more details. | ||
+ | * include/interrupts.h | ||
* lasertag/isr.h | * lasertag/isr.h | ||
* lasertag/buffer.h | * lasertag/buffer.h | ||
* lasertag/detector.h | * lasertag/detector.h | ||
* lasertag/main.c | * lasertag/main.c | ||
- | * support/bufferTest.h | + | * lasertag/support/bufferTest.h |
- | * support/bufferTest.c | + | * lasertag/support/bufferTest.c |
- | * support/runningModes.h | + | * lasertag/support/runningModes.h |
- | * support/runningModes.c | + | * lasertag/support/runningModes.c |
You are expected to create and implement the following files. See the provided header files (.h) for a description of each function. | You are expected to create and implement the following files. See the provided header files (.h) for a description of each function. | ||
Line 94: | Line 93: | ||
* ''buffer_size()'': simply returns the capacity of the buffer in elements. | * ''buffer_size()'': simply returns the capacity of the buffer in elements. | ||
- | **Note: you will have to write this ADC buffer code from scratch.** For help, you can read this [[http://ece390web.groups.et.byu.net/dokuwiki/doku.php?id=queue_and_array|queue tutorial/explanation]]. | + | **Note: you will have to write most of this ADC buffer code.** See [[milestone_3_task_3#adc_buffer_sketch|ADC Buffer Sketch]] below for code to get started. You can also refer to your queue.c code for inspiration (but don't copy any ''double'' data types if you cut and paste). |
- | Carefully test your ADC buffer code independent of the detector. You can do this by uncommenting ''bufferTest_runTest()'' in main.c. It will not be possible to fully test your detector implementation if the buffer is not working properly. | + | Carefully test your ADC buffer code independent of the detector. You can do this by uncommenting ''buffer_runTest()'' in main.c. It will not be possible to fully test your detector implementation if the buffer is not working properly. |
==== Interrupt Service Routine ==== | ==== Interrupt Service Routine ==== | ||
- | Implement the two functions in isr.c | + | Continue the implementation of isr.c |
* ''isr_init()'': | * ''isr_init()'': | ||
- | * Perform initialization for interrupt and timing related modules. | + | * Perform initialization for timing related modules (those with ''tick()'' functions). |
+ | * Add a call to ''buffer_init()''. | ||
* ''isr_function()'': | * ''isr_function()'': | ||
* Invoke all of the tick functions. | * Invoke all of the tick functions. | ||
Line 116: | Line 116: | ||
- Now, repeat the following steps ''elementCount'' times. | - Now, repeat the following steps ''elementCount'' times. | ||
* If interrupts are enabled (check to see if the interruptsEnabled argument == true), briefly disable interrupts by invoking ''interrupts_disableArmInts()''. You must disable interrupts briefly while you pop an element from the ADC buffer. Otherwise, if an interrupt occurs while you are "popping" a value from the buffer, the interrupt routine and your ''detector()'' routine may simultaneously access the ADC buffer and may cause ''indexIn'', ''indexOut'', or some other field of the ADC buffer to be miscomputed. This kind of problem can be very difficult to track down because it is hard to reproduce, so it is best to avoid the problem in the first place. | * If interrupts are enabled (check to see if the interruptsEnabled argument == true), briefly disable interrupts by invoking ''interrupts_disableArmInts()''. You must disable interrupts briefly while you pop an element from the ADC buffer. Otherwise, if an interrupt occurs while you are "popping" a value from the buffer, the interrupt routine and your ''detector()'' routine may simultaneously access the ADC buffer and may cause ''indexIn'', ''indexOut'', or some other field of the ADC buffer to be miscomputed. This kind of problem can be very difficult to track down because it is hard to reproduce, so it is best to avoid the problem in the first place. | ||
- | * pop a value from the ADC buffer (use ''buffer_pop()'' for this). Place this value in a variable called ''rawAdcValue''. | + | * Pop a value from the ADC buffer (use ''buffer_pop()'' for this). Place this value in a variable called ''rawAdcValue''. |
* If the interruptsEnabled argument was true, re-enable interrupts by invoking ''interrupts_enableArmInts()''. | * If the interruptsEnabled argument was true, re-enable interrupts by invoking ''interrupts_enableArmInts()''. | ||
* Scale the integer value contained in ''rawAdcValue'' to a ''double'' that is between -1.0 and 1.0. Store this value into a variable named ''scaledAdcValue''. The ADC generates a 12-bit output that ranges from 0 to 4095. 0 would map to -1.0. 4095 maps to 1.0. Values in between 0 and 4095 map linearly to values between -1.0 and 1.0. **Note: this is a common source of bugs. Carefully test the code that does this mapping.** | * Scale the integer value contained in ''rawAdcValue'' to a ''double'' that is between -1.0 and 1.0. Store this value into a variable named ''scaledAdcValue''. The ADC generates a 12-bit output that ranges from 0 to 4095. 0 would map to -1.0. 4095 maps to 1.0. Values in between 0 and 4095 map linearly to values between -1.0 and 1.0. **Note: this is a common source of bugs. Carefully test the code that does this mapping.** | ||
Line 275: | Line 275: | ||
To pass off your system to the TAs, you must do the following: | To pass off your system to the TAs, you must do the following: | ||
- | - Demonstrate an isolated test of your detector (see instructions for the isolated test below). | + | - Demonstrate an isolated test of your hit detection algorithm (see instructions for the isolated test below). |
- Demonstrate a system test of the entire laser-tag system as implemented thus far (see instructions below regarding shooter and continuous modes). | - Demonstrate a system test of the entire laser-tag system as implemented thus far (see instructions below regarding shooter and continuous modes). | ||
- Run "./check_and_zip.py 390m3-3" to create a .zip file of your project. Submit only one .zip file per team. The TAs will give credit to both members of the team. | - Run "./check_and_zip.py 390m3-3" to create a .zip file of your project. Submit only one .zip file per team. The TAs will give credit to both members of the team. | ||
==== 1. Detector Isolated Test ==== | ==== 1. Detector Isolated Test ==== | ||
- | You will write ''detector_runTest()'' and demonstrate its operation to the TAs. You will also demonstrate your system running in the provided shooter and continuous modes. | + | You will write ''detector_runTest()'' and demonstrate its operation to the TAs. Interrupts are not enabled for this test. |
- | ''detector_runTest()'' will test the detector using the isolated test described below. | + | ''detector_runTest()'' will test your hit detection algorithm following the steps described below. As a suggestion, organize your hit detection algorithm into a local sub function named ''hit_detect()'' so it can be called by the test. This sub function should also be called by ''detector()''. |
=== Isolated Test Details === | === Isolated Test Details === | ||
- | For this test, simply provide power data for the detector by calling ''filter_setCurrentPowerValue()'' for each of the 10 frequencies. Then call ''detector()'', which should retrieve the power values. The isolated test must perform the test upon two sets of data as described below: | + | For this test, simply provide power data for your hit detect function by calling ''filter_setCurrentPowerValue()'' for each of the 10 frequencies. Then call your hit detect function, which should retrieve the power values. The isolated test must perform the test upon two sets of data as described below: |
- | - Create a first set of power data and provide a fudge-factor value that will detect a hit when you invoke ''detector()''. After running ''detector()'', you would invoke ''detector_hitDetected()'' to determine if a hit occurred. | + | - Create a first set of power data (10 calls to ''filter_setCurrentPowerValue()'') and provide a fudge-factor value that will detect a hit when you invoke ''hit_detect()''. After calling ''hit_detect()'', you would invoke ''detector_hitDetected()'' to determine if a hit occurred. |
- | - Create a second set of power data that will not detect a hit when you invoke ''detector()''. Use the same fudge-factor as you used for the first set of data. Again, invoke ''detector_hitDetected()'' to determine if a hit occurred. | + | - Create a second set of power data that will not detect a hit when you invoke ''hit_detect()''. Use the same fudge-factor as you used for the first set of data. Again, invoke ''detector_hitDetected()'' to determine if a hit occurred. |
==== 2. System Demonstration ==== | ==== 2. System Demonstration ==== | ||
- | Add the provided shooter and continuous mode functions using the provided source code. Demonstrate your system in both shooter and continuous mode and show that your system runs the same as the videos: | + | Enable the shooter and continuous mode test functions provided in main.c. Demonstrate your system in both shooter and continuous mode and show that your system runs the same as the videos: |
* [[https://www.youtube.com/watch?v=y_XvR_NCjQA|Video Demonstration of Shooter Mode]] | * [[https://www.youtube.com/watch?v=y_XvR_NCjQA|Video Demonstration of Shooter Mode]] | ||
* [[https://www.youtube.com/watch?v=s7QPsCfhY-w|Video Demonstration of Continuous Mode]] | * [[https://www.youtube.com/watch?v=s7QPsCfhY-w|Video Demonstration of Continuous Mode]] | ||
Line 300: | Line 300: | ||
* Run-time in timerIsr should be 10-20% or less. | * Run-time in timerIsr should be 10-20% or less. | ||
- | Note that the performance values shown below are "ballpark" figures. Don't worry too much if your statistics vary a fair amount from those shown below. These numbers were achieved using -O3 optimization. You can follow this [[https://www.youtube.com/watch?v=osogOHBzlHI|video]] to modify the compiler optimization settings in your SDK. | + | Note that the performance values shown below are "ballpark" figures. Don't worry too much if your statistics vary a fair amount from those shown below. |
The picture shown below is for shooter mode. | The picture shown below is for shooter mode. |