Let's Design and Build a (mostly) Digital Theremin!

Posted: 8/4/2026 4:24:31 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Max Headroom

Throughout the project, I've been worried about bad DPLL lock, which is possible due to the strong harmonics associated with square wave drive.  One way to reduce the number of bad lock scenarios is to reduce the operating range of the DPLL, but this has consequences that I didn't anticipate.  Touch the antenna and the LC resonant frequency is instantly and dramatically reduced, but it takes finite time for the drive frequency to catch up, and during that slew other resonant frequencies may be stimulated and locked to.  Limiting the upper or lower range doesn't help, and might actually exacerbate things.  Starting the DPLL at the nominal frequency is a good first step though.

Anyway, now that these scenarios have hopefully been laid to rest via the new hardware / software watchdog, I though it was time to take a fresh look at the lock range.  I decided to remove the lower range limit altogether, and after some testing this appears to be both a simplification of the logic and a good move.  The maximum frequency limit being so close to the smaller inductor resonance has bothered me too, someone could attach a very short antenna and be operating even nearer to the limit.  So I added some headroom here.  The granularity of this adjustment is by octaves, and adding another one doesn't seem to change the operation.  So this appears to be a good move as well.  In summary: YAY!

Posted: 8/5/2026 2:18:32 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Encoder Autopsy

Got a wild hare (hair?) to take apart a couple of encoders to see what makes them tick.  Jumping right in:


Above: Inexpensive generic PEC11 encoder bought off eBay, which is full height.  Note the triple contacts, one on each side to contact the continuous inner section of the toothed conductor, two per side to contact the the toothed section.  The contacts appear to be dry.  Note also generous milky grease on the detent spring.  The internal shaft extension is plastic.


Above: Expensive Bourns PEC11H-4115F-S0020 encoder, which is low profile.  It similarly has two contacts for the continuous inner section, but only one per side for the toothed section.  The shaft is metal all the way through, and there is only a bit of grease on the detent spring.  Notably, there is some form of grease on the conduction side too.


Above: Closer views of the generic encoder (left) and Bourns (right).  Note there is much more lube on the detent side of the generic encoder.  Note also the small plastic shaft end insert on the Bourns which actuates the pushbutton dome switch.

So, what to make of the above?  I think the reason the Bourns has such noisy rotary switch contacts is due to the single contact per side on the toothed section.  Dual contacts make continuous conduction more likely.  The noise could also be due to the grease or whatever being on the conduction side, though that may be there intentionally to extend the life?  The Bourns is supposedly a 100,000 cycle unit, but the batch I bought was so noisy that they're pretty much unusable [LINK].  I wonder if putting some DeoxIT on the contacts might fix the Bourns, or make the generic units last longer?

Posted: 8/7/2026 1:52:54 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

LCD Dimmer

Revisiting the LCD backlight dimming circuit.  The old one was pretty simple, just slightly filtered PWM, with the frequency placed at the highest hum filter notch (200Hz / 240Hz).  This caused interference for one kit builder, so more filtering seemed to be in order.


Above: improved LCD backlight dimmer circuit.

The candidate began as a second order low pass filter based on the single transistor Sallen-Key topology - which can be formed by disconnecting C1 from ground and connecting it to the emitter of Q2.  This turned out to be a bit noisier than a simple 2 RC filter, so I went with that.  I added input buffer transistor Q1 so the impedance could be increased, and C1 & C2 were then reduced to conveniently smaller values.  The buffer also raises the turn on voltage to roughly 1.4V, which is close to the center of the PWM signal driving the input, so we use a PWM duty cycle of 50% for off, and 100% for full on.  Very little power is dissipated by Q2 or R6, so these can be non-power types such as 2N3904 and 0805 (I have yet to encounter a modern transistor that is as versatile as the 2N3904).  R4 is to protect Q1 and Q2 when C2 discharges at power off.  R5 is to prevent self oscillation.  I breadboarded the circuit and drove the input via a function generator and it behaved just like the sim.

Posted: 9/22/2026 3:08:32 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Carolina!


Above: Tammie, Carolina Eyck, and me at Ontario Beach Park, Rochester, NY.

Tammie and I traveled up to Rochester to deliver an Etherwave Pro to Carolina, which she then used in concert this last weekend.  We got to hang out with her for a couple of days, hiked some nature trails, ate at some good restaurants, and sat in on her rehearsal with the orchestra.  Good times!

Posted: 9/22/2026 8:17:41 PM
JPascal

From: Berlin Germany

Joined: 4/27/2016

What a nice photo!

Posted: 9/25/2026 8:10:41 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"What a nice photo!"  - JPascal

It was a very nice visit!  Carolina took us to nature areas where we hiked the trails, and we got to sit in on a rehearsal of the concert she performed in last weekend, which was thrilling!

Posted: 9/27/2026 4:57:06 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

DIY DSE

