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

8.33  PROJECT 28—WAVEFORM GENERATOR                 235
                     BEGIN/MAIN
                            Configure DAC port PA_4 as analog output
                            Store waveform voltage samples in array Waveform
                            DO FOREVER
                                   DO for all sample points
                                           CALL GenerateV(sample)
                                           Wait 1 millisecond
                                   ENDDO
                            ENDDO
                     END/MAIN



                     BEGIN/GenerateV(sample)
                            Generate voltage at the DAC equivalent to sample
                     END/GenerateV
            FIG. 8.109  Program PDL.



            8.32.5 Program Listing

              Fig. 8.110 shows the program listing (program: Arbitrary). At the beginning of the pro-
            gram, the waveform voltage sample points are stored in a floating point array called Wave-
            form. Function GenerateV generates the given voltage at the DAC port. Inside the main
            program, the voltage sample points are sent to function GenerateV to generate the required
            waveform.
              Fig. 8.111 shows the generated waveform. In this figure, the vertical axis is 0.3V/division
            and the horizontal axis is 2ms/division.




                          8.33 PROJECT 28—WAVEFORM GENERATOR

            8.33.1 Description
              This is a waveform generator program which can generate the following waveforms: fixed
            voltage, sawtooth waveform, triangular waveform, sine waveform, and arbitrary waveform.
            The parameters of each type of waveform are received from the keyboard.



            8.33.2 Aim

              The aim of this project is to show how a waveform generator program can be developed.
   244   245   246   247   248   249   250   251   252   253   254