Thursday, 26th June 2014

In an experiment  to study oscillations of a loaded spring, we could obtain position time data and plot graph.

To determine the spring constant of the given spiral spring we need to measure frequency and time periodic time.

Today I could get this done by fitting the data by writing the following code…

from pylab import *
import expeyes.eyesj, time
import expeyes.eyemath as em

p = expeyes.eyesj.open()
p.set_state(10,1)
f = open(‘srf.dat’,’r+’)
ta = []
da = []
strt = time.time()
et =0
while et < 30:
dist = p.srfechotime(8,3)
et = time.time() – strt
ta.append(et)
da.append(dist)
s = ‘%5.3f\t %d’%(et,dist)
#s = ‘%d\t %d’%(et,dist)
f.write(s + ‘\n’)
print s
time.sleep(0.1)
vfit, par = em.fit_sine(ta,da)
print par
plot(ta, vfit)
plot(ta,da)
#plot(t,v)
show()

 

par[1] gives frequency of oscillations..

Now I will create the  GUI and the experiment will be completely ready…. 🙂