Jared Baxter
/
Impedance_Fast_Circuitry
Impedance Fast Circuitry Software
Fork of DSP_200kHz by
Diff: main.cpp
- Revision:
- 81:30d699e951a8
- Parent:
- 80:7a4856c596fc
- Child:
- 82:f6fbbb8a2139
--- a/main.cpp Thu Aug 03 17:38:02 2017 +0000 +++ b/main.cpp Wed Aug 30 00:02:06 2017 +0000 @@ -46,10 +46,11 @@ -#define pre_compute_length 500 -#define demodulation_length 125 -#define CarrierFrequency 200 +#define pre_compute_length 176 #define SAMPLEFREQUENCY 100000 + +#define CarrierFrequency (float(SAMPLEFREQUENCY)/pre_compute_length) + //float i_mod_pre[demodulation_length+(INPUT_ARRAY_SIZE/DECIMATION_FACTOR)]; //float q_mod_pre[demodulation_length+(INPUT_ARRAY_SIZE/DECIMATION_FACTOR)]; uint16_t out_val_pre[pre_compute_length]; //used to write values to the dac @@ -59,7 +60,7 @@ void pre_compute_tables() { // This function will precompute the cos and sin tables used in the rest of the program for(int precompute_counter = 0; precompute_counter < pre_compute_length; precompute_counter++){ - out_val_pre[precompute_counter] = (int) ((cos(twopi * CarrierFrequency /SAMPLEFREQUENCY * precompute_counter)+cos(twopi * 1000 /SAMPLEFREQUENCY * precompute_counter+3.14159265359)) * 1023.0 + 2048.0);//12 bit cos wave + out_val_pre[precompute_counter] = (int) ((cos(twopi * CarrierFrequency /SAMPLEFREQUENCY * precompute_counter)) * 2046.0 + 2048.0);//12 bit cos wave } //float decimated_frequency = 6250; @@ -89,6 +90,15 @@ pc.baud(230400); + float test_crashing = 1.0/0; + if (isinf(test_crashing)) + pc.printf("INF DETECTED"); + test_crashing = sqrt(-1.0); + if (isnan(test_crashing)) + pc.printf("NAN DETECTED"); + pc.printf("Demod Freq: %d\n\r",DEMOD_1000HZ); + pc.printf("1/0: %f\n\r", 1.0/0); + pc.printf("sqrt(-1): %f\n\r", sqrt(-1.0)); //pc.printf("High: %x Mid: %x Low: %x",SIM->UIDH,SIM->UIDML,SIM->UIDL); @@ -139,11 +149,12 @@ filters f2 = filters(4, 8, &f3, 8, 64, Coeffs_12500,DEMOD_No_Demod); filters f1 = filters(2, 8, &f2, 64, 64, Coeffs_100k,DEMOD_200HZ); + /* filters f4_b = filters(4, 8, NULL, 8, 32, Coeffs_782,DEMOD_No_Demod); filters f3_b = filters(4, 2, &f4_b, 4, 32, Coeffs_1563,DEMOD_No_Demod); filters f2_b = filters(4, 8, &f3_b, 8, 64, Coeffs_12500,DEMOD_No_Demod); filters f1_b = filters(2, 8, &f2_b, 64, 64, Coeffs_100k,DEMOD_1000HZ); - + */ //filters f_pre = filters(2, 2, &f1, 64, 64, Coeffs_50k,false); //float output_print_buffer[PRINT_BUFFER_LENGTH];//used to store the adc0 values(current measurment) @@ -202,7 +213,7 @@ //input_50k[0] = static_input_array0; //input_50k[1] = static_input_array1; f1.input(input_50k,64,DEMOD_200HZ); - f1_b.input(input_50k,64,DEMOD_1000HZ); + //f1_b.input(input_50k,64,DEMOD_1000HZ); //status_3 = 1; //pc.printf("Y"); //status_3 = 0;