Answered You can hire a professional tutor to get the answer.
EE285 Lab 9 :Real Time Note Tuner In this lab, you will write code that continuously reads blocks of data from the PicoScope 2205 and outputs the...
EE285 Lab 9 :Real Time Note Tuner
In this lab, you will write code that continuously reads blocks of data from the PicoScope 2205 and outputs the data to standard output. Your output should be suitable for piping into your spectral program from Lab 8. In the event that your spectral program did not work correctly, one has been provided for you on Blackboard. In a nutshell, you are writing a program to replace your note generator from Lab 3. The user and programming manual has been linked on Blackboard, and you will need it to finish the lab. Before you begin, use the User and Programming Manuals to answer and turn in the following questions:
- Should you be using AC or DC coupling for our musical note tuner?
2. What voltage range should you use? It may be helpful to look back at the output of the Windows PicoScope software to determine this.
3. Will we need to use triggering? Why or why not?
4. Why will we be using block mode for our application instead of streaming mode?
5. You will need to specify a "timebase" so the
PicoScope knows how many samples to
take per second. What is the timebase for sampling rates of 1500 Hz, 3000 Hz, and 6000 Hz? The equation is frequency = MaxSamplingRate / (2 * timeBase). You can get the max sampling rate from the User Manual; assume that only Channel A is active.
Once you have answered those questions, you can begin to write your software. Your lab virtual machine should already have the Picoscope drivers installed to /opt/picoscope, but if that directory does not exist, follow the instructions at www.picotech.com/linux.html to install them with apt-get. Download the ee285pico.h header file and the build.sh script file on Blackboard. The first file contains a function you will need in this lab and the second one contains a script that will make compiling your program easier
You will need to run the following command to make the script executable: chmod+x build.sh Create a new C program and include the header file and make sure it compiles (using the command towards the end of the lab manual) ee285pico.h contains a function called kbhit(). It returns true if the user has pressed a key and false at all other times. Have your program read blocks of data and output them to standard output until the user presses a key. In the programming manual, go to Chapter 3 and read up on the general procedure for interfacing with the PicoScope. Follow this general procedure as well as the steps listed in the rubric, as these will help you design your program. You will use the answers to the above questions in order to determine what to pass to the functions as you call them. You can assume that you will always be taking in blocks of 8000 and using a sample rate of 6000. You will need to make sure that your program outputs data in a way that your spectral program can read it. If you are using your own version of the spectral program from Lab 8, you will need to remove the two fgets lines from the spectral program that absorbed the comments generated by Lab 3 as your Lab 9 code will not need to create those lines. Because you are piping data into your spectral program, you normally would not be able to directly print to the screen. However, using the function fprintf(stderr, str, ...) where str is your format string and the ... are your optional variables like in a printf statement, you can bypass this pipe and print directly to the screen. This is very helpful when you are trying to debug. Additionally, we would like you to use this to print out errors in your program if they are encountered such as no oscilloscope being found, an error happening while opening the oscilloscope, and so on. In the event that one of these errors happens, your program should print out what the error was and quit immediately. You will compile and run your program as follows: ./build.sh lab9.c ./ picoscope | ./spectral n 8000 s 6000
Here is my musical note generator code:#include <stdio.h>