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

Posted: 11/5/2019 8:32:12 AM
Buggins

From: Theremin Motherland

Joined: 3/16/2017

LTSpice simulation of quadrant heterodyne pitch sensor.

OpAmp based Colpitts oscillator with 5mH inductor (air core 32mm frame 0.1mm wire 70mm winding), tuned to produce ~10KHz frequency change between near and far hand distances.
Analog switch based heterodyne with quadrant output: requires two reference frequency signals - with frequency 1-4KHz bigger than minimal oscillator frequency, two PI/4 phase shifted switch enable pulses, with duty cycle = PI/4 or even less (depends on switch performance).
Output of two LP filters can be feed to Line In since it's in audio range for tuned theremin.

LtSpice model:


Simulation: oscillator output signal and two reference frequency pulses for switch enable:


Single heterodyne ouput for different C_hand:


Heterodyne output FFT (peaks are not narrow enough due to short window length):


Two quadrants heterodyne output: 

This signal may be sampled by MCU (e.g. using audio ADC) to calculate hand position from frequency.
Aplitude probably should be reduced to fit Line In range to avoid clipping (if ACD doesn't have pre-amp with K < 1).
Quadrant signals allow to eliminate amplitude changes - phase can be obtained using tan2() function.

Model to play with can be found on GitHubsin_osc_opamp_v1.asc

If reference frequency is less than 400KHz, Teensy 4.0 is able to generate it with <4KHz step precision (divider from 150MHz timer base frequency should be divisible by 4 to have exact quadrant values). So, output of heteridyne will vary 1KHz..11KHz to 5KHz..16KHz depending on oscillator frequency, if oscillator is designed to produce frequency change 10KHz for full hand distance range.
So, it's ok to use internal PWM or Timer for producing 2 phase aligned ref signals.

Posted: 11/5/2019 9:24:25 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Vadim, I'm probably just dense, but what is the purpose of quadrature here?  Does the phase difference between the two heterodyning outputs give you some information?

Posted: 11/6/2019 3:35:29 AM
Buggins

From: Theremin Motherland

Joined: 3/16/2017

Vadim, I'm probably just dense, but what is the purpose of quadrature here?  Does the phase difference between the two heterodyning outputs give you some information?

Phase difference between two outputs is PI/4 with high precision.

Having single sine output, it's hard to determine phase. Signal may vary by amplitude and phase simultaneously.Exact phase can be determined only at crossing of zero. If we track amplitude, other points may be obtained with asin() but sometimes it's hard to distinguish between sin(x+n) and sin(x-n) points.

Having two sine signals shifted by PI/4 is trivial: (a*sin(phi) and a*cos(phi)) gives exact phase using tan2() independently of amplitude of signal - for every sample. It even allows to track frequencies  f_sample < f < f_sample/2 - if phase diff between two samples is negative, use phase_diff = 2*PI-phase_diff
Both signals should have proper zero point calibration and relative amplitude calibration to produce precise results. But this approach is not sensitive to amplitude change of both signals together (e.g. due to damping while hand approaches antenna or due to increased tank C).

Posted: 11/6/2019 3:18:58 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Thanks for that explanation Vadim!

And thanks for the LTSpice file!  It made me install Wine (Win emulator) in Linux Mint so that I could run LTSpice, something I should have done on day one. 

When I open your sim file it complains that AD8616 and CD4066 aren't found.  I think it's OK to replace AD8616 with AD8618 (which is in the LTSpice library)?  What are you using for CD4066?

Posted: 11/6/2019 4:44:39 PM
Buggins

From: Theremin Motherland

Joined: 3/16/2017

Thanks for that explanation Vadim!And thanks for the LTSpice file!  It made me install Wine (Win emulator) in Linux Mint so that I could run LTSpice, something I should have done on day one.  When I open your sim file it complains that AD8616 and CD4066 aren't found.  I think it's OK to replace AD8616 with AD8618 (which is in the LTSpice library)?  What are you using for CD4066?

Hello,

I believe, I've downloaded collection of LTSpice components from http://ltwiki.org/?title=Components_Library_and_Circuits#A_Large_LTspice_Folder_from_Bordodynov

As an opamp I'm planning to use AD8052ARZ - fast low cost rail-to-rail opamp. AD8616 is used in simulation because there are only a few rail-to-rail opamps in library.

Instead of CD4066 I'm going to use ADG721BRMZ - fast two channel switch with small ON resistance.
CD4066 is the only analog switch I found in ltspice collection.

BTW, does your FPGA have dual channel ADC? If so, quadrant sine approach could provide better results than PLL based one.

Posted: 11/12/2019 1:03:24 PM
Buggins

From: Theremin Motherland

Joined: 3/16/2017

KiCad projects: opamp based oscillator with clean sine output.

Suitable for analog theremins as well.

PCB size is selected based on boxes I found for sensors (mounted near to antenna, contains long 11cm air core inductors on 32mm plastic tube frame).

Prototype PCB: GitHub link - for building on 2.54mm pitch prototyping PCB. ICs are actually soic-8 but soldered on soic-8 to dip8 adapter breakout.
OpAmp replacement: any 3.3V rail-to-rail pin compatible.
SP721 - no replacement, but optional if you don't bother about ESD protection.

SMD version of PCB: GitHub link


Use this LTSpice model for simulation.

Posted: 11/13/2019 11:20:43 AM
Buggins

From: Theremin Motherland

Joined: 3/16/2017

Created Teensy 4.0 Digital Theremin thread on Teensy (PJRC) forum.


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