public static void InitLoopThoughWave(DataBlock db) { find_max = true; delta_time = 0; fine = 0; extreme = 0; extreme_time = 0; m_db = db; adc_ptr = 0; zero = m_db.GetAverage(0); }
override public void SetDataBlock(DataBlock db) { m_db = db; int lastValue = 0; int run = 0; int average = m_db.GetAverage(0); textBox1.Text += string.Format("Average {0}\r\n", average); textBox1.Text += string.Format("Sample Rate {0}\r\n", db.m_sampleRate); textBox1.Text += string.Format("\r\nFreq from zeroes:\r\n", db.m_sampleRate); for (int i = 0; i < db.GetChannelLength(); i++) { int value = db.GetVoltage(0, i);; if (value > average && lastValue < average) { textBox1.Text += string.Format("{0} {1} {2}\r\n", i, run, 1.0 / ((float)run / (float)db.m_sampleRate)); run = 0; } run++; lastValue = value; } textBox1.Text += string.Format("\r\nFreq from self correlation:\r\n", db.m_sampleRate); double old = 10; for (int i = 0; i < db.GetChannelLength() / 2; i++) { double c = correlate(db, i); if (c > old) { double waveLength = 2 * (double)i / (double)db.m_sampleRate; textBox1.Text += string.Format("{0}\r\n", 1 / waveLength); break; } old = c; } }
override public void SetDataBlock(DataBlock db) { m_db = db; int lastValue=0; int run = 0; int average = m_db.GetAverage( 0 ); textBox1.Text += string.Format("Average {0}\r\n", average); textBox1.Text += string.Format("Sample Rate {0}\r\n", db.m_sampleRate); textBox1.Text += string.Format("\r\nFreq from zeroes:\r\n", db.m_sampleRate); for (int i = 0; i < db.GetChannelLength(); i++) { int value = db.GetVoltage(0, i);; if (value > average && lastValue < average) { textBox1.Text += string.Format("{0} {1} {2}\r\n", i, run, 1.0/((float)run/(float)db.m_sampleRate) ); run = 0; } run++; lastValue = value; } textBox1.Text += string.Format("\r\nFreq from self correlation:\r\n", db.m_sampleRate); double old = 10; for (int i = 0; i < db.GetChannelLength() / 2; i++) { double c = correlate(db, i); if (c > old) { double waveLength = 2* (double)i / (double)db.m_sampleRate; textBox1.Text += string.Format("{0}\r\n", 1 / waveLength); break; } old = c; } }