![]() |
Forum Index : Microcontroller and PC projects : Read PWM duration
Author | Message | ||||
cwilt Senior Member ![]() Joined: 20/03/2012 Location: United StatesPosts: 147 |
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: AustraliaPosts: 239 |
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 StatesPosts: 147 |
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. |
||||
bigmik![]() Guru ![]() Joined: 20/06/2011 Location: AustraliaPosts: 2946 |
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) <<< |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |