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

Posted: 7/5/2013 1:05: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

NOTE: This is a bit off-topic, and does not relate to Dewsters great project - it is about a typical crap digital theremin design:

*** Digital "theremin" project using PSoC 4 ***

Ok - I paste this here because I dont really think it deserves a seperate thread, am a bit loath to even paste it here, as, IMO, this is a useless example of how to abuse both the theremin concept and a powerful IC in one 'hit'.. And how to give those who say that "digital" theremins are rubbish even more ammo.

Cypress Semiconductor Corp launched their latest low cost PSoC IC a few months ago, and have been running a "100 designs in 100 days" contest at Element-14. A Cypress developer has submitted a "theremin" based on the low cost "Pioneer" board for the PSoC 4.

You can find it here . All the design files are given, but to fully examine them you need to download PSoC Creator (free from Cypress) - To play with the software you need the Pioneer board (which costs £17).. This Pioneer board is incredibly good value for money IMO, and I may well be using it in my theremins - it has both a PSoC 4 and PSoC 5 on board - the PSoC 5 has analogue 4Q multipliers and can implement register switching functions, the 4 can implement the UI etc.. But I would never use the PSoC CapSense to implement the sensor!

The developer states that all you need to do to extend the sensing range from the couple of inches he demonstrates (using a short piece of wire for the pitch antenna, and another for the volume antenna) is to increase the size of the antennas - and that by doing this you can extend the range to a metre.....

Well - In my expierience, this is utterly untrue - I have never been able to get more than about 40cm usable sensitivity from PSoC Capsense, and there is almost no usable linearity (perhaps 20 semitones are playable) unless one does extensive linearization computation..

Even though I have a Pioneer board, I have not bothered to try this design - far too many other more important distractions! To me, the conductive "theremin toothbrush" detailed a while ago here on TW was nearly as musical as this horrible "musical" toy.

Yeah - But there is also, for me, the embarassing memory of the fact that I started this theremin journey with a PSoC based toy that, although better than whats presented in the above, wasnt that much better... :-(

Dewster, on the other hand, started his "journey" with quite a presentable demo of a digital theremin  IMO.. The only digital theremin I have seen which impressed me so far..

Fred.

>> ps .. I think the PSoC 4 is a great little IC (and the Pioneer board is loaded with potential) - Connect it to a reasonable front-end and do some sensible audio generation with it and one could build a reasonable low-end theremin IMO.. But the demonstrated "theremin" could be bettered by a circuit using a few 555 timers and diode mixer!

Posted: 7/5/2013 2:57:45 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Thanks for that pointer Fred!  Not sure how in-sync the audio is with the video, but it looks like there is significant delay between his movements and changes in the sound produced, which (if true) isn't surprising as literally anything can be done if there is sufficient time to average out noise (the designer has at most perhaps 10 ms to work with before the player starts noticing a lag due to reduced vibrato, etc.). 

Not trying to knock people fighting the good fight, but IMO he could have done a bit more homework before releasing it.  The continuous pitch mode seems to have an even shorter range and is rather frighteningly unmusical (I believe I could still hear some pitch stepping going on).  "It could easily work up to a meter if I put a better antenna on it" - I need to steal that line!

Posted: 7/5/2013 2:12:02 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

NOTE: This is a bit off-topic, and does not relate to Dewsters great project - it is about a typical crap digital theremin design:

"I believe I could still hear some pitch stepping going on" - Dewster

Most certainly!

"It could easily work up to a meter if I put a better antenna on it" - I need to steal that line!" - Dewster

The thing is, you dont need to! ;-)

What exactly is a "better antenna" anyway, LOL ;-) .. An large air coil connected to a 40cm x 15mm copper tube with apropriate modifications to the sensoe circuit?

"Not trying to knock people fighting the good fight"

Ahh - Here we have a different opinion - IMO, the "good fight" is the fight to produce something good, something worth showing.. IMO, those who produce rubbish are the enemy! ;-)

I have looked over the code a bit, and it really has IMO had little care put into it at all - absolutely no attention to detail whatsoever IMO - its not even fit for a reasonable "proof of concept" experiment.. Even the CapSense has just been used with near default values, the discreet step mode quantizing table genetation has been lifted from a public
http://subsynth.sourceforge.net/midinote2freq.html (The developer did acknowledge this)..

I think though that even if one spent months honing CapSense, it could not be turned into a useful theremin sensing mechanism - At least not without extensive modification to the front end.. One can use CapSense for long range sensing - but as you say, you need a LONG time to average the values - by long I am talking >100ms - and one still needs to linearize the results.. The "filters" I see in the design are:

