0
\$\begingroup\$

I have implemented a 20 order FIR Low pass filter, 1000 HZ cutoff frequency on Sparten - 6 FPGA. First I calculate the coefficients in Matlab, Then I directly put them in vhdl code. Here are my coefficients.

H(0) <= to_signed(26,16); --10000HZ cutoff
H(1) <= to_signed(67,16);
H(2) <= to_signed(169,16);
H(3) <= to_signed(369,16);
H(4) <= to_signed(686,16);
H(5) <= to_signed(1111,16);
H(6) <= to_signed(1606,16);
H(7) <= to_signed(2108,16);
H(8) <= to_signed(2542,16);
H(9) <= to_signed(2836,16);
H(10) <= to_signed(2940,16);
H(11) <= to_signed(2836,16);
H(12) <= to_signed(2542,16);
H(13) <= to_signed(2108,16);
H(14) <= to_signed(1606,16);
H(15) <= to_signed(1111,16);
H(16) <= to_signed(686,16);
H(17) <= to_signed(369,16);
H(18) <= to_signed(169,16);
H(19) <= to_signed(67,16);
H(20) <= to_signed(26,16);

Now Actually I am taking an torque feedback Input from some sensor, The torque is converted in voltage. The voltage is digitize into 16 bit format.The filtered value, output of the filter is in 32 bit format.

Here is the snapshot of Teraterm. How do I convert the these values to voltages ? enter image description here

enter image description here Thanks.

Edited: On Page number 16 of this document they have given the conversions:

Now They have discussed about +IN, -IN, Vref. I would like to give my voltages here which I can measure on the adc pins using a multimeter:

enter image description here

Now ADC datasheet part: enter image description here

Now the Digitized displayed values:

enter image description here

All of the above three image are recent. so How to relate the voltages at pins and the digitized value of voltage on the MISO pin, which I displayed on real term.

finally how to understand that what value of filter output represent what voltage ? What is the effect of applying FIR filter here ? Did it do something good or not ?.. In matlab simulations It definitely does some good & removes the peaks, but I am not able to understand in the implementation.

Thanks please someone.

\$\endgroup\$
1
\$\begingroup\$

Defining Vin as (+IN) - (-IN).

This is a Bi-Polar ADC with the output in 2's Complement Format. In 2's complement the MSB is considered to be negative, specifically a value of -32768 for a 16bit number. This gives a range of 0 to 32767d for positive inputs and 65535d to 32768d for negative inputs. Or in binary 0 to 0111111111111111 for 0 to positive fullscale and 1111111111111111 to 1000000000000000 for -1LSB to negative fullscale.

The gain from your ADC voltage (Vin) to data output is:

D = Vin/Vref * 2^(n-1) for positive Vin

D = (Vref+Vin)/Vref * 2^(n-1) + 2^(n-1) for negative Vin

So in your case (assuming a positive Vin) D = Vin/2.96 * 2^(15) so for Vin=1V D = 1/2.96 * 2^15 = 11070d and any ADC value >= 32768 is negative (i.e. -IN > +IN)

When you apply this to the FIR filter there is a gain factor associated with the filter taps. Remember the transfer function is: sum(x*h) where x is the input data sequence and h is the coefficient sequence so the DC gain is sum(h). For your example that's 25980d (by my calculation).

So applying 1V to the ADC (differentially) gives 11070d at ADC output and 11070 * 25980 = 287598600 at the output of the FIR.

Or working backwards: Vin = FIR_output/25980 * 2^(-15) * 2.96

e.g. for FIR_output = 413365728

Vin = 413365728/25980 * 2^(-15) * 2.96 = 1.437V

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ 1. My ADC output ranges like (When I am changing the torque value by hand) : increase from some lower value to 32768 and when I increase torque more.. It starts from 1 then goes to 32768 again. 2. For 1st image (Teraterm): Vin: 24100*2.96/2^(15) = 1.17v & the FIROUT: 413365728/25980*2^(-15)*2.96 = 1.437 v. Why is it increasing? the voltage should decrease after application of FIR, As I am using it to remove peaks from my input voltage. Thanks a lot for such interest. \$\endgroup\$ – user3217310 Aug 8 '14 at 16:32
  • \$\begingroup\$ I am printing the values as: xil_printf("FIR_datain: %d FIR_dataout: %d \n\r",reversedNum, reversedNum1); Should I use something else other than %d so that I can get values greater than 32768 ? \$\endgroup\$ – user3217310 Aug 8 '14 at 17:39
  • \$\begingroup\$ I've added some explanation of 2's complement where the MSB is considered negative (-32768). So any value >32768 is negative. This probably explains what you're seeing. \$\endgroup\$ – akellyirl Aug 9 '14 at 10:07
0
\$\begingroup\$

The ADC value is proportional to the voltage, ideally so that the largest value it can express is equivalent to the reference voltage. From that, you can calculate the number for 1V, and divide the ADC value by this number to get voltage.

The filter multiplies a constant signal by a factor that is equal to the sum of the coefficients. You will have to divide the end result by this value.

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Hi I added more details to the question. Can you be more specific in your answer now maybe you can give me some calculation too ? \$\endgroup\$ – user3217310 Aug 8 '14 at 12:12
  • \$\begingroup\$ The additional details do not add anything of value to the computation. The ADC output is going to be relative to \$V_{ref}\$, so you need to know this voltage -- it is not in the data sheets. \$\endgroup\$ – Simon Richter Aug 8 '14 at 13:01
  • \$\begingroup\$ The filter just introduces a multiplication, which you have to reverse, and a delay, which you can't reverse without looking into the future. \$\endgroup\$ – Simon Richter Aug 8 '14 at 13:02
  • \$\begingroup\$ The Vref is 2.96 volt, as I measured it on the pin. \$\endgroup\$ – user3217310 Aug 8 '14 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.