Alternate ways to generate tone

Posted: 5/2/2013 12:50:15 AM
thewriter

Joined: 5/2/2013

Hi,

I'm currently designing a digital theremin (ie: no analog components) for fun and I've reach a road-block in my design.
From what I've gathered online, the theremin subtracts two oscillating signals, a fixed and a variable oscillator, to send to the speaker. Furthermore, the variable oscillator is affected by the placement of the user's hand in relation to the verticle antenna (this acts as a capacitor and this flux causes a change in frequency). The subtracting takes the two signals outside of the audible range (ex: 501kHz and 500kHz) and an audible tone (501-500=1kHz). This makes sense since each tone would have a varying frequency depending on placement of the hand.

If any of that is incorrect, please please correct me.

So, again, I want to design it purely (well, as much as possible) in the digital domain. I thought of using a look up table containing values for a 20kHz sine wave. However, this is a fixed frequency and I would theoretically only produce one tone at varying volumes.

What determines the frequency range of the variable oscillator? I can model a fixed oscillator as a look up table, but I can't do that with a variable oscillator.

Sorry if this is confusing. English is not my primary or first language.

Posted: 5/2/2013 1:39:21 AM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

Your understanding is more-or-less correct..

You say "This makes sense since each tone would have a varying frequency depending on placement of the hand."

Thinking in terms of "tones" is probably misleading.. With a conventional theremin, there are two high frequencies, one is fixed at say 285kHz, and the other is variable (controlled by hand capacitance) and will go lower as the hand approaches the antenna (capacitance increasing).. this variable oscillator will be tuned to go from 285kHz at the "null" position (furthest from the antenna, say about 60cm) down to say 281kHz with the hand almost touching the antenna..

The difference frequency will therefore go from 0Hz (null) at 60cm, to 4kHz (285k-281k) closest to the antenna.

To implement an all digital theremin is not possible..

The signal being looked at / used to produce an audio tone is an analogue signal - capacitance change - whatever method you use to obtain this data, it is analogue, and if you want to process / produce an audio signal digitally from this data, you need to do some form of analogue to digital conversion.

Analogue to digital, in this context, could mean having an analogue front-end (AFE) which produces a difference frequency (effectively a conventional theremin front end) which produces logic level outputs you can feed to your digital stuff..

Or you can do it some other way - As Dewster is doing - Driving an oscillator digitally and looking at phase change for example.

But forget the idea of "no analogue components" - If you can design something which works even slightly usably and doesnt need inductors (coils) you would be doing better than anyone else ;-) ..

May as well try to design a theremin which used no conductors. You are setting yourself an impossible (and pointless) goal - it cant be done!

Just for fun ?!  ;-) ... Herein lies the crunch - If you are not interested in a playable instrument, you could use a couple of (or perhaps even one) TS555C timer IC's - they run up to 2.7MHz, and can connect directly to an antenna as the "timing capacitor" and give a usable change of frequency from changing hand capacitance - feed this frequency into your digital stuff and you have the simplest capacitance sensor available.. Or you could use a PSoC Capsense part and do it all in the chip..

But both of the above, even if they look "digital" are in fact analogue front-ends - And both are useless for making a usable musical instrument.

Fred.

Posted: 5/2/2013 5:35:36 AM
thewriter

Joined: 5/2/2013

Thank you for the response. I really appreciate the length and detail you put into it.

"If you are not interested in a playable instrument...you have the simplest capacitance sensor available."

Would this not produce an as accurate sound? I am indeed looking to build a playable instrument. If I wanted to use an AFE, what would be the best way to generate the oscillation?

Most of my experience is in the digital domain and I have very little analog experience (by experience I mean exposure to theory and application).

I read up a bit on the capsense, and it seems that it turns any metal object into a capacitor. My only worry with this is that I would not have enough pitch resolution to produce an accurate sound.

My plan is to implement echo, reverb, and other similar effects with the raw data received from the ADC. I noticed there are four knobs on many different theremin model. They were Volume, Pitch, Waveform and Brightness. I can guess that the first two change the way the antennae react to your hand. I read online that the last two relate to timbre. Could the last two be implemented as DSP or would they cause a change in the circuit prior to reaching the microprocessor?

