Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Pulse Width Meassurement

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Pulse Width Meassurement
Moderator:
ANCY

Post Reply
Follow this topic



Pulse Width Meassurement

sebastian.mysyk posted on 07 Dec 2010 4:10 AM PST
Member
4 Forum Posts

Hello,

 

I´m dealing with the Problem how to meassure the time between two rising Edges of a PWM-Signal with the Frequency of 250 Hz.

Anybody who knows a sollution, because the cypress sollutions are without source code and I can´t reproduce their way of solving the Problem...




Re: Pulse Width Meassurement

sebastian.mysyk posted on 09 Dec 2010 11:08 PM PST
Member
4 Forum Posts

Hello,

 

of course I have to meassure the time between a rising and a falling Edge!



Re: Pulse Width Meassurement

Gautam Das posted on 26 Dec 2010 10:52 AM PST
Cypress Employee
742 Forum Posts

Hi Sebastian,

 

You can measure the Duty cycle of your external PWM signal by using 'Capture' input in the 'Counter' component.

1) Use 2 Counter components, Counter1 and Counter2

2) Configure Counter1's Capture Mode to 'Rising Edge' and Counter2's Capture Mode to 'Falling Edge'.

3) Connect the same external signal whose PWM is to be measured to both the 'Capture' inputs of the Counter Components.

4) A common clock (internal) of suitable frequency is connected to Counters' Count input.

5) Check the Interrupt 'On TC' box for both the components and connect the interrupt Components to the Interrupt Terminal of the Counters.

6) Also check Reload Counter 'On Capture'.

7) Now whenever there is an Interrupt on Rising Edge (in Counter1), Reload the Counter2 to 0 (assuming both the counters are in Up-Counters mode) in the ISR.

8) Whenever there is a Falling Edge (in Counter2), read the value. This value corresponds to the HIGH period of the given External Signal.

9) The total time period of the given external signal is the period between two Rising Edges (in Counter1).

10) The ratio of the values got in Step 8 and Step 9 gives the Duty Cycle of the PWM Signal.

 

Higher the Frequency of the clock used, better is the resolution of the value obtained.

 

Please let us know if this helps.

 

Regards,

dasg



Re: Pulse Width Meassurement

sebastian.mysyk posted on 07 Jan 2011 05:22 AM PST
Member
4 Forum Posts

Hello,

 

Thank you for the Tips! I had allready found another sullution, but it´s always good to know several ways!

I tried it and it works as fine as my sollution!

 



Re: Pulse Width Meassurement

Zafod posted on 27 Jul 2012 06:27 AM PST
Member
4 Forum Posts

I have tried your method of measureing pulse width, but being very new to Creator (this is my second project) I am stumbling on this project.  Do you have a project built for this?  If so could you forward it to me?

 

Thank you,

Mike Allen

AS&E



Re: Pulse Width Meassurement

Bob Marlowe posted on 27 Jul 2012 07:20 AM PST
Top Contributor
1768 Forum Posts

My best experiences when measuring pulse-width was

Using an up-counter (UDB) with appropiate width. Set period to max, do not care for compare.

Provide the count - input with a stable cloc, connect the clock-input with busclock, connect capture (rising edge) with your signal to measure. Set reload counter at Reset, TC and Capture.

Poll counter state in a loop. When capture has happened read the valid captured value, when overflow or TC has happened the measure is invalid, no signal.

 

Bob

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20