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

Posted: 12/15/2013 1:43:17 AM

From: Northern NJ, USA

Joined: 2/17/2012

"Looks ok ish..."  FredM

Doh!  Yes, it does seem reasonable now that you put it that way.

Measuring the primary with the secondary open and shorted (51.39mH, 35.67mH) and the secondary with the primary open and shorted (105.6uH, 51.05uH) and finding the coupling:

{[1-(35.67/51.39)]*[1-(51.05/105.6)]}^(1/4) = 0.63

So it is pretty coupled, and it seems so on the bench - I can obviously load the primary by loading the secondary.

The effective turns ratio is the square root of the open circuit inductance ratios:

[51.39/0.1056]^(1/2) = 22

So if the secondary has 50 windings, the primary has 50*22=1100, or 366 per "donut" which I can believe.

And if I'm seeing 2.5V p-p on the sense winding, that means the antenna swing is 2.5*22 = 55V p-p, which I also believe given the rather wimpy 1k drive resistor current.

Posted: 12/15/2013 2:58:46 AM

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

LOL ;-)

Just shows how comparatively lazy I am on maths - I simply count the turns on my winding, measure its inductance, use an online calculator to get Al, and use this AL with the same calculator to find the number of turns on the other winding (whos inductance I know, but turns I dont)..

I did do a spreadsheet once, but its usually quicker to find this calculator than to find / run my spreadsheet.

It gives me ball-park figures I can usually work with.

Posted: 12/17/2013 5:23:19 PM

From: Northern NJ, USA

Joined: 2/17/2012

I find it odd that a tool that I rely on daily, my calculator, is technically poorer than the ones I've owned in the relatively distant past.  I'm currently using an HP35s - it's merely OK - I'm seriously jonesing for one of the earlier HPs that are no longer in production.  I previously mentioned the WP34s project here, which re-purposes an HP30b business calculator via a new software load and some keyboard stickers.  The ARM processor in the HP30b is no slouch.

You can purchase the whole thing for \$75, but it's back-ordered at the moment, I'm an inveterate cheapskate, and I'd rather DIY whenever it makes sense, so:

I bought a "like new" HP30b off Amazon for ~\$20, and the key stickers from the project for \$6, but the programming cable is the fly in the ointment.  After closely examining the WP manual and other on-line resources it is clear that the cable amounts to nothing more than a TTL (3.3V) level RS232 interface with two push button switches added.  Shopping around I was quite surprised to find a USB to TTL RS232 cable for \$4 on Newegg, which even has the coveted FTDI chipset.  Haven't received any of this yet, will keep you posted on the progress.

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

I'm really stoked by the existence, ready availability, and low cost of this USB TTL RS232 converter!  It means I can stick a UART (have some highly polished verilog to do just this) in my Hive processor and directly communicate with it, upload code, etc.  This, coupled with some cheap serial Flash (like the 1MB  W25Q80BV at Adafruit for \$2) should give me lots of code space to stretch out in.  I'm thinking the boot code could be a simple Flash loader, and the Flash could have a default "golden" load in a non-erasable space, with a check for a new load with good CRC at boot and some kind of load mode (user buttons pressed at power-up).

I do wish the FPGA I'm using had more block RAM.  16kB for the main memory is pretty confining.  But it will be hand-coded, and if I can swap code in and out easily from a larger Flash space then maybe it won't be so bad.

Speaking of Adafruit, the Teensy 3.1 board for \$20 looks like a good deal to base a digital Theremin around.  32 bit 48MHz processor, lots of memory and IO including ADC & DAC.

Posted: 12/17/2013 9:48:39 PM

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

"Speaking of Adafruit, the Teensy 3.1 board for \$20 looks like a good deal to base a digital Theremin around.  32 bit 48MHz processor, lots of memory and IO including ADC & DAC." - Dewster

IMO, at \$25, probably one of the the biggest bargains for processor boards right now is the PSoC 4 "Pioneer" kit - http://www.cypress.com/?rID=77780  It contains two PSoCs, the PSoC 4 with Cortex Arm M0 (32 bit 48MHz) processor, and the PSoC 5 with Cortex Arm M3 (32 bit 62MHz ) processor..

This board is intended for PSoC 4 development, but has a PSoC 5 interfacing it - this PSoC 5 can be independently programmed (JTAG is available seperately for both processors, so if one has a programmer, you dont need to use the PSoC 5 to access the PSoC 4).

The only down side to this kit is that only 10 of the PSoC 5 ports are available on a header .. But the full set of IO is available from the PSoC 4 in Arduino (and other) "shield" formats.