Thanks again for your help fred. It really helped clear a lot of confusion.

Posted: 5/2/2013 11:15:35 AM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

First, I need to make it clear that I would not even think about an "all digital" theremin - Oh, I once did.. It looked simple.. But I think one needs to be a highly skilled digital engineer whith the ability to design complex systems using FPGA's and tech of that ilk to do the job well.. Someone like Dewster who designs his own processors in FPGA archetecture could make a worthy digital theremin.. Not me! ;-)

To make a theremin which is worth building, IMO it needs to be playable..

About (IMO) the simplest AFE which is usable, is probably the Jaycar / Silicon Chip kit - this has no linearization but still manages playability which borders on acceptable IMO.

If you have no analogue expierience at all, I would strongly advise getting one of these kits to take care of the front-end.

The other options are the Smirnov oscillators, or building a Moog EM front-end ..

But whatever you pick, its the analogue front-end which will make the theremin.. It is this which, if correctly designed, gives a good antenna voltage less subject to interference, and which gives the required sensitivity.. And if you look at the technical postings here, you will find pages on this subject.

Put in crude terms, think of the AFE as your Analogue to digital converter.. The entire digital system depends on the quality of this A/D - This is what you must get right.. Everything which follows is easy.

"My plan is to implement echo, reverb, and other similar effects with the raw data received from the ADC. I noticed there are four knobs on many different theremin model. They were Volume, Pitch, Waveform and Brightness. I can guess that the first two change the way the antennae react to your hand. I read online that the last two relate to timbre. Could the last two be implemented as DSP or would they cause a change in the circuit prior to reaching the microprocessor?"

All you need into your digital "section" is data relating to hand position - This data is "mixed signal" in that it will contain the information related to hand position, and this data will be analogue but "reduced" in some way so that some data will be lost.. Let me explain:

If one generates a difference frequency using logic "heterodyning" you end up with a logic level square wave you can feed to your digital stuff.. This square wave will carry analogue data (as in, continuously variable with no quantizing) related to hand position, but it will not carry any data related to the wave shape from multiplying the two oscillators.

If one had a system which produced a logic level PWM (variable pulse width with constant frequency) from the hand position, you would again have a "mixed signal" - this PWM signal will carry analogue data (as in, continuously variable with no quantizing) related to hand position, but it will not carry any data related to the wave shape from multiplying the two oscillators.

If one generates a voltage from the hand position, you would  have a "analogue signal" -  (as in, the voltage would be continuously variable with no quantizing) related to hand position, but it will not carry any data related to the wave shape from multiplying the two oscillators, and would need to be converted to a real digital signal (involving sampling the voltage with an ADC and therebye quantizing it).

In all the above, the digital system would get raw data related to hand position, and once in the digital system as numeric data, "analogue" is lost - the digital stuff will process this data sequentially and do with it what it needs to - generate audio frequencies / waveforms, process these "numeric" "virtual" waveforms etc.. Within the digital system, there are no "frequencies" or "signals" there is only numbers - a continuous stream of quantized changing numbers .. The designers job is to get these numbers to a form where, when streamed into a Digital to Analogue converter, the output of this converter is the waveform they want. 

So you dont need (and cannot use) any tone shaping prior to the digital stuff.. Any such circuitry prior to digitization is redundant and actually, if used, would make obtaining accurate data more difficult.

The simplest way is probably to take a standard theremin front end (the Silicon Chip kit is ideal for a basic theremin) and give it a simple logic level mixer..

An example of this can be found in my http://thereminworld.com/files/Pages/28/files/SkywaveHi.pdf

The RF Subcircuit - The front end is a modified S/C design - You dont need IC2 or any of the components related to it - you just need the circuitry up to the VARBUF and REFBUF outputs.. The basic SC board does not have these buffers me thinks - so you would need to fit them, possibly use IC2s socket for a "piggyback" board to these parts and the other bits..

VARBUF and REFBUF are converted to logic level square waves by IC4 (a LM393 comparator) and these square waves are fed to the REF and VAR inputs on the DIGB subcircuit on the following page.. (I used the LM393 because it is cheap and fast - but there are other ways which work.. a couple of transistors could be used to square up the signals and give a 5V pulse out - I just wanted to be sure I got a reliable waveform into the PSoC - Also, I needed to build it fast and never had time to mess with anything else)

IC1 was a PSoC which worked entirely in the digital domain - It took the reference and variable oscillator logic signals and directly processed these to automatically mute the instrument, and to give visual tuning aid for the null point... Your digital theremin could connect in a similar way..

But perhaps of more interest is the digital "mixer" - I believe I may have "invented" this - Or certainly think I may have been the first to use such a scheme with the theremin.. U2:A takes the logic level reference and variable oscillator signals, and outputs a clean logic level difference frequency.. absolutely ideal for feeding into a digital system - no mess with edge jitter one gets from using comparators on audio signals etc..

With the H1 theremin, this difference signal (DIF) was fed to the PSoC (IC1) which piped it from pin 3 [P11] to pin 5 [P10] when not muting.. U2:B simply produced a lower octave square wave.

Fred.

"If you are not interested in a playable instrument...you have the simplest capacitance sensor available." - FredM

"Would this not produce an as accurate sound? I am indeed looking to build a playable instrument. " - Thewriter

Forget about sound for now - What you need for a digital theremin is accurate capacitance / position data for the range (about 60cm) you require. Simple RC low voltage schemes (like the TS555C) cannot give that - or at least not without a LOAD of effort to resolve signal from the overwhelming noise it is lost in when the hand is distant from the antenna.

"I read up a bit on the capsense, and it seems that it turns any metal object into a capacitor. My only worry with this is that I would not have enough pitch resolution to produce an accurate sound."

You are correct on this - This is the big problem with digital.. Resolution. However you get the data, this data needs to be converted to numbers - These numbers need to be big enough (and accurate enough) to resolve the pitch to 1 cent for a "pro" instrument - thats 1/100th of a semitone.. So the numbers need to be 12 bit or better. All processing must also occur quickly (<< 10ms) and CapSence is simply not able to get close to these requirements.

Posted: 5/2/2013 8:12:35 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

thewriter, IMO FredM is right on with his info.

I would recommend you not use a fixed oscillator or heterodyning - just measure the period of the variable oscillator directly.  You can do this by measuring the period and averaging over many cycles to increase precision, or you can divide the frequency down somewhat (the divider is then something of an average or low pass filter).  For my designs, I use FPGA digital logic to stimulate an LC tank, then use feedback from this to keep the oscillations going.  This forms a phase locked loop, so I can use the average loop phase error as a direct indication of operating frequency.  But it can be done much more simply with an external analog oscillator and period measurement.

Once you have a digital number for the period, you can subtract this from a fixed number very close to it, and run the result into a numerically controlled oscillator (NCO) or similar to produce an audio tone.  If the frequency is high enough you can use the NCO to drive a counter that is an index into a wavetable, giving you any arbitrary waveform you like.

Most of the engineering work boils down to SNR, getting enough bits of resolution quickly enough and noise-free enough.  If you had the luxury of averaging all day you could probably play the thing across the room (then you would REALLY be fighting drift) but response time should be less than 10ms for analog Theremin playing techniques to work.  One cent is the 1200th root of 2, or ~1.00057779, or ~0.06% change.  You want at least 3 cents accuracy at the most sensitive point of human hearing (~1kHz) which is 0.17%.  1/0.17% = 576 or about 2^9, or 9 bits.  Add approximately one bit for each playable octave, though in the bass region the ear is much less sensitive to pitch, and the pitch numbers get smaller here as well, which works out rather nicely.  The pitch number itself can have some noise dither if that dither is ultrasonic and fairly white, but obviously the more stable the pitch number the easier things are.

It's kind of amazing that one can actually obtain this kind of info at the necessary rate, what with all the environmental noise, thermal noise in the circuitry, and the relatively tiny capacitance change being measured (on the order of a pF for the entire audio range).

Secondary effects like thermal stability and drift can plague you once you have the thing up and running.  This is where the similarly constructed reference oscillator and heterodyning (as is in all analog Theremins) can really help.  I'm going to try air core inductors next, once I finish my FPGA processor design (famous last words).

Posted: 5/2/2013 9:28:05 PM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

"I would recommend you not use a fixed oscillator or heterodyning - just measure the period of the variable oscillator directly." - Dewster

Thanks Dewster - I never included that clearly in my list of "options" - but it is one of the simplest and most effective ways of deriving the raw data.. It was one of the first schemes I used back when doing things digitally.

For me, the difficult aspect of this approach was largely due, I think, to the limitations of the PSoC 1 (M8) processor and the maximum 24MHz clock available in this chip to drive the UM's - Once I had divided the incoming frequency down to extend the period available to get the required resolution, the latency was too long - then add to this the 4-MIP RISC processor, and it was unusable..

With a slow (and clumsy) digital system I found that deriving the difference frequency before feeding this into the digital processing was the only way to go.. Even the new PSoCs could now probably deal with direct oscillator input and give almost good enough resolution, and FPGA's are much faster.

The big advantage of the above is that one only needs one oscillator per sensor (no reference oscillator) - The disadvantage is that one can be blighted by drift problems.

OFF TOPIC:

thewriter:  --- The following is a rant I am compelled to post, sorry :-( 

I think that you would be wise to stop and think deeply about why you are embarking on this project and what you hope to get from it.. (1) Take whatever time you imagined, worst case, you would spend on this project, and multiply that by at least 10 -

As an engineer, I have been estimating the time jobs will take for  30 years.. Oh, I got these estimates severely wrong at times, sometimes jobs taking 3 times my estimate - But I never got anything so badly wrong as theremins! - 6 months turning into 5 years and counting.. ! 

(2) Accept that you will be forced to deal with stuff you have never dreamed of - you will need to study and absorb new data and stretch your mind in ways you never came close to at university.

(3) You may not come out with a theremin matching your original plans .. But you will come out a far better engineer than you were when you started! -

If it starts to take over your life though, fight it! - If you have ANY inclination to compulsive or obsessive behaviour, DROP IT NOW AND WALK AWAY!

The bloody theremin has stolen my life - I could have bought an E-Pro for a tiny teeny fraction of what my theremin obsession has cost me.. Yeah, ok, I learned a lot.. But it could possibly have been cheaper for me to attend MIT for 3 years!

Fred.

Posted: 5/3/2013 2:24:56 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

24MHz is probably near the feasibility minimum (I've had my prototype running OK at 25MHz) but the circuitry would have to be able to respond exactly on the clock, and not some indeterminate time after (like an interrupt).  A counter is probably also the minimum low pass filter construct, but some useful information is discarded with it (not all clock edges provide information downstream) likely making it somewhat more susceptible to noise than a proper digital filter.

"The bloody theremin has stolen my life..."  - FredM

Oh, come on Fred, you've loved every minute of it!  ;-)

Not having nearly as much research time in, I won't pretend I know nearly as much as you or Thierry do about Theremins, but coils and transformers now have a reasonably comfortable place in my head, where "hmm, what is this bunch of wire doing here?" used to reside.  Oscillators aren't as mysterious as they once were.  There isn't much better in life than backfilling brain areas of confusion and borderline superstition with insight and hard reality.  But the process does tend to require lots of time and commitment.  The trick is to latch onto an interesting project that requires you to inflate your knowledge base (or have it latch onto you like a blood sucking tick!).

Posted: 5/4/2013 3:43:30 AM
FredM

From: Eastleigh, Hampshire, U.K. ................................... Fred Mundell. ................................... Electronics Engineer. (Primarily Analogue) .. CV Synths 1974-1980 .. Theremin developer 2007 to present .. soon to be Developing / Trading as WaveCrafter.com . ...................................

Joined: 12/7/2007

" come on Fred, you've loved every minute of it!  ;-) " - Dewster.

I dont deny that..

But its much the same as a gambler or any addict enjoying what they are doing, and enjoying the "buzz" they get from it..

All fine until they take it to the point where it ruins their lives - they take that big gamble and lose their home, or they screw their health up.

OFF TOPIC:

All I am trying to do is warn people of the danger - Most will see this as me being silly or perhaps even presenting self pity.. I care not ;-) .. IMO, those drawn to theremins seem to be a bit less "well balanced" than the majority, LOL -

Particularly technical people who have any tendency to OCD or those kind of disorders are, I fear, at risk from the theremin.. However, I accept that these are probably the people least likely to heed my warning!

IMO, the theremin is not worthy of any risk to ones finances or long-term happyness, its not worthy of consuming time you should be spending with your children and those you love.. Things like finding a solution to the energy crisis or world poverty may be worth such a risk, but not the bloody theremin!

Fred.

Posted: 5/8/2013 3:49:36 AM
thewriter

Joined: 5/2/2013

Hi, Sorry for such a late response. I've been a bit busy.

As far as the AFE goes, I decided not to go with the jaycar kit because that approach seems too easy. It sounds like I'm merely assembling a theremin and not really understanding what is going on. 

An example of this can be found in my http://thereminworld.com/files/Pages/28/files/SkywaveHi.pdf

The RF Subcircuit - The front end is a modified S/C design - You dont need IC2 or any of the components related to it - you just need the circuitry up to the VARBUF and REFBUF outputs.. The basic SC board does not have these buffers me thinks - so you would need to fit them, possibly use IC2s socket for a "piggyback" board to these parts and the other bits..

I'll be honest, I tried to look at that but it seems a bit over my head. I've never dealt with layouts this complex...and that's a bit sad since I imagine this is one of the more lesser complex schematics. Sometimes I feel that I spend too much time in the digital domain. My passion lies within embedded systems and firmware (I'm slowly getting into those areas), and since you sound like a veteran [please take this as a compliment :)], would you happen to know how important the knowledge of the circuitry at this level is required? I always assumed that my time in industry would be spent reading over datasheets and attending meetings. I'll find out within a couple weeks I guess :P.

