You only need to place your timer code inside the DoSample function. Everything else should be outside the function. So it should looke something like this:
Code:
def DoSample():
global AMPLITUDE, TOTALCYCLES, X1, X2, samples
data1 = flock1.get()
HEADLAT = data1[0]
HEADVERT = data1[1]
HEADAP = data1[2]
HEADYAW = data1[3]
HEADPITCH = data1[4]
HEADROLL = data1[5]
head_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(HEADAP) + '\t' +str(HEADLAT) + '\t' +str(HEADVERT) + '\t' +str(HEADYAW) + '\t' +str(HEADPITCH) + '\t' +str(HEADROLL) +'\n'
tracking_data.write(head_data)