1:) The sensor update rate - this is set to 30ms / sensor, so the total update time for both sensors is 60ms.. this does give a degree of analogue filtering / averaging - as in, the charge value will be determined by the average capacitance of the sensor / antenna for 30ms.. but IMO 30ms is right on the edge of usibility - 60ms is intollerable - and although some filtering is applied, a single sample can easily be corrupted by a large noise event - IMHO the following filters will not satisfactorily reduce the effect of such 'events'.

2:) The "in-built" filter selected - This is configured with a first order IIR 1/2 filter, the crudest filter available.. (Returns one-half of the most current sensor value added to one-half of the previous filter value.)

3:) Filter in the main() routine:

/* some FIR (does it really matter?) */  
 tone = (0.2*(float)prox_pprev + 0.6*(float)prox_prev + 0.2*(float)proximityCounts);

This simply takes present and previous two values.

------------------------------------

 

In fairness, this was posted for a PSoC 4 contest not a theremin contest - I have refrained from commenting there.. IMO, anyone seriously intending to produce a theremin will eventually find TW and/or Levnet, and have their ideas critically and usefully "tested" when these are exposed to thereminists.

Fred.

Posted: 7/5/2013 8:00:33 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Ahh - Here we have a different opinion - IMO, the "good fight" is the fight to produce something good, something worth showing.. IMO, those who produce rubbish are the enemy! ;-)"  - FredM

I agree.  But sometimes the best a person can do is put a nail in a block of wood, and in that case they probably don't know they're the enemy! ;-)

I assume the digital filters (IIR & FIR) are operating at the sampling frequency, or 60ms.  That's pretty bad as they are just slowing things down that much more.  In a digital Theremin, good (sufficient SNR and resolution) samples need to come in at a rate of some 10s of kHz minimum for filtering to be effective (average noise, trade response time for increased resolution).  Sampling above the audio sampling rate (~50kHz) likely minimizes audible glitching, zippering, etc. during pitch changes.

It's kind of wild that analog Theremins can get by with so little in the way of post filtering, though I suppose the multiple high Q LC sections, the large antenna voltage swings, and the full wave mixing do a lot to condition what we hear.

Posted: 7/6/2013 11:29:50 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

NOTE: This is a bit off-topic, and does not relate to Dewsters great project - it is about a typical crap digital theremin design:

"I assume the digital filters (IIR & FIR) are operating at the sampling frequency, or 60ms.  That's pretty bad as they are just slowing things down that much more." - Dewster

yeah - data updates come in once every 60ms.. All processing / filtering works with this raw data, except for the actual analogue integration at the sensor.

The data aquisition could be speeded up quite a lot by reducing the bit resolution - This implementation is using 16 bit resolution which is more than whats needed - but the CapSense wizard in the new PSoCs / PSoC creator only seems to give a choice of 8 bit or 16 bit - To really tune the sensor you would need to go into the UM and modify it for perhaps 12 to 14 bit.. I have no idea how easy or otherwise it is to do this with the new PSoCs.. I did extensive work on CapSense with the old PSoCs (where it was easy to specifically set the resolution), but even trimming the resolution I could not get good enough performance and eventually gave up - since then I havent kept up with the field or PSoC in general..

IMO, the principle of CapSense is badly suited to theremin application - in essence, it consists of a constant current supplied by an IDAC, this current is applied to the sensor for a count period (this period is determined by the required resolution) and the count corresponding to the charge on the sensor is monitored / sampled at the end of this period..

However - Any voltage induced in the sensor from external sources affects the returned value.. Where the capacitive path is small, as with a button or slider, ground is the most significant return path - so sensing usually works reliably... But when the object being sensed is more than a few inches from the sensor (antenna) the most predominant "return" path could have a substantial potential imposed on it from other sources - mains and mains harmonics for example, and high energy radiated logic signals from leads to displays etc can also really screw the readings up - as I discovered with my Epsilon project... If one gets several lines changing state simultaneously and this co-incides with sampling of the sensor, the returned value can be seriously screwed up.

I think that its not worth even looking at CapSense for this application - And perhaps this is what annoys me about this project more than anything else.. The project was submitted by a Cypress employee AFAICS, the PSoC 4 does a lot, and is well suited to many applications - but long range capacitance sensing using CapSense is not, IMO, one of the things it is good at - and its certainly completely useless for a theremin application!

If you want to build a theremin using a PSoC, I think one needs to use a AFE as you have done for your FPGA implementation.

Fred.

 

