Monday, December 21, 2020

DCO 1.4 with memory / 3.3v Vcc

I intend to access memory from the DAC when using it as a wavetable oscillator. I have bought a large number of Winbond W25Q128 128Mbit SPI flash memory chips, however, they are 3.3v max.

That's not really a problem though - the PIC16F18346 and the DAC8830 runs fine on 3.3v, I just need to remember that when adding memory! I've tested and it looks ok. I can however NOT use 5v for the DAC reference, so to get the same output amplitude we need to recalculate the charge voltages.

DCO 1.4 tiny but major bug

Crap. I really messed up when I ordered the DCOs. I misread the datasheet, it says the DAC can drive loads of 60k unbuffered. I read this as "max 60k resistors" on the output, when in fact it is the opposite, minimum 60k. 

I even changed the 100k input resistor to 22k to prevent issues - 100k would have worked just fine :-(

I have tested the circuit and the effect is that the DAC is not able to get the output all the way up to 5V, it tops out around 4V and more importantly, at an unknown voltage. For charging the cap this may not be a big deal as the charge time is calibrated anyway, but for using the DAC as a wavetable DCO this really messes up things.

So, what can be done about it? Well, we have a few options

- 1: Replace R5 and R3 with 120k resistors (this lets us do what was originally planned, having a second external buffer to use as wavetable output.

- 2: Remove R3, R5 and R1 and R5. Replace R3 with a solder blob, effectively making an op amp buffer connected to ground, the same way we normally disable opamps. Then use an external opamp instead of IC3B, tapping the CHARGE_VOLTAGE pin and re-injecting the result at the CAP output pin. We may even be able to leave R3 in place, though I'll need to read up on this first.

- 3: remove R5 only, tapping the CHARGE_VOLTAGE, buffer it and then reinjecting at the other end of R5, however, that point is not exposed so we need a wire.

- 4: Desolder R5, cut the power lines and both cap inputs to the IC3 TL072 and use a whole separate one for both A and B.

Seeing as I can't solder anymore, option 2 or 4 is the simplest work for someone else desoldering the resistors, or me cutting the resistors in two. Option 2 will use a little bit more power as the opamp will still be in place, option 4 requires more opamps on the "main" board.

Distortion tested

 I breadboarded the distortion PCB today and it works as it should. 

As designed the overdrive is effective from above 5v, and tops out at approx 10V for soft clipping and a bit higher for hard. This means that the output is a lot louder when distorted, but that can be adjusted using the gain pot.

Take these considerations when wiring on the breadboard:

- If no filter caps are used, you must put a wire between the two HP pins (3 and 4). 

- Use a 200/100k resistor divider from 15v to a positive input opamp buffer to get 5V for the logic level

- Use a 10k resistor to GND on the clip mode pin, then you can use a wire from clip mode to 5v to change mode without removing the GND connection

- Input/output: I used my i/o module. Input should be amplified 5x (2x att, 10x gain), output should be attenuated 5x (10x att, 2x gain). Even with this, the input is not high enough to distort. I had to add an additional inverting amp (10k input and 100k feedback resistors, 10x gain) to get proper distortion.

PS: I have a couple of errors on the I/O board: the 1/4" jacks have Tip and Ring swapped so it shorts when using a mono cable. Also, the silk screen is wrong, it says that Gain is 2x when jumper is open and 10x when closed, it should be the other way around. Also, it seems that there is a fair bit of HF loss but that may have been before I got att/gain set correctly.

Sunday, December 20, 2020

Muliplexed evelopes

I've dreaded doing the envelopes for a long time, mostly because there is always something crazy happening that takes a long time to debug. But now I have a very good working prototype.

I looked at my previous post here: http://atosynth.blogspot.com/2015/02/sample-and-hold-acquisition-time.html

Using 10nF sample and hold caps I wrote (5 years ago...) that an update time of 25uF seems appropriate. I have, however, not shown the original circuit, I have to go back and check if I buffered the op amp or not - because when I redid it now I could not get the desired speed. I had to run updates for at least 50uS. When I added an opamp after the dac however, things changed. I can't see any difference even when I run updates at 16uS. 

So, I've written an arduino program that updates a dac every 25uS. This is multiplexed to as many channels as possible, and the overall refresh rate is 1kHz.  I had a lot of issues related to starting/stopping the various times and ended up with a 25uS timer running all the time, just turning off the DAC update when all channels have been updated.

The output chain goes like this:

DAC8830 -> TL07x buffer -> CD4051 mux -> output buffer, 10nF cap + TL07x 

The mux is controlled by aCD4520 clock (only two pins needed for clock, one for next and one for reset-to-zero). Before an update, the inhibit signal of the mux is raised, turning off the outputs. The clock is progressed, switching to the next output. The DAC is updated and settles in 1uS, then inhibit is turned off and the output turned on. It is left to charge the cap for the remainder of the time between DAC updates, approximately 16uS. Rinse and repeat.

I tried updating a square wave at 1kHz too, it looks surprisingly good. The edges are slightly rounded, but that seems to be an artefact of the caps as increasing the charge time does not affect it.

DAC control. 1: chip select, 2: SPI clock. 3: DAC data, 4: mux inhibit

1kHz square wave on one of the outputs

Envelope output, 1kHz sample rate

Closeup of steps. Each step is held by the sample and hold cap, the DAC is disconnected right after the start of each step



Friday, December 4, 2020

Tons of new circuits ready!

So much has happened this summer and fall, and I haven't written about half of it! Some of it is directly related to the XM8, but most is utility circuits. I simply decided that I had to take time to do do some intermediate steps before building the final voice cards.

A shortlist of circuits I've designed, breadboarded, tested and finally produced at JLCPCB/DirtyPCBs follows below. Everything has been soldered by my good friend and colleague Stig-Rune!

Analog CV bank with 16 CVs in groups of 4.



For each CV you can select between lin or log/antilog  response, as well as uni or bipolar operation. Per group of four you can select the CV range, 0 to 2.5V, 5V or 10V (or +/-2.5V etc for bipolar). I did fuck up the PCB slightly so I had to cut a trace in three places and solder a wire. Also, I messed up a cable so I shorted the outputs, almost overheating the opamps. After that it worked perfectly. Output is via 10 minijacks and a 10p IDC connector for easy connection to a breadboard.


Quad input/output module with 1/4" jacks


For each module you can select input or output connected to the 1/4" jack, and the opposite will be connected to a minijack. Both ends are also connected to a 10p IDC connector for easy connection to a breadboard. For each channel there is an option of 10 or 2 x attenuation and 10 or 2 x gain, meaning you can either have a unity gain circuit, a 5x attenuation (for line out-ish) or 5x gain (for input).


24/48 button module, digital

A digitally scanned button module (without the microcontroller), chainable for up to 48 buttons. Serially read so it only requires four pins + power, making it possible to combine it with the potentiometer module on the same cable.


8 to 64 potentiometers module, digital


A digitally scanned potentiometer module (without the microcontroller). Each module has 8 potentiometers, and 8 modules may be chained for a total of 64 potentiometers. As with the button board, it only requires four pins, and it shares the same clock and reset pins at the button module so a total of six pins + power is needed for all digital modules. During testing I discovered that pin 9 on IC2 - one of the address lines - should have been connected to GND. Now it is floating, so it isn't possible to set the address correctly. It's an easy fix however.


4 x IDC Passthrough module

A simple panel with IDC connectors on both sides, makes it possible to route IDC connectors as a group through the front or back panel without putting the cable through a hole.


Bitcrusher

A combined 12 bit sample rate reducer and bit rate reducer with analog and digital control, based on a PIC16F18446 microcontroller with built-in ADC. Described in separate posts. I've ordered 25 of these.


20kHz LPF

A filter module that can be used as an anti-aliasing filter for ADC input and reconstruction filter for DAC outputs. I use the same configuration in the Bitcrusher and intend to use this for the combined DCO/wavetable oscillators. The circuit comes from this page: https://www.analogfilters.com/anti-aliasing-filter/


Voltage Controlled Distortion

A distortion module for the XM8, the second of the two pre-filter FX (the bitcrusher being the other). Controllable distortion amount and output amplitude, as well as switch between hard and soft distortion. Untested.


Memory


A DIL mounted SMD chip, 128Mbit, for use as sample memory for the wavetable oscillators etc. Untested.


Prophet VS keyboard controller

A new revision of the 68b01 clone for the Prophet VS. I've ordered 20 of these so I have for future sales. They have all been programmed but are missing legs.


Modular synth power bus board

16p Doepfer standard boards with 7 connectors. A bit short but cheap to build.


10p and 16p breadboard IDC connectors

Tiny boards with an IDC connector on one side and legs on the other, making it easy to use ribbon cables between breadboards and modules


Unbuilt designs

In addition, I have PCBs for the following that has NOT been soldered yet:



Breadboard power and I/O module

Has input for +/-15v and a regulator for 5V. Also has IDC connectors for chaining multiple boards, and small chain-boards that can be fitted upside down to connect multiple boards. Connects to the power busses on the breadboard. No more risk of messing up polarities! Also: a 10p Doepfer compatible power connector, although the doepfer uses +/-12V, not 15V, and a 10p I/O connector that connects a ribbon cable to 10 pin headers for easy and stable connections. Pin 10 may be connected to ground with a jumper.


Breadboard coax connector and I/O module

A board with four coax connectors and the same 10p I/O connector as the board above. Will give stable connection points for oscilloscop, function generator and other gear that uses coax.


15-to-12v DC converter module

A module that converts +/-15v from either a molex connector or a 10p IDC connector to +/-12v and +5v. Output is through a 16p connector, compatible with the Doepfer standard. Also has a two pin header for injection of Gate and CV 


All in all 16 different boards! Needless to say, I'm more than pleased! I'm getting so close to being able to test an initial voice board, I just need to program some digital envelopes.


Bonus

I finally got the following soldered and ready for testing:

Two versions of the sample and hold buffer, one with some large caps and some filtering and one in a tiny DIL14 format, both quad sample & hold:



Then the second version of the DCO, this time with DAC output to make it a wavetable oscillator too:



Saturday, November 21, 2020

Bitcrusher tested

I got the bitcrusher from JLCPCB working today. Last week I discovered that some of the tiny 0402 resistors had lifted from their pads, so the input filter did not let the signal through. Last night my wife soldered them (I love her and how skilled she is, those parts are soooo small!), and today I was finally able to test everything.

The left pad of the two 0402 resistors have lifted. Not sure if this happened in production or when the pins were soldered.


I am still surprised at how recognisable the output is at 1 bit 27kHz. It has a lot of noise, but the music is still very audible. I am still not entirely convinced that it does not leak from the input, but when I reduce to 0 bits everything goes silent so I guess it is actually possible,

I had a lot of trouble getting the sample rate high enough, currently the max is at 27kHz with a 1:1 prescaler on timer 1 and a timer start value of 0xFEFF. Changing to 0xF0FF drops sample rate to 2kHz, so it's really sensitive. I need to work more on this but I am fairly confident that 44kHz should be possible.

I still want to confirm that the filters work as expected and have a 20kHz cutoff, but if that works as expected I think I'm ready to mass produce the filter. Perhaps just doing a quick input SPI check first.


Here is my test setup btw, for future reference.



I've also tested the filter response for the input filter. It works fairly well although there are some slightly strange things going on. 

First of all, at 10-15kHz, the output signal (what the ADC sees) is amplified slightly, before it drops towards 20kHz. At 20kHz it is close to what I see in the simulation, so that's great. At 25kHhz it is even lower than what was simulated. There is also some distortion on the sine wave, not much but visible. I'm not too worried though, as this is not a hifi system. The tests sounded good enough to me. I'm more worried about the phase shift I see even at low frequencies, They may be very audible if the signal is mixed with the original. We'll just have to see (hear).

5kHz - no amplitude difference but a slight phase change

10kHz, the output has suddenly increased by 0.2V (5-10%)


At 20kHz we have a very visible attenuation. The filter is designet for 20kHz cutoff

Heavy attenuation at 30kHz





Friday, November 6, 2020

Shanpu switches

 I got a shipment of sample switches from Shanpu in Taipei today. I had to pay full DHL express freight but they were very nice and sent me the samples for free. I will be able to buy directly from them in multiples of 100 of each item, and the price ends up at around $1.4 per switch including cap, but shipping and a rather steep low-volume fee of $100 for orders below 1000 means the real cost is closer to $3-4 depending on the number of switches I buy.

There are several switches to choose from. All are rated at 1,000,000 cycles!

The SPH2S has an audible click and a short travel of 0.2 to 0.3mm, 190 +/- 50gf force

The SPH2T has a very audible click and a medium long travel of 0.4 to 0.6mm, 230 +/- 50gf

The SPH2N has a no audible click and a very long travel of 1.0 to 1.4mm, 60 +/- 40gf


Then there is a low profile version, but it is only rated for 100,000 cycles, so unless it is more suitable due to the low profile, I should really go for one of the others.

The SPFSP1 has an audible click and a short travel of 0.2 to 0.4mm, 200 +/- 50gf force


In some ways I like the N version best, it sits somewhere between the keyboard switch feel of the Nord keyboards and the normal clicky synth button. It doesn't feel quite right somehow though, it's like the travel is a bit too short or something.

The T is a bit too noisy for me, so that leaves me with the S. The click feel of the S is closest to the D50 when comparing to some of my synths. It is a little bit on the heavy side though, switching between it and the N makes me think I like the feel of the N better.


But then there is another issue - caps.

I ordered six different caps in four different designs

YCA085C, a 9.6mm round, transparent black cap with a "lense" effect on top. It turns out that it is glossy, and because of the way it has been made, with a hole in the center, the light is rather uneven. Not too much, but it is not the best.

YCA151A, same as YCA085C, but one mm shorter and Ice color (translucent white). The light is much better, but this may simply be because more light gets through due to the color, or it is because it is 1mm shorter. I have to retest the black one with a smaller diode. Of course, its white when switched off, so it will not blend into the design if I choose a black front panel.

YCA080C, an 8mm round transparent black cap. It has a more frosted look and is flat on top. It looks really great and the light is much better too. It has ONE major drawback though, and that is that it's only 3.3mm long. If I use a 3mm panel, or a long travel switch, it is simply too small for me. It's really a shame, because it's hands down the winner when it comes to looks. Oh, and it would be a perfect match for the 8mm black alu 

YCA059C, an oval transparent black. It is too small for my liking.

YCA044A, a square, 7.5mm ice white cap with a slightly rounded top. It looks good, but is too thin, and the led is clearly visible through, so I can't use it.

YCA043C, a square, 7.5mm transparent black cap with flat top. Unfortunately it is simply too transparent and completely useless. It WOULD however make a perfect base for glueing the black 8mm alu caps on top of, if I want to use them with the same switches. I may even use them for the red square Aliexpress caps.

Bonus test: The red square aliexpress caps look ok with the led, though they have an internal pattern that is very visible. It doesn't really look like they are meant to be backlit.

That means that I'm probably down to two options: The biggest round transparent black cap with whatever switch I like the best, or the 8mm round cap with the S-model switch and a thinner panel. I must test if I can get away with 2mm aluminum.


Update:

1 - There is an even better option for attaching aluminum caps: They sell a 5mm round cap, YCA052, which probably will fit very well inside the aluminum - perhaps with a 1mm gap that could possibly be filled with glue? There is also a 6mm one, YCA046. Perhaps I should buy both just to check. BTW: The top of the alu cap may be too thick for this option, but the extra cost of buying 100 caps is so little that it would be stupid not to do so.

2 - For the switches where the led will NOT be used, it would be possible to put a piece of black cardboard inside and coloring the edges of the cap holder black to get a much darker cap - the white parts shine through and making the insides black helped a lot.

3 - changing from a 270Ohm to a 150Ohm for the thicker transparent black cap helps. Still not as good as the other though, so I definitely have to test 2mm aluminum panels.

Tuesday, October 6, 2020

Nyquist and reconstruction filters in practice!

I assume you've heard about the Nyquist sampling theorem? It basically says that you have to sample a signal at twice the sample rate of the highest frequency you want to represent, that's why CDs have a sample rate of 44kHz - to be able to reproduce signals around 20kHz.

You may even have heard that doing so, you are not only able to reproduce an approximation of the original signal - you can reproduce an exact copy.

But have you actually seen this happen in practice? Let me show you! 


Sampling

A/D and D/A conversion is fairly simple in its basic form. Use an ADC and check the signal amplitude/level at set intervals. DAC is the reverse, set the amplitude of the output to whatever you got from the ADC (There is more to it than that for high quality signal reproduction, but for the sake of the discussion, and for the level of accuracy I need this suffices). 

Try this at home, looking at the output on an Oscilloscope and you'll quickly realise that the output looks nothing like the input. It has jagged edges, you can clearly see the height and length of the individual samples as output from the DAC. 

This is because there is one (two) more very important element(s) needed. To prevent aliasing - a higher frequency signal (outside of the audible frequency range) masquerading as a lower frequency one, we need to use a low pass filter before the ADC to remove frequencies that cannot properly be captured, e.g. frequencies above 1/2 of the sampling frequency.

When playing back the signal we need to do the same - as the DAC outputs a stepped signal it will generate lots of higher frequencies as well. By using a filter with the same cutoff - this time called a reconstruction filter - those are removed (once again, this is more complicated in practice for a high quality signal, but let's forget about that for a minute).


Ok, so that all sounds great on paper. Output a stepped signal and apply some magic, and you should get the original signal. But it can't be that easy, right?


Let's look at some photos:


DAC output (top) vs output after reconstruction filter
DAC output (top) vs output after reconstruction filter

Here we see the output of a sampled sine wave (top) vs the output after the 20kHz reconstruction filter. It looks amazing! It works for other waveshapes as well of course, though if we were to zoom in on the edges of the triangle wave we would see that it's slightly rounded - this is because the frequencies required to reproduce it faithfully have been removed by the two filters. This is of course not a big deal as we wouldn't hear them anyway. 

Sampled and reconstructed triangle wave, tips are rounded by filtering.


The effect is even more pronounced with square waves which get a clear oscillation at the edges



Increasing the frequency of the input shows that the DAC output no longer resembles the input as closely - it has very few samples per cycle of the sine wave:




Now things start getting strange. Increasing the frequency even further "distorts" the DAC output even more. Remember, Nyquist says that it should be possible to reproduce a sine wave with only TWO samples per cycle. It sounds incredibly strange, but it actually works! Here is a 15kHz signal, filtered at 20kHz. The DAC output looks nothing like the sine wave it is supposed to represent:


Seeing this for the first time blew my mind. How is it even possible?! Well, read up on the theory behind it in Steven W. Smiths awesome book "The Scientist and Engineer's Guide to Digital Signal Processing" (available for free as separate pdfs from his web page) if you want the theory.


Effects of filtering


Now, there are some effects of filtering still present. First, we get some phase distortion, which increases as we approach the cutoff frequency of the filters. Looking at the input and output sines we can see that they don't line up properly:


As far as I know, this is not audible on its own. It WILL however be audible if the signal is mixed back with the original signal (which incidentally is how phasers are made). (PS: The photo is slightly misleading. Some of the apparent phase shift is only a delay between the input and output due to the time it takes for the DSP chain to process the signal. But the phase shift definitely increases as we approach the filter cutoff)

The second effect is that the amplitude (volume) of the output will decrease as we approach the filter cutoff. This is nothing special to this circuit, it's just how filters work - they do not have an absolute cutoff point, instead they gradually attenuate more and more. Having higher order filters with more stages will help - I'm using six poles in mine. High quality reconstruction filters however, do this differently. As we know how the filter affects the amplitude, we can do the reverse in advance - increase the volume of those frequencies. This cancels out the effect of the filter, keeping the volume constant for much longer. I have not bothered with this in my circuit as we're talking about fairly high frequencies anyway.

Saturday, September 26, 2020

Fake op amps?

I'm currently breadboarding the reconstruction/anti aliasing filter for the bitcrusher. Last night I noticed heavy distortion when the frequency approached 15kHz. Nothing helped, I even tried buffering the signal. 

Today I switched the TL072 op amps for 4558 opamps. And it worked straight away! I then swapped for some other TL072 with other numbers and it still worked.

I then tried using the original TL072s as simple buffers. When approaching 10kHz the sine input turned more and more to a saw wave. 

I popped in some other op amps I had laying around. LM1458 worked fine. Two versions of TL074 worked fine. But another batch of TL072 and one TL082, all with numbers fairly similar to the original TL072, failed in the same way.


Failing:

81SHC8M


At 20v p-p distortion is seen as early as 10kHz



Heavy distortion at 15kHz

Even worse at 20kHz

Reducing the amplitude to 14v p-p doesn't help



Working:

TL072 - 58CVY8M


Working fine at 20v p-p, 35kHz



I can only conclude that my stash of op amps has been infested by fake or faulty op amps. I tried googling the issue and found this:

https://sound-au.com/fake/counterfeit-p4.htm

https://forum.allaboutcircuits.com/threads/fake-tl082-are-actually-a-cheaper-model.141005/

https://www.muffwiggler.com/forum/viewtopic.php?t=179427

That site compares two TL072s - one with the number 18MDSHY which is assumed fake, and one 85AK87M, which is assumed original.

Funny thing, my *TL082* is numbered 18MDSHY... and the TL072s are 81SHC8M and 61SHC8M (My print is not bad in any way btw). My working TL072 is 58CVY8M and TL074s are 

LM1458 is WHY28M. It works fine at 20-30kHz but exhibits the same behaviour at 35kHz. That may be ok for an LM1458 though, I don't know.

Guess I'll have to dump my stash then :-(

Friday, September 25, 2020

Switches and caps again

 I've been trying hard to figure out a working combination of switches and key caps. I really don't want to use the normal tactile switches that so many old synths use. They wear out over time and the travel is very short.

Where I come from - IT - (and in the rest of the world I guess), mechanical keyboards are all the rage. Incidently, I used Cherry ML switched (and concidered Cherry MX) when I did the Machinebeats drum machine more than 10 years ago, long before Cherry MX became THE keyboard key. I even had a Cherry keyboard in the 90s. But I digress. What I'm saying is I want to use a proper switch, rated for millions of clicks.

The problem is keycaps. While Cherry do/did sell some non-keyboard keycaps, they are still square and keyboard-looking. That's why I want to create my own keycap. But 3D-printing the tiny mounts used for the various switches is not a very good option, especially with a filament based 3D-printer.

My idea is to use a commonly available keycap and mount MY part on top of that. That gives a much bigger surface to glue things to. However, getting a completely flat keycap seems almost impossible.

I'm considering four different switches: Cherry ML, Cherry MX low profile, Kailh Choc and Kailh Choc V2. The MX low profile seems really hard to find, but I've ordered the Kailh variants for testing.

After a few failed attempts, some nice, almost flat Kailh Choc caps arrived from Ali Express today. I immediately tried filing them down using some 180 grit sand paper. And voila! It looks great! The cap height went from 0.13" to 0.12", and now it's completely flat. Great Success! Only issue is the cap is ABS, so I can't laser cut the outline.






I'm still waiting for the switch. I've also ordered some round, flat-looking caps for the Choc V2, but it seems like I have a good option for the Choc so I might as well go with that.

On a separate note - using black keys was a really good idea, it is very easy to see when I have filed it down enough to be flat :-D

Sunday, August 30, 2020

DIY keycaps

 I'm trying to make some keycaps for the Cherry ML that are smaller than the standard square ones. My first try was mildly successful:




These were made using 0.8mm matte black acrylic. The text is engraved while the outline is cut. On the one with text, the hole has been cut as well, and we can see that it got too hot - the thin part below the hole is bent. 

On the second one, the hole has been made by engraving 6-7 times. This generates a lot less heat. Unfortunately, I chose to cut the outline afterwards, which made the thin part bend again. I think that cutting first, then engraving, would solve the problem.

I intend to mount the 0.8mm on top of a 3-4mm clear acrylic piece. It would also be worth trying to glue the pieces first to see if the cut gets better. I could then engrave the hole and stop once I reach the clear acrylic.

The text will be filled with white Lacquer-Stik.



I will glue the keycap on top of a fastening mechanism from other keycaps. The only issue is to get a good bond between the acrylic and the ABS which the keycap is probably made of. I've found a glue that promises ok results - Acri Bond 120.

Finally, I did the cutting with less powerful settings than our laser manual states.

3mm clear/black: speed 40, power 100

0.8mm black: speed 100, power 100