Subject:
|
Re: touch sensors - two at a time ?
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Wed, 29 Dec 1999 16:34:25 GMT
|
Viewed:
|
1602 times
|
| |
| |
In lugnet.robotics.rcx.legos, John P. Looney writes:
> I'm trying to build a sensor apparatus at the front of my bot, and it works,
> mostly.
>
> It's made up as a pair of touch sensors. The idea being that if one is
> activated, it turns around slightly, to avoid the sensor, but if both are
> activated, we should take more drastic action.
>
> However, I tried to do something like
>
> if (SENSOR1 < 0xf000 && SENSOR3 < 0xf000) { both }
> else if (SENSOR1 < 0xf000) { just one }
> else if (SENSOR3 < 0xf000) { just one }
> else { All is OK }
>
> However, if I touch both sensors at the same time, it just accepts one, then
> the other. I suppose it's a race condition of some sort. Any ideas how to sort
> this out ?
>
> Also, apart from www.legoworldshop.com, is there anywhere I can buy add on
> bricks & RCXs ? They are pretty expensive there!!!
The problem you are having, is that the processor is much faster than a human
being...
The code will allways tend to see one sensor befor the other, because of the
processors speed, unless you can hit them together to within a very few mSec.
Two solutions exist:
1) Start a timer when one sensor is touched, and accept the other if you are
within a small time interval.
2) If you _only_ really want to see both sensors, try 'wire anding' the
sensors. There are details of how to do this on the web, and this only needs
one input (saving a precious resource...).
3) Do the test using a 'and'. So it becomes if((SENSOR3<0xf000) &&
SENSOR1<0xf000)).
Best Wishes
|
|
Message is in Reply To:
| | touch sensors - two at a time ?
|
| I'm trying to build a sensor apparatus at the front of my bot, and it works, mostly. It's made up as a pair of touch sensors. The idea being that if one is activated, it turns around slightly, to avoid the sensor, but if both are activated, we (...) (25 years ago, 29-Dec-99, to lugnet.robotics.rcx.legos)
|
4 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|