def calibrate_ROM(self):
		threshold = 50
		x_ = self.neutral

		#hold min
		m = []
		for ii in range (10):
			x = pwt.measure_pw_us(channel)
			# will usually throw away the first point
			if np.absolute(x - x_) > threshold:
				ii -= 1
			else:
				m.append(pwt.measure_pw_us(channel))
			x_ = x
		self.min = sum(m)/len(m)

		#hold max
		M = []
		for ii in range (10):
			x = pwt.measure_pw_us(channel)
			# will usually throw away the first point
			if np.absolute(x - x_) > threshold:
				ii -= 1
			else:
				M.append(pwt.measure_pw_us(channel))
			x_ = x
		self.max = sum(M)/len(M)

		c = []
		for ii in range (10):
			x = pwt.measure_pw_us(channel)
			# will usually throw away the first point
			if np.absolute(x - x_) > threshold:
				ii -= 1
			else:
				c.append(pwt.measure_pw_us(channel))
			x_ = x
		self.neutral = sum(c)/len(c)
#=========================
# OPEN WRITE STREAM
#=========================
# File needs to be removed before execution
ofile = open('signal.csv','wb')
w = csv.writer(ofile, delimiter=',',quoting=csv.QUOTE_NONE)

print('Write stream initialized')
w.writerow([aileron, elevator, motor, rudder])

#=========================
# EXECUTE PROCESSES
#=========================
try:
	while(True):
		pw = int(pwt.measure_pw_us(aileron_in))
		# aileron.set_pw(pw)

		aileron_filt = cheby2.rtfilter(pw, ic_input, ic_filter)
		aileron.set_pw(aileron_filt['y'])
		ic_input = aileron_filt['ic_input']
		ic_filter = aileron_filt['ic_filter']

		w.writerow([pw, aileron_filt['y']])
		# w.writerow([pw])
		stdout.write("\rPulse Width: %d" %pw)
		stdout.flush()

except KeyboardInterrupt:
	pass