Pulsin command

TinkerJim

Member
I am considering a code containing a “pulsin” command configured to start its timing from a high to low transition on its pin.

I am not clear however on what happens during execution if the line with the pulsin command is encountered when its pin value is low ?

Does execution wait a while for the pin to first go high and then wait another while (up to timeout) for it to go low to start timing the pulse? Or is the command ignored b/c its pin is already low ? Or would it start timing immediately, thus possibly yielding a shortened pulse reading?
 

TinkerJim

Member
Thanks, Hippy. But my question is: if the pulsin command is set up with state = 0, what happens if execution encounters that pulsin line when the pin it is tied to is already low?
 

TinkerJim

Member
Please let me rephrase my question as follows: The 08M2 is running, and pin C.3 is currently low. Next the command “pulsin, C.3, 0, w0” is encountered. Pin C.3 is still low. What happens? Does execution wait to see if pin C.3 goes high? Or does it just skip the command b/c pin C.3 is not already high?
 

hippy

Technical Support
Staff member
Thanks, Hippy. But my question is: if the pulsin command is set up with state = 0, what happens if execution encounters that pulsin line when the pin it is tied to is already low?
If will be waiting for a falling edge. If it does not see that it will timeout after about half a second (655ms) at 4MHz, returning with a zero value in the result variable.

So, the command waits for the pin to go high then times from it then going low. Or timesout.
 

TinkerJim

Member
If will be waiting for a falling edge. If it does not see that it will timeout after about half a second (655ms) at 4MHz, returning with a zero value in the result variable.

So, the command waits for the pin to go high then times from it then going low. Or timesout.
Thanks again, Hippy! That answers the question exactly !!
 

looking

New Member
Hello,

I have a related question to this topic:

What happens if a pulse starts shortly before the timeout of PULSIN occurs?

Will the timeout be restarted and the pulse be measured correctly?
Or is the pulse measurement stopped at timeout and therefore an incorrect (too short) pulselength will be the result?

Thank you.
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

The timing will start at the rising or falling edge of the pulse and will continue for the length of the pulse. The initial waiting timeout is cancelled when the pulse starts.
 
Top