In addition to processors, these parts have user configurable "in chip" modules, both digital (PLD type configurable blocks) and analogue configurable blocks (A/D, D/A, Multipliers,Amplifiers,Comparators,Switched capacitor,Capsense etc) and the PSoC 5 has additional configurable 'sub processors' to implement digital filters and the like, and an extremely powerful DMA structure to interconnect modules etc.

The PSoC 4 is a bit weak on its UM capability compared to the PSoC 3 and 5, but its their low cost part - However, combined with the power of the PSoC 5 one has a really exceptional board.. I just wish they'd had the 5 as the main chip with the 4 in a supporting role, or that they had a low cost PSoC 5 kit!

Data on this kit: http://www.cypress.com/?docID=47035 (big .pdf file - not quick!)

Fred.

ps - I am a PSoC consultant, acredited by Cypress Semiconductor - But I get nothing from promoting their parts..(I got this acreditation on the PSoC 1 range after completing training, producing a product using PSoC for a client, and passing an exam and interview - more gruelling than getting a Bsc! .. I have not gone through the process for the PSoC's 3,4 and 5 - I would fail! ;-)  Quite often I have been a pain to them by being publicly critical ... In this case however, I think their board is hard, if not impossible, to beat - particularly if you want configurable logic and some analogue functions on-chip, and a reasonable processor or two. Also, they give away the whole development environment - Configuration editor, compiler, debugger..

Posted: 12/18/2013 5:24:33 PM

From: Northern NJ, USA

Joined: 2/17/2012

"I just wish they'd had the 5 as the main chip with the 4 in a supporting role, or that they had a low cost PSoC 5 kit!"  - FredM

That does seem a bit upside down, though it appears to be a fantastic value!

Interesting how everything programmable seems to be converging on much the same type of SoC: processor, memory, peripherals, ADC, DAC, programmable logic.  Mid level and above FPGAs have had hard processors for a while now, and recently they've all jumped over to ARM variants.  Some of the newer FPGAs have ADC.  The PSoCs are unusual in that they have programmable analog - hard to know how much that might fully catch on, though it must be a much cleaner and more flexible environment to work in.

Posted: 12/19/2013 12:22:06 AM

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

" The PSoCs are unusual in that they have programmable analog - hard to know how much that might fully catch on, though it must be a much cleaner and more flexible environment to work in." - Dewster

Not sure about the value of the analogue - there were a load of configurable analogue chips a while ago, but they never caught on. The PSoC 1 analogue was quite feeble and noisy - IMO, the analogue UM's never met the published spec, and certainly were unusable for higher end audio.. Also, even with PSoC Designer, getting the configuration right was a nightmare.

These new (3,4,5) parts are much better - the trouble though with all analogue stuff in a chip like these is the supply voltage - there just isnt enough headroom for many real-world applications - 5V P-P or 3.3V P-P just isnt enough - and thats assuming full rail to rail is available, which in practice its not... I think having analogue is a big + , but strangely, not such a big + for analogue designers who will still, most likely, want their external analogue circuits.

I havent played much with the analogue in the new PSoCs, so may eat my words - Certainly the ADCs are fine, and the IDACs seem fine, and the comparators behave well - I havent used the other analogue UMs yet - but hope to in the next few weeks - want to see how the multipliers behave with theremin input waveforms ;-) .. Also want to see if I can do some functions like analogue squaring and linearity correction using these..

I think convergence was inevitable - IMO its probably more to do with the need for common "platforms" due to the learning time it takes to master complex parts - Its great to know that by mastering ARM, I am not stuck with using PSoC but can use what I learn on many other parts with this core.. This was not the case with PSoC 1 where the "MCU" was obscure and almost useless, and I had to spend a lot of time mastering it so I could program at ASM in order to squeeze anything useful from the processing part of these parts.

For something like the open.theremin though, I think the PSoC could be ideal - the AFE could be constructed using an on-chip amplifier, the mixer implemented internally with a D-Latch, no external active stuff needed at all.

Posted: 1/6/2014 6:36:41 PM

From: Northern NJ, USA

Joined: 2/17/2012

