Controlling guitar volume with microcontroller

Started by JP19, July 01, 2022, 05:10:55 PM

Previous topic - Next topic

JP19

Hi, I'm looking for some help solving a problem I have when gigging.

I'm generally pretty busy the whole time in my band and can't ever find a moment to adjust my amp mid song. Basically I want to make a pedal to put at the end of my chain that works kind of like a volume pedal but isn't a volume pedal. I want to be able to control my level (and also ideally boost) without the unpredictability of a 'wah style' volume pedal (I gigged with one for a few years but hated it).

I'm thinking a standard stomp box with 2 momentary footswitches connected to a microcontroller and a line of maybe 5 LEDs. When you turn it on the middle LED is lit and it's unity gain. When you hit one foot switch it jumps to a louder step and when you hit the other it jumps to a quieter step. Kind of a preset stepped volume pedal. For those 'oh @#$% my solo is too quiet' moments etc.

I've messed around with arduinos etc enough to be pretty happy with the microcontroller side of things, but I'm wondering what the best way is to be able to control the guitar's volume with a microcontroller. Ideally I want to be able to cut and boost.

I had some ideas but not really sure the best way to proceed..

- Inverting opamp with a digital pot or LED/LDR combination?
- Some sort of VCA chip?

This is a one off and will live on my live pedalboard, so I'm really after the cleanest best sounding way to do this and don't mind using some fancy obscure IC if it's going to make it better. I'm not looking for mojo, just don't want to add noise. Also if this pedal already exists please let me know as I will just buy it instead!

Thanks!

PRR

Out-of-box thought: many of these mini-brains will do "model airplane servo" (in standard library) which is a very cheap yet repeatable way to turn a pot. When I messed with BASIC Stamp well over a decade ago I threw in a servo but never got past the demo code (the urgency was a sophisticated timer not a knob-turner).
  • SUPPORTER

JP19

Ooh I'd never thought of doing it mechanically! I will look into that as a possibility..

stallik

#3
I'm sure I recall an interview with Neil Young (though can't find it now) where he mentioned that adjusting his amp volume also caused a tone change which is why his 'Whizzer' unit altered both volume and tone via servos

I once made a sequential switcher utilising a thumb wheel switch and homemade actuators to press the buttons. The thumb wheel introduced various resistors in place of a boost circuit volume pot. That gave me 10 steps varying from below to above unity gain. I gigged with it a few times but it turned out to be less useful than the guitar vol pot


Insanity: doing the same thing over and over again and expecting different results. Albert Einstein

Processaurus

See Geofex.com "multi-vol" concept.

The core chips are a latch IC, and an analog switch. The latch does the radio push button type logic with several footswitches, and the audio gain is done by the analog switches. No code necessary.

idiot savant

I'd go ssi2164 VCA for the audio path. Easy, clean, GTG.

https://www.soundsemiconductor.com/downloads/ssi2164datasheet.pdf

Great examples right in the datasheet(figures 1, 7 & 9). Just stick a buffer in front.

Feed it voltage control from the onboard DAC of a MCU, or filtered PWM. Easy to implement your LED level indicator, and footswitches that way too.

anotherjim

You can get Digipots with up/down button control built-in. Not had any dealings with any kind myself and they're probably going to be SMD...
https://www.analog.com/media/en/news-marketing-collateral/product-selection-guide/Choosing_the_Correct_Digipot.pdf

Ripthorn

I designed this project a couple years ago. Basically exactly what you're asking for, I think. https://scientificguitarist.wixsite.com/home/the-big-littler
Exact science is not an exact science - Nikola Tesla in The Prestige
https://scientificguitarist.wixsite.com/home

Ben N

Not what was requested, but if we're already getting microcontrollers involved, I imagine some clever person could could rig up a Bluetooth transmitter with a volume knob to go in an Altoids tin on a guitar strap to control your VCA/Arduino+digipot/whatever.
  • SUPPORTER

ElectricDruid

