zero - hundred display

Hi all,

I've been trying to get a value going from 0 to 100 on an LCD display using a PIC micro controller (VCC- 5v, VEE - 0V) with AtoD (10 bit - but converted to 8 bit in software). The hardware used is a simple non-inverting op amp (LMC660 single supply) with non inverting pin connected to a voltage divider of 0.05v (my step voltage). I have a

10K linear pot (wiper connected to output) acting as the feedback resistor along with a 100 ohm resistor to ground.

My problem is that although I get movement of numbers from 0 to 100 there is always slight jumps. E.g if number is set to 6 it will jump from ~ 3 to 9. At first I thought it was capacitance of the POT leads so I trimmed that down to a minimum - but still the problem remains.

I have thought about using a current mirror to set the current, but the circuit described above is using that principle. And anyway the pot value would have to be high to avoid offset voltage errors.

beginning to feel I've turned full circle....any help on this issue would be much appreciated.

Regards,

Ozzy.

Reply to
ozzy
Loading thread data ...

So--you are trying to vary the gain of the op amp to change the voltage fed (I assume) to an ADC input -- probably the ADC in the PIC. You are asking for trouble from noise in the op amp, and noise pickup from anywhere else. I would suggest instead simply tying one end of the pot to +5 (also used for the PIC and specifically as the reference for the ADC in the PIC), and the other end to ground. Then the wiper will pick off a voltage linearly proportional to the rotation. You can try putting that directly into the PIC, or if you want, buffer it with a unity-gain op amp follower. The op amp circuit would be pot wiper to the (+) input and the op amp output to the PIC and back to its (-) input. But I just looked at the ADC spec for a 16F684, and it suggests the ADC is useable with up to a 10k ohm source resistance feeding the input. Your 10k pot will show no more than 2.5k. In fact, for more stable readings, I would not bother with the op amp buffer, but I would put about 1k ohm between the pot wiper and the ADC input, and some capacitance between the ADC input and ground: if I didn't need it to change super-fast, I'd probably use 1uF. That would give you response to final value within a couple dozen milliseconds, max.

Note there's always the chance for flicker between two numbers. A numerical algorithm can add just a touch of hysterises to the reading, and can also do a moving average (or exponential decay average) of the values.

Cheers, Tom

Reply to
Tom Bruhns

Tom,

Appreciate the fact you've taken some time out to help me here - will be giving this a go soon.

But just one question. You state that a 10K input impedance is acceptable to the 16f684, and will be no more than 2.5K (as it is in parrallel with Rss - is that right?). Does'nt this depend on Vdd - it ranges from 5K to 11K giving an effective input impedance of 3.3K to ~5K.

Regards,

Ozzy.

Reply to
ozzy

I suggest you connect your 10K pot across the 0V/5V supply and feed the input into the ADC (source impedance 0-2.5K which is okay for all PICs). You can then multiply by 25 (result will fit in 16 bits) and throw away the least significant byte (moving the radix point over 8 bits). You'll then have a very stable 0-100 as a result, and no significant offset errors.

If you don't have a hardware multiplier or multiply routine, you can hard code it by noting that 25 = 16 + 8 + 1, which reduces to two adds of the number shifted by 4 and 3 bits respectively to the original number. Then throw away the least significant byte.

Eg. result of 512 = 0x200 from the ADC (midscale),

0x2000 0x200
Reply to
Spehro Pefhany

Spehro,

What you've described seems to be the most accurate method. I guess I was thinking too much in terms of hardware, and neglected the somewhat simpler software method. Thanks for the help.

Regards,

Ozzy

Reply to
ozzy

I'd replace that opamp. It's a pig. It'll break into oscillation even if you look at it crosseyed. (Nearly as bad as the pig dog AD8099.) john

--
Posted via a free Usenet account from http://www.teranews.com
Reply to
john jardine

Um, the PIC ADC is OK being fed with any source whose effective series resistance is less than 10k ohms. If you use a 10k pot, tied to +5 (Vdd, I suppose) on one end and ground on the other, then the wiper will look like a voltage source with between zero and 2.5k ohms in series. That's at most 1/4 as much as the PIC can tolerate, so you should be fine. I suggested adding another 1k in series, and a capacitor to ground, to insure that the voltage remains stable even as the PIC ADC switches among inputs, etc. The 2.5k comes from the pot, at center position, being 5k to +5 and 5k to ground, and that gives you a Thevenin equivalent source of 2.5V at 2.5kohms.

And of course, Spehro kindly gave you an algorithm for converting that

0-1023 reading to 0-100. I guess it will actually only reach 99, unless you round, but that may be OK.

Cheers, Tom

Reply to
Tom Bruhns

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.