A Solution to measure following levels ...
Hi, Wirecut
Pulsin is a command that MUST wait for the leading edge ...
so, if you want to measure, say a PWM signal, you're tempted to Write :
PULSIN Input, 1, Hilev1
PULSIN Input, 0, Lolev1
...
... Am I right ???
But using Pulsin twice will do the Following :
READ correctly the High level ...
RESET it's detection mechanism ( some µs necessary !!! )
WAIT for an incoming falling edge
READ the Low level pulse
RESET it's detection mechanism ( some µs necessary !!! )
WAIT for an incoming rising edge
READ the High level pulse
then it doesn't see the falling edge for the 1st following Low level ( has happend some µs ago !!! )
THEN it will wait for the NEXT falling edge ... wich is the SECOND low level state ...
so, let's resume ...
you read hi state 1, lo state 2, hi state 3, lo state 4
INSTEAD of : hi state 1 , lo state 1, hi state 2, lo state 2 .... etc, etc
TURNAROUND ...
PULSIN Input, 1, Hilev1
RCTIME Input, 0, Lolev1
RCTIME Input, 1, Hilev2
RCTIME Input, 0, Lolev2
...
if using a 4Mhz clock, add 1 unit correction to RCTIME measured values
if using a 20 Mhz clock, add 4 units to RCTIME Measured values
And now, you'll get your values right !!! ... or very, very, very, very close, to be honest !!!
Alain
Last edited by Acetronics2; - 9th May 2008 at 12:47.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks