Precision current control with Digital Potentiometers

Started by MoltenVoltage, October 25, 2010, 11:58:53 PM

Previous topic - Next topic

MoltenVoltage

Everyone familiar with the PT2399 knows that you vary the delay time with a resistance.  There are a couple chips floating around that perform this function using a digital potentiometer whose resistance is set based on a tap tempo input.

The problem is that digital potentiometers have even worse tolerances than mechanical ones, sometimes +/- 30%.

Suddenly your calculated delay time can sound like triplets instead of 1/8th notes.

There are some brute force methods of minimizing these errors, none of which are very practical (e.g. hand-sorting large batches of digipots).

I thought that maybe putting 2 100K pots (which read 70K each for a total of 140K) with a resistor in parallel would solve the problem until I made a spreadsheet and found that the errors don't exist at 0 and 100, but they get larger and larger until you get to 50% where they peak.  With a 140K resistance scaled down the error is over 8%, so the problem is slightly less, but not much.  Of course the further off your initial resistance, the greater the error.

I've read all the microchip app notes but can't find anything that solves the problem of precision programmed current control. 

Being a programmer primarily, I assumed that a "digital potentiometer" would have "digital precision", until I had them on the breadboard and read the nominal resistance of a batch of 100K pots at 70-80K average.  This makes consistent precision control of the PT2399 a challenge.

The other thing I've noticed is that I can never get precise reads on the nominal resistance.  It changes from multimeter to multimeter, and when I perform current tests using the nominal resistance and a known voltage, it can be 5% off from the calculated value.

So, the questions remaining are:

1) How to achieve precision resistance values using digital potentiometers

2) How to get consistent readings of the resistance of digital potentiometers

Hopefully 19,000 heads are better than one!  Thanks!
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

JKowalski

#1
Quote from: MoltenVoltage on October 25, 2010, 11:58:53 PM
I've read all the microchip app notes but can't find anything that solves the problem of precision programmed current control. 

Why don't you just use a precision DAC with the required analog components to use the output to control the PT2399 pin?

It doesn't have to be a resistance change.


I think digital pots are mainly used for controlling volumes of audio signals & similar where total resistance isn't that important...

cloudscapes

I second the precision DAC idea. 12 bit is probably enough for something that's foot-tapped. DACs won't give you the three-lug pot digital pots will, but I don't think that's needed with the 2399, if I recall.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

MoltenVoltage

Thanks for the responses.

I don't think you can just apply a varying voltage to Pin 6, but I may be wrong.

I looked at the datasheet and it does say that Pin 6 is a VCO frequency adjustment:
"Overall delay time is determined by internal VCO clock frequency, and user can easy to change the VCO frequency by changing the external resistance."

However, Pin 6 is a current drain to ground, and I don't think can just put a voltage onto a pin that is expecting a current drain to ground.

The only other way that I know of to control current using a voltage is with an FET, but then you are just trading one problem for another since they are at least as variable as the digipots.

Chris, were you thinking of an FET when you said "required analog components"?
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

pjwhite

I'll offer a third vote for a DAC.  Even an 8-bit DAC would probably be good enough.  You could use a current-output DAC, but a voltage-output DAC with a resistor in series with the output would probably work as well.

Looking at the data sheet for that delay chip, it appears that the delay time is not related linearly to the control resistance.  I also doubt that the numbers given in the data sheet for delay vs resistance are very accurate or consistent from one device to the next.  The VCO must use one of the external capacitors in the oscillator circuit, and the frequency accuracy would be directly tied to the tolerance of this cap.

If you're looking to get precise control of the delay time, I would say that you should find a pin on the PT2399 where you can pick up the VCO frequency output and measure it against a crystal controlled reference.  Then, using successive approximation, adjust the VCO control DAC until you get the exact frequency you want.

I don't think there's any way that blindly setting a resistance value on the VCO control pin will ever give you an exact 100.00ms delay.

octfrank

I would vote against a DAC here, given the VCO uses a single resistor to set speed and the speed increases as the resistance decreases I would guess it is some form of current starved VCO in which case the speed is controlled by the current allowed to flow through pin 6. Pin 5 says it is a clock out so monitoring that and adjusting the current allowed to flow through pin 6 would probably be the best solution.
Frank Thomson
Experimental Noize

cloudscapes

I did it once by driving an NPN with an AVR's PWM (like a DAC) which in turn starved the 2399's VCO. worked like a charm, though a lot of biasing was needed. and I wasn't doing tap so wasn't interested in acuracy.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

MoltenVoltage

Monitoring the pin 5 output is a great idea, as I checked that it varies proportionally to the Pin 6 resistance BUT the clock is between 1 and 17Mhz.  Calculating those speeds is beyond the reach of my 40MIPS chip.

Maybe some sort of high speed phase lock loop system could resolve those speeds - in a manner similar to the FM tuner auto-tune function?  Just thinking out loud with very little practical knowledge of how those systems work.
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

JKowalski

Quote from: MoltenVoltage on October 28, 2010, 01:42:47 AM
Monitoring the pin 5 output is a great idea, as I checked that it varies proportionally to the Pin 6 resistance BUT the clock is between 1 and 17Mhz.  Calculating those speeds is beyond the reach of my 40MIPS chip.

Maybe some sort of high speed phase lock loop system could resolve those speeds - in a manner similar to the FM tuner auto-tune function?  Just thinking out loud with very little practical knowledge of how those systems work.

Yeah, a phase locked loop would work. That would basically give you the ability to clock the PT2399 externally.

PLL's are pretty finicky circuits to design. But it is doable. Another plus with PLLs is that you can stick a frequency divider chip in the loop to multiply the frequency input - enabling you to input much lower speeds to get the right high speed clock output on the PT2399. So you can probably use your aforementioned 'chip'.

MoltenVoltage

I already tried using a 4017 to divide the clock frequency (I was going to cascade 2 to divide by 100), but the clock output of the PT2399 gets really lousy below about 10MHz - very non-sinusoidal with extra peaks, and it just gets worse from there down to 1MHz.  As a result, the 4017 gets the count wrong.  I assume a PLL circuit would have the same problem.  I doubt a schmitt trigger could even clean it up, as the clock's waveform distortion gets really severe at the lower speeds.  I suppose I could chart the count errors and make a table for the dsPIC to read, but that seems like a very in-elegant answer.

I also tried putting a voltage into pin 6 (with and without a series resistor) and it wouldn't delay at all until the voltage got near zero, then it was just acting as a current drain again.

MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

ElectricDruid

Interesting problem.

The 'Use a DAC' approach is definitely viable. Here's a couple that'd do the job:

http://www.maxim-ic.com/datasheet/index.mvp/id/4806
http://www.analog.com/en/digital-to-analog-converters/da-converters/ad5398a/products/product.html

These are both 'current sink' DACs, so could be connected directly to the PT2399.

Alternatively, the datasheet for the Microchip MCP4821/4822 series DACs has details on building a programmable current source:

http://ww1.microchip.com/downloads/en/devicedoc/21953a.pdf (page 25)

This would work with a lot of other DACs too.

Hope this gives you a few ideas!

Regards,
Tom

slacker

#11
According to Merlinb you can control it with voltage in the range 0 - 2.5 volts, have a look here http://www.diystompboxes.com/smfforum/index.php?topic=87543.0 never tried it myself.

Not that I have any programming skills, but my thought was to use the clock out for error correction, but it seems like that's probably not doable.
Here's another idea that will probably work, very brute force though. Use a digipot, or whatever to control pin 6, then have another output from you uC that sends a pulse to the input of the PT2399, and another to read from the output. Set the digipot to some resistance say 1k, fire a pulse through the PT2399, calculate how long it took. Repeat over a range of resistances. Don't know what you'd do with data after you'd collected it, presumably you could use it to do some sort of lookup table or for error correction. I guess you could do this each time the pedal was turned on or store it somehow.

Probably be easier if we all just stopped trying to make the old PT2399 do stuff it's not designed to do and embraced something like the FV-1.

puretube

Quote from: slacker on October 28, 2010, 02:42:47 PM
Probably be easier if we all just stopped trying to make the old PT2399 do stuff it's not designed to do and embraced something like the FV-1.

This! +/- 1 clock-pulse...  :icon_smile:

MoltenVoltage

