// test_filter1st.thd // demonstrates the use of a first order filter model // // include models we need #include "gensin.thd" #include "filter1st.thd" // set up model var AMP = 1; var gen = GenSin(AMP, 6.28, 0); // 1 Hz generator with amplitude AMP, and shift 0 var filter = Filter1st(gen.m_state , 1, .1); // Filter gen signal time const = .1, gain = 1 // set up diagram var g = Graph("Filter"); // helper functions for plotting the diagram function f_gen() { return gen .m_state.value; }; function f_filter() { return filter.m_state.value; }; g.addSeries(f_gen, -AMP ,AMP ,RGB(0,128,0), GRAPH_MIN_Y|GRAPH_MAX_Y, "gen"); g.addSeries(f_filter, -AMP ,AMP ,RGB(255,0,0), GRAPH_MIN_Y|GRAPH_MAX_Y, "filter1st"); // simulate while (simulator.time < 1) { simulator.run(.01); };