Yoichi Nagashima
/
CQ_nagasm_08_notch_test
add 60Hz/50Hz notch filter
Revision 1:8fa2f521009a, committed 2014-12-16
- Comitter:
- nagasm
- Date:
- Tue Dec 16 23:41:53 2014 +0000
- Parent:
- 0:5ec74240d7f1
- Child:
- 2:048d8bddb100
- Commit message:
- update - notch on/off, etc.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
notch.hpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Dec 16 08:28:20 2014 +0000 +++ b/main.cpp Tue Dec 16 23:41:53 2014 +0000 @@ -8,6 +8,7 @@ xbee.baud(38400); xbee.attach(&rx_fifoset, xbee.RxIrq); timer_setup.attach_us(&timer_interrupt, 5); // 5usec + notch_1 = notch_2 = 60; coef_set(60); // Ham notch filter set while(1){ tx_fifo_check(); @@ -16,7 +17,7 @@ float data1 = (float)gain * (analog_value2.read() - 0.5f); // A/D in (3) if (data1 < 0) data1 = -data1; // always detection ON if (fir_lpf != 0) data1 = FIR_calc1(data1); // FIR calc (1) call - data1 = notch_filter1(data1); + if (notch_1 != 0) data1 = notch_filter1(data1); if(timer_value[2] > 2999){ // 15msec timer_value[2] = 0; if(max_count != 0) data1 = move_mean_calc1(data1); @@ -28,7 +29,7 @@ float data2 = (float)gain * (analog_value3.read() - 0.5f); // A/D in (4) if (data2 < 0) data2 = -data2; // always detection ON if (fir_lpf != 0) data2 = FIR_calc2(data2); // FIR calc (1) call - data2 = notch_filter2(data2); + if (notch_2 != 0) data2 = notch_filter2(data2); if(timer_value[4] > 2999){ // 15msec timer_value[4] = 0; if(max_count != 0) data2 = move_mean_calc2(data2); @@ -57,6 +58,12 @@ sum_clear(); break; case 0x03: + notch_1 = sum & 0x01; + break; + case 0x04: + notch_2 = sum & 0x01; + break; + case 0x05: coef_set(sum & 0x3f); break; }
--- a/notch.hpp Tue Dec 16 08:28:20 2014 +0000 +++ b/notch.hpp Tue Dec 16 23:41:53 2014 +0000 @@ -34,6 +34,7 @@ const float _50Hz_a1 = 1.937188, _50Hz_a2 = -0.939101, _50Hz_b1 = -1.999013, _50Hz_c0 = 1.938304; float a1, a2, b1, c0; float y1[3], y2[3]; +int notch_1, notch_2; void coef_set(int herz){ if(herz < 55){