Subject:
|
Re: My first Lego robotics competition
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Thu, 14 Sep 2000 08:56:23 GMT
|
Viewed:
|
849 times
|
| |
| |
"Rob Stehlik" <Robbby31@hotmail.com> writes:
>
> I am looking for a clear explanation of how to multiplex
> sensors. I would like to attach two touch sensors to the
> same port on my robot. It seems to me that each sensor
> gives the same raw value when pressed (with some minor
> variation due to pressure). How can I differentiate
> between the two sensors?
If you have the Cybermaster touch sensors, you can multiplex all
three on a port, see
http://www.mpi-sb.mpg.de/~juergen/lego/cybermaster-touchsensors.html .
Use a task to look at the raw values and decode which sensors are
pressed, e.g. in NQC:
#define TOUCH_SENSOR SENSOR_1
int touch_sensor_state;
#define PRESSED_WHITE ((touch_sensor_state & (1 << 0)) != 0)
#define PRESSED_RED ((touch_sensor_state & (1 << 1)) != 0)
#define PRESSED_YELLOW ((touch_sensor_state & (1 << 2)) != 0)
task main()
{
start touch_sensor_decoder;
// here you can use PRESSED_YELLOW etc. as boolean values
...
}
task touch_sensor_decoder()
{
int v;
SetSensorType(TOUCH_SENSOR, SENSOR_TYPE_TOUCH);
SetSensorMode(TOUCH_SENSOR, SENSOR_MODE_RAW);
while(true){
v = TOUCH_SENSOR;
if( v > 777 ) touch_sensor_state = 0;
else if( v > 740 ) touch_sensor_state = 2;
else if( v > 720 ) touch_sensor_state = 4;
else if( v > 668 ) touch_sensor_state = 1;
else if( v > 600 ) touch_sensor_state = 6;
else if( v > 551 ) touch_sensor_state = 3;
else if( v > 312 ) touch_sensor_state = 5;
else touch_sensor_state = 7;
}
}
// Cybermaster touch sensors connected in series, raw values
// raw r y w state
// 805 o o o 0
// 750 o x o 2
// 733 x o o 4
// 707 o o x 1
// 629 x x o 6
// 573 o x x 3
// 530 x o x 5
// 98 x x x 7
This works quite well for me.
Otherwise, and if pure LEGO is not required, you can put in
resistors yourself, see the link in the other posting,
and use a similar program.
Or, just an idea, maybe a really really long cable can be
used for a resistor? Also, sometimes touch sensors give
slightly different values, don't know if that can work.
Do you really need to differentiate? Maybe you can know
which one is pressed from the direction of movement?
> Also, is it possible to multiplex a rotation sensor,
> and a touch sensor?
I don't think so. You would have to put the input port
into raw mode and count rotations yourself (not easy),
and it would miscount when the touch sensor is pressed.
> My final request, and probably the most important, is
> I would like some ideas and examples of programs for
> robots to navigate an area without getting stuck.
> I have to stay way from the walls, and hopefully away from
> the other robot. Any tips and tricks for programming a
> "stuck proof" robot would be greatly appreciated.
Make a supervisor task that checks if it is stuck and does
some corrective action. If I remember correctly there is
something to this end in Dave Baum's book.
Good Luck
Jürgen
--
Jürgen Stuber <stuber@loria.fr>
http://www.loria.fr/~stuber/
|
|
Message is in Reply To:
| | My first Lego robotics competition
|
| Hello, I am soon going to enter my first Lego Robotics competition, and I would like some help. I guess there is no better place to go for Lego wisdom than Lugnet! I am looking for a clear explanation of how to multiplex sensors. I would like to (...) (24 years ago, 13-Sep-00, to lugnet.robotics)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|