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

Posted: 9/9/2024 7:03:16 AM
Mr_Dham

From: Occitanie

Joined: 3/4/2012

This is the first time I've heard of a homopolar toroid.  Was that for a current sensor (e.g. Rogowski coil)?

In the electricity distribution domain, an homopolar toroid is a 20cm toroid ferrite with a secondary winding only, the tree phase wires pass through it and then you get an image of homopolar current at the secondary winding. In a lab, if current injection box has not enough power you need to manually wind a primary winding (e.g. 100 turns for 100 A injection). 

"https://patents.google.com/patent/US6414475" 

Yes, I would have loved to have such a machine, or only the same idea, at that time. I used a kind of weawing shuttle instead. Depending on whether the toroid can or cannot open, the experience is not the same...

Posted: 9/9/2024 1:26:12 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Coiled Plates

So I've done a few rough experiments using three different coils as the Theremin antenna:

A CW (clockwise) solenoid, a CCW solenoid, and a spiral, all made of household solid copper wire.  Note that the spiral can be flipped over to make it CW or CCW.  I measured total Q while sitting on directly on top of a 10mH solenoid, and again with 30mm or so of spacing between the antenna and the 10mH solenoid.  As expected, total Q decreases a bit when the plate coil is counter wound to the 10mH and placed closer to it.  So nothing earth shattering or dramatic to report.

I also messed around in a spreadsheet, calculating the relative capacitance of a 2D rod type antenna to one's finger, where the finger is held a constant distance from the rod, but moved up and down the rod.  Playing with conductive weighting towards the ends of the rod, it seems one needs to massively weight the ends of the rod (vs the center) to make the up and down finger movement produce a constant response, and this response is only sorta linear when the finger is quite close, like 10mm or 20mm.  Moving closer you get a "hollowing out" of the middle, moving farther gives slightly better linearity over a solid conductive rod, but the returns are fairly marginal, and I have no idea how to very heavily weight conductivity to the rod ends like that.

The whole point of this investigation was to see if 
1. a nearfield plate could be better linearized over the area being addressed by the hand, and also 
2. if the plate could be made less of a Q damping "shorted turn" when placed very near the coil.  

The initial conclusion for (2) is that a spiral seems to allow closer placement to the coil.  For (1) the spiral turns could be concentrated more towards the outer edge.  But a spiral wouldn't have the full intrinsic C of a solid continuous plate.  What might work is a plate with a hole in the center, the diameter of which somewhat larger than diameter of the 10mH coil.  This and narrow radial slot cut in it to minimize the current loop might help to defray damping.  The hole, and extra plate material at the edges going 90 degrees backward might help to accentuate the edge response, improving linearity a bit.  The covering insulation might limit closeness and prevent hollowing out of the center response.  This is my next TODO experiment.

A square plate somewhere between 150mm to 200mm on a side feels to me like a comfortable playing surface size.

Posted: 9/26/2024 5:28:40 AM
gerbold

Joined: 9/26/2024

Hi, this is Klaus Hoffmann. I'm new to both Theremins in general and D-Lev in particular. I'm no musician either.
I started this weekend to dig into the subject and found https://d-lev.com/ an interresting project, especially as the device is played by real musicians in concerts.

The first step I reached is to build the Hive assembler on Windows 10 and with it build the *.spi and *.mif files from theremin.hal. I want to share my experience.



Build instructions for hive_sim.exe on Windows 10 using Cygwin g++.

Preconditions:
- install Cygwin and here especially `gcc-g++`
- download and unzip https://d-lev.com/source/d-lev_sw_source_2024-01-08.zip
- delete hive_sim and hive_sim.o (obsolete executable and object file)
- backup 94e67227.spi, hive_0.mif, hive_1.mif, hive_2.mif, hive_3.mif (will be generated)

1) fix hive_pkg.cpp
In the function `str_trim()` replace these two lines:

Code:
    while (ch_is_white(str.front())) { str.erase(str.begin()); }
    while (ch_is_white(str.back())) { str.pop_back(); }

with these two lines:
Code:
    while (str.length() && ch_is_white(str.front())) { str.erase(str.begin()); }
    while (str.length() && ch_is_white(str.back())) { str.pop_back(); }

