Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Reading PWM

Status
Not open for further replies.

Kryten

New Member
Hi

I got some inclonometers that give me a PWN out. Can this bee read with a PIC?

I bet i can but some kind of explanation would be nice
 

Space Varmint

New Member
Hi

I got some inclonometers that give me a PWN out. Can this bee read with a PIC?

I bet i can but some kind of explanation would be nice

Sure. You can use port change interrupt to detect activity or to let you know whenever it changes state. You will probably need to use your timer such as TMR0 configured for interrupt so that you can time the pulse width duration. Using those two techniques combined you can scheme up all sorts of ways to tackle it.
 
Last edited:

tarts

New Member
Hey
I started exactly the same thread here:
Reading PWM signal - RC Groups
and successfully completed my project.
In short use Interrupt-on-Change to start and stop the timer. Ie when input goes high reset the timer, when it goes low then read the timer and this is the width of the pulse.
There are other methods doing that but this seemed to be the simplest and most accurate.
And don't forget to add 100nF capacitor close to the 5V supply pins, this will increase the accuracy of reading.
 

Kryten

New Member
Thanks tarts thats kinda what i need.

Although I plan to have it read out a number based on the duty cycle of the PWM but I could possibly use you're code as a base and then just work it to my specs ;)

TY
 
Status
Not open for further replies.

Latest threads

Top