Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:54 25 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Read PWM duration

Author Message
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 03:39pm 29 Apr 2012
Copy link to clipboard 
Print this post

I have a need to read the duration of a PWM pulse. I tried using Setpin pin, 4 for period measurement but no luck. My next idea is to use 2 interupts. One for rising edge, the other for falling, and record the time between.

Any better ideas?
 
vk4tec

Senior Member

Joined: 24/03/2012
Location: Australia
Posts: 239
Posted: 11:32am 30 Apr 2012
Copy link to clipboard 
Print this post

I know how to do it in Assembly Language

You wait for a rise ( or fall ) and then start a counter.

You wait for a rise ( or fall ) and then stop a counter.

Based on clock speed and instruction cycles, I then know.

And XTAL freq .

- Andrew -
Andrew Rich VK4TEC
www.tech-software.net
 
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 09:10pm 30 Apr 2012
Copy link to clipboard 
Print this post

Andrew,

I assumed that is what the duration setting is for setpin, but it always seems to return 0. I am using 2 xbee's to do IO pass through. Analog in on the remote produces a PWM output on the local xbee. Duration varies with voltage on the remote pin.

I have not found any example code using the duration setting. Perhaps I am not doing it in the proper order.Edited by cwilt 2012-05-02
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2914
Posted: 10:01pm 30 Apr 2012
Copy link to clipboard 
Print this post

  cwilt said   I have a need to read the duration of a PWM pulse. I tried using Setpin pin, 4 for period measurement but no luck. My next idea is to use 2 interupts. One for rising edge, the other for falling, and record the time between.

Any better ideas?


Gday Cwilt,

How small is the smallest expected pulse likely to be? That might help in assisting your answer..

Also is the pulse likely to repeat often etc? (I assume it would)

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024