Posted: 7/9/2013 9:36:26 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Today I flashed the Hive processor running a simple binary counter with one of its cores ("hello world" for the HDL set) onto the Altera EP4CE6E22C8N FPGA demo board I got off of eBay.  Running at 180MHz I'm seeing 175mA or a little less than a watt consumed from the 5V wall wart, which I suppose is around what I was expecting, but more than I'd like. Once the PLL and other things are in there I imagine it may draw around 1W.

The board has 3.3V, 2.5V, and 1.2V linear LDO regulators, and the core logic uses 1.2V, so I assume a majority of the power is being turned into unwanted and useless heat at the regulators.  The FPGA itself is a warmish 38C.  The 1.2V regulator is 53C.

=======================

BTW, if anyone uses and loves HP calculators for their engineering work, there is a WP-34S project going on here which re-purposes an HP-30B financial calculator and turns it into an HP-42s + HP-16c + other good stuff.  Buy a WP-34S ready-made for $75 here complete with crystal.  It seems the scarce programming cable is the fly in the ointment for going the potentially cheaper DIY route (the HP-30B can be had for $25 or so, the keyboard sticker set $6) which is a simple serial cable with some kind of level conversion going on and a couple of buttons.  I have a (currently best of the worst) HP-35s so I'm able to hold off for a while.  (One of the things I've always wanted to do was make something between a laptop and a calculator.)

Posted: 7/10/2013 11:18:04 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

"("hello world" for the HDL set) " - Dewster

Congratulations! - Always a big moment... LOL, although it rarely impresses anyone else ;-) I remember putting together a TMS9900 system and powering it up for the first time - it was a major project, my first serious computer... The teletype kicked into life and typed out "hello world" - And my wife said "all that junk just to do that ?? "  ;-)

Interesting WP-34S project -

Ok, this is probably blasphemy.. But wouldnt it be easier to just develop an app for something like an android tablet? .. Couldnt one just have your android turn into a WP-34S, complete with dedicated touch keyboard on the display, rather than take a business calculator and reprogram that, and buy a sticker for the keys?

Fred.

Posted: 7/10/2013 12:31:02 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"Couldnt one just have your android turn into a WP-34S..."  - FredM

An Android tablet wouldn't give you that tactile swivel key "click" you get from an HP which from my experience seems to substantially reduce key-in errors.

Posted: 7/10/2013 10:32:16 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

"An Android tablet wouldn't give you that tactile swivel key "click" you get from an HP which from my experience seems to substantially reduce key-in errors." - Dewster

AHA! ;-) So its back to the tactile aspect again!  .... This capacitive stuff is rubbish, isnt it! ;-)

So - A tactile transparent stick-on swivel key button overlay for an android tablet then !

;-)

The things people are doing to make the stupid capacitive interface tactile again... Heres a joystick (it is placed on a capacitive screen and wiggled, LOL ;-).... how long before some manufacturers think its a good idea to include this as standard - then keys - then.....

Hey - at this rate, we might even eventually get back to that utterly brilliant invention most of our kids have never even seen - the rotary dialing telephone!

Back in the early 90's I filed a patent for a rotary 'mask' to fit on a mobile phone, this would protect the (circularly rearranged) buttons from accidental activation - buttons could be accessed by the finger in a rotary manner we were all used to back then.. but one did not need to go back to a start position, simply position the dialing hole over the key you wanted, then click it..  the dial was sprung so it returned to a safe position (over the "answer" key which was only active when there was an incoming call) and keys werent accidentally pressed when the phone was in ones pocket..

No one was even the slightest bit interested...

Posted: 7/11/2013 1:01:16 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"So its back to the tactile aspect again!  .... This capacitive stuff is rubbish, isnt it! ;-)"  - FredM

Coupling a display to a capacitive grid forms a very flexible and fairly powerful generalized interface.  But the way they tend to be implemented lately they only give video / audio feedback and little if anything in the way of pressure or velocity sensing.  Whenever I approach such an interface that's foreign to me I groan a little inside, wondering how cantankerous it will inevitably be.  The local DVD rental kiosk had one of the nastiest touchscreens I've ever encountered, had to use more than one finger pressed fairly hard against the glass for it to register.  It got replaced at one point, likely due to someone (perhaps inadvertently) putting their fist through the screen.

Microphonics could be used to register touch and velocity, as could higher resolution and faster capacitance measurement (timing two threshold like they do in MIDI keyboards).  I've spent some time thinking about this, but not since I got involved with Theremin development.  An FPGA would be ideal to do this for a keyboard as there are tons of independent high speed IO, the trick would be to minimize the external components and somehow normalize the response of each sensor.

That adhesive joystick is kind of a hoot!  And Fred, you are a patenting fiend (with excellent ideas to back them up)!

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