Go to Post Yes, an expanded FIRST will look far different than it does today. - GaryVoshol [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-03-2007, 17:02
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 211
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
measuring resistance via ADC

Short version: How do I measure the value of a variable resistor (i.e. a resistor which changes values, not a potentiometer which acts as a voltage divider) via the analog input of a VEX controller?


Long version: This is not for a FIRST project, but I will be using a VEX controller. I am trying to find the color of several different objects, or rather to group the objects of the same color together (I don't actually care what the absolute colors are). I plan to do this by shining an RGB LED (http://www.sparkfun.com/commerce/pro...roducts_id=105) at each object and measuring the reflected light of each color using a photoresistor (http://www.radioshack.com/product/in...uctId=2062590). The question is: what's the best way to make this measurement?

I have experimentally determined that the photoresistor has a range from about 50 ohms (when illuminated by a white LED flashlight held very closely) to about 1.8 megaohms (when covered by my hand).

I have several possible solutions and would like opinions on which might be best, and ideas for any other possible solutions.

Option (1) is probably the easiest. I take a fixed value resistor, and connect it to the photoresistor to make a voltage divider, and measure that value with the VEX's ADC on the analog input, something like this:

+5 ---<photo>---<analog in>---<resistor>--- GND

The big question with this is what value to use for the fixed resistor? The larger the resistor, the less of the full range of the ADC is used. If the resistor is too low, however, then when the photocell is low, you've got a very low resistance connection directly from power to ground. On the FRC controller, this causes a problem with the symptom of the "code error" light, and the code not running; I assume the VEX controller is similar.

Option (2) is to build an RC circuit as follows:

GND ---<capacitor>---<photo>--- I/O Pin

This takes advantage of the fact that the I/O pins on the VEX controller can do digital output as well as both analog and digital input. The idea is to set the pin "low" for a "long" time, to fully discharge the capacitor. Then set the pin "high" for a "short" time. This will partially charge the capacitor. Finally set the pin to "analog in", and read the value. A lower resistance on the photoresistor will have allowed the capacitor to charge more. (2b) Would be to first fully charge the capacitor, and then discharge it for a short time and then measure the value.

I have not yet calculated values for the capacitor or for a "long time" or a "short time".

The advantage to option (2) over option (1) is that it allows you to have the full range of your ADC values. The disadvantage is that it requires more complex programming, which means the potential for more errors in the system. Additionally, I think that the ADC on the processor uses the charging of an internal RC circuit to do its ADC conversion. This might potentially be a problem when trying to use that to measure an external RC circuit.

Option (3) is like option (2), but move the I/O pin to the middle:

GND ---<capacitor>---<I/O Pin>---<photo>--- X

X could be either +5 or ground, possibly through an additional fixed resister, to ensure that you always have a minimum resistance between +5 and ground.

I'm not sure that (3) has any real advantages or disadvantages over (2).


Like so many things in engineering (and in life), there is more than one way to do it. I believe all of these methods would work. (If you think any wouldn't work, why wouldn't it work?) What other methods can you think of that would work? Which of all the methods discussed (here and as hopefully suggested by others below) do you think is best, and why?

--AJY
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
  #2   Spotlight this post!  
Unread 27-03-2007, 20:56
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: measuring resistance via ADC

50-1M is a rather large swing to be handling. The next step is to see how much of it you need to be concerned with. Also, you need to be sure your sensor idea will work before you go through the pain of creating this elaborate set up. Using a multimeter, check to see if you can tell the difference between these colours yourself. How much of a difference is there? Then, go to a different lighting environment and try again. Go to yet another and try again. I'm going to guess you may need to rethink things there.

However, lets assume that it will work great. Hooray!

I prefer method 2 over method 1 for several reasons. The biggest reason is that you will get a non-linear response. However, this is probably a "choose your own poison" preference, both are reasonably sound.

For method one, the static resistor probably ought to have a resistance larger than 150 Ohms. This puts the maximum draw at 25mA - a reasonable current to pull from the battery. However, even this is a rather large waste. Lets figure out how to select a bigger resistor.

Assume that we have D bits of good resolution on our ADC, the minimum range of resistances we need to be concerned with is A through B, and we need to be sensitive to resistivity changes of as small as C.

The ADC can pick up changes up to 5 / (2**D) V.
Given a resistance of R for the fixed resistor:
A resistivity change of C will result in a voltage change of
5V * [A*C] / [(A+R)*(A+R+C)]
on the low end. If this is less than what the ADC can pick up, you have a snowballs chance of success. Realistically, you want a MUCH larger window of error. Repeat the calculation for the high end by replacing A with B.

The highest current draw will be 5V / (A+R)


As for method two: You want to use the ADC as a comparator, instead of as an ADC. As you said, charge the capacitor with the PIC and let the photoresistor discharge it to ground. A timer module on the PIC should make this process very easy for you. Remember that PIC output pins can only source 25mA. I'd put a series resistor in there as a safety.

As for sensitivity, I have a tutorial to run in 4 minutes. Sorry...

Good luck!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Measuring Muzzle Velocity Team 614 Rules/Strategy 8 28-01-2006 14:53
Measuring box size Max Brin Technical Discussion 1 26-01-2006 12:16
Measuring Motor Characteristics DonRotolo Motors 1 08-01-2006 19:39
Measuring a Pulse Width MikeDubreuil Programming 22 21-07-2005 10:22
SHU measuring stick sanddrag Rules/Strategy 13 08-01-2003 21:23


All times are GMT -5. The time now is 22:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi