Petscii Forums "PETSCII.COM"
« ADC Hacking »

Welcome Guest. Please Login or Register.
Nov 20, 2009, 9:42pm




Petscii Forums "PETSCII.COM" :: General :: DTVHacking :: ADC Hacking
Page 1 of 2 » Jump to page   Go    [Search This Thread][Send Topic To Friend] [Print]
 AuthorTopic: ADC Hacking (Read 1,226 times)
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 ADC Hacking
« Thread Started on May 19, 2006, 8:01am »

Gmoon, as you asked, I started a new thread. Okay.. let me clarify.. I only played with the ADC for a few minutes yesterday. I ran the program and immediatly saw $FF on my screen. I guess that is what the ADC reports when resistance is at its highest. I put a thermistor on the loop and it droped to $00. NO matter what I did with the thermistor it always read $00.

Second thing.. I also played with a resistor.. All I had handy was a 680 ohm that I had spare for using on the video circuit.. Not an SMD, but a regular axial lead style. I hooked it up and it also read $00.

Third thing. When I remove the resistor from the circuit I can actually watch the numbers count up from $00 to $FF on the screen. I would have thought it would have jumped immediatly from $00 to $FF upon removing the resistor. But it takes about half a second and counts its way up. So I was trying to say that the ADC isn't as speedy at sampling as I thought. It can probably only take an accurate sample about twice a second. That's my educated guess, anyway.
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #1 on May 19, 2006, 9:12am »

Ok, I got ya now.

1) You need a voltage divider. Just connecting to GND or Vcc won't do it. No matter what the value, the resistor is just limiting current, not changing voltage.

My earlier test worked because the POT was still installed, so there was a path thru the POT to Vcc.

Here's a crude graphic (we can add a pic when time allows):

          Vcc
|
T1
|
ADC--------- (was the POT wiper/center)
|
R1 (15K to 4.7K)
|
GND


T1 is your thermistor, R1 is bottom half of voltage divider. The values for R1 are just a starting point, and will depend on:


  • a) your thermistor's base value and range of resistance
  • b) the temp range you're trying to sample
  • c) the ref voltage of the ADC


The ADC doesn't sample a full range between Vcc and GND, we've already verified that.
[EDIT--this is NOT the case, it does sample 0-3.3V. More info later in this thread]

But pick the right values for T1 and R1 and you can tailor it, no problem.

Another resistor can be added to between T1 and Vcc if needed (depending on the thermistor's minimum resistance, target temp range, etc.)

2) When you disconnected the resistor from GND, you didn't replace the value with any other voltage. The ADC is free to 'float', and just returns to whatever is it's natural bias. Or a preset weak bias--by itself (the ADC, disconnected), wouldn't have any strong voltage source present to interact with the input values.
« Last Edit: May 21, 2006, 10:06pm by gmoon »Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #2 on May 19, 2006, 11:17am »

Ahhh.. Here is where I show my ignorance on analog electronics. I thought a resistor did limit voltage. I always knew you had to use them to drop voltage on an LED, but I always use those nifty LED calculators on the internet to do that.

Truth is.. I don't even remember what the ratings were on the thermistors I have.. I've had them sitting around for a year or more. The bag still has the mouser part#. When I get home I'll look up the number and find out the specs on it.. then maybe you can help me taylor the correct resistance on the ground side.
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #3 on May 19, 2006, 2:35pm »

I think when you connect resistors inline with other components, sometimes the components themselves become part of a voltage-divider. A good ADC should be pretty high-impedance so as not to effect the input value, tho. It wouldn't 'present' itself much, electrically.

Sure, lemme know what thermistors you've got.

If you stick with a value for R1 near the thermistor's rating, (i.e. R1=10k for T1=10K) you should be in the ballpark.

My weekend trip's been bagged due to the unending rain, so I'll test it here, also. I removed the POT a couple days ago.
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #4 on May 20, 2006, 9:27am »

REALLY good news:

Despite the POT's limited range of motion, my assumption that the voltages were proportional to the limited range was WRONG!

The POT can rotate 270 degrees, but it's resistance range is only 180! (same as the steering wheel) The extra unused 45 degrees on each side are direct-connect to each side pin.

VOM readings of wiper pin, while running ADCRD:


ADC val Voltage (center pin)
-------------------------
0 0.0
128 1.66
255 3.3


So the ADC is set to read a FULL range of voltages from Vcc to GND (+3.3v to 0v). (I couldn't test the POT on the board, but I could have tested the center pin insitu. oops.)



On to a thermistor test (using voltage divider described in prev post):
(4.7/4.7 --> R1/T1)


4.7k/4.7k 10k/10k
--------------------------------------
A) 72 79
B) 105 107
C) 145 140


Where
A = cold pack from freezer
B = room temp
C = T1 between thumb and forefinger

Hardly scientific, but I'd guess a range from 35-40 to 90-95 F (A to C)

Max change: 73 units
Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #5 on May 20, 2006, 12:05pm »

THat sound promising.. here is the datasheet for my thermistors:

http://www.thermometrics.com/assets/images/rl20.pdf
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #6 on May 20, 2006, 12:12pm »

Which one(s) do you have?
Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #7 on May 20, 2006, 2:21pm »

Woops.. forgot to write that on there.

I have this one:

RL2003-289-95-D1

It is 500 Ohms.
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #8 on May 20, 2006, 4:09pm »

I'd just start with a similar value for R1, like 470 ohms or 560, etc.

Again, the actual value of R1 will depend on what kind of range you're trying to sample. If you can first figure what the center of the temp range you want, you can insert different values for R1 until your readings are near the center of the ADC (assuming you've also provided that temp on the thermistor.)

You can setup the the voltage divider and substitute a VOM for the ADC (just use a 3.3v supply)--it will display the voltage range you're getting. That will verify that you're in your target range. Regardless, you can't go wrong with 3.3v, nothing in that circuit could hurt your ADC. (If you need to stretch the range, you could also use a 5V supply, but we won't go there yet.)

I would insert a current limiting resistor between the ADC and the center of the voltage divider. I was adding up to 1K, and it didn't effect the ADC readings at all (it doesn't need much current when it samples.) It's not vital, but your thermistor has a low-resistance value, so more potential for current flow.

Also, because you have a low-end resistance value, your circuit will draw more current than a higher-resistance thermistor. It will use more power, although not a huge amount--total resistance of the divider shouldn't fall to less than 1K ( ~500 for T1, ~500 for R1 --and the thermistor will probably never reach it's theoretical lowest R value.)

And lower-resistance value thermistors are subject to other errors--they tend to heat themselves! (more current--more heat)

You should look for a more detailed document from GE, one that has the formulas for converting the non-linear resistance values into a more useful form. BASIC should work great for that.

If you can't find specific formulas, then there are some general one's that should work.
Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #9 on May 20, 2006, 4:39pm »

Okay.. I'll play with that later.. One question for you, since you seem to know a lot about this stuff. Is there anyway to use the ADC in the hummer for reading voltage? Ideally between 0V and 14V? I'd like to have a readout in my shuttlecraft showing the current battery voltage (which will be 12V lead-acid) and maybe even the 5V system which will feed off of the 12V system.
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #10 on May 20, 2006, 6:00pm »

Ahh, I know just enough to get me in trouble. But, thanks.

That should be pretty easy to do:

Make a voltage divider with Vin = 12V, and the divided value = ~3.3v (the highest value the ADC can read). (or give it a little more leeway, if you like-- 14 V, or whatever your battery charger is rated.)

But I see you're thinking 14V, anyway:

Vin 14v (battery)
|
R1 (22K)
|
------------Vout (3.23v)---to ADC
|
R2 (6.6K)
|
GND

When the battery voltage drops, the Vout voltage will too. Design the same type of circuit for Vin = 5V.

Some sample values as the voltage drops:

Vin Vout
-------------
12 2.77
11 2.54
10 2.3

Be easy to convert these value to ADC output--hookup your VOM and the hummer ADC together, use a POT for your voltage divider (wired exactly as the hummer pot, heck, use the hummer pot). Compare the voltages to the ADC reading. Done.

Or-- this is approx-- (adcval / 77.5757) * 4.333 = voltage

How did i do it? Just search for "voltage divider", and use the formula, or the many online calculators (like the LED ones you mentioned.)

One more thing: measuring battery voltage can only be done accurately when the battery is under load (in use.)

You could use higher-resistance values, too. The ADC has VERY low current requirements, as we have seen.
« Last Edit: May 21, 2006, 8:01pm by gmoon »Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #11 on May 20, 2006, 6:02pm »

One more note, about inserting a current-limiting resistor between the ADC and the voltage divider:

I still think it's a good idea, but remember, the ADC was directly connected to +3.3v and GND when the POT turned to it's limits. So not critical, but still smart...
Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #12 on May 22, 2006, 11:07am »

My brain isn't working here for some reason. I'm trying to figure out if I can construct a circuit which would allow me to sample different sources.. But the different sources would be:

1) Monitor several thermistors
2) Monitor voltage of 12V system
3) Monitor voltage of 5V system

I know it was possible with an additional circuit to sample more than one thermistor.. but since these 3 things would all need different voltage dividers, do you think it is feasable to setup a different circuit, or will I still need to invest in a new ADC with multiple inputs?
Link to Post - Back to Top  IP: Logged
gmoon
Wizard's Apprentice
*****
member is offline

[avatar]


[homepage]

Joined: Mar 2006
Gender: Male
Posts: 876
Location: Ohio, USA
 Re: ADC Hacking
« Reply #13 on May 22, 2006, 4:22pm »

The circuit shouldn't be too difficult--just tap the middle of each voltage divider, connecting each to one side of each bi-di analog switch. Then connect all the switches (other side) to the ADC. You know how to to select the current switch, you've already go that figured.


______switchA---voltdiv_A
/
/
ADC--1K-------switchB---voltdiv_B
\
\______switchC---voltdiv_C


Of course you'll need different voltage-dividers for each input, but that's only 1 resistor per thermistor, and two per external voltage monitor. You've got a lot more flexiblity that way. You might decide to use a different thermistor in the future, and if you use this technique, you can mix-and-match them (and other inputs, as we've seen.)

Even if you choose to go with another ADC, you'll still be using separate dividers.

The 1K resistor is just a current limiter, for safety. Experiment with that, you might be able to go higher and not effect the ADC values.

As far as it working, it SHOULD work OK. The voltage monitors aren't a problem. Sampling voltage is what the ADC does. If the thermistors work with the analog switch, the rest will, too.

I would test everything on a breadboard first, certainly. Be aware of the currents involved, especially with a 12 car battery. They can source a huge amount of current. But the voltage dividers really work.

And check your values with a VOM BEFORE you connect the ADC. Give yourself a little more 'headroom' if you think the battery circuit might rise above 14V. But the SNAD01C can operate at upto 5+ V, so 20, 25 volts on the VD input probably won't hurt it. (PROBABLY--some chips, like AVRs, can operate at 2.7 - 5V (ATmega8L, etc.), but aren't 5v tolerant when run at the lower voltages. But I think the ADC is pretty rugged.)
Link to Post - Back to Top  IP: Logged
David Murray
Moderator
*****
member is offline

[avatar]


[homepage]

Joined: Dec 2004
Gender: Male
Posts: 1,561
Location: Kennedale, TX
 Re: ADC Hacking
« Reply #14 on May 22, 2006, 4:39pm »

I'm not using a car-battery. They are sealed-lead-acid like in a UPS or backup lighting. But they still can produce a lot of current. I'm hoping to experiment with that in the next day or two. I'm still trying to finish up my video in what spare time I have. As soon as that is done, it is back to ADC stuff. Your posts have given me a lot to think about.
Link to Post - Back to Top  IP: Logged
Page 1 of 2 » Jump to page   Go    [Search This Thread][Send Topic To Friend] [Print]

Google
Webjledger.proboards.com
Click Here To Make This Board Ad-Free


This Board Hosted For FREE By ProBoards
Get Your Own Free Message Boards & Free Forums!