Twitchy ADC LTC1298 12-bit analog to digital converter
mica
Posts: 23
Howdy,
Just getting into the microcontroler stuff. Really cool. I have a project that involves a BS2 and a LTC1298 Analog to digital converter. I got it working but the values coming out are almost unusable. The ADC has 2 channels. They should range from 0 to 4095. When I give an input voltage between 0 and 5 volts I get something like 1740 but the number will jump +/- 20 to 30. Is this normal?
And I'm using it in two-channel mode and not as a differential. Differential is a real mess[noparse]:)[/noparse]
As I do not have an oscilliscope I thought it was my sensor. But then I used a battery and resisters to cut down the voltage to something like 4.7v and it was still all over the place.
Also, channel 0 will not zero out. when connected to ground it should read 1 or 0. Currently it will vary depending on reset from 200 to 800 when grounded. Channel 1 will go to 0 or 1 when connected to ground and 4095 when 5 V. But yes channel 1 is just a jumpy.
Do you think it is a bad ADC or maybe the type in general is twitchy? Should I try the 8-bit? Or can someone recommend a better one.
Also, for my project all I really need is one channel
Thanks,
Mica
Just getting into the microcontroler stuff. Really cool. I have a project that involves a BS2 and a LTC1298 Analog to digital converter. I got it working but the values coming out are almost unusable. The ADC has 2 channels. They should range from 0 to 4095. When I give an input voltage between 0 and 5 volts I get something like 1740 but the number will jump +/- 20 to 30. Is this normal?
And I'm using it in two-channel mode and not as a differential. Differential is a real mess[noparse]:)[/noparse]
As I do not have an oscilliscope I thought it was my sensor. But then I used a battery and resisters to cut down the voltage to something like 4.7v and it was still all over the place.
Also, channel 0 will not zero out. when connected to ground it should read 1 or 0. Currently it will vary depending on reset from 200 to 800 when grounded. Channel 1 will go to 0 or 1 when connected to ground and 4095 when 5 V. But yes channel 1 is just a jumpy.
Do you think it is a bad ADC or maybe the type in general is twitchy? Should I try the 8-bit? Or can someone recommend a better one.
Also, for my project all I really need is one channel
Thanks,
Mica
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
Are you sure you mean the LTC1298? I'm using one as we speak, and pins 1-8 are chip select and Vdd, and 3-4 are gnd and DIN.
Mica, as Sid says, try a cap and resistor to buffer. For more slowly changing signals you can use a larger cap. For example on my hot tub, which has a *very* slow change in temp but a very long run of wire from sensor to ADC, I use a 1uF cap. Smooths it right out.
Also, it depends on what you are reading. If it is changing a lot, so is your number going to change a lot. In this case, you can do a software fix, collecting say 10 samples and averaging them. Also, being mounted on a breadboard, or being mounted next to something noisy (xfrmr, PWM, etc) can also introduce 'bounce" to the readings. Also put a decoupling cap across the power pins of the ADC.
What are you trying to read?
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
TOP VIEW
VREF - 1
+IN - 2
–IN - 3
GND - 4
CS/SHDN - 5
DOUT - 6
CLK - 7
VCC - 8
Sid
(Somebody else is looking at the pin-out for the LTC1286. )
Post Edited (PJ Allen) : 1/7/2006 5:34:59 PM GMT
Now quit pickin' on me
Sid
My data sheet is the same as PJ's. My bad on the pinout, meant to type that pins 3-4 are CH1 and GND. Sid, I think you are looking at the LTC1286, which has the pinout as you describe.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
A·variation/deviation of 20-30 parts in 4,096 is less than 1%.· How stable is the voltage that you're measuring?· I wouldn't expect to have repeatability to 1 digit or anything.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Give you a little more idea on my setup, this is all being done on the Rev C board I recieved in the Basic STAMP discovery kit. For power I'm using a new 9V battery. My sensor is a hall-effect sensor pivoting over 2 mangnets. I'm making an AOA (Angle of Attack) sensor or my R/C airplanes. The data will be fed into an Eagle Tree Systems Telemetry recorder. Once I get a stable read from the AD I can feed that into a digipot and send out a variable resistance to the temperature sensor (not that important). Measuring the hall effect sensor with my voltmeter it will read between 2.10 volts and 3.78 volts for a 40 degree sweep. If I just leave the sensor alone, so not moving, the meter will read a very stable reading of something like 3.10v. So I can't see the thousandths place or 0.001 but I would expect the AD to fluctuate no more then half of 8.333 or say +/- 5 on the safe side (given AD's 0.00122 resolution). Given other unknows even +/- 10 would work. I have a 6 page report with pictures I sent to parallax support if you want it.
Based on your suggestons above and some experiments I thought of I'm still stuck, but did learn some things. For the cap between 4 and 8 I originally had a 10uf tantalum. I tried backing this down to 1.0 and even tried two 10uf or 20uf. No help. But then using my volt meter I measured across pin 4 and 8. I'm seeing it jump quickly between 4.96 and 4.97v. Could this be it? Keep in mind this is on the board so it is a regulated voltage coming from a battery. I would not expect this kind of noise.
Do you think it would be worth wiring 3 AA batteries to get the power supply under the 5v regulator? Or maybe a 4.2 volt LiPo
Also, I know there could be some instability from my sensor, so I went to a pot to cut down the voltage. Still saw the high variation. So I still think it is something to do with the AD.
Thanks guys,
Mica
You didn't say anything about testing for ground loops. If you have a 10 kohm potentiometer, hook the outside legs directly from pin 4 to pin 8, and hook the center leg to both input channels 0 and 1, and connect a 0.1 uf capacitor from the center leg to pin 4. Okay, short direct connections. Set the output of the potentiometer to 2.5 volts using your multimeter. Run a short program on the Stamp that simply reads the two ADC channels and displays the result. What does the ADC say then?
I was trying to make sense of your observation:
That sounds like a programming issue, or maybe inconsistent wiring to the inputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
With the 10kpot, 0.1uf cap & setup how you described channel 0 and 1 at 2.5v gave between 2028 to 2029. Very good! Now if I turn the pot to 0 ohm so ch 0 & 1 are at the input V I get 4095. Good! Now if I slowly increase the resistance and so the difference in V, just below 3.72 or 1.25 from ground to channel the reading jumps to 9999. If I keep on bringing the V relative to ground down, ch 0 & 1 will jump between 0262 or 1262. Nothing in-between, both channels just flash back and forth on those numbers, 0262 or 1262.
So is my AD working correctly (i.e. I’m doing something wrong)? Isn’t the 1.25V some magical number? This sounds like a program problem with the 0262 or 1262 but maybe the way the pot is working, this is causing it. Any light on this would be great.
Regarding ‘ground loops’, my mechanical engineering definition of this is having different power supplies and not having a common ground. I have only one power source and that is from the board that came with the kit. You also hinted at an example of long wire. My wire coming from the hall-effect sensor is kind of long, say 12 inches. I can cut that down to about 2 in if you say so.
Also, the hall-effect, Honeywell SS-19T sensor has it’s own resistance, about 2k. Would this resistance cause a ‘ground loop’? Is there any way around it?
Is it time to get an oscilloscope or is there some way around all of this?
Mica
Suppose XX is your BASIC Stamp, which is driving loads such as a couple of LEDs and whatever else.
Suppose YY is your LTC1298 converter.
Suppose SS is your sensor.
Suppose ZZ is a servo motor.
The ground loop is the bottom line in the diagram that connects together the Vss supply and the grounds for all the devices. Due to those currents, the voltages you measure at different points along the "ground" can be different and also have different amounts of noise, depending on ohms law and the magnitude of the currents and the size of the wire or pcb traces and the contact resistance of connections (such as wires stuck in a white prototyping block). If you move the bottom connection of the sensor along the line (loop) from a to c the reading on the ADC will change. The specifics depend on exactly what is there. When the bottom reference point of the sensor is connected right next to the reference point of the ADC at "b", as it is with the potentiometer example, that should minimize both the DC errror and the noise. It is possible to wire systems in a "star" that radiates from "v" and "a", so that the digital and analog parts of the circuit are separated from one another. You always have to be thinking about potential ground loops when you include an ADC in a digital system. It all has to do with those hidden currents and how you route the wiring.
Noise pickup from external sources is another issue. That can be addressed by shorter leads, twisted pairs, shielding, and filtering (capacitor or software.).
Now, the business with the readings at less than 1.25 volts is a mystery, not due to ground loops. If the voltages as shown on your multimeter are okay, could you post your test code? It sounds like some kind of math or underflow error. hmmm.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
For others that stumble into this same problem, with this working circuit if I leave the voltmeter on (even off but still ‘wired’[noparse];)[/noparse], the readings go wild again. So take your voltage read for the position, then disconnect and let it settle and look at the debug. Settle time even for an entire sweep is one read with the half-second delay in the program below.
Also, at least for my voltage range of 2.10 to 3.78 from the hall sensor, I don’t get the wild number jumps. This goes for the simple subtraction and division to get the number into the 0 to 127 range of my digipot. So I think I’m good to go.
Thanks again. I think I’m going to go outside now[noparse]:)[/noparse]
Mica
' {$STAMP BS2}
' {$PBASIC 2.5}
'-- A/D converter variables --
CS CON 0 ' Chip select; 0 = active
CLK CON 1 ' Clock to ADC; out on rising, in on falling edge.
DIO_n CON 2 ' Data I/O pin _number_.
config VAR Nib ' Configuration bits for ADC.
AD VAR Word ' Variable to hold 12-bit AD result.
startB VAR config.BIT0 ' Start bit for comm with ADC.
sglDif VAR config.BIT1 ' Single-ended or differential mode.
oddSign VAR config.BIT2 ' Channel selection.
msbf VAR config.BIT3 ' Output 0s after data xfer complete.
HIGH CS ' Deactivate ADC to begin.
HIGH DIO_n ' Set data pin for first start bit.
again: ' Main loop.
FOR oddSign = 0 TO 1 ' Toggle between input channels.
GOSUB convert ' Get data from ADC.
DEBUG "channel ",DEC oddSign, ": ",DEC AD,CR ' Display data.
PAUSE 500 ' Wait a half second.
NEXT ' Change channels.
GOTO again ' Endless loop.
convert:
config = config | %1011 ' Set all bits except oddSign.
LOW CS ' Activate the ADC.
SHIFTOUT DIO_n,CLK,LSBFIRST,[noparse][[/noparse]config\4] ' Send config bits.
SHIFTIN DIO_n,CLK,MSBPOST,[noparse][[/noparse]AD\12] ' Get data bits.
HIGH CS ' Deactivate the ADC.
RETURN ' Return to program.
debug dec AD, cr
it will say 2497
Right after the debug ADC add:
AD = AD*/$012C
then debug it again.· It should display very close to 2.930.· You might have to change the C to B or D to get closer.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
Sorry but I'm missing something. Keep in mind I've only been dealing with microcontrollers for 9 days now. If I put in the equation you specified, AD=AD*/$012C and run the debug again, exact same debug, I see the following:
channel 0: 2386 <-- This is from the AOA sensor
channel 0: 2796 <-- post AD=AD*/$012C
This is at 2.78 volts form the sensor... of couse the readings are after I remove the voltmeter from the circuit.
Can you give me a little more info?
Mica
Implementation advice. The AOA sensor and ADC based on my past ‘user errors’ you helped me get past will obviously need to be kept close together. But I would like to keep the BS2 up inside the wing. This distance will be about 9 to 12 inches. Considering the wires from the BS2 pins are digital, do you think this will be a problem?
Mica
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I’m using the LTC1298 to take readings from a homemade light sensor using a phototransistor. The reading is displayed on a 4-digit LED display using a MAX7219 driver. Right now the circuit appears to be working ok but I occasionally see erratic readings.
That pinout is for the LTC1286. Take a look at page 2 of the Linear Technology data sheet. It is the single channel differential input version and should have a 1286 or 1286I marking on it.No marking is listed on the data sheet for the LTC1298. It is the dual channel version. Data sheet attached.
Why not put the signal on both channels so you can compare the results? I don't like floating pins so I usually have a 10k resistor from the pin to gnd or Vcc, usually gnd for an ADC.
Have a small (0.1 or 0.01uF) between Vcc and gnd as close to the ADC chip as possible to reduce supply noise.
Verify that the ADC pins are connected to the right signals.
I’ll add the 10K resistors to ground for each channel as a precaution.
Already have the decoupling caps in place.
A good filter is a 10k resistor in series, with the output of the 10K into a 10uf tant. cap. lead the other lead to ground. Repeat this and go into another 10K resistor with the 10uf. cap. to ground.
Finally I used some averageing in my programing. The readings are as steady as a fluke meter.
Appreciate the help...I’m on the higher side of 70 and self-teaching myself on microcontrollers.
Remember if you want accurate readings use precision resistors on your volt dividers. Like DALE RN60D series 1% or less.
For best performance, these converters need capacitors on their analog inputs. The sampling process disturbs the input a bit. The right capacitor will filter that disturbance out. The LTC1298 is specified to have an input capacitance of 20pF. You'll want a capacitor at least 100x that. So .002uF to .1uF would be reasonable. Larger is fine as well. It will also help with filtering noise from whatever you are measuring.
The output from microcontroller to ADC should not change unnecessarily. The ADC128S has many input bits which are marked "don't care." This allows them to be set to whatever is convenient. The ADC is designed to sample after receiving the channel number. If a pin changes during the sampling process it can add noise to the result. Some pins like the clock pin must change, that is unavoidable. I don't know if SHIFTOUT leaves the pin in the last state, or zeros it. The PAUSE 275 might help with that.