Something new I built - fun with decade counters

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Joe., lisa, luketeaford, Kent

Post Reply
User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Mon May 18, 2020 11:05 am

guest wrote:
Sun May 17, 2020 7:38 pm
the leakage will be dominated by the MUX.
Yeah, that's what I was wondering about that. It's interesting to note though, the datasheet for LMC662 shows right on the first page a "low leakage S&H" using the 4066 as the switch. Both the 4066 and the MUX506 claim the same OFF leakage (10pA), so I guess that is about as good as I'm going to do for now. I will try the existing MUX506 in conjuction with LMC662 and 0.1u PP caps just to see how it does though. They are coming in my latest Mouser order anyhow.

Synthiq
Veteran Wiggler
Posts: 551
Joined: Mon Feb 06, 2017 3:10 pm
Location: California

Re: Something new I built - fun with decade counters

Post by Synthiq » Mon May 18, 2020 12:29 pm

Wouldn't it be simpler to just refresh the data in the S/H repeatedly as KSS mentioned above instead of relying on extremely low leakage components. If an Arduino A/D-convert the input signal at the same time as it is sampled by the S/H, it can be recreated by a PWM indefinitely and be used to refresh the value in the S/H. With a good filter, it is possible to generate a stable signal with a PWM in less than 1 millisecond so a 12 channel S/H can be refreshed 80 times per second or more.

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Mon May 18, 2020 2:18 pm

I'm very green when it comes to microcontrollers, but I would think with even the Arduino route, the S/H caps, as leaky as they may or may no be don't need to be there at all, right? Can't the Arduino just be set up to sample the input and average over, say 5us every time it sees a clock pulse from the same thing signal that is clocking the main MUX? It would store 12 of these points, and then when done sampling, output them, with DAC of choice, sequentially for each clock pulse.

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Mon May 18, 2020 2:25 pm

there are some non-microcontroller techniques if you want, but they are pretty part intensive. you could clock through a small SRAM, or a shift registers, or octal latches and do your own ADC to store them. then its a simple 8b R/2R ladder at the output. if you used SRAM, you could have another knob to recall various patterns - ie you could have banks of waveforms.
openmusiclabs.com

Synthiq
Veteran Wiggler
Posts: 551
Joined: Mon Feb 06, 2017 3:10 pm
Location: California

Re: Something new I built - fun with decade counters

Post by Synthiq » Mon May 18, 2020 7:03 pm

devinw1 wrote:
Mon May 18, 2020 2:18 pm
I'm very green when it comes to microcontrollers, but I would think with even the Arduino route, the S/H caps, as leaky as they may or may no be don't need to be there at all, right? Can't the Arduino just be set up to sample the input and average over, say 5us every time it sees a clock pulse from the same thing signal that is clocking the main MUX? It would store 12 of these points, and then when done sampling, output them, with DAC of choice, sequentially for each clock pulse.
The Arduino ADC can convert a sample in 13us but Atmel recommend a 5 times slower clock for 10 bit resolution so you may be limited to 65us depending on requirements. This may be good enough for your circuit.

The VCO clock and the processor clocks are asynchronous, so on the output side some sort of double buffering should probably be used to minimize the timing jitter. I think it's best to let the controller output a byte/word for each VCO clock but only latch it into the DAC at the next VCO clock.

Once the processor starts to output 12 samples, it's not a big step to output arbitrary waveforms and it starts to look like a sample player.

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Tue May 19, 2020 10:21 am

Well, I have 12 segments, so at 10kHz output, the clock is going 120Khz, which has a period of just 8.3us, so that sounds like it is potentially too slow. I took out my Arduino Uno yesterday and started playing with triggering an interrupt with the clock, so I guess I'll see how it keeps up.

If I want faster, it sounds like Teensy is a huge jump up in speed, although, I want to keep this thing as simple as possible. Of course, there is the danger of massive scope creep :D. I COULD make a wavetable osc, or a sample device, etc... but..yeah. Scope creep. I guess I'd still keep it 100% if it was possible. :D Which, as guest points out, it probably is, but at the cost of a bunch more parts.

Lots to think about.

In the meantime, it has been nice breaking into the Arduino stuff again and learning some uC programming. I looked at my last files I had made in Arduino and they were from December 2018.. It's been a minute!

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Tue May 19, 2020 10:34 pm

OK, got it going on the Arduino! So far my speed concerns are valid. The limits so far:

using digitalWrite: 3.3kHz output (~40kHz clock)
using port manipulation (straight binary port address): About 11kHz (~132Khz clock)

