Hi all,
I'm looking to understand the math behind the pulsin command.
I have seen some examples and some posts here but also giving diferent maths.
The background objective is to try and measure the output signal of a Futaba RX.
I will be working with a 4Mhz pic, but here's my thoughts:
Resolutions
20Mhz - 2us
10Mhz - 4us
4Mhz - 10us
The pulses that will be measured will be:
pulse left = 1ms
pulse center = 1.5ms
pulse right = 2ms
( all in a 20ms period )
Now, I need to count these pulses and detect if it’s a 1ms,1.5ms or 2ms within the 20ms frame.
I will maybe have to use DEFINE PULSIN_MAX 2000 to limit pulsin to 20ms.
So far so good...
Searching the net i've seen an example code using a 4Mhz pic and was like this:
SERVOMAX CONST 165
PULSIN portd.0, 1, W0
IF W0 > SERVOMAX THEN
Portb.0 = 1
ENDIF
My interpretation of this code is that the pulsin return value of a 2ms pulse would be ~200.
Now, i've seen somewhere here a math like : ( For a pulse of 1.5ms and 10Mhz clock ) : 150*10/4=375 counts
Assuming that math for a pulse of 2ms and a 4Mhz clock would be : 200*4/10=80 counts
My doubt is :
Since the resolution for 4Mhz is 10us, the count for a 2ms pulse shouldn’t be, not 80, not 200 BUT 20 ?
Thanks
Bookmarks