PWM with Micro not as Expected

Thread Starter

ElectricSpidey

Joined Dec 2, 2017
1,333
So I’ve been working with the PSoC 5LP lately, and one thing I don’t understand is why the PWM doesn’t reach full 0% to 100% Duty Cycle even if I set a Compare Value of 0 or 100. (period of 100)

I have resorted to using additional logic such as this to achieve 0 and 100% Duty Cycles.

A_PWM_Fix.JPG

So my question: is this normal for a Micro using an internal hardware timer based PWM?

Because it really isn’t what I would expect.
 

Thread Starter

ElectricSpidey

Joined Dec 2, 2017
1,333
Sorry @atferrari I missed your question.

The processor is ARM Cortex M3, on a PSoC 5LP development board. (CYPRESS)

And yes, there are many things I don't understand, but I wasn't really asking for troubleshooting, just if this behavior is normal or not. I'm used to this using analog PWM, but I assumed a micro would be different, and go all the way to 0%.

@mckenney "CompareMode?" please clarify.
 

atferrari

Joined Jan 6, 2004
4,122
Sorry @atferrari I missed your question.

The processor is ARM Cortex M3, on a PSoC 5LP development board. (CYPRESS)

And yes, there are many things I don't understand, but I wasn't really asking for troubleshooting, just if this behavior is normal or not. I'm used to this using analog PWM, but I assumed a micro would be different, and go all the way to 0%.

@mckenney "CompareMode?" please clarify.
Sorry Electric but I am not ARM conversant. Just in case, keep in mind that a real 100% or 0% duty cycle means an output fully high (or low) all the time while the PWM output is enabled.
 

BobTPH

Joined Jun 5, 2013
2,587
If I understand you correctly, the output turns off at reset of the counter and on when the counter is greater than the compare register.

If that is the case, you can get 0% by setting the compare to 101. You cannot get 100% since zero is not > 0 so it will be low for one cycle.
If I have the on / off backwards, the you can get 100%, but not 0%.

Bob
 

Thread Starter

ElectricSpidey

Joined Dec 2, 2017
1,333
I understand what you are saying, but above 100 is an invalid entry.

I'll have to set the CV to "Less" and invert the output to test your theory.
 

BobTPH

Joined Jun 5, 2013
2,587
I understand what you are saying, but above 100 is an invalid entry.
How so? The register is certainly some number of bits, so, if you can put 100 in it you can put 101. It simply guarantees that the compare will never trigger.

Are you talking about a library fuction that takes the duty cycle as a percentage, rather than the actual value placed in the register? If that is the case then there is a bug in that function.

Bob
 

Thread Starter

ElectricSpidey

Joined Dec 2, 2017
1,333
Thank you @BobTPH

No, the IDE simply wont let you place a value greater than the period.

I did the test, and you are correct, the thing that I didn't notice was that one cycle on the chart because I always was looking at 100% and not seeing the one cycle difference.

A_Dialog_Box_3a.JPG

So I feel like a fool, but a fool who has learned something. :)

Thanks again!
 
Top