Whenever I change anything in the D-Lev FPGA logic, I usually have to compile it many times in Quartus before hitting on a build that meets timing (or is close enough).  The builds are tedious because I have to manually change the place & route seed between each build, and the build takes around 5 minutes on my aging PC, so there's a lot of sitting around and babysitting.  This activity is known as "seed sweeping".  The 180MHz processor clock domain is the hardest to reach timing closure, usually giving me results in the high 160s to mid 170s, and rarely a bit higher than 180.

Quartus has a built-in tool to automate this process called "Design Space Explorer".  IMO DSE tries to do too much though, as it juggles various synthesis and place & route build parameters, when all you generally want is a seed sweep of a single initial synthesis result.  I never felt all that secure about committing to the best timing result as there just were too many parameters in play.  In their infinite wisdom, Intel / Altera decided to remove DSE from the free version of Quartus, which strikes me as kinda nuts as a business strategy, but who am I.  They also removed the LogicLock feature, which might have helped me speed up the average build.  And they 86ed the simulator a long time ago.  By all means, let's hobble the hardware we're trying to sell by crippling critical software support of it, that's the ticket.

Anyway, I'm in the process of redesigning the D-Lev kit, and a new FPGA pinout seemed called for in order to help clean up the routing on the main printed circuit board.  One of the really great features of FPGAs is the ability to move the pin assignments all over the place.  I'm sure this has saved many a prototype from the trash.

Back to the build, I consulted with Chat GPT and it suggested a BASH script.  The script opens the config text file that contains the seed number, deletes that line, and adds a new line with the new seed.  It then performs a place & route followed by timing analysis by calling the Quartus command line executable versions of these Quartus modules.  Finally, it greps the timing results file and reports the top speed of both clock domains to the screen and also by appending the results to a text file.  It does all this in a loop, incrementing the seed until it reaches the maximum value specified in the script, and then stops.

Where has this script been all my life?  I've spent many days just doing builds, particularly when designing and implementing the processor.  What a relief!

Here's a the results of sweeping seeds 5 through 10:

Code:
Seed 5:
; 166.09 MHz ; 166.09 MHz      ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 211.19 MHz ; 211.19 MHz      ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;
Seed 6:
; 166.92 MHz ; 166.92 MHz      ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 212.49 MHz ; 212.49 MHz      ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;
Seed 7:
; 181.52 MHz ; 181.52 MHz      ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 219.2 MHz  ; 219.2 MHz       ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;
Seed 8:
; 172.8 MHz  ; 172.8 MHz       ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 212.09 MHz ; 212.09 MHz      ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;
Seed 9:
; 165.7 MHz  ; 165.7 MHz       ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 213.54 MHz ; 213.54 MHz      ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;
Seed 10:
; 175.38 MHz ; 175.38 MHz      ; pll_core|altpll_component|auto_generated|pll1|clk[0]  ;      ;
; 209.16 MHz ; 209.16 MHz      ; pll_spdif|altpll_component|auto_generated|pll1|clk[0] ;      ;

Seed 7 meets 180MHz timing, so I picked that.  The other clock has to hit 196.666666MHz, and it's rare that it doesn't.

Posted: 10/3/2026 1:12:46 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Hard Core Logo *

I'm hoping the whole "use PCB material as panels" works out.  Here is the D-Lev logo plate rendered in KiCAD:

I removed the outer ring that is normally there when the logo plate is 3D printed.  The ring helps to keep everything level when sanding off the matte black spray paint, but I think it looks a bit cheesy.  Here the background is matte black solder mask and the white lettering is silkscreen.  The base is 1.6mm FR4 with HASL over the copper.  The same logo is on the back, so hopefully at least one side will be cosmetically useful.  I ordered quantity 10 from JLCPCB for $13.58 including shipping, and this will be a test for how the larger PCB panels might turn out.

* https://en.wikipedia.org/wiki/Hard_Core_Logo

Posted: 10/11/2026 8:50:03 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Tyranny Of The Familiar

https://www.externaldesign.com/tech-tyranny-of-the-familiar/

Constraints channel creativity, and those constraints are formed from very early decisions that - in the larger scheme of things - may or may not be all that ideal.  After the fact, it's hard to see beyond the mountains that get built on them.  For this project I sometimes wish that I could find a musical / technical person paradoxically raised in a cave, to evaluate it with a clean pair of eyes.  What am I blind to, what early decisions did I (and others) make that might be holding it back?  What's the ultimate Theremin?  Perhaps there's no single answer, but it's likely that there are better configurations waiting to be found.

How much expectation is driven by simple adaptation and familiarity to what's available?

Posted: 10/11/2026 7:11:32 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

LCD Dimmer (take 3)

I took another look at the LCD backlight dimmer circuit and finally settled on this:

Changes:
1. Lowered the filtering RC impedance.
2. Added R5 (100 Ohm) and C3.

Both of these changes were due to my worrying that the strong electric fields might influence the circuit.  On the bench I noticed that my finger touching either lead of R5 caused the LED to light, so it was a relatively high impedance point, and C3 fixed this.

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