Calculate Elapsed time using PiMotion™ Timer¶
This Python code calculates the elapsed time using the PiMotion™ timer.
import pilib
import time
def ns_to_s(t):
# function to convert nanoseconds to seconds
return (float)(t/1000000000.)
# make a connection to the PiMotion
pm = pilib.Pidev('192.168.1.200')
t_0 = pm.time_get_clock() # read the time from pimotion
time.sleep(1.0) # stay here for 1.0 seconds
t_1 = pm.time_get_clock()
t_diff = t_1 - t_0 # calculate the elapsed time
print ("Elapsed time = %f" % (ns_to_s(t_diff)) )