1 2 Previous Next 19 Replies Latest reply on Mar 6, 2011 8:05 PM by WeGa_288606

    20 Channel Function Generator


      Hello Everyone,


      I am very new to the PSoC concept but I am very interested in growing my skills. My project goal is to develop a 20 channel function generator with an USB interface and then use an API/GUI to select the type of signals I would like on each of the 20 outputs. My requirements are such that the amplitude is in the range of 0-3 volts in 0.05 step and 0-20 Hz in 0.01 step (roughly 7 bit and 11 bit respectively). For the short term however my questions are:


      1. Would I be able to meet such requirements with a PSoC 3?


      2. Would there be much in external circuitry required?


      3. Could I use internal amplifiers to adjust the amplitude i.e. gain control?


      4. For now I would just like to get started with generating a square wave (not a PWM based design) on 20 of the PSoC3 pins so I can probe around with an Oscope as I explore how to use the hardware/software. I have the first touch PSoC3 starter kit. I am thinking I need  comparators/timers (20 of them actually) and just toggle the output with the count as 1/2 the period of the square wave. I do need to hold the resolution requirements for this. Not really clear how to get started on this. I watched some Cypress Videos and I have general navigation skills but I just need some help picking the right direction.


      Guidance is highly appreciated.


      Best Regards,



        • 1. Re: 20 Channel Function Generator

          Hello Wess,


          It's quite an ambitious application that you are trying to develop with PSoC3.  An USB dll file is already available and hence provoding an USB GUI is possible.


          PSoC 3 has 4 Op-amps, 4 Comparators, 4 DACs(Configurable as either IDAC or VDAC). There are 4 SC/CT blocks, which are nothing but combination of Opamps and switched capacitances- these can be configured as Programmable Gain Amplifier(PGA), Inverting/Non-Inverting amplifier, Mixer, Track and hold block .


          Using VDACs it is possible to generate analog waveforms. This code example shows how to generate a Sine wave using a DAC- 



          Sine Wave Generator with DAC - PSoC® 3 / PSoC 5 - http://www.cypress.com/?rID=38627


          You can use a VDAC and multiplex it with Track and hold component as described in the following blog post to generate more waveforms- Buy One Get Three Free - Making Four VDAC8s from Onehttp://www.cypress.com/?rID=43474. You may need external filter on top of this implementation to get smooth waveform.




          However for generation of square wave you have multiple options. You can use the PWM modules- which are avaliable as Fixed function blocks and UDB based implementation.


          This blog post gives some information about the same, 


          How Many PWM Outputs Can a PSoC 3 or 5 Generate? - http://www.cypress.com/?rID=40091


          UDB Doubters- http://www.cypress.com/?rID=43496




          I hope this helps, Please let us know if you need any further help.





          • 2. Re: 20 Channel Function Generator

            Hi Udayan


            Thanks for the help and fast reply. I got my PWM up fairly quickly. Would you please help me understand the 4-OP-AMPS limitation here? For example when I had read the data sheet for PSoC3 I recall reading something like "Any GPIO to any digital or analog peripheral routability" So I thought I would be able to use say 20 of the OPAMPS on the pins? Sorry for the basic question but I really do not have PGA/FPGA background what so ever but I am trying to come up to speed on this stuff.


            Is there a PSoC that you believe could help me achieve my design goal?







            • 3. Re: 20 Channel Function Generator

               Hello Wess,


              Yes you can connect/route any peripheral(including Op-amps) to any pin on the chip. However there are only 4 Opamps available for your use on PSoC3 device. Apart from these 4 Opamps you have 4 Comparators and 4 SC/CT blocks as told earlier. You can get amplifiers with programmable gain using these SC blocks. 

              • 4. Re: 20 Channel Function Generator

                OK thanks but that is not the question I am asking. You are suggeting that I only have 4 available and my question is why could I not map a OPAMP to every pin on the PSoC for example? Like the one post you referenced on PWM showed that it is possible to have 52 PWM? What determines the limit of each of the features? Why 4 OPAMPs and not 52 for example or 52 SC/CT etc....? Is this is the datasheet? If so what part? I looked for it but it is not sticking out at me.... Thanks...

                • 5. Re: 20 Channel Function Generator

                   Hello Wess,


                  In PSoC3 we have what is called UDB-Universal Digital Block. These blocks are programmable blocks which can be configured to implement any digital logic. That includes any communication protocol like I2C, SPI, state machine or even PWM. There are 24 such UDBs and using each UDB we can get 2 PWMs and using the fixed function Timers we can get 4 more PWMs. The PSoC architecture is such that there are only 4 Op-amps and 4 SC/CT Blocks. You can connect these blocks to any pin on the chip. The part CY8C3866 is the part that has all the features. Refer to its datasheet available at  http://www.cypress.com/?rID=35178, you will get information about all the features available on PSoC3. You can have 52 Op-amps or 52 SC/CT blocks on one chip. Please describe the kind of waveforms that you need to generate and the parameters and controls you want have on your GUI. 



                  • 6. Re: 20 Channel Function Generator

                    For now I would be happy generating a square positive pulse varying frequency and amplitude through the GUI. Eventually I would like to have sine wave, bipolar square pulse, (+/-) uni polar square pulse, and sawtooth all varying frequency and amplitude. The immediate goal is just to learn and understand PSoC. This is not for a bench top function generator this is for a biomedical drug delivery system that our group is researching.  

                    • 7. Re: 20 Channel Function Generator

                      Hello Wess,


                      Alright you could understand basics of PSoC3 first and then get into complex projects. The tool used to create projects for PSoC3/PSoC5 is PSoC Creator. Go through the following Application Note to understand how to create projects on PSoC Creator. It also illustrates basics of PWM module. 


                      The Example project attached(pdf file) should help you understand the USB interface. The project is being updated for the latest version of PSoC Creator as of now. It will be available on the website soon, you can use it once it is up on the web.



                      • 8. Re: 20 Channel Function Generator

                        Do you have an example of how to generate a bipolar square wave?

                        • 9. Re: 20 Channel Function Generator

                          Hello Wess,


                          When you say Bipolar Square Wave, what voltage levels are you referring to. Because PSoC(or any microcontroller) is typically powered by an unipolar supply, 5V, 3.3 V etc). Once you get the PWM from PSoC ,you may have to use external components to perform level shifting if you need negative voltage level.

                          • 10. Re: 20 Channel Function Generator



                            I would like to generate a signal from -2 V to 2 V. Isnt the sine wave example generating a bipolar wave? I have not tried it yet but it must be for it to be a sine wave. no?

                            • 11. Re: 20 Channel Function Generator

                              Hello Wess,


                              You might have to use external components to get negative voltages. PSoC is powered by unipolar supply(0.5V to 5V ). To generate a square wave with -2 Volts and 2 Volts amplitude, you may need some kind of level translator(op-amp based or other ic) in addition to PSoC. Infact no microcontroller would be able to do this.





                              • 12. Re: 20 Channel Function Generator

                                How about -3.3 to 3.3?

                                • 13. Re: 20 Channel Function Generator

                                  Hi Wess,




                                  Converting a unipolar signal from PSoC to a bipolar can be done in a much more simpler way. This would require external passive components: a Capacitor and a diode.


                                  A clamper will can be used to convert a sine wave of 0-4V into a -2 to +2V Sine wave. The voltage source required for this clamper can also be derived from PSoC, by voltage divider (or a VDAC).


                                  You can understand about the basics of clamper by glancing through Wiki link  






                                  This is a cost effective and simple way to achieve voltage shifting over using external opamps or shifters.





                                  • 14. Re: 20 Channel Function Generator

                                    Hello Wess,


                                    It is not possible to generate any negative voltage, since the chip is not capable of operating at those voltages.You can generate a PWM with voltage levels 0-VDDD(0-3.3V or 0-5 V) or (0 - Vref), where Vref is a configurable voltage above 0 Volts.


                                    Correction to post Number 6, You can not have 52 Op-amps or 52 SC/CT blocks on single PSoC chip.

                                    1 2 Previous Next