Sure, limit the current into the Propeller pin using a 2.2K resistor, then use one of the counters to measure the pulse width. The attached program measures a high-going pulse in another cog so that you don't have to wait around for the pulse to arrive; when it does the measurement will be made and written to a hub variable.
Yes.
Put a series resistor (3K3 to 4K7) between the prop pin and the signal source.
Use waitpeq or waitpne to wait for a signal transition on the pin and store the value of cnt in a register.
Use waitpeq or waitpne to wait for another signal transition and store the value of cnt in another register.
Subtract the first cnt value from the second to get the number of clock cycles between the two transitions.
Multiply by the period of the clock to get the pulse width.
It only measures the high desired part of the signal, using the low undesired portion for counter and hub activities. It was designed to work like the BASIC Stamp PULSIN function looking for a high pulse.
[noparse][[/noparse]Edit] I've attached an update that measures a high- or low-going pulses. The init() method includes a mode parameter (0 for low, 1 for high).
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
Put a series resistor (3K3 to 4K7) between the prop pin and the signal source.
Use waitpeq or waitpne to wait for a signal transition on the pin and store the value of cnt in a register.
Use waitpeq or waitpne to wait for another signal transition and store the value of cnt in another register.
Subtract the first cnt value from the second to get the number of clock cycles between the two transitions.
Multiply by the period of the clock to get the pulse width.
John Abshier
[noparse][[/noparse]Edit] I've attached an update that measures a high- or low-going pulses. The init() method includes a mode parameter (0 for low, 1 for high).
Post Edited (JonnyMac) : 1/4/2010 7:52:26 PM GMT
John Abshier