PWM- trying to use it as a one shot and change the pulse width?

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

cross mob
Anonymous
Not applicable

Anyone have a good example (source and HW set-up) of using a PWM in a 1 shot configuration and changing the pulse width value. creater 3 environment.

0 Likes
9 Replies
Anonymous
Not applicable

Creator 3?

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

Actually quite simple, place on schematic, double click,

   

and config, trigger can be single trigger or multiple trigger.

   

The just start up with API and give it the trigger. Reset after

   

event, or other possibilities via interrupt.

   

 

   

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

Probably you are using Creator 2.2 and a PSoC3.

   

Set the trigger in the "Advanced" configuration tab to "multi-trigger" . While the PWM is waiting for a trigger pulse you may set the pulse-width with the API WriteCompare() to any value within the given limit.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

OK

   

The multiple trigger is not quite giving me what I want, but I have more basic question.

   

How does the 3 of these interact?

   

   

PWM_1_WriteCounter(19);

   

PWM_1_WritePeriod(counterValue);

PWM_1_WriteCompare(2);

   

   

With the multitrigger setup you suggested, I'm finally able to vary the distance between pulses by setting the period value, but get many of them. I suspect there are knob setting to just get one, but I'm still tinkering to find the right combination.

   

What I'm after is simply to vary the width of the pulse, one time.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked
        The pulsewidth is set with PWM_WriteCompare(). Bob   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored
        
  • WritePeriod() sets the length of the complete PWM period (the maximum counter value - with normal PWM, it therefore sets the PWM frequency)
  •     
  • WriteCompare() sets the counter value when the PWM output changes from high to low (so it sets the duty cycle)
  •     
  • WriteCounter() sets the current counter value, so it influences when the next compare event happens (by going either forward or backward in the PWM timespace)
  •    
   

When using the multi-trigger mode, the next trigger event will only be start a new cycle after a complete PWM period has been completed (in the component data sheet, look at page 32ff).

0 Likes
Anonymous
Not applicable

This is what I ended up with (just the schematic loaded).

   

comments...

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

No image to see here...

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

If you are trying to post an image, post as .BMP, and make it the last

   

thing you paste in the thread. I have found Firefox most of the time will

   

do this, whereas IE rarely.

   

 

   

Regards, Dana.

0 Likes