Time Period Measurement Functions
    Phoenix allows precise time interval measurements using the Digital I/O sockets and the Analog Comparator input CMP. The Digital I/O Sockets are specified from 0 to 3 and a value of  '4'  implies the CMP input.
Passive measurement of time interval between level changes

float = r2rtime (integer pin1, integer pin2)
Returns the time interval between a rising edge on pin1 to a rising edge on pin2.  The pins should be different. # Gets the time interval between a rising edge on pin0 to a
# rising edge on pin1 in usec.
data=r2rtime(0,1)

float =  r2ftime (integer pin1, integer pin2)
Returns the time interval between a rising edge on pin1 to a falling edge on pin2. Pins could be the same.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
print p.r2ftime (0,1)

float = f2rtime (integer pin1, integer pin2)
Returns the time interval between a falling edge on pin1 to a rising edge on pin2. Pins could be the same
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
# prints time interval between a falling edge on
# pin0 to a rising edge on pin1 in usec.
 
data=p.f2rtime(0,1)

float = f2ftime (integer pin1, integer pin2)
Returns the time interval between a falling edge on pin1 to a falling edge on pin2. Pins must be distinct.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
# time interval between a falling edge on
# pin0 to a falling edge on pin1 in usec.
data=p.f2ftime(0,1)

float = multi_r2rtime(integer pin, integer skipcycles)
Measures the time between two raising edges. Number of cycles to skip in between can be specified.
# Time taken for 10 cycles
print p.multi_r2rtime(0,9)

float = pendulum_period(integer pin)
Used for measuring the period of oscillation of a pendulum using the light barrier. multi_r2rtime() should have done the job if light barrier output signal has clean edges.
Light barrier connected to Digital Input D3

print p.pendulum_period(3)

Time interval from an action on an Output pin and a level change on an Input pin.
float = set2rtime (integer pin1, integer pin2)
Returns the time interval from setting a bit on output pin1 to the rising edge on input pin2.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
prints time interval in microseconds from setting making Digital Output pin HIGH to the rising edge on the input pin 0.

print p.set2rtime(0,0)

float = set2ftime  (integer pin1, integer pin2)
Returns the time interval from setting a bit on output pin1 to the falling edge on input pin2.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
# Sets the data to time interval from setting output pin0 to # the falling edge on an input pin0 in usec.

data=p.set2ftime(0,0)

float = clr2rtime (integer pin1, integer pin2)
Returns the time interval from clearing the output pin1 to the rising edge on input pin2.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
# Sets the data to time interval from clearing output pin0 # to the rising edge on an input pin0 in usec.


data=p.clr2rtime(0,0)

float = clr2ftime (integer pin1, integer pin2)
 Returns the time interval from clearing the output pin1 to the falling edge on input pin2.
pin1 : 0 to 3 means the Digital output pins.
pin2 : Input pins 0 to 3, or 4 for ACMP input
# Sets the data to time interval from clearing output pin0  # to the falling edge on an input pin0 in usec.

data = p.clr2ftime(0,0)

float = pulse2rtime (integer pin1, integer pin2)
Generates a pulse on pin1 and returns the time interval from that pulse to the rising edge on pin2.
pin1  : 0 to 3 Outputs
pin2  : 0 to 4 Digital inputs of ACMP

pulse2fime() is similar except waiting for a LOW
#Time interval from  a 13 usec wide pulse output pin0 to a
#HIGH on digital input pin 0. LOW TRUE TTL pulse.

print p.pulse2rtime(0, 0)