Open.Theremin.Xtreme - Open.Theremin.Uno with an Arduino Due-like core

Posted: 12/26/2016 5:01:30 AM
Macka

Joined: 12/26/2016

Hi guys,

I am embarking on building an Open.Theremin using a custom PCB and a SAM3SD8C ARM Cortex MCU (very similar to the Arduino Due's MCU, SAM3X8E). The CPU is clocked at 64MHz, but the timer/counter module is clocked at 16MHz to match the OTU.

I have quite a few features in mind that I plan to add to this project, but first I need to get the basics working (my current objective is to get pitch and volume control functioning correctly).

The design is based on the OTU V3 alpha, so it does not have a way of sampling the VOs directly, maybe in a future revision I'll correct that. Other potential flaws in the design are:

  • neither pitch or antenna inputs are connected to capture pins, so this is handled in interrupts only (same as the OTU's volume)
  • the chip select for the tuning DAC is connected to the designated peripheral output - this is only a very minor issue

Schematic: https://www.dropbox.com/s/tlzje1lb8cegjnb/Open.Theremin.Xtreme%20Rev%202.pdf?dl=0

The code has been manually ported from the Arduino IDE to Atmel Studio.

So far I've managed to:

  • get the start up sequence to play
  • the pitch to respond (poorly)
  • get USB<->serial working for control and debug info
  • add 3 routines based on the OUT V3 code for measuring:
    • the 16MHz timer clock (generally reads to ~16001465 Hz)
    • the pitch frequency leaving the flip-flop (reads about 360 Hz - 400 Hz with me away from the antenna)
    • the volume frequency leaving the flip-flop (reads about 7737 Hz with me away from the antenna)

I have had no success with automatic calibration and little to no success with the volume - I'm trying to track down if the latter is an issue with the way interrupts work on this chip or something else.

What I have noticed, however, is if I modify the debouncing routine to use 2 and 4, I do get some, albeit very poor, response

    if (PIOA->PIO_PDSR & IO_VOLUME_INPUT){
        deb_v++;                                    // volume pin counts debouncer
    }
     
    if (deb_v==3) {
        NoInterrupts();                             // Stop pitch and volume interrupts
        vol_counter=vol_counter_i;                  // Get Timer-Counter 1 value
        vol=(vol_counter-vol_counter_l);            // Counter change since last interrupt   
        vol_counter_l=vol_counter;                  // Set actual value as new last value
    }
     
    if (deb_v==5){ //4 works, 5 does not
        flag_vol=true;                             // set flag after 5 bounces   
    }

Is anyone able to tell me what frequencies I should be expecting coming out of the flip-flops? I'm suspecting the pitch frequency is ok, and the volume frequency is off, since with the debounce counters set to 3 and 5, vol=0 except when my hand is touching the antenna.

Any ideas on where to look to resolve the issue would be much appreciated.

 

-Andrew

Posted: 12/26/2016 8:04:55 AM
Thierry

From: Colmar, France

Joined: 12/31/2007

RTFM - the building instructions on the open.theremin website say it all... On the output of both flip-flops, you'll have to find around 800Hz with everything far away from the antennas - and steadily increasing when approaching.

Posted: 12/26/2016 9:30:11 AM
Macka

Joined: 12/26/2016

"RTFM - the building instructions on the open.theremin website say it all... On the output of both flip-flops, you'll have to find around 800Hz with everything far away from the antennas - and steadily increasing when approaching."

The only thing I can find on the site is a reference to an audio output of 600Hz. As I understand it, the frequency of the pitch input doesn't map directly to the audio frequency, but I could be wrong.
http://www.gaudi.ch/OpenTheremin/images/stories/OpenTheremin/ArduinoTheremin/open_theremin_uno_v2_instruction.pdf

I'll hook up my scope (though last I checked it matched what my measurement routines were telling me). I don't think I'm getting anywhere near 800 Hz or 600 Hz, even when making tuning adjustments with the DACs.

Posted: 1/14/2017 7:39:14 AM
Macka

Joined: 12/26/2016

Ok, so, life happened and I didn't manage to get the probes onto the board until now.

Whilst I'm not able to get far away from the theremin, I am moving away until the frequency stops changing drastically; there is obviously more of an effect with the antennas connected.

With the antennas removed, I'm seeing:

Volume fixed osc: 461.019 kHz
Volume variable osc: 475.250 kHz
Volume input (post flip-flop): 14 kHz

Pitch fixed osc: 499.995 kHz
Pitch variable osc: 506.250 kHz
Pitch input (post flip-flop):6.289 kHz

With the antennas in place (difficult to measure repeatably), I'm seeing:

Volume fixed osc: 461.019 kHz
Volume variable osc: 468.555 kHz
Volume input (post flip-flop): ~7.626 kHz

Pitch fixed osc: 499.995 kHz
Pitch variable osc:  500.585 kHz
Pitch input (post flip-flop): ~571 Hz

When I used multisim to try to predict the output, the results did not match the DSO, so I performed some analysis in Excel and can confirm that the recorded flip-flop output matches the Excel prediction for all but the last measurement (pitch input ~571Hz) - Excel tells me I should have ~1.176 Hz

Is no one else able to verify the volume input frequency?

Posted: 1/14/2017 10:24:04 AM
Thierry

From: Colmar, France

Joined: 12/31/2007

Multisim won't help you here. Correct Theremin operation depends sometimes 1/100 of a picoFarad. That's why you have variable capacitors to compensate differences in the antenna geometry and the environment. On my open.theremin v2 I have tuned everything to obtain 800 +/- 40Hz at both flipflop outputs with the antennas connected and the circuit correctly grounded.

Posted: 4/16/2017 12:33:26 PM
Macka

Joined: 12/26/2016

Ok, I seem to have partially rectified the issue by adding another ~33pF in parallel with the 330pF in the volume variable oscillator. I suspect that either my 330uF is out of tolerance or dropping from 5V to 3.3V for the power supply is having an effect.

I've rewritten the calibration routine so that it tries to get both variable oscs as close to 800 Hz as possible - this seems to get the theremin working, though I don't think it's working optimally (this is what it sounds like https://www.youtube.com/watch?v=pcvT7_V7S1o). When trying to write the calibration routine I did a sweep of the DACs (step sizes 15 (pitch) and 5 (volume)) recording the frequency of the flip-flop output; I expected the response to be roughly linear but neither oscillator turned out that way:

 

Since the calibration routine works differently from the original (closer to how the OTU V3 works) I'll probably have to play with how the unmuting code works as well - if I unmute with my hand near the antenna it all seems to go backwards (gets quieter as I move away).

I think there's still a fair bit of mucking around and learning before I can get this working as well as I'd like.

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