PWM Block in One-shot Application

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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
  2.     
  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
  4.     
  5. I don't really see a major difference between the two run modes (one-shot with single or multiple triggers)
  6.    
   

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

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.



Bob
 

View solution in original post

8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.



Bob
 

Anonymous
Not applicable

Bob,

   

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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

   

compare.

   

 

   

Regards, Dana.

Anonymous
Not applicable

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

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

   

 

   

https://secure.cypress.com/psoc5lp/?source=CY-ENG-HOMEPAGE&medium=Body-Products

   

 

   

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

   

 

   

Regards, Dana.

Anonymous
Not applicable

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

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes