Teensy 4.0 600MHz ARM Cortex M-7 MCU - ideal for digital MCU based theremin?

Posted: 2/24/2020 4:49:03 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"If distance close to antenna falls into such region, it's not a problem at all.

But if unlikely such point corresponds to hand distance far from antenna, it would become unplayable (playable distance will at least drop to 60-70 cm instead of 90-100)."  - Buggins

I'm betting you'll find 1.0 m out pretty much moot in terms of anyone wanting / trying to play there.  It's a laudable goal, and I can get the D-Lev to respond to pinky movements pretty far away, but it doesn't have any real, practical value as even slight body movements and other environmental "noise" entirely swamp it.  Even 0.6 m is way out there on the edge iMO (0.6 m for me is my hand right at my side).  Early on, my dream was to play "Somewhere Over the Rainbow" with just my pinky at 1.0 m, and now I see that as more of a gimmick than anything else.

Would the introduction of a bit of dither help break up these points?  Perhaps environmental noise will be sufficient here?  The D-Lev needs dither to "pave over" sticky spots where the LC period aligns perfectly with some integer multiple of the sampling clock, is that what's happening here?

I'm wondering what would happen if you replaced the running average FIR with IIR?  That way the most recent sample is weighted the most, and the filter construct is incredibly compact and fast in SW with minimal memory needs so you can cascade a bunch of them if you like.

Also, there is the matter of mains hum to address at the end of this.  Without the variable 4th order IIR and a series of notch filters at the mains fundamental and harmonics, the D-Lev would likely be plagued with hum.  All of this requires a somewhat high sampling rate (I do it at the audio rate of 48kHz) and care so that hum and such don't have a chance to substantially alias down into the useful passband of ~100Hz.  Hum filtering in the digital domain is THE major thing you can do to clean up the axis numbers.  Mine are so clean now that I can see the individual data steps at null.

[EDIT] Also wanted to add, if you can get the thing to be linear right up to the antenna, then this opens up a real playing range for the player that isn't normally there for them on analog Theremins.  This means the player can use more of the creamy smooth near-field which responds mainly to the hand, and abandon some of the problematic far-field which unfortunately responds to pretty much anything and everything.

Posted: 2/24/2020 6:14:05 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017

At 60cm, even current filter will work. Let's target to more practical and realistic distance

Tried adding some noise to oscillator edges.
It looks like it helps to cleanup up small spikes.
E.g. with noise which moves deviation for most of points from 1 to 10, there is visible change.
Non-major points disappeared.
Main points - F_BUS / K still there, and have mostly the same value.
Even divider gives x2 bigger peak than odd one.
There are ~5 smaller peaks between odd and even divider points, with value ~2, 3, 4, 5.. times smaller than odd peak.
Not sure what would be real noise level on sensor input. It will become clear after testing on real hardware.

Will try some different filtering as second stage. Maybe different window to FIR filter instead of rectangular. Maybe IIR. Not sure if IIR will not be affected by these special points.

Does 50/60Hz noise really modulates oscillator frequency? 
Is it applicable to simple oscillator, not PLL one? Shouldn't high voltage on antenna (+-80V in my model) reduce this effect?

Posted: 2/24/2020 7:53:42 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Tried adding some noise to oscillator edges.
It looks like it helps to cleanup up small spikes.
E.g. with noise which moves deviation for most of points from 1 to 10, there is visible change.
Non-major points disappeared.
Main points - F_BUS / K still there, and have mostly the same value."  - Buggins

The most effective dither is added before any truncation to form the clock.  For instance, adding pseudo-random noise vector to the NCO phase accumulator value (but don't accumulate it) and using the MSb of this as the output clock.

I'm currently adding a synchronous 48kHz triangle wave to the PLL NCO frequency input, which obviously dithers the frequency, and which gets removed by synchronous sampling at 48kHz.  I believe most of this makes it to the LC as the PLL cutoff is set to ~2kHz (the PLL can't track it quickly enough).

"Not sure what would be real noise level on sensor input. It will become clear after testing on real hardware."

I think, unless you do high resolution heterodyning (?), or your sample clock is literally or effectively > 1GHz, then some form of dither is generally necessary.

"Will try some different filtering as second stage. Maybe different window to FIR filter instead of rectangular. Maybe IIR. Not sure if IIR will not be affected by these special points."

Probably not?

"Does 50/60Hz noise really modulates oscillator frequency? 
Is it applicable to simple oscillator, not PLL one? Shouldn't high voltage on antenna (+-80V in my model) reduce this effect?"

I believe it is applicable to all oscillators.  My thinking is if the oscillator responds to your hand movement then it probably responds just as well to oscillation of the electrical field around it (same thing?).  Higher voltage just reduces other interferers (such as oscillator internal noise), and is an indication the LC has high Q, thus is more selective (better at rejecting adjacent RF) than low Q.

Posted: 2/25/2020 4:10:11 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017

Played a bit more with my simulation.

Output of first stage (new_counter_value - delayed_counter_value)%counter_width for fixed input frequency produces two values, a and a+1.
To check if it's a or a+1, we just take bit 0 from first stage value.
Let's check how it does look like.

At some points it looks like pseudorandom noise.


Code:
980064.2598497419 2048 2048 513554567 6 513554569.73 1.827
    near diff 2048 pos 10000
    period*2038~=249535 pattern=11110101011110101011110101011010101111010101111010101111010101101010111101010111101010111101011110101011110101011110101011110101
    period*2040~=249780 pattern=00101010100101010100101010110101010010101010010101010010101011010101001010101001010101001010100101010100101010100101010100101010
    period*2042~=250024 pattern=01010101001010101001010100001010100101010100101010100101010000101010010101010010101010010101001010101001010101001010101001010100
    period*2044~=250269 pattern=10101011110101011110101111110101111010101111010101111010111111010111101010111101010111101011110101011110101011110101011110101111
    period*2046~=250514 pattern=01010000001010000001000000001000000101000000101000000100000000100000010100000010100000010000001010000001010000001010000001000000
    period*2048~=250759 pattern=10111111110111111111111111111111111011111111011111111111111111111111101111111101111111111111110111111110111111110111111111111111
    period*2050~=251004 pattern=00000000000000000100000000100000000000000000000000010000000010000000000000000000000001000000000000000000000000000000000100000000
    period*2052~=251249 pattern=11111111011111101011111101011111101111111101111110101111110101111110111111110111111010111111011111111011111111011111101011111101
    period*2054~=251494 pattern=00000010100001010100001010100001010000001010000101010000101010000101000000101000010101000010100000010100000010100001010100001010
    period*2056~=251739 pattern=11110101011010101011010101011010101111010101101010101101010101101010111101010110101010110101011110101011110101011010101011010101
    period*2058~=251984 pattern=00101010110101010110101010110101010010101011010101011010101011010101001010101101010101101010100101010100101010110101010110101010


Locally, it's periodic signal with some period, e.g. in sample below period is 5. But this periodic pattern changes at some rate. It alternates between two patterns with number of 1s changing by 1.
E.g. 11000 and 11100, or 10000 and 11000.


Code:
990105.671752909 2048 2048 508346213 18 508346224.30 5.534
    near diff 2048 pos 10000
    period*2038~=247004 pattern=0001000010000100001000010000100001000010000100001000010000100001000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000100001000010000100001000010000100001000010
    period*2040~=247246 pattern=0010000100001000010000100001000010000100001000010000100001000010000100001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110000100001000010000100001000010000100001000010000100
    period*2042~=247489 pattern=1110011100111001110011100111001110011100111001110011100111001110011100111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110011100111001110011100111001110011100111001110011100
    period*2044~=247731 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111111111111111111111111111111111111111111111111111111111
    period*2046~=247973 pattern=1001110011100111001110011100111001110011100111001110011100111001110011100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000111001110011100111001110011100111001110011100111001110011
    period*2048~=248216 pattern=0001000010000100001000010000100001000010000100001000010000100001000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100001000010000100001000010000100001000010000100001000010
    period*2050~=248458 pattern=0010000100001000010000100001000010000100001000010000100001000010000100001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100001000010000100001000010000100001000010000100001000010000100
    period*2052~=248701 pattern=1110011100111001110011100111001110011100111001110011100111001110011100111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111100111001110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111100111001110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111100111001110011100111001110011100111001110011100111001110011100111001110011100111001110011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111100111001110011100111001110011100111001110011100111001110011100
    period*2054~=248943 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111111111111111111111111111111111111111111111111111111111111111111
    period*2056~=249185 pattern=1001110011100111001110011100111001110011100111001110011100111001110011100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001110011100111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001110011100111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001110011100111001110011100111001110011100111001110011100111001110011100111001110011100111001110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001110011100111001110011100111001110011100111001110011100111001110011
    period*2058~=249428 pattern=0001000010000100001000010000100001000010000100001000010000100001000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000010000100001000010000100001000010000100001000010000100001000010



Point with period 15:


Code:
983066.8302437316 2048 2048 511986024 5 511986026.57 1.649
    near diff 2048 pos 10000
    period*2038~=248773 pattern=11111100000001111111100000001111111100000001111111100000001111111100000001111111100000001111111100000001111111100000001111111100
    period*2040~=249017 pattern=11111100000111111111100000111111111100000111111111100000111111111100000111111111100000111111111100000111111111100000111111111100
    period*2042~=249261 pattern=11111100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100
    period*2044~=249505 pattern=11111101111111111111101111111111111101111111111111101111111111111101111111111111101111111111111101111111111111101111111111111101
    period*2046~=249749 pattern=11111011111111111111011111111111111011111111111111011111111111111011111111111111011111111111111011111111111111011111111111111011
    period*2048~=249993 pattern=11100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100011111111111100011
    period*2050~=250237 pattern=10000011111111110000011111111110000011111111110000011111111110000011111111110000011111111110000011111111110000011111111110000011
    period*2052~=250482 pattern=00000011111111000000011111111000000011111111000000011111111000000011111111000000011111111000000011111111000000011111111000000011
    period*2054~=250726 pattern=00000011111100000000011111100000000011111100000000011111100000000011111100000000011111100000000011111100000000011111100000000011
    period*2056~=250970 pattern=00000011110000000000011110000000000011110000000000011110000000000011110000000000011110000000000011110000000000011110000000000011
    period*2058~=251214 pattern=00000011000000000000011000000000000011000000000000011000000000000011000000000000011000000000000011000000000000011000000000000011



Point with period 3:


Code:
989035.6999165233 2048 2048 508896161 16 508896169.90 4.420
    near diff 2048 pos 10000
    period*2038~=247271 pattern=11111111111111111111111111111111111111111111111111101101101101101101101101101101101101101101101101101111111111111111111111111111
    period*2040~=247513 pattern=10010010010010010010010010010010010010010010010010000000000000000000000000000000000000000000000000001001001001001001001001001001
    period*2042~=247756 pattern=00100100100100100100100100100100100100100100100100110110110110110110110110110110110110110110110110010010010010010010010010010010
    period*2044~=247999 pattern=11111111111111111111111111111111111111111111111111101101101101101101101101101101101101101101101111111111111111111111111111111111
    period*2046~=248241 pattern=10010010010010010010010010010010010010010010010010000000000000000000000000000000000000000000001001001001001001001001001001001001
    period*2048~=248484 pattern=00100100100100100100100100100100100100100100100100110110110110110110110110110110110110110110010010010010010010010010010010010010
    period*2050~=248727 pattern=11111111111111111111111111111111111111111111111111101101101101101101101101101101101101101111111111111111111111111111111111111111
    period*2052~=248969 pattern=10010010010010010010010010010010010010010010010010000000000000000000000000000000000000001001001001001001001001001001001001001001
    period*2054~=249212 pattern=00100100100100100100100100100100100100100100100100110110110110110110110110110110110110010010010010010010010010010010010010010010
    period*2056~=249455 pattern=11111111111111111111111111111111111111111111111111101101101101101101101101101101101111111111111111111111111111111111111111111111
    period*2058~=249697 pattern=10010010010010010010010010010010010010010010010010000000000000000000000000000000001001001001001001001001001001001001001001001001


Second stage filter averages these values and gives us additional bits of useful information. Averaging is working while second stage filter window is much longer than period of pattern alternation.

But near some points (I suspect it's F_TIMER * A / B where A and B are integers) it becomes too deterministic - periodic sequence switches to different values too slow, maybe slower than length of filter window size.
Changing of delay value leaves period the same, just providing different average.
E.g. below there is a point with output data period = 5


Code:
freq diff width period min max-min avg exactS
990098.8173689365 2048 2048 508349644 364 508349759.47 142.302
    near diff 2048 pos 10000
    period*2038~=247005 pattern=1100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100
    period*2040~=247248 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2042~=247490 pattern=0001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001
    period*2044~=247732 pattern=0111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111
    period*2046~=247975 pattern=1111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111
    period*2048~=248217 pattern=1100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100
    period*2050~=248460 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2052~=248702 pattern=0001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001
    period*2054~=248944 pattern=0111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111
    period*2056~=249187 pattern=1111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111011110111101111
    period*2058~=249429 pattern=1100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100011000110001100



Another point with period = 6


Code:
990371.5647311745 2048 2048 508209529 307 508209769.77 102.861
    near diff 2048 pos 10000
    period*2038~=246938 pattern=0110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111
    period*2040~=247180 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100
    period*2042~=247423 pattern=1000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000
    period*2044~=247665 pattern=1001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000
    period*2046~=247907 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011
    period*2048~=248150 pattern=0111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111100111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111110111
    period*2050~=248392 pattern=0110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000110000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111
    period*2052~=248634 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100000100
    period*2054~=248877 pattern=1000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000011000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000001000
    period*2056~=249119 pattern=1001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111001111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000111000
    period*2058~=249361 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011



Really bad point: contains mostly 000s or 111s. At some long intervals 0 switches to 1 and then back. Interval of switching is longer or comparable to second stage FIR filter width.


Code:
999998.2614211813 2048 2048 503316480 2017 503317406.50 722.912
    near diff 2048 pos 10000
    period*2038~=244560 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2040~=244800 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2042~=245040 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2044~=245280 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2046~=245520 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2048~=245760 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2050~=246000 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2052~=246240 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2054~=246480 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2056~=246720 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    period*2058~=246960 pattern=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    near diff 2048 pos 22345
    period*2038~=244561 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2040~=244801 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2042~=245041 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2044~=245281 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2046~=245521 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2048~=245761 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2050~=246001 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2052~=246241 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2054~=246481 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2056~=246721 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    period*2058~=246961 pattern=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


Second stage filter will not help to fix this allignment, unless it's FIR with low cutoff frequency. But in this case, we will have big latency.

Tried to add dithering to osc signal (synchronous to osc signal, with frequency/512). No effect.


W/o this second stage filter (and as a worst case if far distance interval falls into bad area), we will have 16 bits of data.
Probably it's not bad. E.g. at 60cm, 5 bits still left. I hope it should be enough.
In lucky case, 5-7 additional bits will be available.

Tuning oscillator to good area seems to be tricky: it's necessary to fit into ~2KHz interval (0.02pF precision trimmer cap?).
Would not tuning be destroyed by changed environment (e.g. theremin moved to another place)? What is typical C range influenced by environment?


UPD: two ideas how to gain more bits in worst case:
1) After some distance threshold, dynamically increase delay in first stage of filter. Up to 2 bits may be collected for x4 increased latency on far distances.
2) If it's hard to tune oscillator frequency to fit good area (without second stage degradation), why not change timer frequency? CPU clock can be set in 12MHz steps, and F_BUS (which is F_CPU/4) has 3MHz steps, which is smooth enough.

Posted: 2/26/2020 2:14:08 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Really bad point: contains mostly 000s or 111s. At some long intervals 0 switches to 1 and then back. Interval of switching is longer or comparable to second stage FIR filter width."  - Buggins

I believe this is a form of aliasing, the generation of troublesome low frequency data.  The only solution I know of is continuous dither of either the source (osc in this case) or the receiver clock (processor crystal).  The minimum necessary dither amplitude (in terms of instantaneous phase) is obviously one sample clock period, measured at the reciever.  One could also slowly vary the source frequency by some small amount to break these modes up.  (The D-Lev dithers the source with an adjustable amplitude 48kHz triangle wave).

You could conceivably generate a square wave synchronous to your lowest final sampling rate, filter with RC and somehow feed it to your oscillator to modulate it a bit.  Seems pretty fiddly though.

Posted: 2/26/2020 2:57:18 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017

Update on sensor performance investigaton results.

Implemented IIR filter as second stage using floating point.

It has 4 stages, and the same filter K in range 0.001..0.003 in all stages.

Input of IIR is output of first stage - sequence of differences between captured timer counter for recent edge and one delayed by 2048 edges.

Falling and raising edge information goes in the same flow. So, 2048 half-periods corresponds to 1ms, with effective introduced latency 0.5ms

I'm not sure how to determine latency introduced by IIR filter.

Below there are simulation results for frequency range between two peak error points.
Floating point results are scaled to match one from FIR second stage. 1 corresponds to 10+1 bits from first stage (delay + double edges, 1024*2) + 10 bits from second stage FIR.

Standard deviation less than one means that we have 20-21 bits of useful information introduced by two stages of filtering.

Input of filter has its own about 4 meaningful bits, so total number of bits from sensor is 24-25.
On diagrams, you can find standard deviation value by frequency.
Vertical axis 1024 corresponds to all 10 bits of theoretical gain from second stage are wasted. 256 corresponds to only 4 bits collected from second stage.
Value less than 1 means 1024 or more bits are added by second stage of averaging.

Results for filter K = 0.0025:

Results for filter K = 0.0015:

The smaller K is, the better it filters out peaks at resonance points.
With K=0.0015 there are 2 bits in worst case, 10bits for 70% of frequencies, 8 bits for 98% of frequencies, 6 bits for 99.5% frequencies.


Are deviation peaks really as bad as they look?

Let's try to analyze output of filters near bad point.

On charts below, difference between filter output and input frequency, scaled to 1024 as first stage LSB.

On horizontal axis, 1 corresponds to 0.1ms

Oops, sines appear.

Filter output is modulated with sines. Middle point is exact frequency value.

Zooming in.

The closer input frequency is to resonance, the bigger is amplitude of sine, and lower its frequency.

When input frequency is getting too close to resonance point, filter transforms sines to strange pulse like waveforms.

With amplitude 18, modulation frequency is ~500Hz

With amplitude 100, modulation frequency is ~300Hz

Amplitude 300, modulation is ~200Hz

Amplitude 500, modulation is ~140Hz

Amplitude 600, modulation is ~40Hz

I'm not sure if smaller modulation frequencies can be generated by sensor.

Even if this frequency modulation of sensor output could be audible, it's not a bug, it's a feature - free automatic vibrato

If it's still unpleasant behavior, we can try to change timer clock. Teensy 4 F_CPU has 12MHz steps, and hence F_BUS can be set with 3MHz step.

I believe it's enough to make sure that far hand distance falls into quiet region.

UPD: images fixed

Posted: 2/26/2020 3:23:34 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017


I believe this is a form of aliasing, the generation of troublesome low frequency data.  The only solution I know of is continuous dither of either the source (osc in this case) or the receiver clock (processor crystal).  The minimum necessary dither amplitude (in terms of instantaneous phase) is obviously one sample clock period, measured at the reciever.  One could also slowly vary the source frequency by some small amount to break these modes up.  (The D-Lev dithers the source with an adjustable amplitude 48kHz triangle wave).

You could conceivably generate a square wave synchronous to your lowest final sampling rate, filter with RC and somehow feed it to your oscillator to modulate it a bit.  Seems pretty fiddly though.


I tried to implement oscillator signal synchronous dithering in simulator. It should be synchronous to oscillator because filter is synchronous to oscillator, not to sampling frequency. I believe it's not a problem for sound synthesis, because new pitch value is required by start of new frame (~once per 1000 cycles), and value from filter will be smooth enough. Inside frame, pitch and volume will be interpolated (linear interpolation should work fine).

My plan was to add /256 divider clocked from sensor oscillator, convert it to triangle with RC, smooth oscillator square wave to have less sharp edges, and mix dithering with oscillator signal, and then pass to buffer. Signal edges should be shifted slowly forth and back with 1/256 of oscillator clock. Dithering should be removed by any FIR filter with window = n*256

Whatever parameters for dithering I'm trying to set in simulator, I don't see any useful effect on peak levels.

Posted: 2/27/2020 3:17:36 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017

Update of theremin sensor filter investigation using simulation.


Modified sensor simulator app, added several features.
Now it calculates "exact bits" parameter for each tested frequency. It takes min/max values and calculates offset from real frequency, taking max from offsets - absolute max error.
log2(measuredValue / absoluteError) gives number of valid bits in result.
After removing of unchanged top bits (4.5 bits, 5% range is used), remaining value is exact bits count - number bits which contain only useful hand position information w/o any noise/modulations.

With first stage filter delay 4ms, following results are achieved:

31513 of 31513 (100.000%) cases with exact bits > 22.0
31507 of 31513 (99.981%) cases with exact bits > 23.0
31497 of 31513 (99.949%) cases with exact bits > 24.0

