- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a PWM signal coming as an input. I want to read the DC average of the signal. What is the simplest way to do this?
Will using an analog pin do the trick? Or do I have to use a counter ?
-Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK a PWM signal is a digital signal with a specified duty cycle (0 to 100%). Converting that to a DC it would be sufficient to measure period and high time of the signal where period/high time will give the duty cycle. Indeed this can be done best with counters / timers.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I found a thread with some solutions that would fit my needs. Specifically post number #12 has example project by danaknight.
http://www.cypress.com/forum/psoc-5-device-programming/pwm-measurement
But it uses UDB components to detect the falling edges. How do I detect the falling edges without UDB which are not available in PSoC 4100M series.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Setup the pin's interrupt on your needed edge.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have implemented duty cycle calculation with counter/timer. But PWM on a pin requires one counter.
Is there a way to calculate duty cycle of multiple PWM signals using one counter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Setup a pin interrupt for each of the PWMs you have to read. In the handler read a counter used as a time-base. So you can calculate the duty cycle. Are you reading servo-controls in the range of 1 to 2ms?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for the noob question. I didn't understand what you meant by counter used as time-base. Did you mean to setup the interrupt on both rising and falling edges and read a normal up-counter to know the duty-cycle?
The signals are not servo controls. I have six PWM signals that could turn on any time. They are 100Hz signals. They have variable duty cycle. I have to find the duty cycle of the signals when the PWM starts. Some of these signals could also be running simultaneously.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you mean to setup the interrupt on both rising and falling edges and read a normal up-counter to know the duty-cycle? Yes, right. You need 6 input pins, each with an own interrupt.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for the tips. I implemented your suggested method of getting counts from rising and falling edge interrupts on a pin.
The PWM are on Port6 of PSoC4100M series. I get the following error when I try to connect the interrupts to pins of port 6
Port 6 can only support one interrupt at a time and cannot include pin component "Pin_PWM_2" since the port is already assigned an interrupt from "Pin_PWM_1"
Does that mean that I can't use more than one interrupt on the Port-6 and I will have to connect the PWM on other ports?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does that mean that I can't use more than one interrupt on the Port-6 and I will have to connect the PWM on other ports?
Yes. On PSoC4 ports >= 4 are restricted in interconnections and interrupt handling.This has been corrected with the newly introduced _S and -L series.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, now I am facing the same problem with Port2 and Port3. Also I have tried this now on the Pioneer Kit - CY8CKIT-042-BLE.
Does this have something to do with the fact that "PSoC has a single GPIO interrupt vector which is common for all the GPIO pins." as mentioned in the post here
You also have comment in this thread saying that " Since all enabled GPIOs use the same interrupt it is evident to read the states of all engaged pins and exit the ISR as soon as possible because no other GPIO-interrupt can be handled during that time." But this post is quite old.
Best Regards