Linearizing ADC

MrChips

Joined Oct 2, 2009
30,824
The OP still has not explained in detail what he is trying to do and what the current setup looks like. But without knowing the details, I submit the following solution. The 5V is from the USB cable.

 

SgtWookie

Joined Jul 17, 2007
22,230
Our OP wants to see a voltage in the range of ~0v-4v from the guitar pedal in order to be able to read it using the ADC of a microcontroller.

Changing the pot is out. Our OP doesn't want to open the pedal, which is understandable. The pedal only has two conductors in the cable and phono plug.

So, see the attached.
Since the available voltage (3.3v) is less than the required output, a CMOS 555 timer is employed as a regulated charge pump to boost the supply to ~ 5.1v.

C1 & C2 are required to keep the supply relatively clean. They should be located as close to the 555 timer as possible, particularly C2; it should be across the Vcc/GND leads. C5 should also be connected directly to the 555's ground terminal.

R1/C5 provide the timing for the 555. The output frequency will be ~66kHz. When the 555 output pin 3 is low, C3 is charged via D2, when the output is high, C4 is charged by C3 via D3.

When the voltage at node "Supply" reaches ~5.1v, Q2's base starts conducting, which turns off the 555 charge pump. The pink trace on the plot shows the supply voltage stabilizing at ~3.6mS.

C4 keeps the supply voltage across the current supply constant. It would not be a bad idea to add a 100nF/0.1uF poly metal film or ceramic cap in parallel with it.

D1, D4, Q1, R4 and R9 are the constant current circuit. The collector of Q1 sources ~100uA current to the pot.

On the plot, the output voltages are shown with the Rpedal pot value at 1m Ohms (0.001 Ohms) to 40k Ohms in steps of 5k Ohms.

Output will vary a bit over temp. I didn't simulate that portion with the charge pump, as it takes a fair amount of time to run.

You will need to put a 10nF cap from the ADC input to ground. As the output from this circuit is rather high impedance, be certain to allow adequate settling time between ADC reads (at least several mS), or your ADC will deplete the charge on the input cap.
 

Attachments

Last edited:

MrChips

Joined Oct 2, 2009
30,824
Maybe the OP was on the right track in the first place and that is to linearize the result. Since the voltage is read into a PC, this is easy to do:

R2/R1 = Vo/(V - Vo)

The ratio Vo/(V-Vo) will give you the ratio of R2:R1

If R2 = 40K max and R1 = 10K, the max value of Vo/(V-Vo) will be 4.

where V = supply voltage
Vo = voltage from GUITAR PEDAL (R2).
 
Last edited:

Thread Starter

weesh

Joined Sep 30, 2011
15
Our OP wants to see a voltage in the range of ~0v-4v from the guitar pedal in order to be able to read it using the ADC of a microcontroller.

Changing the pot is out. Our OP doesn't want to open the pedal, which is understandable. The pedal only has two conductors in the cable and phono plug.

So, see the attached.
Since the available voltage (3.3v) is less than the required output, a CMOS 555 timer is employed as a regulated charge pump to boost the supply to ~ 5.1v.

C1 & C2 are required to keep the supply relatively clean. They should be located as close to the 555 timer as possible, particularly C2; it should be across the Vcc/GND leads. C5 should also be connected directly to the 555's ground terminal.

R1/C5 provide the timing for the 555. The output frequency will be ~66kHz. When the 555 output pin 3 is low, C3 is charged via D2, when the output is high, C4 is charged by C3 via D3.

When the voltage at node "Supply" reaches ~5.1v, Q2's base starts conducting, which turns off the 555 charge pump. The pink trace on the plot shows the supply voltage stabilizing at ~3.6mS.

C4 keeps the supply voltage across the current supply constant. It would not be a bad idea to add a 100nF/0.1uF poly metal film or ceramic cap in parallel with it.

D1, D4, Q1, R4 and R9 are the constant current circuit. The collector of Q1 sources ~100uA current to the pot.

On the plot, the output voltages are shown with the Rpedal pot value at 1m Ohms (0.001 Ohms) to 40k Ohms in steps of 5k Ohms.

Output will vary a bit over temp. I didn't simulate that portion with the charge pump, as it takes a fair amount of time to run.

You will need to put a 10nF cap from the ADC input to ground. As the output from this circuit is rather high impedance, be certain to allow adequate settling time between ADC reads (at least several mS), or your ADC will deplete the charge on the input cap.
1) What's an OP?
2) I'm using a Silicon Labs C8051F321 chip which has a free timer on it, can I use that instead of the 555?
 

Thread Starter

weesh