So, the second option gets me close. If I went Teensy, it would be there no problem. So that's an option.


On the other hand, I was looking and 12 channel DACs are not so bad actually. This guy is a couple bucks: https://www.mouser.com/datasheet/2/348/ ... 807213.pdf.

I could use a MUX to bring the pot values into an arduino and then output them in parallel with the DAC. This way there are no asynchronus clock issues to deal with at all. This would allow easy storage of user slider shapes, as well as the random function or more interesting digital things....

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Tue May 19, 2020 10:56 pm

i can help write some code thats much faster. if youre just doing 8b, you can write a whole register at once in one clock cycle. looking up a piece of data from memory should only be 2 clock cycles. so for straight playback, timings in the MHz range should be possible.
openmusiclabs.com

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Tue May 19, 2020 11:18 pm

also, for sampling on the ADC at 8b resolution you can go up to 76ksps or so.
openmusiclabs.com

KSS
Super Deluxe Wiggler
Posts: 2040
Joined: Mon Jan 25, 2016 7:28 am

Re: Something new I built - fun with decade counters

Post by KSS » Wed May 20, 2020 12:31 am

This is not where I hoped this would go when I mentioned polysynth forefathers.

User avatar
EATyourGUITAR
has no life
Posts: 4591
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Something new I built - fun with decade counters

Post by EATyourGUITAR » Wed May 20, 2020 8:31 am

KSS wrote:
Wed May 20, 2020 12:31 am
This is not where I hoped this would go when I mentioned polysynth forefathers.
rest in pease
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Wed May 20, 2020 10:14 am

guest wrote:
Tue May 19, 2020 10:56 pm
i can help write some code thats much faster. if youre just doing 8b, you can write a whole register at once in one clock cycle. looking up a piece of data from memory should only be 2 clock cycles. so for straight playback, timings in the MHz range should be possible.
Oh, that would be awesome if you can share anything on that! Everything I've been able to find stops at writing to the port using interrupts. The guy who owns the Teensy company has a video on youtube where he changes the interrupt prioirty to the max (0) and gets up to 1.5Mhz pulse counting but that's on a faster Teensy, not a Arduino Uno.

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Wed May 20, 2020 10:18 am

KSS wrote:
Wed May 20, 2020 12:31 am
This is not where I hoped this would go when I mentioned polysynth forefathers.
Am I going down a route like that Jim Williams article on the Wein oscillator? :hihi: :doh: :guinness:

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Wed May 20, 2020 9:39 pm

In news back on the analog front, I just received some LMC660s and some .1uF PP Panasonic caps and WOW, much much better. I just set a S&H wave on my 3 channel prototype and went and prepared dinner. An hour and 15 minutes later, the wave is in the same place as it was when I started. No noticeable change on the oscilloscope. With the TL082s, the caps all bled entirely down during a <2 hour grocery shopping trip.

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 12:35 am

what size were the capacitors before? at 0.1uF, theres a limited sample rate you can achieve. lets say there is a 100ohm on resistance in your switches, then youre looking at 4*100*0.1uF = 40us min sample time. if there are 10bins per sample, thats 400us, or 2.5kHz.
openmusiclabs.com

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Thu May 21, 2020 10:25 am

I tried .01 and .1uF previously. They were Wimas that claimed to be PP. Both leaked though. Obviously the .01uFs faster though. But I would deem both rates kind of unacceptable.

I do realize that 0.1uF is kind of big for sampling time for sure.

Just thought I would share that the op amp does appear to be making a big difference.

I still think I'm going to implement the uC on this, because I can now easily add presets and a store button and such. Plus those LMC660s are like $3 a pop and would need 3 of them, plus the caps, plus a noise circuit.

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 11:32 am

have you tried swapping the 082 back in just to verify its the opamps and not the capacitor?
openmusiclabs.com

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 11:33 am

if you go the micrcocontroller route, do you want the microcontroller to produce the master clock as well?
openmusiclabs.com

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Thu May 21, 2020 12:15 pm

guest wrote:
Thu May 21, 2020 11:32 am
have you tried swapping the 082 back in just to verify its the opamps and not the capacitor?
No, but I will try to do that tonight. Although, based on the fact that the original caps were the same material (supposedly) and the large Ib difference in the 2 op amps, I would be surprised if it was the caps!
guest wrote:
Thu May 21, 2020 11:33 am
if you go the micrcocontroller route, do you want the microcontroller to produce the master clock as well?
I'm thinking no, because with the 3340 at the heart, it is still very analog, which i like, and I think the mixing of the clock-frequency harmonics at a sawtooth or triangle is a very nice feature which is easy to implement this way. I'm thinking at this point, Arduino Nano to handle pots MUX + memory, S&H (both wave sample and "noise" (random)), and the rest of the core would stay as it is now with the original prototype. But, I always welcome opinions or comments on why my ideas are not great (which is often the case!) :hihi:

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 12:32 pm