My Hive verilog processor core is up to v04.05.  Tried last night and this morning to update the SVN depository at opencores but couldn't.  Not sure what's up with opencores (and I know I'm looking a gift horse in the mouth to some degree) but it doesn't seem to be very user friendly: many aspects of a project are not editable, getting your code on there in the first place and managing it later is a complete nightmare, and they haven't sent out a newsletter in over 6 months so my project isn't getting the full exposure it might.

Ah well, here is the latest design document:

http://www.mediafire.com/view/x7qci2cv4vyvdei/Hive_Design_2014-01-05.pdf

And the latest verilog if anyone is interested:

It now has 8 indexed stacks per thread (up from 4), a UART, and a general reshuffling of opcodes.  With 8 stacks the operand fields are now nibble wide (1 pop bit, 3 stack index bits) which makes everything work out in hex quite a bit better, and with this, the Hive project finally, at long last, feels somewhat complete to me.  So I'm going to do my level best to not change the design for a while and concentrate on getting the Excel simulator up and running, and on getting some generic boot code in there to accept uploaded code and stick it in Flash for speedier development.

[EDIT] The programming examples at the end of the design document have been expanded and refined.  I'm particularly proud of the SQRT and EXP2 subroutines.  And binary search division is the bees knees when you have a single cycle multiply at your disposal.

[EDIT2] With some help I finally got the files up at opencores (I was using the wrong SVN path):

http://opencores.org/project,hive

Posted: 1/24/2014 8:48:18 PM

From: Northern NJ, USA

Joined: 2/17/2012

Choking on Tempco!

I somewhat scientifically placed a Bourns 6310 50mH choke with thermocouple taped to the windings and with electrical access wires in an old plastic first aid kit box, and stuck it in the freezer for a few hours.  Took it out, sat the closed box on my bench, connected the probe and coil to my instruments, and monitored the inductance while the coil heated up to room temperature.  I'm seeing approximately 740ppm change per degree C, which I think pretty much knocks it out of the running for my uses.

To put this change in perspective, there was a ~1mH change over the range of -11 to +17 C.  A whopping 2% - and that ain't milk!

I performed the same experiment with one of my hand-wound air-core coils (~6mH) and saw essentially no change in inductance (to 4 decimal places) over the full temperature range.

So it looks like the plastic display box I was hoping to use is also out, as it isn't large enough to house good sized air core inductors.  I knew this day was coming.  At least I have my air-cores to fall back on.

The 6310 may be good enough for the volume side though?

Posted: 1/24/2014 9:48:40 PM

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

Thanks for that useful plot, Dewster! - Yeah, my ATE was giving wrong readings if yours are correct - I suspected as much!

"The 6310 may be good enough for the volume side though?" - Dewster

*See Edit below..

IMO, its good enough for pitch! IF (and only if) one does dynamic correction for temperature - Its dead easy to have a thermistor or semiconductor junction temperature sensor outputting a voltage proportional to temperature, and to feed this to a control node on the oscillator / AFE... Doing this (having a preset) one can not only trim away the inductors error, you can also trim away any other errors (capacitors, adjustable inductors, semiconductors etc)... Oh, one still gets some error (the tempcos of components can be non linear and the relationships between these and the temperature sensors output and the control node function can add complexity) but so far I have found that these are insignificant compared to uncompensated performance.

But without any such dynamic correction, things get much harder - one must rely on matching the tempcos of components so they cancel each other out - and depend on using same topology oscillators so they drift together (which doesnt compensate for the antenna inductance).

Fred.

*Edit -> .. Just noted that you are using the 6310 (50mH) part .. I have never used these (SRF is way too low for my frequencies anyway) - Never gone larger than the 6306 (10mH).. and tend to go for series connected lower L inductors if I need more than 5mH - prefer to use two 6304's for 10mH

But I expect the Tempco's will probably be similar.. I doubt that the cores will have different ferrite for larger inductances - But they might have.. I notice that other manufacturers change their cores as inductance increases, even in the same series (Hammond 1530 series for example - switches from Iron to Ferrite core at 25mH)

Posted: 1/24/2014 10:39:57 PM

From: Northern NJ, USA

Joined: 2/17/2012

Fred: I can imagine doing tempco with a thermistor via analog means might not be too impossible, but how about digitally?  I'd need something that kicks out ~14 bits or so of temperature information (wild guess, depends I suppose on the C/bit and how much the circuitry needs correcting) so as not to get audible stepping correction events happening on the pitch side.  The ones I'm seeing available at hobby sites are 12 bit and use a goofy 1 wire communication protocol.

A large air coil on the pitch side is attractive from other angles: it physically separates the drive side from the sense side thus increasing sensitivity; and it looks purdy and gives it genuine Theremin gravitas.  Cost isn't much more either.  I think I'd rather start with inherently stable components (if it isn't too much trouble) and work up from there.