DSP program for the Surfboard hardware (PCB to be open sourced) http://www.avbotz.com/ourauv/electrical/signal-processing/

Dependencies:   MODDMA SimpleIOMacros mbed-dsp mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers hydro_dsp.cpp Source File

hydro_dsp.cpp

00001 #include "hydro_dsp.h"
00002 
00003 arm_iir_lattice_instance_q15 iir_filter[NUM_CHANNELS];
00004 
00005 // TODO: need an A and B for each possible frequency
00006 // our pinger: 27k
00007 // dave's pinger(s): TODO: ask about this
00008 q15_t A_27k0[FILTER_ORDER] = {};
00009 q15_t B_27k0[FILTER_ORDER+1] = {};
00010 
00011 // Set these variables to select which set of coefficients (taps) we use
00012 q15_t* A_select = A_27k0;
00013 q15_t* B_select = B_27k0;
00014 
00015 q15_t state_arr[NUM_CHANNELS][FILTER_ORDER + BLOCK_SIZE];
00016 
00017 q15_t filtered[BLOCK_SIZE];
00018 
00019 void setup_dsp()
00020 {
00021     memset(state_arr, 0, 2*NUM_CHANNELS*(FILTER_ORDER + BLOCK_SIZE));
00022     for (int i = 0; i < NUM_CHANNELS; i++) {
00023         arm_iir_lattice_init_q15(iir_filter+i, FILTER_ORDER, A_27k0, B_27k0, state_arr[i], BLOCK_SIZE);
00024     }
00025 }
00026 
00027 // Figure out where the wave starts in the filtered output
00028 // TODO: does this work?
00029 // Returns the index of the first "high" in the signal or -1 if there is none
00030 int find_timestamp_tdoa(q15_t* filtered)
00031 {
00032     // Uncomment the num_hits stuff if our filtering sucks
00033     //char num_hits = 0;
00034     for (int j = 0; j < BLOCK_SIZE; j++)
00035     {
00036         if (filtered[j] > TDOA_THRESH || filtered[j] < -1 * TDOA_THRESH)
00037         {
00038             return j;
00039             /*num_hits++;
00040             if (num_hits > TDOA_MIN_NUM_HITS)
00041             {
00042                 return j;            
00043             }*/
00044         }
00045     }
00046     
00047     return -1;
00048 }