32 lines
429 B
Python
32 lines
429 B
Python
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
import fft
|
|
import IIR_filter
|
|
|
|
class zerocross_meas(object):
|
|
"""docstring for fft_meas"""
|
|
def __init__(self):
|
|
|
|
# Old value
|
|
self.y_old = 0
|
|
|
|
# Zerocross flag
|
|
self.flag = False
|
|
|
|
|
|
def detect(self, y):
|
|
|
|
self.flag = 0
|
|
|
|
# If positive zerocross is detected
|
|
if self.y_old < 0 and y > 0:
|
|
self.flag = True
|
|
|
|
self.y_old = y
|
|
|
|
|
|
|
|
def print(self):
|
|
print(self.freq)
|