I went back and did some more tests (since I don't always get the best results at 3 a.m.), and found that the 4017 actually does a decent job of dividing the clock output across the range that matters for a tap input.  I calculated an error of between 1 and 3 percent, but some of that could very well be due to my frequency counter.

It's worth noting that the 4017 hits a very definite ceiling at 10MHz, at which point it just stops counting.

I was hoping the FV-1 would work, but I really want something that can do at least 1 second of delay, and the PT2399 is the only practical solution I can find.

Also, since tayda sells the PT2399 for $.54 each (thanks frequency central!), it makes it a very attractive component.

Now I just hope the relationship between delay time and clock frequency is linear.  :icon_eek:

Sincerest thanks for all the feedback!
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

puretube

#14
Quote from: MoltenVoltage on October 28, 2010, 05:52:22 PM
I was hoping the FV-1 would work, but I really want something that can do at least 1 second of delay, and the PT2399 is the only practical solution I can find.

...makes 2 seconds if using the Mark Hammer/Bill Rupert/puretube - trick... (=1st channel out to 2nd channel in)

[edit]: insert:  :icon_rolleyes:

MoltenVoltage

Since the FV-1 has 32K ram, doesn't that limit the total time @ 44.1kHz to about .72 seconds, whether you are using one channel or two, or does each channel have its own 32K ram bank?

MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!

Kindly Killer

I just hacked my second Fab Echo with the Taptation kit from the store. The first one is spot on - perfect sync, but the layout and footswitch I used are not really road-worthy.

Which inspired me to do another, nicer one, which of course is out of sync to the point that is neither fish nor foul - tap doesn't work but it's not quite as good as a DMM, soo....

I'm wondering - the delay times on mine are a little short of what they are supposed to be; would it work to just put a trimpot inline with the wire that goes to pin 6 of the pt2399? Or is it off by a different amount at every time.

slacker

It will be out by different times for different speeds. Adding a trim will just let you add a fixed amount of time, you might find a setting of the trim that is good enough for a range of times, but it will never be exact.

Taylor

#18
Quote from: puretube on October 28, 2010, 06:11:43 PM
Quote from: MoltenVoltage on October 28, 2010, 05:52:22 PM
I was hoping the FV-1 would work, but I really want something that can do at least 1 second of delay, and the PT2399 is the only practical solution I can find.

...makes 2 seconds if using the Mark Hammer/Bill Rupert/puretube - trick... (=1st channel out to 2nd channel in)

Don't see the explanation of your trick other than the parenthetical statement there, but that's not the way to get 2 seconds. Converting a-d-a twice doesn't make any sense when you can just lower the sampling rate to 16k, which is what you're doing with the stereo trick anyway, except with higher fidelity.


Quote from: MoltenVoltage on October 29, 2010, 02:03:23 PM
Since the FV-1 has 32K ram, doesn't that limit the total time @ 44.1kHz to about .72 seconds, whether you are using one channel or two, or does each channel have its own 32K ram bank?



Yes, but you don't need to sample that high. The FV1 is way nicer sounding at 1 second(32k sample rate) than the PT2399 is at the same length. With a little filtering you can get a nice clean 2-second delay, as noted above, by using a 16k xtal. I have actually played around with getting much more time out of the chip than that even - with software sample rate reduction you can get a usable 8 seconds out of it, or if you're nasty, a whole minute.  :)

You might say you want more fidelity than 32k sample rate will give you, but the PT2399 just plain does not give more fidelity than the FV1 at 1 second. And no guitar speaker goes to 16k anyway.

BTW, Karl, I have no problem with you and don't want to stir anything up - just curious if this is homework for a commercial device?

MoltenVoltage

#19
You're right about the long delay times on the PT2399, they do sound pretty lousy (at least in the rebote), but the short delay times sound really good, the chip is very inexpensive, and there already exist multiple layouts and projects.

Maybe I'm wrong, but I don't think a 16K sampling rate translates directly into a max audio frequency of 16 kHz.  You also have to look at the bitrate which, if I understand Frank right, is limited to 14 bits on the FV-1.

The other reason I hesitate to develop a controller for the FV-1 is that I think most people are intimidated by having to code the FV-1 themselves (I'm not in any hurry to learn another device).  If there were out-of-the-box presets that were long pure delays, I would be much more motivated to come up with something.  hint hint Frank!
MoltenVoltage.com for PedalSync audio control chips - make programmable and MIDI-controlled analog pedals!