8 Replies Latest reply on Nov 8, 2014 11:14 AM by DaKn_263916

    PWM Block in One-shot Application

      I am trying to implement a one-shot using the PWM block.  My system must rapidly (< a few 10s of usec) respond to a rising edge trigger pulse by putting out a fixed pulse length output (pulse length of ~10msec).  The trigger signal may have multiple transitions, so I would like to trigger the one-shot on the first rising edge transition and ignore further triggers until the period of the one-shot is over.  I am using a clock frequency of 1 MHz on the PWM block


      I have tried a variety of approaches using the PWM block, but I am having several major problems:

      1. There's a delay of several msec between the trigger pulse and the output pulse
      3. I want the output to be low and pulse high after trigger.  I seem to end up with an output that is initially high and pulses low when triggered
      5. I don't really see a major difference between the two run modes (one-shot with single or multiple triggers)

      Does anyone out there have an example of successfully using this block for this sort of thing?

        • 1. Re: PWM Block in One-shot Application

          Welcome in the fascinating (and sometimes complicated) world of PSoCs!




          You may invert the output of the PWM with a NOT-gate to get the level you like to have.


          Select one shot with multi-trigger, the other solution will run only once and needs a reset.


          Consider posting the complete project to have us chack all of your settings. To do so, use
          Creator->File->Create Workspace Bundle (minimal)
          and attach the resulting file.


          • 2. Re: PWM Block in One-shot Application



            Thanks so much for the prompt reply.  I will have to parse this PWM block that I am trying to understand from my overall design to facilitate studying and sharing.  I have a workaround for now using some down counters, but it's not very elegant.  I'll bundle up my confusion in a manner that allows you to focus on the question at hand.


            By the way, are you surprised that the PWM block has so much delay after trigger?  I was wondering if this is just intrinsic to the part and doesn't adversely impact its normal usage...




            Best, Rich

            • 3. Re: PWM Block in One-shot Application

              I have used PWM in one-shot so far and I did not find any issues with a delay when starting the PWM. You are quite sure to have the comparision set up properly? I just remember (as a PSoC5 user) that there are differences between the inactive output stage of a PSoC3 and PSoC5, there must be something regarding this matter in the datasheet.





              1 of 1 people found this helpful
              • 4. Re: PWM Block in One-shot Application

                If the compare is set up < or <= then PWM has to count down from period


                value to compare point before output goes high. If you set it to > or >= then


                PWM output goes high in 1 clock from trigger and does not drop until it hits






                Regards, Dana.

                1 of 1 people found this helpful
                • 5. Re: PWM Block in One-shot Application

                  Hmmm.  Dana, I think you might be onto something there.  I'll run in the lab and try it now.  Thanks to all of you for your help. 


                  I am new to the PSOC environment having been an analog circuit designer for 20 years.  I love the PSOC, but am lousy at debugging my designs short of building it and measuring things the old fashioned way.  I wish I understood how to use the internal diagnostic registers better as I see you guys do in your helpful posts on various topics; I am a hack at C programming, but can get by in a pinch.




                  Best, Rich

                  • 6. Re: PWM Block in One-shot Application

                    Each datasheet has a section of API calls you can use in your code. Also be cognizant and read any foot notes when using an API, sometimes there are side effects.




                    In general read the datasheet for the component (just right click it when it is not selected).




                    There are many sample projects using various components you can draw from, on start page of


                    Creator, “Find Example Projects” link. As well many ap notes on various topics/components.




                    Additionally there are TRMs (Tech Ref Manuals), one for the architecture, the other called the register reference with fine detail on various components registers.




                    Don’t get overwhelmed, do not try to read TRM end to end. Just start with datasheets, then if you feel something not


                    complete consider looking at TRM  section for that component. TRMs can be found by going to cypress.com, pick the


                    family, usually there is a link on that page to TRMs, or docs and search for “technical reference manual”.




                    On start page of Creator, “Find Example Projects” link, many example projects and code for components that you can draw from.








                    And always use the forum for help, it is supported by many users with diverse experience and Cypress employees.




                    Regards, Dana.

                    1 of 1 people found this helpful
                    • 7. Re: PWM Block in One-shot Application

                      Thanks Dana.  That is kind of you to take time to fill me in.  I will follow your advice and read those topics.


                      I actually meant to go in the lab and test the PWM block, but I got sucked into another interesting artifact of the product I am working on (500 volt, 30 amp pulse generator).  This lead to me completely forget why I was there in the first place.  I'll get to it on Monday I hope.


                      Best, Rich

                      • 8. Re: PWM Block in One-shot Application

                        Here is an example of a one shot, but I did it with PSOC 5LP, just change


                        part to a PSOC 3, should work (famous last words....:)




                        Regards, Dana.