View previous topic :: View next topic |
Author |
Message |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
Capturing a PWM output, is there a module for this ?? |
Posted: Tue Jul 18, 2017 9:12 pm |
|
|
Hi,
I want to capture the PWM output from a AS5048 position encoder IC (https://www.digikey.com/product-detail/en/ams/AS5048B-HTSP-500/AS5048B-HTSP-500CT-ND/3188619)
Is there a dedicated module on a18F or 16F PIC micro controller for this ??
thanks
a |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Tue Jul 18, 2017 9:21 pm |
|
|
The CCP (capture/compare) module will do what you want. The CCP works in capture mode with a dedicated timer to "capture" the timer's count when a rising edge or a falling edge, or, depending on the particular PIC, any edge is seen on the CCP input pin. When a capture event is seen, an interrupt fires. It's up to you to figure things out based on the timer and the line's state and how you set it up.
The only thing the CCP module has problems with is fast edges/high frequencies. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Wed Jul 19, 2017 4:23 pm |
|
|
I was curious about the device so downloaded the pdf. While almost any PIC can capture the PWM 'value' (1KHz rate) you will have to do some 'math'.
While the PWM signal is 4096 bits there's an extra 24 for Init, error and exit times. Those 24 bits will have to be subtracted from the overall 4119 bits.
Good news is there's an SPI interface you need to use to program the device, so you can simply read the position registers and compare to your 'compute PWM output' function to tweak your math.
Jay |
|
|
|