I want to use the TMS320F28035+ADS1298 devices to detect ECG signals.To do this, processor should be HPS (0.005Hz), BSF (50 Hz), LPF (150Hz) filters. For this I use the function IIR5BIQ32 from C28x_DSP_fixed_point_library and EZIIR tool for filter design.
The experimental conditions:
1. hardware: ECG simulator, TMS320F28035+ADS1298+TFT to resistration and display ECG, XDS100 v2 debuger.
2. software: CCS v4, C28x_DSP_fixed_point_library (use IIR5BIQ32 function), Matlab 2006, EZIIR tool.
3. Sample frequecy 500, data from ADC 24bit, investigated by various filters varinty (bat, cheb type 1, ceb type2, elep), bandstop supression 20-40 db, bandpass ripple 0.1 db.
4. At TFT visually comparing the signal to the filter and after filter.
At the moment, I have developed and tested LPF and BSF. It is work fine. But HPS not work. I experimented with the LPF and BSF and all worked well.
Experiments with HPF showed that there is a dependence on the filter cutoff frequency:
1. Fp=30Hz, Fs=10 - all types HPF work fine.
2..Fp=10Hz, Fs=5Hz - Filter work (stop constant and low frequency part of signal), but bed. After filtering the signal noise appears.
3. Fp=10Hz, Fs=1Hz (or every 1<Fs<Fp<10 Hz) - filter not work, output everytime zero. (In matlab all normals)
4. Fp=1Hz, Fs=0.1Hz, or Fp=0.1 Fs=0,05, or Fp=0.05 Fs=0,005(or 0.01) (it is my target) (or every 0.01<Fs<Fp<1 Hz) - filter not work, filter output of large-amplitude chaotic sgnal. I think the filter is not stable. (In matlab as before, all the normals)
Questions:
1. Data format.
In documentation on the function IIR5BIQ32 of states: the format of input data Q31 and output data same Q31. So I have to make a shift to 8 my 24-bit signed number (ADC result), and I will get a number in the format of Q31. So I have to make the shift to the left to 8 bit my 24-bit signed number (ADC result), and I will get a number in the format of Q31. If the filter output in the format Q31, the number obtained after the filter I need shift to right to 8 bit, that the number was in the original format. But if I do it (shift to the right of adding to the eight values of the sign in the leftmost 8 bits, as usual), the amplitude of the signal after the filter 2 times less than before the filter (I can see it on the screen), although it should remain the same. Hence the output value of the filter should be shifted to the right by 7 bits, and the format of the output Q30 and not Q31. This was confirmed by my experiments on all types of filters.In the description of the functions IIR5BIQ32 there is an error? Am I right or wrong?
2 HPF filter.
I would like to know what the above described problem with the HPF filter. Function IIR5BIQ32 is working not correctly, or EZIIR program working not correctly.
And most importantly - how do I filter (for example - fourth order chebishev type 2) with a cutoff frequency less than 10Hz (5, 1, 0.5, 0.1, 0.005, etc.), using the EZIIR tool and the IIR5BIQ32 function? Write a function IIR filter, I can `t own, use the FIR filter as there is no possibility of a large hardware requirements FIR filter (especially memory).
Thanks in advance.
Chukavin Andrej.
Hi,
Andrej Chukavin93807In the description of the functions IIR5BIQ32 there is an error? Am I right or wrong?
The filter coefficients generated by the eziir routine have a scaling factor associated with it and it may be close to 0.5 in your case which is why you are seeing the discrepancy in the amplitudes. The examples in the eziir_matlab.pdf doc show a few examples of this. It isnt explicitly mentioned anywhere so ill make a note to put it in the guide on the next revision. So you can shift left 8, process, then shift right 8 but you will need to compensate for the scaling factor......
Andrej Chukavin93807how do I filter (for example - fourth order chebishev type 2) with a cutoff frequency less than 10Hz
Ill try to create a HPF based on the parameters in your post and get back to you with my findings
Regards,
Vishal
Hello I do not quite understand what you said about scaling factor.
Here is a sample calculation of the two filters:
and second:
Input scaling value first 0.5279, and second 0.0111. But the output value of both filters is twice the amplitude is less than the input (test signal - 2 Hz sine wave, both filters transmit it without distortion). After the filter, I multiply the signal by 2 (divide by 0.5), and the amplitude of the signal becomes an input. If I use these values of the input scale (divide by 0.5279 for the first filter and 0.0111 for the second filter), the first course and runs second to none.
it is my code:
// chenal[4] - signed long, there is ADC 24 bit data
chenal[4]=(chenal[4]<<8); // format Q31
iir.input=chenal[4]; // in filter
iir.calc(&iir); // filter
chenal[4]=iir.output32; // out filter
chenal[4]= (chenal[4]&0x80000000)|((chenal[4]>>1)&(0x3FFFFFFF)); // format Q31->Q30
chenal[4] = _IQ30div(chenal[4], _IQ30(0.5)); // use IQmath function for divide
if ((chenal[4]&0x800000000)==0x800000000) // return to the original format of the data - signed long, 24 bit ADC result
{ chenal[4]=(chenal[4]>>7); chenal[4] = 0xFF800000|chenal[4];}
else chenal[4]=(chenal[4]>>7);
Question: How should I take a scaling factor of output signal from the filter. (In these examples, the value of 0.5 was obtained experimentally).
Just to cite an example of high-pass filter does not work (This is for second question of this topic):
So i went through the example project in controlSUITE, the inverse scaling factor is fed into the IIR structure itself so you dont have to compensate for it. I tried the settings you described in the post and sure enough, there is a divide by 2 in the output. I compensated for it while storing the result....this doesnt cost you anything in terms of assembly instructions, the assembler will use a MOV with shift instruction.
As for the HPF case, the problem is with the inverse scaling factor ISF = 8.5406e-6, which when scaled to the Q format for the design (QFMAT = 13 so scale by 2^13 = 8192) it will round to 0 and this is why your output is all zero. MATLAB wont have any issues as it works in double precision. If possible you might try relaxing the filter parameters