Frequency shifter using analytic signal for ST Nucleo F401RE.
Dependencies: UITDSP_ADDA mbed
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2014-11-12
- Revision:
- 2:ba46d7cbb09e
- Parent:
- 0:4269710caf90
- Child:
- 4:04bb0cfea187
File content as of revision 2:ba46d7cbb09e:
//-------------------------------------------------------------- // Frequency shifter using analytic signal // Frequency is shifted toward 100 Hz higher // 2014/11/12, Copyright (c) 2014 MIKAMI, Naoki //-------------------------------------------------------------- #include "mbed.h" #include "ADC_Base.hpp" // for ADC not using interrupt #include "DAC_MCP4922.hpp" // for DAC MCP4922 #include "HilbertTransform.hpp" // Hilbert transform filter #include "coefsHilbert114.hpp" // Coeffisients of Hilbert transform filter #include "DC_Cut_Coefficients.hpp" // Coeffisients of DC-cut filter #include "Biquad.hpp" // For DC-cut filter #include "TwoPhaseGenerator.hpp" // Two-phase generator using namespace Mikami; const int FS_ = 12000; // 12 kHz ADC_Base adc_(A0, FS_); DAC_MCP4922 myDac_; Hilbert<ORDER_> ht_(hm_); // Hilbert transform filter Biquad DcCut_(c1_); // DC cut filter TwoPhaseGenerator cosSin_(100, (float)FS_); // 100 Hz int main() { myDac_.ScfClockTim3(500000); // cutoff frequency: 5 kHz while (true) { float xn = adc_.Read(); // Read from A0 //----------------------------------------------- xn = DcCut_.Execute(g0_*xn); // DC cut filter float yIn, yQn; ht_.Execute(xn, yIn, yQn); // Hilbert transform filter float cos, sin; cosSin_.Generate(cos, sin); // cos and sin float yn = yIn*cos - yQn*sin; //----------------------------------------------- myDac_.Write(yn); // Write to DAC } }