- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good morning,
I don't manage to find a solution to measure the duty cycle in a PWM signal . I have to measure firstly a constant duty cycle for one signale, secondly i have to treat a signal with variable duty cycle ( such as a sine turned into a PWM modulation) ? How to solve the problem ?
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Easiest approach will be to use a timer that counts on a given internal frequency. The capture input of the timer will save the actual count which you can read-out in a connected interrupt where you reset the timer again.
When using two of these construct you are able to measure both the high-time and low-time of your signal.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Something like this ? D produces a high pulse = period width of PWM inout, its ISR
reads and resets counter.
Set capture on - edge, with ISR enabled in component, capture width
of PWM high time when ISR fires and capture register read.
Resolution clk show = 1 uS measurement resolution, 16 bit counter
can count a period up to ~65K us.
I think you can replace D and its inverter with a T F-F, just did not look at this.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One mod, move PeriodISR to falling edge of period indicator from D, eg. the output
of inverter / data input to D.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello Dana , i need the PWM measurement too. I will give your schematic a try, but i miss some detail info about the proper Counter configutration.
maybe you even have this as little creator project at hand to share. b.r. Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a project, but not working. Seems interrupts not working the way
I wanted, so stumped at the moment, and today have other commitments
so cannot work on it.
The project is PSOC 3 based, runing on -030 board, so you would have to
change device, and should compile into PSOC 5 OK, or so I think.
Note I fixed all re-entrant errors in project, so on PSOC 3 compiles w / no
errors or warnings.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks Dana for sharing your project.
i did porting to kit LP050 and some code workaround (and both ISR).
but results are still not the way i want. 😞
i have no possiblity to change PeriodISR to falling edge as mentioned.
the result i want to get for lcd is:1st line: D.C.xx.yy %
2ndline : Frequency:xx.yy kHz
can you pimp my projectcode for doing so ?
my test signal is TTL 1.02kHz fixed frequency and 0.01 to 99.90% variable duty cycle
from a 2D-rotation hallsensor(360° in 12bit-PWM_angle resolution).
need the correct duty-cylcle value for further calculations of position-change speed..
b.r Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The period ISR taken off the D output, then inverted, is effectively falling
edge, end of the period. The D high time, or its low time for that matter, either width, is =
period of the input signal. So you set the period ISR to rising edge, the D and inverter
take care of the rest.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Attached is a basic project you can modify to suit your needs. Measures pulse width
and duty cycle. It does this not on every input cycle as it is not a pure HW approach
and I chose to do it with one timer. With two timers you could do it on a per cycle basis,
or use Verilog for an optimal; solution.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello dear dana,
thank for your reviewing my project and make it work.
best regards Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Markus
Where are you located? I live near Bremen, Germany
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Bob
I live near Augsburg and work in Kaufbeuren (Allgäu).
greetz from southern Bavaria. Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello dear dana,
thank you for sharing your simplified project. As it works fine on PSoC5LP so far, I like to port your latest Creator-project to
PSoC4000 ( CY8C4013SXI-410) device for having a very small and low-cost solution for wanted flow-meter application comunicating via I2C to host device (PSoC3 based).
unfortunately there is no logic inside the small PSoC400 device, so i consider to use external inverter
and two pins for inputig the PWM-test signal.
PSoC'in is challenging fun.
best regards Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may use a CY8C4245xxx which you can get for $1 at this time in single quantities and that chip includes some logic.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Bob
I consider the PSoC42xx device for a more valuable flowmeter with segment LCD drive, also but later to come.
The PSoC4000 device family came to my mind, while it is the tinyest part with low-pincount (SOIC-8) Cypress offers,
also operating from same +5Volt voltage rail as Hall sensor IC.
planned PCB will have round shape with only 17mm diameter carrying a 4-Pin Molex picoblade (1.25mm) Conector, Hallsensor IC (SOIC-8), PSoC and bypass capacitors to fit the flowmeter hardware. Parts will be mounted on both sides of a doublesided PCB.
Size matters in this particular case, to keep design simple and cheap.
Otherwise i would like to use the more powerful PSoC's of course.
I dont want to use an old 8-bit PIC for new design....so i give the PSoC4000 family a try.
have a nice weekend. greetz - Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Possibly you could use the pin configurable interrupt (it has a falling edge
selection) to get the - edge interrupt for the high time measurement.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Looks like part cost is 40% less -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello dear Dana
I gave your suggestion for the pin with interrupt generation ( falling edge ) a try, but got only ridiculous readings.
any idea what to change to make it work like your solution with inverter included ?
regards Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may be affected by oring of GPIO for interrupts, and not clearing
ISR. Take a look at this thread, towards the bottom -
http://www.cypress.com/?app=forum&id=2232&rID=74969
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
well, I apologize for warming this up again, I am new to PSoC and I am trying to port this project to a PSoC 4 (4245 Chip) and I am loosing hair at an alarming rate. Please, can someone help me or point me in the right direction as I am having to use an UDP counter.
Many Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Kayle,
We recommend you to create a new thread with your query with the right key word as subject rather than adding your query as comment to an old thread. You might not get the attention from our contributors when you comment on an old thread and also we recommend to keep the discussion aligned with the question asked in the thread, so that it will be helpful for other members who are searching for answers.
Best Regards,
VRS