Joined Sep 30, 2011
15
Maybe the OP was on the right track in the first place and that is to linearize the result. Since the voltage is read into a PC, this is easy to do:

R2/R1 = Vo/(V - Vo)

The ratio Vo/(V-Vo) will give you the ratio of R2:R1

If R2 = 40K max and R1 = 10K, the max value of Vo/(V-Vo) will be 4.

where V = supply voltage
Vo = voltage from GUITAR PEDAL (R2).
The voltage is actually read by the ADC on the chip I mentioned above. I'm not sure what you mean by Vo? There's volate coming from the GUITAR PEDAL? :)
 

MrChips

Joined Oct 2, 2009
30,824
OP stands for Original Post, i.e. you, weesh.

If your supply voltage is 5V, for example, and the ADC reading is Vadc, do the following calculation:

result = Vadc / (5 - Vadc)

"result" is a ratio which you can scale to any value as you wish. That is, multiply "result" by any constant number to give you your desired answer.
 

SgtWookie

Joined Jul 17, 2007
22,230
1) What's an OP?
The "original poster" or the "originating poster"; the person who started the thread - in this thread, that's you. :)

2) I'm using a Silicon Labs C8051F321 chip which has a free timer on it, can I use that instead of the 555?
If you have a spare pin or two, sure - why not? Use the uC I/O pin instead of the 555 pin 3.

You could actually do away with R2/R3/Q2 as well; replace them with a 5.1v Zener.
 

SgtWookie

Joined Jul 17, 2007
22,230
Hmm - division and multiplication in microcontrollers leads to code bloat. Include math.h, start slinging those mult & div operators around, then wonder where all your memory went and why your program slowed to a crawl. :confused:

If you have to start doing multiplication & division, try to break it up into shifts and adds/subtracts instead.
 

MrChips

Joined Oct 2, 2009
30,824
Hmm - division and multiplication in microcontrollers leads to code bloat. Include math.h, start slinging those mult & div operators around, then wonder where all your memory went and why your program slowed to a crawl. :confused:

If you have to start doing multiplication & division, try to break it up into shifts and adds/subtracts instead.
True, if you don't know how to do it efficiently. I have done a dewpoint calculation from temperature and humidity to one decimal place in both C and F in less than 2K bytes of memory. I challenge anyone to beat that!
 

Thread Starter

weesh

Joined Sep 30, 2011
15
Hmm - division and multiplication in microcontrollers leads to code bloat. Include math.h, start slinging those mult & div operators around, then wonder where all your memory went and why your program slowed to a crawl. :confused:

If you have to start doing multiplication & division, try to break it up into shifts and adds/subtracts instead.
OK, I've been mulling this for two days *might* have a simple solution but my math skills suck.

Vout = (R2*Vin)/(R1+R2)

Vout, Vin, and R1 are all known, is there a way to solve for R2? This output is being sent to my host so I can do all the floating point I want there.

In case I haven't said it lately, this OP is extremely grateful for the help.

Ken
 

kubeek

Joined Sep 20, 2005
5,795
I think that constant current source would be the easiest way to do this.
This should work nicely, D1 is 1n4148, D2 is BAT85 shottky diode, Q1 is BC556. You might need to fine tune R2 to get the proper response.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Kubeek,
That would work great if our OP had ~5v or so available.
Unfortunately, they only have 3.3v available, they want at least 4v out, and your circuit will need 5v or more to generate the current flow desired. That's why the circuit I posted early on the previous page included a charge pump/voltage regulator driven by a CMOS 555.

I think our OP is waiting for some kind of simple solution to drop into their lap. Unless they can come up with a 5v or higher supply, I don't see that happening.
 

kubeek

Joined Sep 20, 2005
5,795
1) The device is USB powered so it's source is constant and produces 3.3V at the VDD pin.
2) 0-4V would be awesome (but I suspect the max would be 3.3V based on VDD above)
3) I'm reading the voltage back on an ADC so at least 200 discrete points would work. In the host computer, I compute a percentage based on the max and min.
Weesh, these values are weird, first USB has 5V power, second why do you want 0-4V range if your ADC is powered with 3.3V? What is your ADC inut range?
 

Thread Starter

weesh

Joined Sep 30, 2011
15
Weesh, these values are weird, first USB has 5V power, second why do you want 0-4V range if your ADC is powered with 3.3V? What is your ADC inut range?
1)I'm taking power off the Vdd pin from the chip, not the USB bus itself.
2)At some point the discussion involved a constant current source.
3)ADC range is 0-3.3V.

I have an off-the-shelf development board, I'm not making a custom pcb so I'm trying a variety of combinations of things to fix this. These values are reported to a PC in which I can do all kindsa math.

Ken
 
Top