I've circled, in the picture below, what I think is what you meant by "circuitry up to varbuf and refbuf". Again, I've probably circled the wrong parts. http://i.imgur.com/WeO4J1E.png

This led me to look over the Smirnov oscillator. Right now, this seems like the best approach due to the fact that he details how to connect it to an Arduino, which happens to be the microcontroller I'm prototyping with. Link. Also, I can assemble the schematics on a breadboard fairly easily. The hard part I feel would be building the inductors L1 and L2.

I believe Sensor #3 would be best suited for me. I would connect the voltage output to the ADC pin of the arduino and then output these values (assuming no DSP...for now) to a speaker using PWM. (Given that I receive a numerical value from the ADC, I could buffer several samples. I think that I would then use a 50% duty cycle for each value received (since I can work backwards to map the numerical value to a frequency)). 

Is the sensor/receiver pair described in the link above for controlling a theremin from a far distance? Right now that's the only thing that makes sense.

The more I thought about it, the more I began to lean towards a pitch only theremin. I'm not saying I wouldn't control volume, on the contrary I still would, but I would do it differently. There would be one antenna for pitch, and I would digitally control the volume (I've already set up input via keypad and an LCD) via buttons. Based off of the circuit diagram from sensor #3, I wouldn't have to modify anything. I only see 1 antenna and I assume that is the one for pitch.

The problem with where I am currently at is that I have a lot of CS knowledge. Algorithms, optimizations, different programming paradigms. I lack in real hardware knowledge. Most, if not all, of the hardware I know relates to transistor level PMOS and NMOS and how to build logic gates out of those. Well, enough of this rant. 

I really just want to learn a lot through this project. Getting a playable instrument is just the icing on the cake. If I really wanted, I could go search online and find a plethora of "arduino based theremins", but it's just living through someone else's work. Eh, this turned into a rant as well. :P

Thanks again for your help, fred and dewster. You both are leagues ahead from where I stand.

Posted: 5/8/2013 3:59:42 AM
thewriter

Joined: 5/2/2013

Also, the website (asmir.theremin.ru) suggests connecting the circuit to an oscilloscope in order to verify that the correct signal is being generated. Unfortunately, I don't have access to a scope nor do I own one. If I follow the schematic  completely, is there any need for one? I did a quick search online and the scopes were more expensive than I hoped. I know I would need one eventually, but I was hoping to get by for now. If only I could somehow do it in software, but oh gosh, that would be too slow. 

I do have a function generator lying around, but I'm not sure how helpful that is. It was a gift from a friend who was forced to leave their job and I have not ever found a use for it.

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