i just read the datasheet, and the MUX506 is way lower leakage than i assumed.

one downside to having the clock be external, is that the microcontroller clock and the vco clock will not be aligned, so you will get jitter. the faster the microcontroller clock, the better this will be. but, im not too familiar with low level programming on the nano, so im not sure what sort of penalities are incurred by using the arduino programming environment for it. ulitimately, its ok if there is a delay in code execution, as long as it is consistent and short enough that all code can execute before the next interrupt. whats the fastest vco clock you will want to use?
openmusiclabs.com

User avatar
devinw1
Super Deluxe Wiggler
Posts: 1366
Joined: Tue Aug 07, 2018 11:20 am
Location: Portland, OR
Contact:

Re: Something new I built - fun with decade counters

Post by devinw1 » Thu May 21, 2020 1:52 pm

Yeah, that's why I was saying why not just use the $2 12 channel DAC and be done with it. Then the "slow"/cheap/basic ATMEGA328 doesn't need to care about the clock of the analog part at all. It's just providing segment voltages and presets. But, then I guess is that might be a bit overkill?

If the uC was taking the clock and we were looking at the other approach, I'd say it needs to handle at least 200kHz because that would result in the top end, musically of the VCO that one would probably use (~16.7kHz C10).

User avatar
EATyourGUITAR
has no life
Posts: 4591
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Something new I built - fun with decade counters

Post by EATyourGUITAR » Thu May 21, 2020 2:14 pm

you can just use a hardware interrupt and timer overclocking on the 328P. your code will start executing within 1/4000000*timerdivider seconds at 4MHz internal crystal. how many clock cycles your code takes to do everything after the interrupt is triggered depends on the code. using the built in analog to digital converter on the 328P analogread() will fuck everything up because the settling time and execution time for analogread() is way way bigger than 6 clock cycles at 4MHz. the other problem you may have is that this kind of interrupt will literally interrupt your code if it is busy. for that reason, you should just put your main inside your hardware interrupt. anything else that needs to happen during the interrupt that is not part of the interrupt routine simply can not happen reliably. talking to a DAC over SPI or I^2C is not going to work here. R2R DAC on the GPIO of the 328P no problem. you can even do it in parallel with a single 8bit instruction if you start mixing AVR assembler into your arduino code.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 2:38 pm

200kHz might be too fast for either sampling or playback without excessive jitter on the atmega. and its probably also too fast for the nano, but i cant say for certain, id have to dig in a bit more there. lets say youre running at 16MHz. everything has to be aligned with the internal clock, so an interrupt comes in, and then there is some edge alignment that happens in hardware, and then some more variable delay in the interrupt jump based on what type of instruction was being executed when the interrupt arrived. so you have 0-3 clock cycles of jitter going on (+/-1.5ck). at 16MHz thats +/-93ns. lets say you want this jitter to be less than +/-0.5% of your oscillator period, that limits the oscillator to 53kHz. the external DAC would solve the playback issue (in the static case. it would not be able to do playthrough at 200Ksps), but there is still the sample rate issue which tops out at 76ksps. but maybe you dont need to sample at 200ksps, only playback?
openmusiclabs.com

User avatar
EATyourGUITAR
has no life
Posts: 4591
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Something new I built - fun with decade counters

Post by EATyourGUITAR » Thu May 21, 2020 4:12 pm

External shift register clocked by hardware external clock would fix that. You are always exactly 1 ext clock tick late but it does get quantized by the same clock. 0 jitter.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

User avatar
guest
Super Deluxe Wiggler
Posts: 4171
Joined: Mon Aug 19, 2013 11:49 am

Re: Something new I built - fun with decade counters

Post by guest » Thu May 21, 2020 4:37 pm

yeah, and i guess an external sample and hold would fix the input as well, but the ADC throughput is still too low. a piece of SRAM and a DAC/ADC combo of some sort would probably be the easiest, and on the same cost as an atmega328p. too bad the smallest SRAM is 32k! i guess it will have a lot of pattern storage.
openmusiclabs.com

Post Reply

Return to “Music Tech DIY”