Welcome to the Parallax Discussion Forums, sign-up to participate.

- 101.5K All Categories
- 812 Announcements
- 47 Propeller Code
- 21 PASM2/Spin2 (P2)
- 4 PASM/Spin (P1)
- 11 BASIC (for Propeller)
- 61 Forth
- 10 C/C++
- 2.8K Propeller 2
- 27.6K Propeller 1
- 18.9K BASIC Stamp
- 9 micro:bit
- 21.1K General Discussion
- 2K Learn with BlocklyProp
- 8.2K Robotics
- 124 Customer Projects
- 3.3K Accessories

## Comments

1,800What if we set min and max dy values? 0 <= |dy| <= 3

13,684Okay. That would be great. Remember they just have to sum to 2040..2047, preferably a single value.

13,6841,800I have the two Tukeys sharing the same taps in BASIC. It half worked first time and completely second time. I'll do the Hann, which won't be quite the same as now, then post the program.

Is this a change or an observation? And side lobes means side lobes, not ramps?

13,684I mean that on the longest filter, the ramp-up and ramp-down are longer.

1,800EDIT:

Add Blackman22 window.

1,800EDIT:

New Blackman window added as fourth one.

1,800I'm curious to know how these windows affect the rise and fall times of square waves. The new Blackman window above is the shortest and thus should have the fastest response.

3741,800Thanks for the graphs.

Was is Vpp98% again? Are the short windows a lot worse than Hann30?

374Generally, the length is the most important factor in how well a filter performs. Probably.

12,17813,684Today I made a 4th-order 22-bit filter that returns a 16-bit sample every clock. You can just do a RDPIN to get a sample.

I modeled an RC integrator and put four in series. The ADC bits feed in as $000000/$3FFFFF. It takes about 256 clocks to settle to a stable 16-bit reading for a steady input pattern. Of course, our ADC is only good for 12 bits, or so, so the filter is overkill.

Here is the filter model in SmallBASIC:

Here is the Verilog code in the smart pin:

This filter works great, but I don't know how practical it is. I think the windowed filters are more realistic, as they are a convenient 8 bits and don't have a RC-looking lag. Plus, they are 50 ALMs smaller. This filter is good for resolution, but not bandwidth.

Here it is sampling a 10KHz 20mV sawtooth. Of sample[15:0], these are bits [8:1]:

13,684Here is the code:

I graphed the filter, too:

1,800How much more logic does this take?

13,684For supporting four windows, it would certainly take less.

374Cutoff frequencies are in MHz and assume a sysclock of 250MHz.

1,800The problem is these new windows are not Hann nor Tukey and I don't know what they are.

1,800http://forums.parallax.com/discussion/comment/1457894/#Comment_1457894

Details of all four are in this edited post:

http://forums.parallax.com/discussion/comment/1457896/#Comment_1457896

There is a family of "raised cosine" windows given by

The new fourth window mentioned above is a Blackman window, which has better stopband attentuation and lower passband ripple than either Hann or Hamming. The chosen Blackman is mostly identical to the Hann and Tukey, which means the logic required to implement it is reduced.

The following table show the taps that are skipped for three of the windows.

The next table shows the plateau taps after the ramps, with the Tukey45 taps at the end of the plateau shift bits. It is easier to see both ramps and the overall similarities between the windows in this second table.

1,800Thanks again for the graphs. Could you please add the new Blackman22 to the above?

http://forums.parallax.com/discussion/comment/1457896/#Comment_1457896

I think it's better to exclude zeroes in the names, hence Tukey68 and Tukey45.

EDIT:

I've noticed that you say the length of Hann30 is 28 but it does have 30 non-zero values.

13,684They are just simple integrations. Close approximation to raised sine.

This SmallBASIC program graphs it all:

Here's the output for the Tukey49:

374cmafilter(8,8,16) = thirdorderfilter(8,0)

cmafilter(4,4,8) = thirdorderfilter(4,0)

cmafilter(4,4,16) = thirdorderfilter(4,8)

cmafilter(8,8,32) = thirdorderfilter(8,16)

cmafilter(8,8,64) = thirdorderfilter(8,48)

cmafilter(x,y,z) is a cascaded moving average. It means filter by a moving average of length x. Then filter the output of that by a moving average filter of length y. Do it again with a moving average of length z. If all 3 numbers were the same it would be a sinc3 filter. This is slightly more general. We basically have a sinc3 with the center part lengthened.

13,684When the program runs in graph mode (g=1), it plots, top-down, the ADC bitstream, a1, a2, a3, a4, and lines for when the filter output has been 16-bit-stable for 10 consecutive samples. Every 320 clocks it switches between 1/6 duty and 5/6 duty, which is what the ADC outputs at GND and VIO readings:

13,684Tony, super work here. This looks very nice. Four good filters.

Do you know what they each sum to? The Blackman22 looks like it goes to 256. Not so sure about the rest.

Thanks for coming up with all these.

1,800Your cascaded third-order filters need more adders bits. I calculate 27 vs 21 and total logic size of the two could be close. I think it would be optimal to have the plateau bits at the end as in the second table.

1,235as far as I recall a RC low-pass corresponds to a PT1 which represents a IIR-Filter. IIR filters are inherently shorter/less expensive to implement than FIR-filters, but have nonlinear phase response and often an non flat passband.

https://gaussianwaves.com/2017/02/choosing-a-filter-fir-or-iir-understanding-the-design-perspective/

1,800Sinc3 uses many more adder bits, of course, so Tukey/Hann/Blackman should be bigger. It's been interesting to work on, if it doesn't make it into rev B.

13,684I wish we had infinite logic, so that we could also implement a 16-bit converter. Then, the streamer could write 16-bit samples to memory whenever it wanted to, as well.

13,684Being able to grab a 16-bit conversion whenever you want it is really nice.

1,800Thanks, Chip. I don't mind if other filters are used, whatever can fit. I counted how many register bits in total were in use the other day for the scope mode and it came to 32x3 + 1x16 = 112. I'm not sure whether that is the limit and the 80 taps you need for one of your cascaded filters are impossible or not. If more bits are available then I could have a look at slightly larger windows that might avoid the need for clamping one of them. Having said that, Hann/Tukey and Blackman might not go together so well as now (see pic below). I've read some good things about the Blackman function, which is a combination of cosine-squared and cosine-squared-squared.