Without this fix, the program will terminate silently without writing the output files when the string `str` reaches zero bytes length.

2) build hive_sim.exe
open cygwin64 terminal
cd "\path\to\d-lev_sw_source_2024-01-08"
g++ hive_sim.cpp -o hive_sim.exe -std=gnu++11

Build instructions for the *.spi and *.mif files.

1) execute hive_sim.exe
It will read theremin.hal and recursively all included files: pkg_boot.hal, pkg_ch.hal, pkg_defs.hal, pkg_enc.hal, pkg_filter.hal, pkg_float.hal, pkg_hcl.hal, pkg_int.hal, pkg_lcd.hal, pkg_midi.hal, pkg_mod.hal, pkg_noise.hal, pkg_osc.hal, pkg_params.hal, pkg_pitch.hal, pkg_spi.hal, pkg_str.hal, pkg_tuner.hal, pkg_uart.hal, pkg_ui.hal, pkg_vol.hal, thd_0.hal, thd_1.hal, thd_2.hal, thd_3.hal, thd_4.hal, thd_5.hal, thd_6.hal, thd_7.hal.
It will write
- hive_0.mif, hive_1.mif, hive_2.mif, hive_3.mif
- 94e67227.spi

2) press any key to continue...
3) enter "quit" (without the quotes) and enter

Compare the written files with your backup. They shall be identical.


