Encoder / digital pot / led ring

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

dirtyhanfri

Well-known member
Joined
Jan 16, 2011
Messages
677
Location
Madrid - Spain
Hi all

I’m starting studying digital electronics, I’d like to learn how to use digital pots, switches and finally being able to interact with them from a computer interface.

I know it’s a long way but I have to start somewhere. I’ll get something running in real world and then try to move on to the computer side.

So I’ve been looking at digital pots. I understand the basics to control it with an encoder.

The thing is I’d like to use a led ring indicator to have visual feedback of the pointer position, and I’m not sure about few aspects here.

I guess I should use a led driver, what kind of IC I’m looking for? Would a simple lm3914 work here? Or I’m right suspecting the needing for a different IC here?

Encoder will give me two signals, Pins A & B, these are fed to the control pins on the digital pot. It’s ok just to parallel them to the led driver?

Maybe I need to use a multiplexer or a micro controller reading encoder signals and feeding different outputs to led driver and digital pot?

I’m really noob about digital electronics, so probably I’m making stupid questions, but I’d like to get a general idea about how everything interacts.

Then i will be able to do equally stupid but more specific questions  ;)



 
You need to design a chain of

encoder (with clock + direction output),
up-down binary counter (to count pulses),
binary to decimal or "one of 16 output" encoder (for LED driving).

Or you can use programmed PIC, arduino, etc...
 
I have done that several time for mic preamp using a PIC. If you are planning to use a rotary encoder a µcontroler is anyway the simplest and most flexible solution since you will probably have several other things to control digitaly.
 
Yes, and you can then add some push-buttons, relays, other led or display.
The interface with the computer can also be managed by the µC ...
 
dirtyhanfri said:
Hi all

I’m starting studying digital electronics, I’d like to learn how to use digital pots, switches and finally being able to interact with them from a computer interface.

I know it’s a long way but I have to start somewhere. I’ll get something running in real world and then try to move on to the computer side.
There are a lot of potential issues with all of this. Just to pick one, what do you want your digipot to do precisely? A digipot has limited voltage range (most are < 5V but a tiny handful are +-15V which are considered "high voltage"), sigificant wiper resistance (meaning you can't really turn them completely off or completely on), non-linearity, fixed resistances, limited power and capacitance. All of this means that you must design the circuit around the digipot. Meaning, if you're thought is to replace the pots of a conventional circuit like a compressor or eq, it will almost certainly not work. You will have distortion and other problems.

As for interfacing with a computer, that is another significant issue because if you use the USB port of an Arduino for example, you are effectively tying a delicate and peaceful audio ground to the noise jungle of a computer ground. MIDI is better because the ground noise is not as hostile and you can use an opto-isolator if necessary but then you have to implement MIDI in the uC which is non-trivial.

dirtyhanfri said:
So I’ve been looking at digital pots. I understand the basics to control it with an encoder.

The thing is I’d like to use a led ring indicator to have visual feedback of the pointer position, and I’m not sure about few aspects here.

I guess I should use a led driver, what kind of IC I’m looking for? Would a simple lm3914 work here? Or I’m right suspecting the needing for a different IC here?
Yes, you need an LED driver. Or possibly just a shift register would do. But there are many problems with this as well. In particular if you're creating an audio circuit that has sensitive high impedance or high gain bits, they might pick up noise from the LEDs turning on / off. I use a special LED driver MAX7221 because it has slew rate limiting to minimize this issue. Also, bear in mind that LEDs chew up a lot of power. If you have 4 rings of 16 LEDs each, even at 10mA that's over 0.5A.

dirtyhanfri said:
Encoder will give me two signals, Pins A & B, these are fed to the control pins on the digital pot. It’s ok just to parallel them to the led driver?

Maybe I need to use a multiplexer or a micro controller reading encoder signals and feeding different outputs to led driver and digital pot?
Yeah, you definitely need a uC. You cannot drive the digipot directly from an encoder. An encoder puts out a parallel binary code. The digipot takes a serial binary code. The two are completely incompatible.

If you are trying to create an audio device controlled digitally, that is a non-trivial exercise. I have looked into this and decided long ago that it is simply not practical in many respects. I finally settled on relays only. I did a Neve relay controlled gain that turned out well. I used a conventional pot read by a uC to control a relay driver L9823. But I dismissed digipots for controlling audio long ago. If you can design the circuit around the digipot like for a simple 2 channel monitor controller or maybe a mic pre that is specifically designed to work with a digipot, then that could be made to work well. There are also low impedance, high voltage analog gate chips like ADG1414 that could work in place of relays as well. But again, these are really exactly like digipots in that you need to design the circuit around the chip (ADG1414 would not work for Neve gain control since parts of the attenuator network are several Kohm).
 
Get an Arduino Uno  (or even an Ardruino Mega or whatever, but the Uno is the oldest and most popular one) or an "Arduino-compatible" board. Download the programming IDE/application from https://www.arduino.cc/ and install it on your computer.  Next, learn a little of the C programming language (this is only slightly more daunting than about everything else combined). You'll use it to write code to read the encoder and write to the digital pot. You send the program to the Arduino board with a USB cable and the IDE software - it'll run on the USB power, but after it's programmed you can unplug the USB and just run the Arduino on a 5 volt power source.

Here's a good LED ring to use (it has active electronics in each LED, you send it data through a serial port), and it conveniently comes with a library for Arduino (so you don't have to write the code to make the lights go on and off, just make function calls to the library), and Adafruit's stuff is well-documented in general:
https://www.adafruit.com/product/1643