#9
This looks like it'd be pretty much what you're after:

https://circuitdigest.com/microcontroller-projects/digital-audio-volume-control-circuit-using-pt2258-ic-and-arduino

The hardware has everything you need, and the PT2258/2257 can control the volume in 1dB steps over a 0 to -79dB range. The project shows the PT2258, which is a six channel chip, but for your job the PT2257 two-channel chip would be enough:

http://www.princeton.com.tw/Portals/0/Product/PT2257.pdf

The Arduino talks to the volume control chip via I2C, so you can just send messages to get the required levels for your 5 steps.

There are loads of digipots on the market that would do a similar job, but ones specifically aimed at audio volume control applications tend to do a better job of that specific task since they include little niceties like only changing the setting at a zero-crossing and so on.

HTH

<edit>added datasheet link

JP19

Thanks for all the responses. Lots to think about there.

While doing it mechanically would certainly be cool (I'm visualising a robot hand twiddling the knobs on my amp), it feels like it would probably break eventually so I'm going to go with something else. Most likely Idiot Savant's suggestion as I'm sure I have some SSI2164 in a drawer somewhere that I bought for a synth project that never happened.

I'll let you know how I get on. Thanks for the help!

JP19

Ok, so I'm some way through trying to work out how to do this with an SSI2164. I'd like to be able to use the gain of the SSI2164 (rather than just attenuating), but in order to do this I need to somehow get the control voltage to go below zero..

After a couple of evenings looking at this https://www.ti.com/lit/an/sloa097/sloa097.pdf?ts=1658233366694&ref_url=https%253A%252F%252Fwww.google.com%252F and coming up with numbers that definitely don't work, the time has come for me to sheepishly accept defeat and ask for help!

So I have a control voltage of 0-5v, how can I scale and offset it to give me -0.66 to 3.3v?

I need a gain of 0.792 to scale it to the correct range of 3.96v (I'm sure I can manage this bit myself with a voltage divider) but how can I offset it by -0.66v? Is this even possible with a single supply? I guess I need to make the 2164 'think' that 0v is something different, or am I getting this all wrong? Any help would be gratefully appreciated!


(SSI 2164 datasheet here: https://www.soundsemiconductor.com/downloads/ssi2164datasheet.pdf )

ElectricDruid

Quote from: JP19 on July 20, 2022, 05:05:03 PM
So I have a control voltage of 0-5v, how can I scale and offset it to give me -0.66 to 3.3v?

I need a gain of 0.792 to scale it to the correct range of 3.96v (I'm sure I can manage this bit myself with a voltage divider) but how can I offset it by -0.66v? Is this even possible with a single supply? I guess I need to make the 2164 'think' that 0v is something different, or am I getting this all wrong? Any help would be gratefully appreciated!

The scale-and-offset is a classic problem for an inverting op-amp mixer. You can't do gain less than one with a non-inverting op-amp, but with an inverting one you can. So you pick a typical value for the feedback resistor, say 47K for starters. Then you calculate the input resistor you need to give you x0.792 gain, which would be 1/0.792=x1.26 times larger = 59.3K. 56K is a bit small, so 62K is probably better. That's about 3.8V after the scaling, but note that it's inverting, so we've got -3.8V to 0V. Some other starting value might get you even closer. Try 33K and see what you get.

Then you need to add an offset. Since your 0-5V input just got inverted as it got scaled, you now need to push it up so -3.8V is only -0.6V or so. So we need a positive offset of about +3.2V. That implies putting in a *negative* voltage. If we had 3.2V handy (which we could generate with a 10K trimmer across a 5V supply, say) we could feed that in via another 47K resistor and we're there. Alternatively, we could connect some larger voltage via another bigger input resistor to scale it down to the required 3.2V. Both methods are equivalent.

Finally, you need to get the single-supply/bipolar-supply thing clear in your head or that's going to confuse you. As far as the 2164 and the op-amps are concerned, there's no such thing as a single supply. They want +/-V and Gnd and that's what we have to provide. HOW we do that is up to us, and that's where the single-supply trickery comes in. ONe way is to split a 9V supply down the middle and treat it as +/-4.5V with a ground in the middle. Voltage is relative, so it mostly amounts to the same thing.

Hope this helps!

idiot savant

Quote from: JP19 on July 20, 2022, 05:05:03 PM
Ok, so I'm some way through trying to work out how to do this with an SSI2164. I'd like to be able to use the gain of the SSI2164 (rather than just attenuating), but in order to do this I need to somehow get the control voltage to go below zero..

After a couple of evenings looking at this https://www.ti.com/lit/an/sloa097/sloa097.pdf?ts=1658233366694&ref_url=https%253A%252F%252Fwww.google.com%252F and coming up with numbers that definitely don't work, the time has come for me to sheepishly accept defeat and ask for help!

So I have a control voltage of 0-5v, how can I scale and offset it to give me -0.66 to 3.3v?

I need a gain of 0.792 to scale it to the correct range of 3.96v (I'm sure I can manage this bit myself with a voltage divider) but how can I offset it by -0.66v? Is this even possible with a single supply? I guess I need to make the 2164 'think' that 0v is something different, or am I getting this all wrong? Any help would be gratefully appreciated!


(SSI 2164 datasheet here: https://www.soundsemiconductor.com/downloads/ssi2164datasheet.pdf )

-0.66V is quite a bit of gain for the 2164. 33mv/dB says that -0.66V is 20dB. If you need that much, no biggie, but something like 6dB, or 10dB might be more reasonable.

If you're using the control circuits in the datasheets, then offsetting is built into them for free.

Lets use this basic linear VCA:



R2, and R3 can be used for balancing and offsetting. When CV == 5V then the VCA makes unity gain. When CV == 0V then the VCA is off. So you can simply adjust R2, or R3 to bias it towards the range you want.

Lets say you want 6dB of gain with your CV at 5V. You simply calculate, or twiddle R3 for the offset you want. 6dB @ 33mv/dB is -0.198V. That means you make R3 bigger to get that offset.

note: this assumes a +5/0/-5 power supply.

PRR

I may be repeating the above, but...

> control voltage of 0-5v, how can I scale and offset it to give me -0.66 to 3.3v?

-0.66 to 3.3 is 3.96. (About 4.) You have 5. So you want a 5/4 divider. 100r and 400r does that.

It starts from zero and you want -0.66V. Non-abstract, this sounds to me like an emitter follower.

Not if you are figuring orbital mechanics, but audio loudness and audio systems are not very precision. Or you may want a 7-cent solution for basic breadboarding where you can wave-off errors for later detailing.


  • SUPPORTER

JP19

Quote from: PRR on July 21, 2022, 09:05:44 PM
I may be repeating the above, but...

> control voltage of 0-5v, how can I scale and offset it to give me -0.66 to 3.3v?

-0.66 to 3.3 is 3.96. (About 4.) You have 5. So you want a 5/4 divider. 100r and 400r does that.

It starts from zero and you want -0.66V. Non-abstract, this sounds to me like an emitter follower.

Not if you are figuring orbital mechanics, but audio loudness and audio systems are not very precision. Or you may want a 7-cent solution for basic breadboarding where you can wave-off errors for later detailing.





Thanks, this looks like the kind of simple solution I need!

I'm still struggling to wrap my head around some basic voltage concepts though, and can't figure out how to hook it up to achieve the +/-5v supply in your schematic.

My guess is that the 0v on the right of your schematic is not actually hooked up to the circuit ground connection, but is connected to the VCA's 'ground' (actually VCC/2 reference voltage), giving +/-4.5v? But what about the 0v on the left of the schematic? I feel like surely it must be hooked up to my circuit ground as the 0-5v from the microcontroller is referenced to my circuit ground, but I'm really not sure!?

Of course this stems from the problem that I don't really understand connecting different circuit elements that are referenced to different grounds. Eg. My microcontroller has 0v/+5v, the VCA thinks it has -4.5v/0v/+4.5v, when actually it has 0v/4.5v/9v if I reference it to the same ground as the microcontroller.. My brain turns to scrambled egg when I start to think about connecting them!

JP19

Quote from: ElectricDruid on July 20, 2022, 05:52:19 PM

The scale-and-offset is a classic problem for an inverting op-amp mixer. You can't do gain less than one with a non-inverting op-amp, but with an inverting one you can. So you pick a typical value for the feedback resistor, say 47K for starters. Then you calculate the input resistor you need to give you x0.792 gain, which would be 1/0.792=x1.26 times larger = 59.3K. 56K is a bit small, so 62K is probably better. That's about 3.8V after the scaling, but note that it's inverting, so we've got -3.8V to 0V. Some other starting value might get you even closer. Try 33K and see what you get.

Then you need to add an offset. Since your 0-5V input just got inverted as it got scaled, you now need to push it up so -3.8V is only -0.6V or so. So we need a positive offset of about +3.2V. That implies putting in a *negative* voltage. If we had 3.2V handy (which we could generate with a 10K trimmer across a 5V supply, say) we could feed that in via another 47K resistor and we're there. Alternatively, we could connect some larger voltage via another bigger input resistor to scale it down to the required 3.2V. Both methods are equivalent.


So I could just hook it up like this? Or would I need to send the +3.2v through another inverting stage first (to make it -3.2v)  before it gets mixed and inverted again.



ElectricDruid

Quote from: JP19 on July 22, 2022, 04:40:26 AM
So I could just hook it up like this? Or would I need to send the +3.2v through another inverting stage first (to make it -3.2v)  before it gets mixed and inverted again.



That looks about right, but yes, it needs to be -3.2V going in to give us +3.2V coming out. I said you could do it with a trimmer across a 5V supply, but I should have said a -5V supply.
If you've got -4.5V for your negative supply, you could use that and then scale it down. 4.5/3.2 = 1.4 and 47K x 1.4 =65.8K.




idiot savant

#18
Quote from: ElectricDruid on July 22, 2022, 09:42:08 AM
Quote from: JP19 on July 22, 2022, 04:40:26 AM
So I could just hook it up like this? Or would I need to send the +3.2v through another inverting stage first (to make it -3.2v)  before it gets mixed and inverted again.



That looks about right, but yes, it needs to be -3.2V going in to give us +3.2V coming out. I said you could do it with a trimmer across a 5V supply, but I should have said a -5V supply.
If you've got -4.5V for your negative supply, you could use that and then scale it down. 4.5/3.2 = 1.4 and 47K x 1.4 =65.8K.

I think it needs +4.5V going in to that 47K, assuming you want that 20dB of gain that is specified.

QuoteMy microcontroller has 0v/+5v, the VCA thinks it has -4.5v/0v/+4.5v, when actually it has 0v/4.5v/9v

Remember that when using a single supply (Figure 6) split as +9/+4.5/0 then voltage above +4.5V attenuates the signal. Voltage below +4.5V amplifies the signal. +4.5V exactly is unity gain. This is at the VC pin.

Looks like the original drawing from JP19 should work(with +4.5V going to that 47K). Remember though, this setup will have an exponential response. This may or may not be desired.

from the datasheet:

QuoteControl ports provide unity gain when VC is equal to the ground reference voltage, or 4.5V in the case of Figure 6.

PRR

Quote from: JP19 on July 22, 2022, 04:38:35 AM
I'm still struggling to wrap my head around some basic voltage concepts though, and can't figure out how to hook it up to achieve the +/-5v supply in your schematic. ...

You are going to have to make/buy some kind of bipolar power supply. +/-12V may work also.

(You might "solve it on paper" with a 0.66V battery, but in real life you need power supplies for other purposes.
  • SUPPORTER