22 bits are guaranteed. Altough, in most of cases there are 28 bits.
Even 22 bits should be enough for playable distances 60-70 cm.

Chart showing number of exact bits vs frequency.

Reducing of latency to 3ms (2ms for filter and 1 ms for audio out) reduces worst case number of bits by 1, to 21, but with better latency.
Reducing of latency to 2ms (1ms for filter and 1 ms for audio out) reduces worst case number of bits to 20.

BTW, what is audible latency when playing theremin?

It's enough for building Teensy 4 theremin with oscillators connected directly to MCU board pins.
Let's experiment on real hardware.


Posted: 2/27/2020 6:29:18 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"BTW, what is audible latency when playing theremin?"  - Buggins

It wouldn't surprise me at all if some "real" (analog) Theremins have some volume latency, so this isn't limited to digital Theremins.  However, I don't believe it's possible for analog Theremins to have pitch latency.

But there's a difference between delay type latency and low pass filter type latency.  Delay type latency or "transport delay" (like a delay line where the bandwidth isn't necessarily impacted) is tolerated less well, and for percussive digital controllers like piano the upper limit seems to be around 10ms or so.  Low pass filtering or "inertial delay" is different IMO, and setting your filtering BW to 100Hz (or perhaps even lower) should be fine. 

For example, the Theremini BW is two orders of magnitude below this, and I don't think noobs (their market) tend to notice it.  But everyone will definitely notice 1s of transport delay.

Rule of thumb to keep in mind when pondering transport delay: sound travels ~3ms / m, so if your speakers are 1m away that's 3ms right there.  Is that disorienting?

Posted: 2/27/2020 7:30:44 PM
Buggins

From: Porto, Portugal

Joined: 3/16/2017


It wouldn't surprise me at all if some "real" (analog) Theremins have some volume latency, so this isn't limited to digital Theremins.  However, I don't believe it's possible for analog Theremins to have pitch latency.

But there's a difference between delay type latency and low pass filter type latency.  Delay type latency or "transport delay" (like a delay line where the bandwidth isn't necessarily impacted) is tolerated less well, and for percussive digital controllers like piano the upper limit seems to be around 10ms or so.  Low pass filtering or "inertial delay" is different IMO, and setting your filtering BW to 100Hz (or perhaps even lower) should be fine. 

For example, the Theremini BW is two orders of magnitude below this, and I don't think noobs (their market) tend to notice it.  But everyone will definitely notice 1s of transport delay.

Rule of thumb to keep in mind when pondering transport delay: sound travels ~3ms / m, so if your speakers are 1m away that's 3ms right there.  Is that disorienting?

So, audio IO delay is transport delay, and Teensyduino Audio Library's default frame size 128 samples (1000/(44100/128)=2.9ms) is actually the same as additional 1 meter from loudspeaker. It looks like even w/o modification of this parameter definition, it's in usable range. Reducing it to 32 gives 0.73ms, leaving more time for trading on averaging.
I believe once prototype on real hardware is ready, it will be easy to tune sensitivity/latency in practice.
"Inertial delay" at least should not eat vibrato. Should be low enough to allow correction of pitch by player.
The, if up to 10ms delay is ok, Teensy 4 has enough chances for implementing fast enough high sensitive sensor.
I hope I won't face 50/60Hz noise problem. Not sure how it could be resolved with MCU.

Theremini is real piece of crap. I'm wondering how did Moog's engineers managed to build such laggy sensors? Even Open.Theremin has better playability.
Vibrato on Theremini doesn't work at all. It's hard to play on ot for inexperienced player because of delay when trying to correct note pitch.
But I saw as Peter Thermen played on it well.
Even display is very slow LCD. Fast LCD with tuner could help a bit. But display itself updates in a second.
The only good part of this device is synthesizer. Some presets are great. Especially "Ethereal" one.
My own Theremin lays partially disassembled somewhere. I was thiking about using its cabinet and antennas for my own design.
But all parts are mounted on melt plastic sticks instead of screws. Cheap. But you cannot unmount any PCB w/o damage of mounting.


BTW, how do you estimate latency introduced by IIR filter, it has infinite response?
Passing step signal on it, checking how fast it changes? What is threshold?
Can we count time to reach 1/2 of target value, 2/3, or something like this?

You must be logged in to post a reply. Please log in or register for a new account.