Page 257 - ARM Based Microcontroller Projects Using MBED
P. 257

8.33  PROJECT 28—WAVEFORM GENERATOR                 243
                        case 5:
                                MyPC.printf("\n\rEnter Time Interval (ms): ");
                                MyPC.scanf("%f", &TimeInterval);
                                MyPC.printf("\n\rEnter Amplitude pairs");
                                MyPC.printf("\n\rHow Many Point Are There?: ");
                                MyPC.scanf("%d", &Points);
                                MyPC.printf("\n\r\n\rEnter Amplitude Values for Every ms: ");
                                for(int k = 0; k < Points; k++)
                                {
                                    MyPC.printf("\n\rAmplitude Value for %d ms: ", k);
                                    MyPC.scanf("%f", &Waveform[k]);
                                }
                                MyPC.printf("\n\rGenerating Arbitrary Waveform");
                                GenerateArbitrary(TimeInterval, Points, Waveform);
                                break;
                   }
               }

            FIG. 8.113, CONT’D



              Figs. 8.114 and 8.115 show some runs of the program. In the first figure, a triangular wave-
            form is generated. The second figure generates an arbitrary waveform with the given
            specifications.
              It should be noted that the period of the generated waveforms become less accurate as the
            frequency increases. This is because of the overheads in the program such as the delays
            caused by the for loops and inaccuracies of the wait statements. More accurate results could
            be obtained if the waveforms are generated inside timer ISRs.




























            FIG. 8.114  Generating a triangular waveform.
   252   253   254   255   256   257   258   259   260   261   262