As I understand on the FPGA a soft processor core named Hive is implemented (https://d-lev.com/research/Hive_Design_2022-10-24.pdf).
I guess the .hal files are the "Hive assembly language" files and hive_sim.exe is both assembler and simulation of the Hive core.
If anyone can point me to the language description I'd be interrested.
I'm also interrested in the use of the generated .mif and .spi files. Where do they go to in the next step?

Posted: 9/26/2024 8:56:06 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"In the function `str_trim()` replace these two lines:" - gerbold

Ah, thanks for that Klaus!  Have to watch C++ strings like a hawk, and C++ programs tend to crash and panic in mysterious ways.  I much prefer Go.

"I guess the .hal files are the "Hive assembly language" files and hive_sim.exe is both assembler and simulation of the Hive core."

Yes.

"If anyone can point me to the language description I'd be interrested."

This is a to-do for me, though I do think a lot of it can be inferred from the use cases, comments, and processor white paper.  The assembler / simulator flags stack faults and interrupt misses (running out of real time), which are the more difficult things for the programmer to manage.  Not sure at this point if future versions of the D-Lev will continue with my Hive processor or not - if not then HAL will probably be largely abandoned along with it.

"I'm also interrested in the use of the generated .mif and .spi files. Where do they go to in the next step?"

The *.mif files replace the ones in the "Q20_v0.9.4" FPGA directory and a build done with Quartus.  This provides the default "golden" SW load in the FPGA block rams (BRAMs) so the D-Lev is un-brickable.  The *.spi file is loaded to the EEPROM via the librarian software, and its CRC is checked at boot - if the CRC is OK then the EEPROM*.spi load replaces the BRAM default *.mif load and boot proceeds.

Posted: 9/26/2024 6:24:18 PM
gerbold

Joined: 9/26/2024

This is my understanding of the KiCad files:

main connects to
+- J1/J2 = FPGA module Waveshare CoreEP4CE6 with ALTERA Cyclone IV chip EP4CE6E22C8N
+- J4 Pitch AFE = d-lev_afe
+- J5 Volume AFE = d-lev_afe
+- J6 Right Encoders = d-lev_encoders (4 turn and push knobs to control the menu in the LCD)
+- J7 Left Encoders = d-lev_encoders (4 turn and push knobs to control the menu in the LCD)
+- J9 LED Tuner = d-lev_tuner_driver + d-lev_8mm_tuner (7 segment digit + star with 13 LEDs)
+- J10 (LED, MUTE, MIDI, MAIN, LINE, RxTx, 5V, GND)
+- J11 (power supply)

d-lev_footprints.pretty - required for the layout (do not yet know how to import into KiCad)
JLCPCB -> probably pre-packed gerber data for https://jlcpcb.com/

One needs
1 Waveshare CoreEP4CE6
1 d-lev_main
1 d-lev_tuner_driver
1 d-lev_8mm_tuner
2 d-lev_afe
2 d-lev_encoders

Is there a BOM (bill of materials) that lists all the connectors, resistors, cables, LCD, buttons, ... that are required?

Quartus seems to be the tool from Intel.
https://www.intel.de/content/www/de/de/products/details/fpga/development-tools/quartus-prime/resource.html
As the Lite edition supports Cyclone IV FPGAs, it is probably sufficient.

Posted: 9/26/2024 11:35:02 PM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

"This is my understanding of the KiCad files"  - gerbold

Yes to all.

"Is there a BOM (bill of materials) that lists all the connectors, resistors, cables, LCD, buttons, ... that are required?"

This is a list of parts, mainly for my accounting purposes, but it may help: https://d-lev.com/source/D-Lev_kit_parts.ods

"Quartus seems to be the tool from Intel."

Yes.  Not trying to discourage you, but if you don't want to regenerate everything from source, all of this is pre-compiled and pre-build for you in the source files, including the gerbers.

Posted: 9/27/2024 6:13:40 AM
gerbold

Joined: 9/26/2024

I tried to compile the FPGA project.
Is this the correct way and which is/are the required output file(s)?

- start Quartus Prime Lite Edition
- open d-lev_fpga_source_2024-01-08\Q20_v0.9.4\ep4ce6e22c8_demo_board.qpf
- menu Processing -> Start Compilation

In the processing window a bunch of lines is shown and finally
>Info: Quartus Prime Timing Analyzer was successful. 0 errors, 3 warnings
> Info: Peak virtual memory: 4915 megabytes
> Info: Processing ended: Fri Sep 27 08:05:55 2024
> Info: Elapsed time: 00:00:03
> Info: Total CPU time (on all processors): 00:00:02
>Info (293000): Quartus Prime Full Compilation was successful. 0 errors, 10 warnings

As a result I see a bunch of new files named ep4ce6e22c8_demo_board.* being created.

Posted: 9/27/2024 7:15:15 AM
gerbold

Joined: 9/26/2024

continue in Quartus Prime Lite Edition to convert the programming files
- menu File -> Convert Programmig Files...
    - Open Conversion Setup Data...: ep4ce6e22c8_demo_board.cof
    - scrol down and press [Generate]
    - Do you want to overwrite [output_file.jic]? [Yes]

The generated output_file.jic is different compared to the ziped file.
This may or may not be a result of my
"Quartus Prime Programmer Version 23.1std.1 Build 993 05/14/2024 SC Lite Edition"
is higher than the originally used
"Quartus Prime Programmer Version 20.1.0 Build 711 06/05/2020 SJ Lite Edition"

Posted: 9/27/2024 8:35:02 AM
dewster

From: Northern NJ, USA

Joined: 2/17/2012

Yes.  Any generated *.mif files should be placed in the Q20_v0.9.4 directory before you run Quartus (it will replace those already there).

After the Quartus run:
1. File | Convert Programming Files... | Open Conversion Setup Data...
2. Select "ep4ce6e22c8_demo_board.cof"
3. Generate | (Overwrite?) Yes

This generates "output_file.jic" which is the programming file.

After this you can connect the programming dongle, power up the FPGA demo board, open the programmer, and select setup the hardware.  It can get a little weird at this point, you may need a bit of hand holding depending on which OS you use (Linux in particular is really weird here).

Posted: 9/29/2024 9:05:30 AM
gerbold

Joined: 9/26/2024

I'm about to search for the parts. While doing so, some open issues have been identified.

1) Is there a wiring plan to parts that are meant to be mounted in the housing and connected to main board connector J10 (or other connectors)? Or maybe even a breakout board that accomodates all the external connectors? Very likely there is no common scheme as different people have various housings and different needs for external connectors.

2) Are the builtin Toslink and the serial interface all that is required to get started? The serial lines Rx and Tx are used to connect the command line librarian to d-lev, right?

3) All mounting holes have a diameter of 3.2mm for M3. Just the mounting hole H5 of the d-lev_8mm_tuner has a diameter of 2.5 mm. Is the 2.5mm hole intended for cutting an M3 thread?

4) All 0.1µF ceramic C have 2.5mm pin distance. Not so C2 of the main baord which has 5mm. Does this C have to be electrically different compared to the others?