I recommend Arduino over other small-board/microcontroller solutions, because it's by far the easiest to learn and get going, and there's lots of support online.  There's a lot to learn in this area, and the faster you can get something going, the better off you'll be as far as feeling rewarded that your time spent studying it is paying off.  It uses an 8-bit microcontroller (specifically AVR, but you don't need to know that) which is the right size for this application. What you'll learn with Arduino will (mostly) carry over to any other microcontroller.

 
I'm an old analog dog, and I got sucked into microprocessor design a couple decades ago... The ability to make simple decisions with code is incredibly powerful. Lots of support circuitry.

JR
 
Thanks for the advices

Squarewave

I’m not trying to have a classic compressor controlled by computer next month.

I’ll start by making a simple volume control, understand how that works and such.

It’s mainly a learning exercise, but of course I’ll end experimenting with it further, no pressures.

Benb

I know Arduino basics, I’ve used it to run grbl in a CNC machine. I even have a spare arduino UNO board.

I’ll take your advice and start learning a bit of the code and experiment with it, will play with reading encoder signals, then translate them to led ring, which I think will be well documented and then move on to control volume with it.

The next logical step seems to be take out the arduino and just use the microcontroller needed for the task.

Don’t want to bit more than I can chew. Slow and steady.
 
You appear to already be on the right track...

Many inexpensive microprocessors can directly accept (read) the digital output from a rotary encoder and compute an effective equivalent volume control setting.  That internal level data, can then be translated to a digital pot control setting and sent to one or more DPOTs probably using serial com (like SPI or I2S).  Finally your LED indicators can be driven by a LED latch that can drive as many as 16LEDs from a single IC and also accepts serial com like SPI.

The same serial com port could be shared by the DPOTs and LED latch, just enabling the one you mean to update, the other will ignore the data. 

While this is a lot of work for such a simple application, its a good basic microprocessor learning project.

JR

PS: If you want to get fancy, you could have your rotary encoder control a digital gain controlled mic preamp chip.

 
The MIDIbox forum might be a good place to start. Boards/kits are available in several different layouts. USB, MIDI, ethernet and a lot of software is available for these boards. See:

http://wiki.midibox.org/
 
Well, more than a year passed since I started this topic, lots of things happened.

I did a few job related projects involving Arduino and learnt a bit along the way.

Few weeks ago I got some digipot and CMOS switches from the local electronics shop,

I moved from Arduino to ESP32 due to it’s Wi-Fi capabilities, and right now I have a device which controls a Digipot and a CMOS switch using buttons, an encoder, or even wirelessly from my iPad. Instead LED ring I’m using a tiny OLED display for showing the info.

Next step is get it into a real audio circuit and check how it comes out...
 

Latest posts

Back
Top