6 Replies Latest reply on May 22, 2011 11:39 PM by gautam.das.g

    Triangular wave Generator without DMA and LUT

    gogulnath.ramadass

      Hi

         

      I am very new to this PSoc Platform. My doubt "is it possible to design a Triangular waveform generator using VDAC without LUT and DMA? If it so how? And how it is possible to generate a negative voltage using VDAC? If anyone know, please tell me that will help me out to finish my project. Thanks in advance.
       

        • 1. Re: Triangular wave Generator without DMA and LUT
          robert.teufel

          Hi,

             

          My doubt "is it possible to design a Triangular waveform generator using VDAC without LUT and DMA? If it so how? And how it is possible to generate a negative voltage using VDAC? If anyone know, please tell me that will help me out to finish my project.

             

          Why would you not want to use DMA and LUT? That is a perfect example for using it. You can also create a table of values in the regular code memory and transfer the data by C-instructions to the VDAC and not use the help of the DMA. It would be subject to jitter and use up some CPU power.

             

          Regarding negative voltage, that is not possible without external components. Please check this contribution in the Design challenge forum  http://www.cypress.com/?app=forum&id=2232&rID=48899

             

          Hope this helps you to finish your project.

             

          Robert

          • 2. Re: Triangular wave Generator without DMA and LUT
            bradley.budlong

             It is possible to implement a waveform using just hardware (VDAC and programmable logic).  The VDAC has the option to use the DAC bus.  This is an 8-bit bus that provides the value for the DAC instead of having the value come from the CPU.  What values it is given is dependent on the hardware that you develop for the programmable logic.  As Robert described, the DMA and LUT approach is likely easier, but this hardware method can be done.  The simpliest approach would be a Verilog implementation of an up / down counter with the state machine logic to control it.  If you aren't comfortable with developing Verilog hardware, then you could implement using a hardware LUT and gates on a schematic.

               

            Brad

            • 3. Re: Triangular wave Generator without DMA and LUT
              gogulnath.ramadass

              Thanks Robert and bjbu, your valuable suggestion will surely help me. but even i tried with timer and VDAC . I want to know whether this will work out or not? Initially i started to generate wave from 0 to 1.024V and vice versa for the next half. Actually i need to Scan my waveform with respect to time, (for eg)  need to increment 0.4 volts every 10 micro secs and vice versa for next half.

                 

               

                 

              #include <device.h>

              void main()

              {
                
                 uint8 i ;
                 Timer_1_Start ();
                 VDAC8_1_Start();

                 

                  VDAC8_1_SetRange(VDAC8_1_RANGE_1V);

                 

              for(i=0;i<255;i++)

                 

              {

                 

              VDAC8_1_SetValue(i);  // increment the value by 0.4 volt on strobe signal 

                 

              }

                 

              if (i==255)

                 

              {

                 

              for(i=255;i>=0;i--)

                 

              {

                 

              VDAC8_1_SetValue(i);   // decrement the value by 0.4 volt on strobe signal 
              }

                 

              }

              • 4. Re: Triangular wave Generator without DMA and LUT
                gogulnath.ramadass

                Thanks Robert and bjbu, your valuable suggestion will surely help me. but even i tried with timer and VDAC . I want to know whether this will work out or not? Initially i started to generate wave from 0 to 1.024V and vice versa for the next half. Actually i need to Scan my waveform with respect to time, (for eg)  need to increment 0.4 volts every 10 micro secs and vice versa for next half.

                   

                 

                   

                #include <device.h>

                void main()

                {
                  
                   uint8 i ;
                   Timer_1_Start ();
                   VDAC8_1_Start();

                   

                    VDAC8_1_SetRange(VDAC8_1_RANGE_1V);

                   

                for(i=0;i<255;i++)

                   

                {

                   

                VDAC8_1_SetValue(i);  // increment the value by 0.4 volt on strobe signal 

                   

                }

                   

                if (i==255)

                   

                {

                   

                for(i=255;i>=0;i--)

                   

                {

                   

                VDAC8_1_SetValue(i);   // decrement the value by 0.4 volt on strobe signal 
                }

                   

                }

                • 6. Re: Triangular wave Generator without DMA and LUT
                  gautam.das.g

                  Hi Gogul,

                     

                   

                     

                  From the above code, since you are incrementing the value of VDAC in steps of 1 count, the VDAC output is incremented in steps of 4mV and not 400mV (0.4V) as you expected (from your previous comment).

                     

                   

                     

                  Since you want the increment to happen on every 10 micro second, you need to insert a delay of 10 microsecond inside the 'for' loops using CyDelayUs(uint16 microseconds).

                     

                  Some extra time will be taken up as the execution of statements also takes up few clock cycles.

                     

                   

                     

                  If you don't consider using DMA, then you can use LUT which is very easy to configure. And using a timer to generate a clock of period 10 micro second will generate an accurate frequency triangular wave.

                     

                   

                     

                  Creating a Custom Component using Verilog will be a very easy procedure to obtain the triangular waveform.