5) There are many one pin connectors of the type Con_01x01_Male. I assume the majority of these does not need to be assambled. Probabyl these are kind of test points or for future use.
d-lev_main: J12 (GND), J13 (+5V), J14 (+3.3V), J20 (gpio_i[2]), J21 (gpio_i[3]), J22 (gpio_o[2]), J23 (gpio_i[3]), J24 (mido_tx_o); mido_tx_o may be the inverted midi_tx_n_o
d-lev_tuner_driver: J3 (DP)
d-lev_afe: J4 (GND), TP7 (C_DIV)

These two are probably required to connect the solenoid. But how exactly are the connections between antenna, solenoid, and d-lev_afe?
d-lev_afe: J2 (L_IN), J3 (L_OUT)

Not clear about the ESD pin. The ESD plane is connected to the mounting solder pins of the EC11. As the mucisian touches these buttons, there is the risk of electrostatic discharge. What is to be done with these three pins?
d-lev_encoders: J8 (GND), J9 (ESD), J10 (GND)

6) The LCD type is not well specified. When searching for displays, I could not find one that really fits the electrical conditons.
From the schematics I get this iformation:
    4*20 characters
    16 pins
    pin 1 GND
    pin 2 3.3V
    pin 3 contrast
    pin 4 lcd_rs_o
    pin 5 GND
    pin 6 lcd_e_o
    pin 7 nc
    pin 8 nc
    pin 9 nc
    pin 10 nc
    pin 11 lcd_data_o[0]
    pin 12 lcd_data_o[1]
    pin 13 lcd_data_o[2]
    pin 14 lcd_data_o[3]
    pin 15 5V
    pin 16 lcd_cathode

In "Let's Design and Build a (mostly) Digital Theremin!_2023-12-30.pdf" I found at one place a hint for HD44780 as the LCD controller and also for Eastrising ERM2004-2 (which uses SPLC780D as LCD controller). Based on what I've read in discussions, both LCD controllers have the same command set but slight timing differences.

https://www.buydisplay.com/download/interfacing/ERM2004-2_Interfacing.pdf
see note page 1 bottom left "If the power supply is 3.3V, please supply 3.3V power to Vdd(Pin2) and LED+(Pin15)"
Pin2 VDD = 3.3V requires Pin15 LED+ = 3.3V
Pin2 VDD = 5V requires Pin15 LED+ = 5V
-> issue in main board: J3 Pin2 = 3.3V; J3 Pin 15 = 5V

https://cdn.shopify.com/s/files/1/1509/1638/files/HD44780_2004_Blaues_LCD_Display_Datenblatt_AZ-Delivery_Vertriebs_GmbH_dbc38321-88f1-4a4c-95da-0babb44c755f.pdf?v=1614340553
Pin3 VO LCD contrast min/typ/max = 4.5/4.8/5.1V
-> issue in main board: RV1 R_POT_US is connected to 3.3V which is too low

Possibly it would be an improvement to have jumpers or solder bridges to select 3.3V or 5V for each of the positive voltage at RV1 R_POT_US, J3 Pin2, J3 Pin15.

7) What are the properties of the power supply? 5V but how much A? Would a USB charger be good enough or does one need a low noise power supply? Recommendations?

8) What are the desired properties of the solenoids?
"Prototype Parts List" dewster 10/10/2018 10:07:36 PM [1598] says
- 2mH air core solenoid for pitch
- 4mH air core solenoid for volume
"Coil Dope" dewster 2/16/2023 10:38:07 PM [2996]
- 1mH pitch coils with 30AWG
- 2mH volume coils with 32AWG
The closest I can get to 38.1mm is PVC pipe with 40mm. Assuming 1mH and 2mH, these commands should calculate the solenoid, right?
- tc-win.exe solenoid -awg 30 -b 1 -fd 40 -c 15 -l 1 -file solenoid
- tc-win.exe solenoid -awg 32 -b 1 -fd 40 -c 15 -l 2 -file solenoid

9) It would be quite helpfull to have some pictures:
- each assembled PCB (standalone)
- the PCBs that are mounted together i.e. main+LCD+FPGA and tuner_driver + tuner_LED8
- all PCBs with their connectors laying on a flat table

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