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 / 606
605  |  607
Subject: 
touch sensors - two at a time ?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 29 Dec 1999 13:37:38 GMT
Viewed: 
944 times
  
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!!!

John



Message has 3 Replies:
  Re: touch sensors - two at a time ?
 
(...) 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 (...) (24 years ago, 29-Dec-99, to lugnet.robotics.rcx.legos)
  Re: touch sensors - two at a time ?
 
(...) It's not a race condition, strictly speaking. It's more of a data sampling error. If you run that it a tight loop you will test the sensors hundreds or thousands of times a second. In order to see a simultaneous press you'd have to hit them at (...) (24 years ago, 29-Dec-99, to lugnet.robotics.rcx.legos)
  Re: touch sensors - two at a time ?
 
(...) 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. (...) (24 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