(The following can be done on paper or via the use of the mbed software. You mus
ID: 3887319 • Letter: #
Question
(The following can be done on paper or via the use of the mbed software. You must turn in all work on paper-no email submissions). Show any calculations needed for full credit 1. Change Example 4.2 in the following ways: a) the analog output is incremented with steps of 0.05 b) add another for loop so the waveform will be more like a triangular waveform, meaning that the new for loop will step the output down in steps of 0.05. You need to show the entire program with the changes 2. Use equation 4.1 to solve for the step size of a 12 bit DAC, wich Vr values equal to 3.3V. Repeat this is Vr = 5.0V. 3. Using Example 4.3, find the a) number of sample points generated by the Aout equation and b calculate the approximate period and frequency of the sine wave. Hint: the period is NOT equal to 0.001s 4. Change the program in Example 4.6 in the following ways: a) replace pin 6 with another valid digita output pin (see Section 3.3), and b) change the program so output Duty Cycles of 25% and 75% for 1000 cycles 5. Change the program in Example 4.5 to: a) have a 20ms period and b) to change the Duty Cycle only every secondExplanation / Answer
1. Here is the code for problem 1.
The code BEGINS from here:
#include "mbed.h"
AnalogOut Aout(p18);
float i;
int main()
{
while(1){
// Step-up loop
for(i=0; i<1; i=i+0.05){ // i is incremented in steps of 0.05
Aout = i;
wait(0.001); // wait 1 millisecond
}
// Step down loop
for(i=1; i>0; i=i-0.05){ // i is decremented in steps of 0.05
Aout = i;
wait(0.001); // wait 1 millisecond
}
}
return 0;
}
Hope this helps...
BEST WISHES!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.