To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 607
606  |  608
Subject: 
Re: touch sensors - two at a time ?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 29 Dec 1999 14:51:02 GMT
Viewed: 
1135 times
  
John P. Looney <valen@nospam.tuatha.org> wrote:

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 ?

If I understand your problem correctly, it has nothing to do with legOS
specifically. Therefore, I will answer, even though I have no experience
with legOS.

The problem is, there is a very small amount of time where, while you're
pushing on the sensors, only one is pressed, and your program is seeing
that one.

The solution that occurs to me is (note this is NQC code...):

if (SENSOR_1 || SENSOR_3) {
  Off(OUT_A + OUT_C);
  Wait(10); // 0.1 second
  if (SENSOR_1 && SENSOR_3) {
    ...
  } else if (SENSOR_1) {
    ...
  } else /* #3 hit */ {
    ...
  }
}

--
Kevin Reid: |    Macintosh:
  "I'm me."  | Think different.



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
    

Custom Search

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