PDA

View Full Version : Need help with PULSIN Timings



Ryan7777
- 10th June 2011, 15:34
I am using a 16F684 with the internal OSC set to 8Mhz and I'm trying to read a 5 volt PWM signal that has the following widths:


1.4mS
1.6mS
2.4mS
3.3mS
4.4mS
5.4mS
6.0mS
8.0mS
9.0mS


I know that PULSIN depends on the actual OSC speed and not the defined OSC speed. and 4MHz will have 10uS resolution, which means 8MHz should have 5uS resolution in my thinking, maybe I'm wrong. If so, then all of my numbers divide nicely by 5 and 1.4mS should equal 1400uS in my PULSIN Variable right? or something close enough.


or would my above widths measure something else in the variable?

Darrel Taylor
- 10th June 2011, 19:56
At 8Mhz, the resolution is 5uS.
But the pulsin result for 1.4mS should be ~280 ... (0.0014 / 0.000005)
at 9.0mS it's ~1800 ... (0.009 / 0.000005)

You'll probably want to adjust the PULSIN_MAX define if 9.0mS is the maximum width.