reading PWM with pic

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
yllis
Posts: 10
Joined: Wed Feb 23, 2011 10:18 am
Location: Finland

reading PWM with pic

Post by yllis » Wed Mar 21, 2012 8:25 pm

How to read pulse width modulation (PWM) signal that is fed to a pic?
Should I make a timer which starts with a rising signal and stops with falling signal?
Or should I try to transfer the PWM to analog signal (voltage), which I would be able to read?
Any advise?
thanks already in advance..

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Thu Mar 22, 2012 12:29 pm

It would be a lot more accurate to measure the width directly, but that might depend on the freq/width you're working with.

Perhaps check out the CCP module Tips and Tricks for some ideas http://ww1.microchip.com/downloads/en/D ... 41214a.pdf

yllis
Posts: 10
Joined: Wed Feb 23, 2011 10:18 am
Location: Finland

Post by yllis » Tue Mar 27, 2012 9:37 am

The CCP module tip is just what I needed. Thanks.

I'm trying to figure out how to write the code to use the capture mode in CCP.
I looked the datasheet of my pic (PIC18f2420), and I also looked the "Using PWM with Swordfish" from the SwordfishWiki pages, but I have to admit that they didn't really help me. I'm bit of a noob..

Post Reply