To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 1889
1888  |  1890
Subject: 
Re: sensor input mux calculations
Newsgroups: 
lugnet.robotics
Date: 
Tue, 29 Dec 1998 22:33:11 GMT
Original-From: 
John A. Tamplin <[jat@Traveller]nospam[.COM]>
Viewed: 
1389 times
  
On Tue, 29 Dec 1998, Fred Bauer wrote:

I've been looking at the multiple sensor input problem...  wouldn't it be simpler to use a series resistor network, rather than parallel, something like this:

--|--[ 10 ohm ]--|--[ 20 ohm ]--|--[ 40 ohm ]--|--[ 80 ohm ]--|--
  |              |              |              |              |
  -------X---------------X--------------X-------------X--------

where X is a switch.

If the calculations are correct, this should give raw readings between 0 and 31, depending on which switches are OPEN.  This would then be easy to decode....  I havn't played with this on the RCX, the resistor values may have to be adjusted or scaled, depending on the accuracy of the A/D conversion, but keeping the values low makes this a (relatively) linear function.

Thanks, I didn't think of that.  Since it is a linear function to convert
the measured resistance to the switch values, this is much faster and also
has better spacing between the values.

Using 300, 600, 1.2k, 2.4k, and 4.8k ohm resistors, you can encode 5
switches on a single input and still fully decode them assuming the actual
measurements are within +/- 4 of the theoretical reading.

Using 800, 1.6k, 3.2k, and 6.4k ohm resistors, you can encode 4 switches
with a acceptable range of +/- 8.

The code to decode it is really simple:

long baseResistor=800; /* smallest resistor, double for next */
int numSwitches=4; /* total number of switches */

int Decode(int value) {
double res;
int switches;

res=10000.0*value/(1023-value);
switches= ~(int)(res/baseResistor+.5) & ((1<<numSwitches)-1);
return switches;
}

Of course, you could try and compensate for wire & connector resistance,
rewrite it to avoid floating point, or even precalculate a lookup table
with 1024 entries.

Hmm, this all assumes that switches have negligible resistance when closed,
but I remember someone on this list saying they were between 600 and 1k
when closed.  I plan on building and testing it tonight, so I guess I will
find out.

John A. Tamplin Traveller Information Services
jat@Traveller.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801

--
Did you check the web site first?: http://www.crynwr.com/lego-robotics



Message has 1 Reply:
  Re: sensor input mux calculations
 
The lego touch sensors are not simple on/off switches like you guys show. There is at least 500 ohms in series with them when they are closed. They also seem to be slightly touch sensitive. A light touch will read 1.5K while a hard push is close to (...) (26 years ago, 30-Dec-98, to lugnet.robotics)

Message is in Reply To:
  Re: sensor input mux calculations
 
I've been looking at the multiple sensor input problem... wouldn't it be simpler to use a series resistor network, rather than parallel, something like this: --|--[ 10 ohm ]--|--[ 20 ohm ]--|--[ 40 ohm ]--|--[ 80 ohm ]--|-- | | | | | (...) (26 years ago, 29-Dec-98, to lugnet.robotics)

8 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR